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 = NgfbUtil::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 WordPress SEO opengraph, twitter, publisher, and author meta tags if (function_exists('wpseo_init') || isset($this->active_plugins['wordpress-seo/wp-seo.php'])) { global $wpseo_og; if (is_object($wpseo_og) && ($prio = has_action('wpseo_head', array($wpseo_og, 'opengraph')))) { $ret = remove_action('wpseo_head', array($wpseo_og, 'opengraph'), $prio); } if (!empty($this->p->options['tc_enable']) && $this->aop()) { global $wpseo_twitter; if (is_object($wpseo_twitter) && ($prio = has_action('wpseo_head', array($wpseo_twitter, 'twitter')))) { $ret = remove_action('wpseo_head', array($wpseo_twitter, 'twitter'), $prio); } } if (!empty($this->p->options['seo_publisher_url'])) { global $wpseo_front; if (is_object($wpseo_front) && ($prio = has_action('wpseo_head', array($wpseo_front, 'publisher')))) { $ret = remove_action('wpseo_head', array($wpseo_front, 'publisher'), $prio); } } if (!empty($this->p->options['seo_def_author_id']) && !empty($this->p->options['seo_def_author_on_index'])) { global $wpseo_front; if (is_object($wpseo_front) && ($prio = has_action('wpseo_head', array($wpseo_front, 'author')))) { $ret = remove_action('wpseo_head', array($wpseo_front, 'author'), $prio); } } if (!empty($this->p->options['schema_website_json'])) { add_filter('wpseo_json_ld_output', '__return_empty_array', 99); } } } do_action($this->p->cf['lca'] . '_init_check', $this->active_plugins); }
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['metatags']) { 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']['NGFB_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('/^NGFB_/', $defined_constants['user']), 'ngfb constants'); // show active plugins $this->p->debug->show_html(print_r(NgfbUtil::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, '_html') !== false: case strpos($key, '_css_') !== false: case strpos($key, '_js_') !== false: case preg_match('/_(key|tid)$/', $key): $opts[$key] = '********'; } } $this->p->debug->show_html($opts, 'ngfb settings'); } // end of debug information }
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 = NgfbUtil::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); } } do_action($this->p->cf['lca'] . '_init_check', $this->active_plugins); }
public function show_form_page() { $short_aop = $this->p->cf['plugin'][$this->p->cf['lca']]['short'] . ($this->p->check->aop($this->p->cf['lca']) ? ' Pro' : ' Free'); if (!$this->is_setting($this->menu_id)) { // the "setting" pages display their own error messages settings_errors(NGFB_OPTIONS_NAME); } // display "error" and "updated" messages $this->set_form(); // 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(NgfbUtil::active_plugins(), true), 'active plugins'); $this->p->debug->show_html(null, 'debug log'); } ?> <div class="wrap" id="<?php echo $this->pagehook; ?> "> <h2><?php $this->show_follow_icons(); echo $short_aop . ' – ' . $this->menu_name; ?> </h2> <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 }
private function activate_plugin() { $lca = NgfbConfig::$cf['lca']; $uca = strtoupper($lca); $short = NgfbConfig::$cf['plugin'][$lca]['short']; $version = NgfbConfig::$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 = NgfbConfig::$cf[$key]['min_version']; if (version_compare($req_version, $min_version, '<')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; deactivate_plugins(NGFB_PLUGINBASE); error_log(NGFB_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(); NgfbUtil::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 show_setting_page($sidebar = true) { if (!$this->is_setting()) { settings_errors(NGFB_OPTIONS_NAME); } $this->set_form_property(); // set 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(NgfbUtil::active_plugins(), true), 'active plugins'); $this->p->debug->show_html(null, 'debug log'); } echo '<div class="wrap" id="' . $this->pagehook . '">' . "\n"; echo '<h1>' . $this->p->cf['plugin'][$this->p->cf['lca']]['short'] . self::$is_suffix . ' – ' . $this->menu_name . '</h1>' . "\n"; if ($sidebar === false) { echo '<div id="poststuff" class="metabox-holder">' . "\n"; echo '<div id="post-body">' . "\n"; echo '<div id="post-body-content">' . "\n"; } else { echo '<div id="poststuff" class="metabox-holder has-right-sidebar">' . "\n"; echo '<div id="side-info-column" class="inner-sidebar">' . "\n"; do_meta_boxes($this->pagehook, 'side', null); echo '</div><!-- .inner-sidebar -->' . "\n"; echo '<div id="post-body" class="has-sidebar">' . "\n"; echo '<div id="post-body-content" class="has-sidebar-content">' . "\n"; } $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 }
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'], '!=')) { NgfbUtil::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 NGFB_PLUGINDIR . 'lib/upgrade.php'; $this->upg = new NgfbOptionsUpgrade($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('NGFB_META_GENERATOR_DISABLE') && NGFB_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.', 'nextgen-facebook'), $options_name); } elseif (!is_array($opts)) { $err_msg = sprintf(__('WordPress returned a non-array value when reading %s from the options table.', 'nextgen-facebook'), $options_name); } elseif (empty($opts)) { $err_msg = sprintf(__('WordPress returned an empty array when reading %s from the options table.', 'nextgen-facebook'), $options_name); } else { $err_msg = sprintf(__('WordPress returned an unknown condition when reading %s from the options table.', 'nextgen-facebook'), $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>.', 'nextgen-facebook'), $url)); } } return $opts; }