SimpleCalendarAdminPagesLicenses

Licenses.

Defined (1)

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

/includes/admin/pages/licenses.php  
  1. class Licenses extends Admin_Page { 
  2.  
  3. /** 
  4. * Constructor. 
  5. * @since 3.0.0 
  6. */ 
  7. public function __construct() { 
  8.  
  9. $this->id = $tab = 'licenses'; 
  10. $this->option_group = $page = 'settings'; 
  11. $this->label = __( 'Add-on Licenses', 'google-calendar-events' ); 
  12. //$this->description = __( 'Manage your premium add-on license keys.', 'google-calendar-events' ); 
  13. $this->sections = $this->add_sections(); 
  14. $this->fields = $this->add_fields(); 
  15.  
  16. // Disabled the 'save changes' button for this page. 
  17. add_filter( 'simcal_admin_page_' . $page . '_' . $tab . '_submit', function() { return false; } ); 
  18.  
  19. // Add html to page. 
  20. add_action( 'simcal_admin_page_' . $page . '_' . $tab . '_end', array( __CLASS__, 'html' ) ); 
  21.  
  22. /** 
  23. * Add additional html. 
  24. * @since 3.0.0 
  25. * @return void 
  26. */ 
  27. public static function html() { 
  28. // Add a nonce field used in ajax. 
  29. wp_nonce_field( 'simcal_license_manager', 'simcal_license_manager' ); 
  30. // Add a license 'reset' button. 
  31. ?> 
  32. <br><br> 
  33. <a href="#" id="simcal-reset-licenses" data-dialog="<?php _e( 'WARNING: Are you sure you want to start over and delete all license keys from the settings?', 'google-calendar-events' ) ?>"> 
  34. <?php _e( 'Delete your license keys', 'google-calendar-events' ) ?> 
  35. <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i> 
  36. </a> 
  37. <?php 
  38.  
  39.  
  40. /** 
  41. * Add sections. 
  42. * @since 3.0.0 
  43. * @return array 
  44. */ 
  45. public function add_sections() { 
  46. $sections = array( 
  47. 'keys' => array( 
  48. 'title' => __( 'Premium Add-on License Keys', 'google-calendar-events' ),  
  49. 'description' => __( 'Enter your add-on license keys below, making sure to activate each one to ensure they are valid.', 'google-calendar-events' ) . 
  50. '<br/><br/>' . 
  51. '<em>' . __( 'Your license keys are used for access to automatic upgrades and premium support.', 'google-calendar-events' ) . '</em>',  
  52. ),  
  53. ); 
  54. return apply_filters( 'simcal_add_' . $this->option_group . '_' . $this->id .'_sections', $sections ); 
  55.  
  56. /** 
  57. * Add fields. 
  58. * @since 3.0.0 
  59. * @return array 
  60. */ 
  61. public function add_fields() { 
  62.  
  63. $fields = array(); 
  64. $this->values = get_option( 'simple-calendar_' . $this->option_group . '_' . $this->id ); 
  65.  
  66. foreach ( $this->sections as $section => $contents ) { 
  67.  
  68. if ( 'keys' == $section ) { 
  69.  
  70. $addons = apply_filters( 'simcal_installed_addons', array() ); 
  71.  
  72. if ( ! empty( $addons ) && is_array( $addons ) ) { 
  73.  
  74. foreach ( $addons as $addon_id => $addon_name ) { 
  75.  
  76. $fields[ $section ][ $addon_id ] = array( 
  77. 'type' => 'license',  
  78. 'addon' => $addon_id,  
  79. 'title' => esc_attr( $addon_name ),  
  80. 'name' => 'simple-calendar_' . $this->option_group . '_' . $this->id . '[' . $section . '][' . $addon_id . ']',  
  81. 'id' => 'simple-calendar-' . $this->option_group . '-' . $this->id . '-' . $section . '-' . sanitize_key( $addon_id ),  
  82. 'value' => $this->get_option_value( $section, $addon_id ),  
  83. 'class' => array( 
  84. 'regular-text',  
  85. 'ltr',  
  86. ); 
  87.  
  88.  
  89.  
  90.  
  91.  
  92. return apply_filters( 'simcal_add_' . $this->option_group . '_' . $this->id . '_fields', $fields ); 
  93.