MI_Plugin_License_Manager

The WordPress Core MI Plugin License Manager class.

Defined (1)

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

/vendor/yoast/license-manager/class-plugin-license-manager.php  
  1. class MI_Plugin_License_Manager extends MI_License_Manager { 
  2.  
  3. /** 
  4. * Constructor 
  5. * @param MI_Product $product 
  6. */ 
  7. public function __construct( MI_Product $product ) { 
  8.  
  9. parent::__construct( $product ); 
  10.  
  11. // Check if plugin is network activated. We should use site(wide) options in that case. 
  12. if( is_admin() && is_multisite() ) { 
  13.  
  14. if ( ! function_exists( 'is_plugin_active_for_network' ) ) { 
  15. require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); 
  16.  
  17. $this->is_network_activated = is_plugin_active_for_network( $product->get_file() ); 
  18.  
  19. /** 
  20. * Setup auto updater for plugins 
  21. */ 
  22. public function setup_auto_updater() { 
  23. if ( $this->license_is_valid() ) { 
  24. // setup auto updater 
  25. require_once( dirname( __FILE__ ) . '/class-update-manager.php' ); 
  26. require_once( dirname( __FILE__ ) . '/class-plugin-update-manager.php' ); 
  27. new MI_Plugin_Update_Manager( $this->product, $this ); 
  28.  
  29. /** 
  30. * Setup hooks 
  31. */ 
  32. public function specific_hooks() { 
  33.  
  34. // deactivate the license remotely on plugin deactivation 
  35. register_deactivation_hook( $this->product->get_file(), array( $this, 'deactivate_license' ) ); 
  36.  
  37. /** 
  38. * Show a form where users can enter their license key 
  39. * Takes Multisites into account 
  40. * @param bool $embedded 
  41. * @return null 
  42. */ 
  43. public function show_license_form( $embedded = true ) { 
  44.  
  45. // For non-multisites, always show the license form 
  46. if( ! is_multisite() ) { 
  47. parent::show_license_form( $embedded ); 
  48. return; 
  49.  
  50. // Plugin is network activated 
  51. if( $this->is_network_activated ) { 
  52.  
  53. // We're on the network admin 
  54. if( is_network_admin() ) { 
  55. parent::show_license_form( $embedded ); 
  56. } else { 
  57. // We're not in the network admin area, show a notice 
  58. parent::show_license_form_heading(); 
  59. if ( is_super_admin() ) { 
  60. echo "<p>" . sprintf( __( '%s is network activated, you can manage your license in the <a href="%s">network admin license page</a>.', $this->product->get_text_domain() ), $this->product->get_item_name(), $this->product->get_license_page_url() ) . "</p>"; 
  61. } else { 
  62. echo "<p>" . sprintf( __( '%s is network activated, please contact your site administrator to manage the license.', $this->product->get_text_domain() ), $this->product->get_item_name() ) . "</p>"; 
  63.  
  64.  
  65. } else { 
  66.  
  67. if( false == is_network_admin() ) { 
  68. parent::show_license_form( $embedded ); 
  69.