Example #1
0
 public static function get_config($idx = '', $filter = false)
 {
     if (!isset(self::$cf['config_filtered']) || self::$cf['config_filtered'] !== true) {
         if ($filter === true) {
             self::$cf = apply_filters(self::$cf['lca'] . '_get_config', self::$cf);
             self::$cf['config_filtered'] = true;
             self::$cf['*'] = array('lib' => array(), 'version' => '');
             foreach (self::$cf['plugin'] as $lca => $info) {
                 if (isset($info['lib']) && is_array($info['lib'])) {
                     self::$cf['*']['lib'] = SucomUtil::array_merge_recursive_distinct(self::$cf['*']['lib'], $info['lib']);
                 }
                 if (isset($info['version'])) {
                     self::$cf['*']['version'] .= '-' . $lca . $info['version'];
                 }
             }
             self::$cf['*']['version'] = trim(self::$cf['*']['version'], '-');
         }
     }
     if (!empty($idx)) {
         if (array_key_exists($idx, self::$cf)) {
             return self::$cf[$idx];
         } else {
             return false;
         }
     } else {
         return self::$cf;
     }
 }
 public static function get_config($idx = false, $filter = false)
 {
     if (!isset(self::$cf['config_filtered']) || self::$cf['config_filtered'] !== true) {
         if ($filter === true) {
             self::$cf['opt']['version'] .= is_dir(trailingslashit(dirname(__FILE__)) . 'pro/') ? 'pro' : 'gpl';
             self::$cf = apply_filters(self::$cf['lca'] . '_get_config', self::$cf);
             self::$cf['config_filtered'] = true;
             self::$cf['*'] = array('lib' => array(), 'version' => '');
             foreach (self::$cf['plugin'] as $lca => $info) {
                 if (isset($info['lib']) && is_array($info['lib'])) {
                     self::$cf['*']['lib'] = SucomUtil::array_merge_recursive_distinct(self::$cf['*']['lib'], $info['lib']);
                 }
                 if (isset($info['version'])) {
                     self::$cf['*']['version'] .= '-' . $lca . $info['version'];
                 }
             }
             self::$cf['*']['version'] = trim(self::$cf['*']['version'], '-');
         }
         // complete relative paths in the image array
         foreach (self::$cf['plugin'] as $lca => $info) {
             if (isset($info['base'])) {
                 $base = self::$cf['plugin'][$lca]['base'];
                 // wpsso/wpsso.php
                 foreach (array('img') as $sub) {
                     if (isset($info[$sub]) && is_array($info[$sub])) {
                         foreach ($info[$sub] as $id => $url) {
                             if (!empty($url) && strpos($url, '//') === false) {
                                 self::$cf['plugin'][$lca][$sub][$id] = trailingslashit(plugins_url('', $base)) . $url;
                             }
                         }
                     }
                 }
             }
         }
     }
     if (!empty($idx)) {
         if (array_key_exists($idx, self::$cf)) {
             return self::$cf[$idx];
         } else {
             return false;
         }
     } else {
         return self::$cf;
     }
 }
Example #3
0
 private static function uninstall_plugin()
 {
     global $wpdb;
     $cf = WpssoConfig::get_config();
     $slug = $cf['plugin'][$cf['lca']]['slug'];
     $options = get_option($cf['lca'] . '_options');
     if (empty($options['plugin_preserve'])) {
         delete_option($cf['lca'] . '_options');
         delete_post_meta_by_key('_' . $cf['lca'] . '_meta');
         WpssoUser::delete_metabox_prefs();
     }
     // delete update related options
     delete_option('external_updates-' . $slug);
     delete_option($cf['lca'] . '_umsg');
     delete_option($cf['lca'] . '_utime');
     // delete stored admin notices
     foreach (array('nag', 'err', 'inf') as $type) {
         $msg_opt = $cf['lca'] . '_notices_' . $type;
         delete_option($msg_opt);
         foreach (get_users(array('meta_key' => $msg_opt)) as $user) {
             delete_user_option($user->ID, $msg_opt);
         }
     }
     // delete transients
     $dbquery = 'SELECT option_name FROM ' . $wpdb->options . ' WHERE option_name LIKE \'_transient_timeout_' . $cf['lca'] . '_%\';';
     $expired = $wpdb->get_col($dbquery);
     foreach ($expired as $transient) {
         $key = str_replace('_transient_timeout_', '', $transient);
         if (!empty($key)) {
             delete_transient($key);
         }
     }
 }
