YIT_Plugin_Licence

YIT Plugin Licence Panel.

Defined (1)

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

/plugin-fw/licence/lib/yit-plugin-licence.php  
  1. class YIT_Plugin_Licence extends YIT_Licence { 
  2.  
  3. /** 
  4. * @var array The settings require to add the submenu page "Activation" 
  5. * @since 1.0 
  6. */ 
  7. protected $_settings = array(); 
  8.  
  9. /** 
  10. * @var object The single instance of the class 
  11. * @since 1.0 
  12. */ 
  13. protected static $_instance = null; 
  14.  
  15. /** 
  16. * @var string Option name 
  17. * @since 1.0 
  18. */ 
  19. protected $_licence_option = 'yit_plugin_licence_activation'; 
  20.  
  21. /** 
  22. * @var string product type 
  23. * @since 1.0 
  24. */ 
  25. protected $_product_type = 'plugin'; 
  26.  
  27. /** 
  28. * Constructor 
  29. * @since 1.0 
  30. * @author Andrea Grillo <andrea.grillo@yithemes.com> 
  31. */ 
  32. public function __construct() { 
  33. parent::__construct(); 
  34.  
  35. if ( !is_admin() ) { 
  36. return; 
  37.  
  38. $this->_settings = array( 
  39. 'parent_page' => 'yit_plugin_panel',  
  40. 'page_title' => __( 'License Activation', 'yith-plugin-fw' ),  
  41. 'menu_title' => __( 'License Activation', 'yith-plugin-fw' ),  
  42. 'capability' => 'manage_options',  
  43. 'page' => 'yith_plugins_activation',  
  44. ); 
  45.  
  46. add_action( 'admin_menu', array( $this, 'add_submenu_page' ), 99 ); 
  47. add_action( "wp_ajax_yith_activate-{$this->_product_type}", array( $this, 'activate' ) ); 
  48. add_action( "wp_ajax_yith_deactivate-{$this->_product_type}", array( $this, 'deactivate' ) ); 
  49. add_action( "wp_ajax_yith_update_licence_information-{$this->_product_type}", array( $this, 'update_licence_information' ) ); 
  50. add_action( 'yit_licence_after_check', array( $this, 'licence_after_check' ) ); 
  51.  
  52.  
  53. public function licence_after_check() { 
  54. /** === Regenerate Update Plugins Transient === */ 
  55. YIT_Upgrade()->force_regenerate_update_transient(); 
  56.  
  57. /** 
  58. * Main plugin Instance 
  59. * @static 
  60. * @return object Main instance 
  61. * @since 1.0 
  62. * @author Andrea Grillo <andrea.grillo@yithemes.com> 
  63. */ 
  64. public static function instance() { 
  65. if ( is_null( self::$_instance ) ) { 
  66. self::$_instance = new self(); 
  67.  
  68. return self::$_instance; 
  69.  
  70. /** 
  71. * Add "Activation" submenu page under YITH Plugins 
  72. * @return void 
  73. * @since 1.0 
  74. * @author Andrea Grillo <andrea.grillo@yithemes.com> 
  75. */ 
  76. public function add_submenu_page() { 
  77. add_submenu_page( 
  78. $this->_settings['parent_page'],  
  79. $this->_settings['page_title'],  
  80. $this->_settings['menu_title'],  
  81. $this->_settings['capability'],  
  82. $this->_settings['page'],  
  83. array( $this, 'show_activation_panel' ) 
  84. ); 
  85.  
  86. /** 
  87. * Premium plugin registration 
  88. * @param $plugin_init | string | The plugin init file 
  89. * @param $secret_key | string | The product secret key 
  90. * @param $product_id | string | The plugin slug (product_id) 
  91. * @return void 
  92. * @since 1.0 
  93. * @author Andrea Grillo <andrea.grillo@yithemes.com> 
  94. */ 
  95. public function register( $plugin_init, $secret_key, $product_id ) { 
  96. if ( !function_exists( 'get_plugins' ) ) { 
  97. require_once ABSPATH . 'wp-admin/includes/plugin.php'; 
  98.  
  99. $plugins = get_plugins(); 
  100. $plugins[$plugin_init]['secret_key'] = $secret_key; 
  101. $plugins[$plugin_init]['product_id'] = $product_id; 
  102. $this->_products[$plugin_init] = $plugins[$plugin_init]; 
  103.  
  104. public function get_product_type() { 
  105. return $this->_product_type;