3 if ( class_exists( 'Yoast_License_Manager' ) && ! class_exists( "Yoast_Plugin_License_Manager", false ) ) {
5 class Yoast_Plugin_License_Manager extends Yoast_License_Manager {
10 * @param Yoast_Product $product
12 public function __construct( Yoast_Product $product ) {
14 parent::__construct( $product );
16 // Check if plugin is network activated. We should use site(wide) options in that case.
17 if( is_admin() && is_multisite() ) {
19 if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
20 require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
23 $this->is_network_activated = is_plugin_active_for_network( $product->get_slug() );
28 * Setup auto updater for plugins
30 public function setup_auto_updater() {
31 if ( $this->license_is_valid() ) {
33 require_once( dirname( __FILE__ ) . '/class-update-manager.php' );
34 require_once( dirname( __FILE__ ) . '/class-plugin-update-manager.php' );
35 new Yoast_Plugin_Update_Manager( $this->product, $this );
42 public function specific_hooks() {
44 // deactivate the license remotely on plugin deactivation
45 register_deactivation_hook( $this->product->get_slug(), array( $this, 'deactivate_license' ) );
49 * Show a form where users can enter their license key
50 * Takes Multisites into account
52 * @param bool $embedded
55 public function show_license_form( $embedded = true ) {
57 // For non-multisites, always show the license form
58 if( ! is_multisite() ) {
59 parent::show_license_form( $embedded );
63 // Plugin is network activated
64 if( $this->is_network_activated ) {
66 // We're on the network admin
67 if( is_network_admin() ) {
68 parent::show_license_form( $embedded );
70 // We're not in the network admin area, show a notice
71 parent::show_license_form_heading();
72 if ( is_super_admin() ) {
73 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>";
75 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>";
82 if( false == is_network_admin() ) {
83 parent::show_license_form( $embedded );