]> _ Git - couzy.git/blob
059d851bd5c0ec1ffd4df09de0390f803a2588b7
[couzy.git] /
1 <?php
2
3 if ( class_exists( 'Yoast_License_Manager' ) && ! class_exists( "Yoast_Plugin_License_Manager", false ) ) {
4
5         class Yoast_Plugin_License_Manager extends Yoast_License_Manager {
6
7                 /**
8                  * Constructor
9                  *
10                  * @param Yoast_Product $product
11                  */
12                 public function __construct( Yoast_Product $product ) {
13
14                         parent::__construct( $product );
15
16                         // Check if plugin is network activated. We should use site(wide) options in that case.
17                         if( is_admin() && is_multisite() ) {
18
19                                 if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
20                                         require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
21                                 }
22
23                                 $this->is_network_activated = is_plugin_active_for_network( $product->get_slug() );
24                         }
25                 }
26
27                 /**
28                  * Setup auto updater for plugins
29                  */
30                 public function setup_auto_updater() {
31                         if ( $this->license_is_valid() ) {
32                                 // setup auto updater
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 );
36                         }
37                 }
38
39                 /**
40                  * Setup hooks
41                  */
42                 public function specific_hooks() {
43
44                         // deactivate the license remotely on plugin deactivation
45                         register_deactivation_hook( $this->product->get_slug(), array( $this, 'deactivate_license' ) );
46                 }
47
48         /**
49          * Show a form where users can enter their license key
50          * Takes Multisites into account
51          *
52          * @param bool $embedded
53          * @return null
54          */
55         public function show_license_form( $embedded = true ) {
56
57                 // For non-multisites, always show the license form
58                 if( ! is_multisite() ) {
59                        parent::show_license_form( $embedded );
60                        return;
61                 }
62
63                 // Plugin is network activated
64                 if( $this->is_network_activated ) {
65
66                         // We're on the network admin
67                     if( is_network_admin() ) {
68                             parent::show_license_form( $embedded );
69                     } else {
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>";
74                             } else {
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>";
76                             }
77
78                     }
79
80                     }  else {
81
82                         if( false == is_network_admin() ) {
83                                         parent::show_license_form( $embedded );
84                             }
85
86                 }
87         }
88         }
89 }
90