Example #4
0
 public static function delete_metabox_prefs($user_id = false)
 {
     $user_id = $user_id === false ? get_current_user_id() : $user_id;
     $cf = WpssoConfig::get_config(false, true);
     $parent_slug = 'options-general.php';
     foreach (array_keys($cf['*']['lib']['setting']) as $id) {
         $menu_slug = $cf['lca'] . '-' . $id;
         self::delete_metabox_pagehook($user_id, $menu_slug, $parent_slug);
     }
     $parent_slug = $cf['lca'] . '-' . key($cf['*']['lib']['submenu']);
     foreach (array_keys($cf['*']['lib']['submenu']) as $id) {
         $menu_slug = $cf['lca'] . '-' . $id;
         self::delete_metabox_pagehook($user_id, $menu_slug, $parent_slug);
     }
 }
Example #5
0
 public function set_config()
 {
     $this->cf = WpssoConfig::get_config(null, true);
     // apply filters - define the $cf['*'] array
 }
 private function min_version_notice()
 {
     $info = WpssoJsonConfig::$cf['plugin']['wpssojson'];
     $wpsso_version = WpssoConfig::get_version();
     if ($this->p->debug->enabled) {
         $this->p->debug->log($info['name'] . ' requires ' . $info['req']['short'] . ' v' . $info['req']['min_version'] . ' or newer (' . $wpsso_version . ' installed)');
     }
     if (is_admin()) {
         $this->p->notice->err(sprintf(__('The %1$s extension v%2$s requires %3$s v%4$s or newer (v%5$s currently installed).', 'wpsso-schema-json-ld'), $info['name'], $info['version'], $info['req']['short'], $info['req']['min_version'], $wpsso_version));
     }
 }
 public function set_objects($activate = false)
 {
     /*
      * basic plugin setup (settings, check, debug, notices, utils)
      */
     $this->set_options();
     // filter and define the $this->options and $this->site_options properties
     $this->check = new WpssoCheck($this);
     $this->is_avail = $this->check->get_avail();
     // uses $this->options in checks
     // configure the debug class
     $html_debug = !empty($this->options['plugin_debug']) || defined('WPSSO_HTML_DEBUG') && WPSSO_HTML_DEBUG ? true : false;
     $wp_debug = defined('WPSSO_WP_DEBUG') && WPSSO_WP_DEBUG ? true : false;
     if (($html_debug || $wp_debug) && ($classname = WpssoConfig::load_lib(false, 'com/debug', 'SucomDebug')) !== false) {
         $this->debug = new $classname($this, array('html' => $html_debug, 'wp' => $wp_debug));
     } else {
         $this->debug = new WpssoNoDebug();
     }
     // fallback to dummy debug class
     if ($this->debug->enabled && $activate === true) {
         $this->debug->log('method called for plugin activation');
     }
     $this->notice = new SucomNotice($this);
     $this->util = new WpssoUtil($this);
     $this->opt = new WpssoOptions($this);
     $this->cache = new SucomCache($this);
     // object and file caching
     $this->style = new SucomStyle($this);
     // admin styles
     $this->script = new SucomScript($this);
     // admin jquery tooltips
     $this->webpage = new SucomWebpage($this);
     // title, desc, etc., plus shortcodes
     $this->media = new WpssoMedia($this);
     // images, videos, etc.
     $this->head = new WpssoHead($this);
     // open graph and twitter card meta tags
     $this->og = new WpssoOpengraph($this);
     // prepare open graph array
     $this->schema = new WpssoSchema($this);
     if (is_admin()) {
         $this->msgs = new WpssoMessages($this);
         // admin tooltip messages
         $this->admin = new WpssoAdmin($this);
         // admin menus and page loader
     }
     $this->loader = new WpssoLoader($this, $activate);
     do_action('wpsso_init_objects', $activate);
     /*
      * check and create the default options array
      * execute after all objects have been defines, so hooks into 'wpsso_get_defaults' are available
      */
     if (is_multisite() && (!is_array($this->site_options) || empty($this->site_options))) {
         $this->site_options = $this->opt->get_site_defaults();
     }
     /*
      * end here when called for plugin activation (the init_plugin() hook handles the rest)
      */
     if ($activate == true || !empty($_GET['action']) && $_GET['action'] == 'activate-plugin' && !empty($_GET['plugin']) && $_GET['plugin'] == WPSSO_PLUGINBASE) {
         if ($this->debug->enabled) {
             $this->debug->log('exiting early: init_plugin() hook will follow');
         }
         return;
     }
     /*
      * check and upgrade options if necessary
      */
     $this->options = $this->opt->check_options(WPSSO_OPTIONS_NAME, $this->options);
     if (is_multisite()) {
         $this->site_options = $this->opt->check_options(WPSSO_SITE_OPTIONS_NAME, $this->site_options, true);
     }
     /*
      * configure class properties based on plugin settings
      */
     $this->cache->default_object_expire = $this->options['plugin_object_cache_exp'];
     $this->cache->default_file_expire = $this->check->aop() ? $this->debug->is_enabled('wp') ? WPSSO_DEBUG_FILE_EXP : $this->options['plugin_file_cache_exp'] : 0;
     $this->is_avail['cache']['file'] = $this->cache->default_file_expire > 0 ? true : false;
     // disable the transient cache if html debug mode is on
     if ($this->debug->is_enabled('html') === true) {
         $this->is_avail['cache']['transient'] = defined('WPSSO_TRANSIENT_CACHE_DISABLE') && !WPSSO_TRANSIENT_CACHE_DISABLE ? true : false;
         $cache_status = 'transient cache use ' . ($this->is_avail['cache']['transient'] ? 'could not be' : 'is') . ' disabled';
         if ($this->debug->enabled) {
             $this->debug->log('html debug mode is active: ' . $cache_status);
         }
         $this->notice->inf('HTML debug mode is active – ' . $cache_status . ' and informational messages are being added as hidden HTML comments.');
     }
     if (!empty($this->options['plugin_wpsso_tid'])) {
         $this->util->add_plugin_filters($this, array('installed_version' => 1, 'ua_plugin' => 1));
     }
 }
