_config = Dispatcher::config(); } /** * Runs plugin */ function run() { add_action( 'admin_init', array( $this, 'admin_init' ) ); add_action( 'wp_ajax_w3tc_verify_plugin_license_key', array( $this, 'action_verify_plugin_license_key' ) ); add_action( 'w3tc_config_ui_save-w3tc_general', array( $this, 'possible_state_change' ), 2, 10 ); add_action( 'w3tc_message_action_licensing_upgrade', array( $this, 'w3tc_message_action_licensing_upgrade' ) ); add_filter( 'w3tc_admin_bar_menu', array( $this, 'w3tc_admin_bar_menu' ) ); } public function w3tc_admin_bar_menu( $menu_items ) { if ( ! Util_Environment::is_w3tc_pro( $this->_config ) ) { $menu_items['00020.licensing'] = array( 'id' => 'w3tc_overlay_upgrade', 'parent' => 'w3tc', 'title' => wp_kses( sprintf( // translators: 1 opening HTML span tag, 2 closing HTML span tag. __( '%1$sUpgrade Performance%2$s', 'w3-total-cache' ), '', '' ), array( 'span' => array( 'style' => array(), ), ) ), 'href' => wp_nonce_url( network_admin_url( 'admin.php?page=w3tc_dashboard&w3tc_message_action=licensing_upgrade' ), 'w3tc' ), ); } if ( defined( 'W3TC_DEBUG' ) && W3TC_DEBUG ) { $menu_items['90040.licensing'] = array( 'id' => 'w3tc_debug_overlay_upgrade', 'parent' => 'w3tc_debug_overlays', 'title' => esc_html__( 'Upgrade', 'w3-total-cache' ), 'href' => wp_nonce_url( network_admin_url( 'admin.php?page=w3tc_dashboard&w3tc_message_action=licensing_upgrade' ), 'w3tc' ) ); } return $menu_items; } public function w3tc_message_action_licensing_upgrade() { add_action( 'admin_head', array( $this, 'admin_head_licensing_upgrade' ) ); } public function admin_head_licensing_upgrade() { ?> get_string( 'plugin.license_key' ) !== '' && $config->get_string( 'plugin.license_key' ) === '' ) { $result = Licensing_Core::deactivate_license( $old_config->get_string( 'plugin.license_key' ) ); if ( $result ) { $this->site_inactivated = true; } $changed = true; } elseif ( $old_config->get_string( 'plugin.license_key' ) === '' && $config->get_string( 'plugin.license_key' ) !== '' ) { $result = Licensing_Core::activate_license( $config->get_string( 'plugin.license_key' ), W3TC_VERSION ); if ( $result ) { $this->site_activated = true; $config->set( 'common.track_usage', true ); } $changed = true; } elseif ( $old_config->get_string( 'plugin.license_key' ) !== $config->get_string( 'plugin.license_key' ) ) { $result = Licensing_Core::activate_license( $config->get_string( 'plugin.license_key' ), W3TC_VERSION ); if ( $result ) { $this->site_activated = true; } $changed = true; } if ( $changed ) { $state = Dispatcher::config_state(); $state->set( 'license.next_check', 0 ); $state->save(); delete_transient( 'w3tc_imageservice_limited' ); } } /** * Setup notices actions */ function admin_init() { $capability = apply_filters( 'w3tc_capability_admin_notices', 'manage_options' ); $this->maybe_update_license_status(); if ( current_user_can( $capability ) ) { if ( is_admin() ) { /** * Only admin can see W3TC notices and errors */ if ( ! Util_Environment::is_wpmu() ) { add_action( 'admin_notices', array( $this, 'admin_notices' ), 1, 1 ); } add_action( 'network_admin_notices', array( $this, 'admin_notices' ), 1, 1 ); if ( Util_Admin::is_w3tc_admin_page() ) { add_filter( 'w3tc_notes', array( $this, 'w3tc_notes' ) ); } } } } private function _status_is( $s, $starts_with ) { $s .= '.'; $starts_with .= '.'; return substr( $s, 0, strlen( $starts_with ) ) === $starts_with; } /** * Run license status check and display messages */ function admin_notices() { $message = ''; $state = Dispatcher::config_state(); $status = $state->get_string( 'license.status' ); if ( defined( 'W3TC_PRO' ) ) { } elseif ( 'no_key' === $status ) { } elseif ( $this->_status_is( $status, 'inactive.expired' ) ) { $message = wp_kses( sprintf( // translators: 1 HTML input button for renewing license. __( 'It looks like your W3 Total Cache Pro license has expired. %1$s to continue using the Pro features', 'w3-total-cache' ), '' ), array( 'input' => array( 'type' => array(), 'class' => array(), 'data-nonce' => array(), 'data-renew-key' => array(), 'data-src' => array(), 'value' => array(), ), ) ); } elseif ( $this->_status_is( $status, 'invalid' ) ) { $message = __( 'The W3 Total Cache license key you entered is not valid.', 'w3-total-cache' ) . ' ' . __( 'Please enter it again.', 'w3-total-cache' ) . ''; } elseif ( $this->_status_is( $status, 'inactive.by_rooturi.activations_limit_not_reached' ) ) { $message = __( 'The W3 Total Cache license key is not active for this site.', 'w3-total-cache' ); } elseif ( $this->_status_is( $status, 'inactive.by_rooturi' ) ) { $message = wp_kses( sprintf( // translators: HTML a tag to W3TC Licence Reset. __( 'The W3 Total Cache license key is not active for this site. You can switch your license to this website following %1$sthis link%2$s', 'w3-total-cache' ), '', '' ), array( 'a' => array( 'class' => array(), 'href' => array(), ), ) ); } elseif ( $this->_status_is( $status, 'inactive' ) ) { $message = __( 'The W3 Total Cache license key is not active.', 'w3-total-cache' ); } elseif ( $this->_status_is( $status, 'active' ) ) { } else { $message = __( 'The W3 Total Cache license key can\'t be verified.', 'w3-total-cache' ); } if ( $message ) { if ( ! Util_Admin::is_w3tc_admin_page() ) { echo ''; echo ''; } Util_Ui::error_box( sprintf( '%1$s%2$s. %3$scheck license status again
', '', $message, '', '', '
' ) ); } if ( $this->site_inactivated ) { Util_Ui::error_box( '' . __( 'The W3 Total Cache license key is deactivated for this site.', 'w3-total-cache' ) . '
' ); } if ( $this->site_activated ) { Util_Ui::error_box( '' . __( 'The W3 Total Cache license key is activated for this site.', 'w3-total-cache' ) . '
' ); } } function w3tc_notes( $notes ) { $terms = ''; $state_master = Dispatcher::config_state_master(); if ( defined( 'W3TC_PRO' ) ) { $terms = 'accept'; } elseif ( ! Util_Environment::is_w3tc_pro( $this->_config ) ) { $terms = $state_master->get_string( 'license.community_terms' ); $buttons = sprintf( '