pmpro_license_settings_page

Add license settings page.

Description

pmpro_license_settings_page(); 

Usage

  1. if ( !function_exists( 'pmpro_license_settings_page' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/license.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = pmpro_license_settings_page(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/license.php  
  1. function pmpro_license_settings_page() {  
  2.  
  3. //only let admins get here 
  4. if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_license"))) 
  5. die(__("You do not have permissions to perform this action.", 'paid-memberships-pro' )); 
  6.  
  7. //updating license? 
  8. if(!empty($_REQUEST['pmpro-verify-submit'])) 
  9. $key = preg_replace("/[^a-zA-Z0-9]/", "", $_REQUEST['pmpro-license-key']); 
  10.  
  11. //erase the old key 
  12. delete_option('pmpro_license_key'); 
  13.  
  14. //check key 
  15. $valid = pmpro_license_isValid($key, NULL, true); 
  16.  
  17. if($valid) 
  18. ?> 
  19. <div id="message" class="updated fade"> 
  20. <p><?php _e('Your license key has been validated.', 'paid-memberships-pro' );?></p> 
  21. </div> 
  22. <?php 
  23. else 
  24. global $pmpro_license_error; 
  25. if(!empty($pmpro_license_error)) 
  26. ?> 
  27. <div id="message" class="error"> 
  28. <p><?php echo $pmpro_license_error;?></p> 
  29. </div> 
  30. <?php 
  31.  
  32. //update key 
  33. update_option('pmpro_license_key', $key, 'no'); 
  34. }  
  35.  
  36. //get saved license 
  37. $key = get_option("pmpro_license_key", ""); 
  38. $pmpro_license_check = get_option("pmpro_license_check", array("license"=>false, "enddate"=>0)); 
  39.  
  40. //html for license settings page 
  41. if(defined('PMPRO_DIR')) 
  42. require_once(PMPRO_DIR . "/adminpages/admin_header.php"); 
  43. ?> 
  44. <div class="wrap"> 
  45. <h2><?php _e('Paid Memberships Pro Support License', 'paid-memberships-pro' );?></h2> 
  46. <p>Paid Memberships Pro and our add ons are distributed under the <a target="_blank" href=http//www.gnu.org/licenses/gpl-2.0.html'>GPLv2 license</a>. This means, among other things, that you may use the software on this site or any other site free of charge.</p> 
  47. <p><strong>An annual support license is recommended for websites running Paid Memberships Pro.</strong> <a href="http://www.paidmembershipspro.com/pricing/" target="_blank">View Support License Options »</a></p>  
  48. <div class="metabox-holder"> 
  49. <div class="postbox">  
  50. <h3 class="hndle"><?php _e('License Key', 'paid-memberships-pro' );?></h3> 
  51. <div class="inside">  
  52. <?php if(!pmpro_license_isValid() && empty($key)) { ?> 
  53. <div class="notice notice-error inline"><p><strong><?php _e('Enter your support license key.</strong> Your license key can be found in your membership email receipt or in your <a href="http://www.paidmembershipspro.com/login/?redirect_to=/membership-account/" target="_blank">Membership Account</a>.', 'paid-memberships-pro' );?></p></div> 
  54. <?php } elseif(!pmpro_license_isValid()) { ?> 
  55. <div class="notice notice-error inline"><p><strong><?php _e('Your license is invalid or expired.', 'paid-memberships-pro' );?></strong> <?php _e('Visit the PMPro <a href="http://www.paidmembershipspro.com/login/?redirect_to=/membership-account/" target="_blank">Membership Account</a> page to confirm that youraccountis active and to find your license key.', 'paid-memberships-pro' );?></p></div> 
  56. <?php } else { ?>  
  57. <div class="notice inline"><?php printf(__('<p><strong>Thank you!</strong> A valid <strong>%s</strong> license key has been used to activate your support license on this site.</p>', 'paid-memberships-pro' ), ucwords($pmpro_license_check['license']));?></div> 
  58. <?php } ?>  
  59. <form action="" method="post"> 
  60. <table class="form-table"> 
  61. <tbody> 
  62. <tr id="pmpro-settings-key-box"> 
  63. <td> 
  64. <input type="password" name="pmpro-license-key" id="pmpro-license-key" value="<?php echo esc_attr($key);?>" placeholder="<?php _e('Enter license key here...', 'paid-memberships-pro' );?>" size="40" /> 
  65. <?php wp_nonce_field( 'pmpro-key-nonce', 'pmpro-key-nonce' ); ?> 
  66. <?php submit_button( __( 'Verify Key', 'paid-memberships-pro' ), 'primary', 'pmpro-verify-submit', false ); ?>  
  67. </td> 
  68. </tr> 
  69. </tbody> 
  70. </table> 
  71. </form> 
  72. </div> <!-- end inside --> 
  73. </div> <!-- end post-box --> 
  74. </div> <!-- end metabox-holder -->  
  75. </div> <!-- end wrap --> 
  76. <?php