private function activate_plugin()
 {
     $lca = 'wpssojson';
     $version = WpssoJsonConfig::$cf['plugin'][$lca]['version'];
     // only our config
     if (class_exists('WpssoUtil')) {
         WpssoUtil::save_all_times($lca, $version);
     } else {
         WpssoJson::required_notice(true);
     }
     // $deactivate = true
 }
Esempio n. 2
0
        private function activate_plugin()
        {
            $lca = WpssoConfig::$cf['lca'];
            $uca = strtoupper($lca);
            $short = WpssoConfig::$cf['plugin'][$lca]['short'];
            $version = WpssoConfig::$cf['plugin'][$lca]['version'];
            foreach (array('wp', 'php') as $key) {
                switch ($key) {
                    case 'wp':
                        global $wp_version;
                        $label = 'WordPress';
                        $req_version = $wp_version;
                        break;
                    case 'php':
                        $label = 'PHP';
                        $req_version = phpversion();
                        break;
                }
                $min_version = WpssoConfig::$cf[$key]['min_version'];
                if (version_compare($req_version, $min_version, '<')) {
                    require_once ABSPATH . 'wp-admin/includes/plugin.php';
                    deactivate_plugins(WPSSO_PLUGINBASE);
                    error_log(WPSSO_PLUGINBASE . ' requires ' . $label . ' ' . $min_version . ' or higher (' . $req_version . ' reported).');
                    wp_die('<p>The ' . $short . ' plugin cannot be activated &mdash; ' . $short . ' requires ' . $label . ' version ' . $min_version . ' or newer.</p>');
                }
            }
            $this->p->set_config();
            $this->p->set_objects(true);
            // $activate = true
            $this->p->util->clear_all_cache();
            WpssoUtil::save_all_times($lca, $version);
            set_transient($lca . '_activation_redirect', true, 60 * 60);
            if (!is_array($this->p->options) || empty($this->p->options) || defined($uca . '_RESET_ON_ACTIVATE') && constant($uca . '_RESET_ON_ACTIVATE')) {
                $this->p->options = $this->p->opt->get_defaults();
                delete_option(constant($uca . '_OPTIONS_NAME'));
                add_option(constant($uca . '_OPTIONS_NAME'), $this->p->options, null, 'yes');
                // autoload = yes
                if ($this->p->debug->enabled) {
                    $this->p->debug->log('default options have been added to the database');
                }
                if (defined($uca . '_RESET_ON_ACTIVATE') && constant($uca . '_RESET_ON_ACTIVATE')) {
                    $this->p->notice->inf($uca . '_RESET_ON_ACTIVATE constant is true &ndash; 
						plugin options have been reset to their default values.', true);
                }
            }
        }