Example #8
0
 private static function uninstall_plugin()
 {
     $var_const = WpssoConfig::get_variable_constants();
     $opts = get_option($var_const['WPSSO_OPTIONS_NAME'], array());
     delete_option($var_const['WPSSO_TS_NAME']);
     delete_option($var_const['WPSSO_NOTICE_NAME']);
     if (empty($opts['plugin_preserve'])) {
         delete_option($var_const['WPSSO_OPTIONS_NAME']);
         delete_post_meta_by_key($var_const['WPSSO_META_NAME']);
         foreach (get_users() as $user) {
             // site specific user options
             delete_user_option($user->ID, $var_const['WPSSO_NOTICE_NAME']);
             delete_user_option($user->ID, $var_const['WPSSO_DISMISS_NAME']);
             // global / network user options
             delete_user_meta($user->ID, $var_const['WPSSO_META_NAME']);
             delete_user_meta($user->ID, $var_const['WPSSO_PREF_NAME']);
             WpssoUser::delete_metabox_prefs($user->ID);
         }
         foreach (WpssoTaxonomy::get_public_terms() as $term_id) {
             WpssoTaxonomy::delete_term_meta($term_id, $var_const['WPSSO_META_NAME']);
         }
     }
     // delete transients
     global $wpdb;
     $dbquery = 'SELECT option_name FROM ' . $wpdb->options . ' WHERE option_name LIKE \'_transient_timeout_wpsso_%\';';
     $expired = $wpdb->get_col($dbquery);
     foreach ($expired as $transient) {
         $key = str_replace('_transient_timeout_', '', $transient);
         if (!empty($key)) {
             delete_transient($key);
         }
     }
 }
 private static function uninstall_plugin()
 {
     $cf = WpssoConfig::get_config();
     if (!defined('WPSSO_OPTIONS_NAME')) {
         define('WPSSO_OPTIONS_NAME', $cf['lca'] . '_options');
     }
     if (!defined('WPSSO_META_NAME')) {
         define('WPSSO_META_NAME', '_' . $cf['lca'] . '_meta');
     }
     if (!defined('WPSSO_PREF_NAME')) {
         define('WPSSO_PREF_NAME', '_' . $cf['lca'] . '_pref');
     }
     $slug = $cf['plugin'][$cf['lca']]['slug'];
     $opts = get_option(WPSSO_OPTIONS_NAME);
     if (empty($opts['plugin_preserve'])) {
         delete_option(WPSSO_OPTIONS_NAME);
         delete_post_meta_by_key(WPSSO_META_NAME);
         foreach (array(WPSSO_META_NAME, WPSSO_PREF_NAME) as $meta_key) {
             foreach (get_users(array('meta_key' => $meta_key)) as $user) {
                 delete_user_option($user->ID, $meta_key);
                 WpssoUser::delete_metabox_prefs($user->ID);
             }
         }
         foreach (WpssoTaxonomy::get_public_terms() as $term_id) {
             WpssoTaxonomy::delete_term_meta($term_id, WPSSO_META_NAME);
         }
     }
     // delete transients
     global $wpdb;
     $dbquery = 'SELECT option_name FROM ' . $wpdb->options . ' WHERE option_name LIKE \'_transient_timeout_' . $cf['lca'] . '_%\';';
     $expired = $wpdb->get_col($dbquery);
     foreach ($expired as $transient) {
         $key = str_replace('_transient_timeout_', '', $transient);
         if (!empty($key)) {
             delete_transient($key);
         }
     }
 }