script.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. header( 'HTTP/1.0 403 Forbidden' );
  4. die;
  5. }
  6. ?><script type="text/javascript">
  7. (function($) {
  8. if( typeof YoastLicenseManager !== "undefined" ) {
  9. return;
  10. }
  11. window.YoastLicenseManager = (function () {
  12. function init() {
  13. var $keyInputs = $(".yoast-license-key-field.yoast-license-obfuscate");
  14. var $actionButtons = $('.yoast-license-toggler button');
  15. var $submitButtons = $('input[type="submit"], button[type="submit"]');
  16. $submitButtons.click( addDisableEvent );
  17. $actionButtons.click( actOnLicense );
  18. $keyInputs.click( setEmptyValue );
  19. }
  20. function setEmptyValue() {
  21. if( ! $(this).is('[readonly]') ) {
  22. $(this).val('');
  23. }
  24. }
  25. function actOnLicense() {
  26. var $formScope = $(this).closest('form');
  27. var $actionButton = $formScope.find('.yoast-license-toggler button');
  28. // fake input field with exact same name => value
  29. $("<input />")
  30. .attr('type', 'hidden')
  31. .attr( 'name', $(this).attr('name') )
  32. .val( $(this).val() )
  33. .appendTo( $formScope );
  34. // change button text to show we're working..
  35. var text = ( $actionButton.hasClass('yoast-license-activate') ) ? "Activating..." : "Deactivating...";
  36. $actionButton.text( text );
  37. }
  38. function addDisableEvent() {
  39. var $formScope = $(this).closest('form');
  40. $formScope.submit(disableButtons);
  41. }
  42. function disableButtons() {
  43. var $formScope = $(this).closest('form');
  44. var $submitButton = $formScope.find('input[type="submit"], button[type="submit"]');
  45. $submitButton.prop( 'disabled', true );
  46. }
  47. return {
  48. init: init
  49. }
  50. })();
  51. YoastLicenseManager.init();
  52. })(jQuery);
  53. </script>