public function __construct(&$plugin) { $this->p =& $plugin; if (is_object($this->p->debug) && method_exists($this->p->debug, 'mark')) { $this->p->debug->mark(); } $this->active_plugins = WpssoUtil::active_plugins(); if (!is_admin()) { // disable jetPack open graph meta tags if (class_exists('JetPack') || isset($this->active_plugins['jetpack/jetpack.php'])) { add_filter('jetpack_enable_opengraph', '__return_false', 99); add_filter('jetpack_enable_open_graph', '__return_false', 99); add_filter('jetpack_disable_twitter_cards', '__return_true', 99); } // disable Yoast SEO social meta tags if (function_exists('wpseo_init') || isset($this->active_plugins['wordpress-seo/wp-seo.php'])) { add_action('template_redirect', array($this, 'cleanup_wpseo_filters'), 9999); } if (class_exists('Ngfb') || isset($this->active_plugins['nextgen-facebook/nextgen-facebook.php'])) { if (!defined('NGFB_META_TAGS_DISABLE')) { define('NGFB_META_TAGS_DISABLE', true); } } } do_action($this->p->cf['lca'] . '_init_check', $this->active_plugins); }
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 }
public function add_header() { $lca = $this->p->cf['lca']; if ($this->p->debug->enabled) { $this->p->util->log_is_functions(); } if ($this->p->is_avail['mt']) { echo $this->get_header_html(apply_filters($lca . '_header_use_post', false)); } else { echo "\n<!-- " . $lca . " meta tags disabled -->\n"; } // include additional information when debug mode is on if ($this->p->debug->enabled) { // show debug log $this->p->debug->show_html(null, 'debug log'); // show constants $defined_constants = get_defined_constants(true); $defined_constants['user']['WPSSO_NONCE'] = '********'; if (is_multisite()) { $this->p->debug->show_html(SucomUtil::preg_grep_keys('/^(MULTISITE|^SUBDOMAIN_INSTALL|.*_SITE)$/', $defined_constants['user']), 'multisite constants'); } $this->p->debug->show_html(SucomUtil::preg_grep_keys('/^WPSSO_/', $defined_constants['user']), 'wpsso constants'); // show active plugins $this->p->debug->show_html(print_r(WpssoUtil::active_plugins(), true), 'active plugins'); // show available modules $this->p->debug->show_html(print_r($this->p->is_avail, true), 'available features'); // show all plugin options $opts = $this->p->options; foreach ($opts as $key => $val) { switch (true) { case strpos($key, '_js_') !== false: case strpos($key, '_css_') !== false: case preg_match('/_(html|key|tid)$/', $key): $opts[$key] = '********'; break; } } $this->p->debug->show_html($opts, 'wpsso settings'); } // end of debug information }
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 — ' . $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 – plugin options have been reset to their default values.', true); } } }
public function check_options($options_name, &$opts = array(), $network = false) { if (!empty($opts) && is_array($opts)) { $has_diff_version = false; $has_diff_options = false; // check for a new plugin and/or extension version foreach ($this->p->cf['plugin'] as $lca => $info) { if (empty($info['version'])) { continue; } $key = 'plugin_' . $lca . '_version'; if (empty($opts[$key]) || version_compare($opts[$key], $info['version'], '!=')) { WpssoUtil::save_time($lca, $info['version'], 'update'); $opts[$key] = $info['version']; $has_diff_version = true; } } // check for an upgrade to the options array if (empty($opts['options_version']) || $opts['options_version'] !== $this->p->cf['opt']['version']) { $has_diff_options = true; } // upgrade the options array if necessary (renamed or removed keys) if ($has_diff_options) { if ($this->p->debug->enabled) { $this->p->debug->log($options_name . ' v' . $this->p->cf['opt']['version'] . ' different than saved v' . $opts['options_version']); } if (!is_object($this->upg)) { require_once WPSSO_PLUGINDIR . 'lib/upgrade.php'; $this->upg = new WpssoOptionsUpgrade($this->p); } $opts = $this->upg->options($options_name, $opts, $this->get_defaults(), $network); } // adjust some options based on external factors if (!$network) { if (!$this->p->check->aop($this->p->cf['lca'], true, $this->p->is_avail['aop'])) { $opts['plugin_filter_content'] = 0; } // if an seo plugin is found, disable the canonical and description meta tags if ($this->p->is_avail['seo']['*']) { foreach (array('canonical', 'description') as $name) { $opts['add_meta_name_' . $name] = 0; $opts['add_meta_name_' . $name . ':is'] = 'disabled'; } } $opts['add_meta_name_generator'] = defined('WPSSO_META_GENERATOR_DISABLE') && WPSSO_META_GENERATOR_DISABLE ? 0 : 1; } // save options and issue possibly issue reminders if ($has_diff_version || $has_diff_options) { $this->save_options($options_name, $opts, $network); if (is_admin()) { if (empty($opts['plugin_object_cache_exp']) || $opts['plugin_object_cache_exp'] < $this->get_defaults('plugin_object_cache_exp')) { if ($this->p->check->aop($this->p->cf['lca'], true, $this->p->is_avail['aop'])) { $this->p->notice->inf($this->p->msgs->get('notice-object-cache-exp'), true); } else { $opts['plugin_object_cache_exp'] = $this->get_defaults('plugin_object_cache_exp'); } } if (empty($opts['plugin_filter_content'])) { $this->p->notice->inf($this->p->msgs->get('notice-content-filters-disabled'), true, true, 'notice-content-filters-disabled', true); } if (!empty($this->p->options['plugin_head_attr_filter_name']) && $this->p->options['plugin_head_attr_filter_name'] === 'head_attributes') { $this->p->admin->check_tmpl_head_elements(); } } } // add missing options for all post types $opts = $this->p->util->add_ptns_to_opts($opts, array('plugin_add_to' => 1, 'schema_type_for' => 'webpage')); // $opts should be an array and not empty } else { if ($opts === false) { $err_msg = sprintf(__('WordPress could not find an entry for %s in the options table.', 'wpsso'), $options_name); } elseif (!is_array($opts)) { $err_msg = sprintf(__('WordPress returned a non-array value when reading %s from the options table.', 'wpsso'), $options_name); } elseif (empty($opts)) { $err_msg = sprintf(__('WordPress returned an empty array when reading %s from the options table.', 'wpsso'), $options_name); } else { $err_msg = sprintf(__('WordPress returned an unknown condition when reading %s from the options table.', 'wpsso'), $options_name); } if ($this->p->debug->enabled) { $this->p->debug->log($err_msg); } if ($network === false) { $opts = $this->get_defaults(); } else { $opts = $this->get_site_defaults(); } if (is_admin()) { if ($network === false) { $url = $this->p->util->get_admin_url('general'); } else { $url = $this->p->util->get_admin_url('network'); } $this->p->notice->err($err_msg . sprintf(__('The plugin settings have been returned to their default values — <a href="%s">please review and save the new settings</a>.', 'wpsso'), $url)); } } return $opts; }
public function show_setting_page() { if (!$this->is_setting($this->menu_id)) { // the "setting" pages display their own error messages settings_errors(WPSSO_OPTIONS_NAME); } // display "error" and "updated" messages $this->set_form_property(); // define form for side boxes and show_form_content() if ($this->p->debug->enabled) { $this->p->debug->show_html(print_r($this->p->is_avail, true), 'available features'); $this->p->debug->show_html(print_r(WpssoUtil::active_plugins(), true), 'active plugins'); $this->p->debug->show_html(null, 'debug log'); } ?> <div class="wrap" id="<?php echo $this->pagehook; ?> "> <h1><?php echo $this->p->cf['plugin'][$this->p->cf['lca']]['short'] . self::$is_suffix . ' – ' . $this->menu_name; ?> </h1> <div id="poststuff" class="metabox-holder has-right-sidebar"> <div id="side-info-column" class="inner-sidebar"> <?php do_meta_boxes($this->pagehook, 'side', null); ?> </div><!-- .inner-sidebar --> <div id="post-body" class="has-sidebar"> <div id="post-body-content" class="has-sidebar-content"> <?php $this->show_form_content(); ?> </div><!-- .post-body-content --> </div><!-- .post-body --> </div><!-- .metabox-holder --> </div><!-- .wrap --> <script type="text/javascript"> //<![CDATA[ jQuery(document).ready( function($) { // close postboxes that should be closed $('.if-js-closed').removeClass('if-js-closed').addClass('closed'); // postboxes setup postboxes.add_postbox_toggles('<?php echo $this->pagehook; ?> '); } ); //]]> </script> <?php }