public static function loadAllOptions() { global $wpdb; $options = wp_cache_get('alloptions', 'wordfence'); if (!$options) { $table = self::table(); self::updateTableExists(); $suppress = $wpdb->suppress_errors(); if (!($rawOptions = $wpdb->get_results("SELECT name, val FROM {$table} WHERE autoload = 'yes'"))) { $rawOptions = $wpdb->get_results("SELECT name, val FROM {$table}"); } $wpdb->suppress_errors($suppress); $options = array(); foreach ((array) $rawOptions as $o) { if (in_array($o->name, self::$serializedOptions)) { $val = maybe_unserialize($o->val); if ($val) { $options[$o->name] = $val; } } else { $options[$o->name] = $o->val; } } wp_cache_add_non_persistent_groups('wordfence'); wp_cache_add('alloptions', $options, 'wordfence'); } return $options; }
/** * PHP 5 constructor * * @since 1.0-beta */ function __construct() { // Define post type and taxonomy names for use in the register functions $this->post_type_name = apply_filters('bp_docs_post_type_name', 'bp_doc'); $this->associated_item_tax_name = apply_filters('bp_docs_associated_item_tax_name', 'bp_docs_associated_item'); $this->access_tax_name = apply_filters('bp_docs_access_tax_name', 'bp_docs_access'); // :'( wp_cache_add_non_persistent_groups(array('bp_docs_nonpersistent')); // Let plugins know that BP Docs has started loading add_action('plugins_loaded', array($this, 'load_hook'), 20); // Load predefined constants first thing add_action('bp_docs_load', array($this, 'load_constants'), 2); // Includes necessary files add_action('bp_docs_load', array($this, 'includes'), 4); // Load the BP Component extension add_action('bp_docs_load', array($this, 'do_integration'), 6); // Load textdomain add_action('bp_docs_load', array($this, 'load_plugin_textdomain')); // Let other plugins know that BP Docs has finished initializing add_action('bp_init', array($this, 'init_hook')); // Hooks into the 'init' action to register our WP custom post type and tax add_action('bp_docs_init', array($this, 'register_post_type'), 2); add_action('bp_docs_init', array(&$this, 'add_rewrite_tags'), 4); // Set up doc taxonomy, etc add_action('bp_docs_init', array($this, 'load_doc_extras'), 8); // Add rewrite rules add_action('generate_rewrite_rules', array(&$this, 'generate_rewrite_rules')); // parse_query add_action('parse_query', array($this, 'parse_query')); // Protect doc access add_action('template_redirect', array($this, 'protect_doc_access')); add_action('admin_init', array($this, 'flush_rewrite_rules')); }
function __construct() { // vars $this->cache = array(); $this->reference = array(); // prevent ACF from persistent cache wp_cache_add_non_persistent_groups('acf'); }
/** * Adds a non-persistent group to the list. * * @uses wp_cache_add_non_persistent_groups * * @param array $args Function arguments. * @param array $assoc_args Function arguments with parameter key. * @return void */ public function add_non_persistent_groups($args, $assoc_args) { if (empty($args)) { WP_CLI::line('usage: wp cache add_non_persistent_groups <group>'); exit; } $group = $args[0]; wp_cache_add_non_persistent_groups($group); }
function init() { //Add non-persistent cache group wp_cache_add_non_persistent_groups(self::SLUG); //Registers GET listener to toggle setting $this->register_endpoints(); //Message if WPML installed if ($this->wpml_installed()) { add_action('admin_notices', array($this, 'admin_notices')); } }
/** * Constructor. * * @since 1.9 */ public function __construct() { if (!bp_docs_enable_folders()) { return; } $this->register_post_type(); $this->register_taxonomies(); // It is my hope and dream that this will one day be persistent. wp_cache_add_non_persistent_groups(array('bp_docs_folders')); add_action('bp_docs_enqueue_scripts', array($this, 'enqueue_assets')); $this->setup_hooks(); }
function flush_cache() { global $wp_object_cache; $wp_object_cache->group_ops = array(); $wp_object_cache->stats = array(); $wp_object_cache->memcache_debug = array(); $wp_object_cache->cache = array(); if ( method_exists( $wp_object_cache, '__remoteset' ) ) { $wp_object_cache->__remoteset(); } wp_cache_flush(); wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache' ) ); wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) ); }
public function init() { wp_cache_add_non_persistent_groups('my-wp-backup'); add_action('admin_post_MyWPBackup_settings', array($this, 'post_settings')); add_action('admin_post_MyWPBackup_import', array($this, 'post_import')); add_action(is_multisite() ? 'network_admin_notices' : 'admin_notices', array($this, 'admin_notice')); global $current_user; $user_id = $current_user->ID; if (is_multisite() && is_network_admin() || !is_multisite() && current_user_can('manage_options')) { if ('1' === filter_input(INPUT_GET, 'mwpb_notice_close', FILTER_SANITIZE_NUMBER_INT)) { add_user_meta($user_id, 'mwpb-notice-1', 'true', true); } } Job::get_instance(); Backup::get_instance(); }
public function add_cache_groups() { if (function_exists('wp_cache_add_non_persistent_groups')) { wp_cache_add_non_persistent_groups(array('bu-navigation')); } }
/** * Add our non-persistent cache group. * * BuddyPress does not have decent (any) cache support for groups-of-member queries. Adding a * non-persistent group here so that we don't have to worry about invalidation. At least this * will help with single pages. */ function cacsp_add_non_persistent_cache_group() { wp_cache_add_non_persistent_groups(array('cacsp_groups_of_user')); }
/** * Starts the WordPress object cache. * * If an object-cache.php file exists in the wp-content directory, * it uses that drop-in as an external object cache. * * @access private * @since 3.0.0 */ function wp_start_object_cache() { $first_init = false; if (!function_exists('wp_cache_init')) { global $_wp_using_ext_object_cache; if (file_exists(WP_CONTENT_DIR . '/object-cache.php')) { require_once WP_CONTENT_DIR . '/object-cache.php'; $_wp_using_ext_object_cache = true; } else { require_once ABSPATH . WPINC . '/cache.php'; $_wp_using_ext_object_cache = false; } $first_init = true; } // If cache supports reset, reset instead of init if already initialized. // Reset signals to the cache that global IDs have changed and it may need to update keys // and cleanup caches. if (!$first_init && function_exists('wp_cache_reset')) { wp_cache_reset(); } else { wp_cache_init(); } if (function_exists('wp_cache_add_global_groups')) { wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts')); wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins')); } }
/** * Start the WordPress object cache. * * If an object-cache.php file exists in the wp-content directory, * it uses that drop-in as an external object cache. * * @since 3.0.0 * @access private * * @global int $blog_id Blog ID. */ function wp_start_object_cache() { global $blog_id; $first_init = false; if (!function_exists('wp_cache_init')) { if (file_exists(WP_CONTENT_DIR . '/object-cache.php')) { require_once WP_CONTENT_DIR . '/object-cache.php'; if (function_exists('wp_cache_init')) { wp_using_ext_object_cache(true); } } $first_init = true; } elseif (!wp_using_ext_object_cache() && file_exists(WP_CONTENT_DIR . '/object-cache.php')) { /* * Sometimes advanced-cache.php can load object-cache.php before * it is loaded here. This breaks the function_exists check above * and can result in `$_wp_using_ext_object_cache` being set * incorrectly. Double check if an external cache exists. */ wp_using_ext_object_cache(true); } if (!wp_using_ext_object_cache()) { require_once ABSPATH . WPINC . '/cache.php'; } /* * If cache supports reset, reset instead of init if already * initialized. Reset signals to the cache that global IDs * have changed and it may need to update keys and cleanup caches. */ if (!$first_init && function_exists('wp_cache_switch_to_blog')) { wp_cache_switch_to_blog($blog_id); } elseif (function_exists('wp_cache_init')) { wp_cache_init(); } if (function_exists('wp_cache_add_global_groups')) { wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache')); wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins')); } }
/** * Starts the WordPress object cache. * * If an object-cache.php file exists in the wp-content directory, * it uses that drop-in as an external object cache. * * @access private * @since 3.0.0 */ function wp_start_object_cache() { global $_wp_using_ext_object_cache; $first_init = false; if (!function_exists('wp_cache_init')) { if (file_exists(WP_CONTENT_DIR . '/object-cache.php')) { require_once WP_CONTENT_DIR . '/object-cache.php'; $_wp_using_ext_object_cache = true; } else { require_once ABSPATH . WPINC . '/cache.php'; $_wp_using_ext_object_cache = false; } $first_init = true; } else { if (!$_wp_using_ext_object_cache && file_exists(WP_CONTENT_DIR . '/object-cache.php')) { // Sometimes advanced-cache.php can load object-cache.php before it is loaded here. // This breaks the function_exists check above and can result in $_wp_using_ext_object_cache // being set incorrectly. Double check if an external cache exists. $_wp_using_ext_object_cache = true; } } // If cache supports reset, reset instead of init if already initialized. // Reset signals to the cache that global IDs have changed and it may need to update keys // and cleanup caches. if (!$first_init && function_exists('wp_cache_reset')) { wp_cache_reset(); } else { wp_cache_init(); } if (function_exists('wp_cache_add_global_groups')) { wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts')); wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins')); } }
function restore_current_blog() { global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache; if (!$switched) { return false; } if (!is_array($switched_stack)) { return false; } $blog = array_pop($switched_stack); if ($blog_id == $blog) { do_action('switch_blog', $blog, $blog); /* If we still have items in the switched stack, consider ourselves still 'switched' */ $switched = is_array($switched_stack) && count($switched_stack) > 0; return true; } $wpdb->set_blog_id($blog); $prev_blog_id = $blog_id; $blog_id = $blog; $table_prefix = $wpdb->prefix; if (is_object($wp_roles)) { $wpdb->suppress_errors(); if (method_exists($wp_roles, '_init')) { $wp_roles->_init(); } elseif (method_exists($wp_roles, '__construct')) { $wp_roles->__construct(); } $wpdb->suppress_errors(false); } if (did_action('init')) { $current_user = wp_get_current_user(); if (is_object($current_user)) { $current_user->for_blog($blog_id); } } if (is_object($wp_object_cache) && isset($wp_object_cache->global_groups)) { $global_groups = $wp_object_cache->global_groups; } else { $global_groups = false; } wp_cache_init(); if (function_exists('wp_cache_add_global_groups')) { if (is_array($global_groups)) { wp_cache_add_global_groups($global_groups); } else { wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts')); } wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins')); } do_action('switch_blog', $blog_id, $prev_blog_id); /* If we still have items in the switched stack, consider ourselves still 'switched' */ $switched = is_array($switched_stack) && count($switched_stack) > 0; return true; }
<?php /** * Turn off persistent caching for users. * * We use memcached for GlotPress because query calculations are very heavy and slow. * * However some issues were noticed with persistent user caching (very likely due to the WP.org setup) * so this turns it off. User queries in GlotPress are comparatively very light. * * We should test this and remove this plugin at a later date. * * @author Nacin */ wp_cache_add_non_persistent_groups(array('users', 'userlogins', 'usermeta', 'usermail', 'usernicename'));
/** * generate() * * @return bool $success **/ function generate() { if (function_exists('memory_get_usage') && (int) @ini_get('memory_limit') < 256) { @ini_set('memory_limit', '256M'); } include_once dirname(__FILE__) . '/xml-sitemaps-utils.php'; # disable persistent groups, so as to not pollute memcached wp_cache_add_non_persistent_groups(array('posts', 'post_meta')); # only keep fields involved in permalinks add_filter('posts_fields_request', array($this, 'kill_query_fields')); # sitemap.xml $sitemap = new sitemap_xml(); $return = $sitemap->generate(); # restore fields remove_filter('posts_fields_request', array($this, 'kill_query_fields')); return $return; }
public function get_content($post_id = 0, $use_post = true, $use_cache = true, $md_idx = null, $src_id = '') { if ($this->p->debug->enabled) { $this->p->debug->args(array('post_id' => $post_id, 'use_post' => $use_post, 'use_cache' => $use_cache, 'md_idx' => $md_idx, 'src_id' => $src_id)); } $content = false; // if $post_id is 0, then pass the $use_post (true/false) value instead if (($obj = $this->p->util->get_post_object(empty($post_id) ? $use_post : $post_id)) === false) { if ($this->p->debug->enabled) { $this->p->debug->log('exiting early: invalid object type'); } return $content; } $post_id = empty($obj->ID) || empty($obj->post_type) ? 0 : $obj->ID; if ($this->p->debug->enabled) { $this->p->debug->log('using content from object id ' . $post_id); } $filter_content = $this->p->options['plugin_filter_content']; $filter_name = $filter_content ? 'filtered' : 'unfiltered'; $caption_prefix = isset($this->p->options['plugin_p_cap_prefix']) ? $this->p->options['plugin_p_cap_prefix'] : 'Caption:'; /* * retrieve the content */ if ($filter_content == true) { if ($this->p->is_avail['cache']['object']) { // if the post id is 0, then add the sharing url to ensure a unique salt string $cache_salt = __METHOD__ . '(lang:' . SucomUtil::get_locale() . '_post:' . $post_id . '_' . $filter_name . (empty($post_id) ? '_url:' . $this->p->util->get_sharing_url($use_post, true, $src_id) : '') . ')'; $cache_id = $this->p->cf['lca'] . '_' . md5($cache_salt); $cache_type = 'object cache'; if ($use_cache === true) { if ($this->p->debug->enabled) { $this->p->debug->log($cache_type . ': wp_cache salt ' . $cache_salt); } $content = wp_cache_get($cache_id, __METHOD__); if ($content !== false) { if ($this->p->debug->enabled) { $this->p->debug->log($cache_type . ': ' . $filter_name . ' content retrieved from wp_cache ' . $cache_id); } return $content; } } elseif ($this->p->debug->enabled) { $this->p->debug->log('use_cache = false'); } } } $content = apply_filters($this->p->cf['lca'] . '_content_seed', '', $post_id, $use_post, $md_idx, $src_id); if (!empty($content)) { if ($this->p->debug->enabled) { $this->p->debug->log('content seed = "' . $content . '"'); } } elseif (!empty($obj->post_content)) { $content = $obj->post_content; } elseif ($this->p->debug->enabled) { $this->p->debug->log('exiting early: empty post content'); } /* * modify the content */ // save content length (for comparison) before making changes $content_strlen_before = strlen($content); // remove singlepics, which we detect and use before-hand $content = preg_replace('/\\[singlepic[^\\]]+\\]/', '', $content, -1, $count); if ($count > 0) { if ($this->p->debug->enabled) { $this->p->debug->log($count . ' [singlepic] shortcode(s) removed from content'); } } if ($filter_content == true) { $filter_removed = apply_filters($this->p->cf['lca'] . '_pre_filter_remove', false, 'the_content'); // remove all of our shortcodes if (isset($this->p->cf['*']['lib']['shortcode']) && is_array($this->p->cf['*']['lib']['shortcode'])) { foreach ($this->p->cf['*']['lib']['shortcode'] as $id => $name) { if (array_key_exists($id, $this->shortcode) && is_object($this->shortcode[$id])) { $this->shortcode[$id]->remove(); } } } global $post; $saved_post = $post; // woocommerce can change the $post, so save and restore if ($this->p->debug->enabled) { $this->p->debug->log('saving $post and applying the_content filters'); } $content = apply_filters('the_content', $content); $post = $saved_post; // cleanup for NGG pre-v2 album shortcode unset($GLOBALS['subalbum']); unset($GLOBALS['nggShowGallery']); if ($filter_removed) { $filter_added = apply_filters($this->p->cf['lca'] . '_post_filter_add', false, 'the_content'); } // add our shortcodes back if (isset($this->p->cf['*']['lib']['shortcode']) && is_array($this->p->cf['*']['lib']['shortcode'])) { foreach ($this->p->cf['*']['lib']['shortcode'] as $id => $name) { if (array_key_exists($id, $this->shortcode) && is_object($this->shortcode[$id])) { $this->shortcode[$id]->add(); } } } } elseif ($this->p->debug->enabled) { $this->p->debug->log('the_content filters skipped'); } $content = preg_replace('/[\\s\\n\\r]+/s', ' ', $content); // put everything on one line $content = preg_replace('/^.*<!--' . $this->p->cf['lca'] . '-content-->(.*)<!--\\/' . $this->p->cf['lca'] . '-content-->.*$/', '$1', $content); if (strpos($content, '>Google+<') !== false) { $content = preg_replace('/<a +rel="author" +href="" +style="display:none;">Google\\+<\\/a>/', ' ', $content); } if (!empty($caption_prefix) && strpos($content, '<p class="wp-caption-text">') !== false) { $content = preg_replace('/<p class="wp-caption-text">/', '${0}' . $caption_prefix . ' ', $content); } if (strpos($content, ']]>') !== false) { $content = str_replace(']]>', ']]>', $content); } $content_strlen_after = strlen($content); if ($this->p->debug->enabled) { $this->p->debug->log('content strlen before ' . $content_strlen_before . ' and after changes / filters ' . $content_strlen_after); } // apply filters before caching $content = apply_filters($this->p->cf['lca'] . '_content', $content, $post_id, $use_post, $md_idx, $src_id); if ($filter_content == true && !empty($cache_id)) { // only some caching plugins implement this function wp_cache_add_non_persistent_groups(array(__METHOD__)); wp_cache_set($cache_id, $content, __METHOD__, $this->p->options['plugin_object_cache_exp']); if ($this->p->debug->enabled) { $this->p->debug->log($cache_type . ': ' . $filter_name . ' content saved to wp_cache ' . $cache_id . ' (' . $this->p->options['plugin_object_cache_exp'] . ' seconds)'); } } return $content; }
public function get_content($use_post = true, $use_cache = true) { $this->p->debug->args(array('use_post' => $use_post, 'use_cache' => $use_cache)); $content = false; if (($obj = $this->p->util->get_post_object($use_post)) === false) { $this->p->debug->log('exiting early: invalid object type'); return $content; } $post_id = empty($obj->ID) ? 0 : $obj->ID; $this->p->debug->log('using content from object id ' . $post_id); $filter_content = $this->p->options['plugin_filter_content']; $filter_name = $filter_content ? 'filtered' : 'unfiltered'; /* * retrieve the content */ if ($filter_content == true) { if ($this->p->is_avail['cache']['object']) { // if the post id is 0, then add the sharing url to ensure a unique salt string $cache_salt = __METHOD__ . '(lang:' . SucomUtil::get_locale() . '_post:' . $post_id . '_' . $filter_name . (empty($post_id) ? '_url:' . $this->p->util->get_sharing_url($use_post) : '') . ')'; $cache_id = $this->p->cf['lca'] . '_' . md5($cache_salt); $cache_type = 'object cache'; if ($use_cache === true) { $this->p->debug->log($cache_type . ': wp_cache salt ' . $cache_salt); $content = wp_cache_get($cache_id, __METHOD__); if ($content !== false) { $this->p->debug->log($cache_type . ': ' . $filter_name . ' content retrieved from wp_cache ' . $cache_id); return $content; } } else { $this->p->debug->log('use cache = false'); } } } $content = apply_filters($this->p->cf['lca'] . '_content_seed', ''); if (!empty($content)) { $this->p->debug->log('content seed = "' . $content . '"'); } elseif (!empty($obj->post_content)) { $content = $obj->post_content; } else { $this->p->debug->log('exiting early: empty post content'); } /* * modify the content */ // save content length (for comparison) before making changes $content_strlen_before = strlen($content); // remove singlepics, which we detect and use before-hand $content = preg_replace('/\\[singlepic[^\\]]+\\]/', '', $content, -1, $count); if ($count > 0) { $this->p->debug->log($count . ' [singlepic] shortcode(s) removed from content'); } if ($filter_content == true) { // remove the sharing buttons filter to avoid recursive loops if (!empty($this->p->sharing) && is_object($this->p->sharing)) { $filter_removed = $this->p->sharing->remove_buttons_filter('the_content'); } else { $filter_removed = false; } // remove all of our shortcodes if (!empty($this->p->cf['lib']['shortcode']) && is_array($this->p->cf['lib']['shortcode'])) { foreach ($this->p->cf['lib']['shortcode'] as $id => $name) { if (array_key_exists($id, $this->shortcode) && is_object($this->shortcode[$id])) { $this->shortcode[$id]->remove(); } } } $this->p->debug->log('saving $post and calling apply_filters()'); global $post; $saved_post = $post; // woocommerce can change the $post, so save and restore $content = apply_filters('the_content', $content); $post = $saved_post; // cleanup for NGG pre-v2 album shortcode unset($GLOBALS['subalbum']); unset($GLOBALS['nggShowGallery']); // add the sharing buttons filter back, if it was removed if ($filter_removed) { $this->p->sharing->add_buttons_filter('the_content'); } // add our shortcodes back if (!empty($this->p->cf['lib']['shortcode']) && is_array($this->p->cf['lib']['shortcode'])) { foreach ($this->p->cf['lib']['shortcode'] as $id => $name) { if (array_key_exists($id, $this->shortcode) && is_object($this->shortcode[$id])) { $this->shortcode[$id]->add(); } } } } $content = preg_replace('/[\\r\\n\\t ]+/s', ' ', $content); // put everything on one line $content = preg_replace('/^.*<!--' . $this->p->cf['lca'] . '-content-->(.*)<!--\\/' . $this->p->cf['lca'] . '-content-->.*$/', '$1', $content); $content = preg_replace('/<a +rel="author" +href="" +style="display:none;">Google\\+<\\/a>/', ' ', $content); $content = str_replace(']]>', ']]>', $content); $content_strlen_after = strlen($content); $this->p->debug->log('content strlen() before = ' . $content_strlen_before . ', after = ' . $content_strlen_after); // apply filters before caching $content = apply_filters($this->p->cf['lca'] . '_content', $content); if ($filter_content == true && !empty($cache_id)) { // only some caching plugins implement this function wp_cache_add_non_persistent_groups(array(__METHOD__)); wp_cache_set($cache_id, $content, __METHOD__, $this->p->cache->object_expire); $this->p->debug->log($cache_type . ': ' . $filter_name . ' content saved to wp_cache ' . $cache_id . ' (' . $this->p->cache->object_expire . ' seconds)'); } return $content; }
/** * Instantiation construction * * @uses add_action() * @uses SlideDeckLitePlugin::wp_register_scripts() * @uses SlideDeckLitePlugin::wp_register_styles() */ function __construct() { define('SLIDEDECK2_URL', plugin_dir_url(__FILE__)); define('SLIDEDECK2_PATH', plugin_dir_path(__FILE__)); SlideDeckLitePlugin::load_constants(); $this->friendly_name = SlideDeckLitePlugin::$st_friendly_name; $this->namespace = SlideDeckLitePlugin::$st_namespace; /** * Make this plugin available for translation. * Translations can be added to the /languages/ directory. */ load_plugin_textdomain($this->namespace, false, dirname(plugin_basename(__FILE__)) . '/languages/'); // Load all library files used by this plugin $lib_files = glob(SLIDEDECK2_DIRNAME . '/lib/*.php'); foreach ($lib_files as $filename) { include_once $filename; } // Loop through $cache_groups to add to Non Persistent Cache if (function_exists('wp_cache_add_non_persistent_groups')) { foreach (SlideDeckLitePlugin::$cache_groups as $cache_group) { wp_cache_add_non_persistent_groups(slidedeck2_cache_group($cache_group)); } } // WordPress Pointers helper $this->Pointers = new SlideDeckPointers(); // The Lens primary class include_once SLIDEDECK2_DIRNAME . '/classes/slidedeck-lens.php'; $this->Lens = new SlideDeckLens(); // The Addons primary class include_once SLIDEDECK2_DIRNAME . '/classes/slidedeck-addons.php'; $this->Addons = new SlideDeckAddons(); // The Cover primary class if (file_exists(SLIDEDECK2_DIRNAME . '/classes/slidedeck-covers.php')) { include_once SLIDEDECK2_DIRNAME . '/classes/slidedeck-covers.php'; $this->Cover = new SlideDeckCovers(); } // The Lens scaffold include_once SLIDEDECK2_DIRNAME . '/classes/slidedeck-lens-scaffold.php'; // The Deck primary class for Deck types to child from include_once SLIDEDECK2_DIRNAME . '/classes/slidedeck.php'; // Stock Lenses that come with SlideDeck distribution $lens_files = glob(SLIDEDECK2_DIRNAME . '/lenses/*/lens.php'); if (is_dir(SLIDEDECK2_CUSTOM_LENS_DIR)) { if (is_readable(SLIDEDECK2_CUSTOM_LENS_DIR)) { // Get additional uploaded custom Lenses $custom_lens_files = (array) glob(SLIDEDECK2_CUSTOM_LENS_DIR . '/*/lens.php'); // Merge Lenses available and loop through to load $lens_files = array_merge($lens_files, $custom_lens_files); } } // Load all the custom Lens types foreach ((array) $lens_files as $filename) { if (is_readable($filename)) { $classname = slidedeck2_get_classname_from_filename(dirname($filename)); $prefix_classname = "SlideDeckLens_{$classname}"; $slug = basename(dirname($filename)); if (!class_exists($prefix_classname)) { include_once $filename; $this->installed_lenses[] = $slug; } if (class_exists($prefix_classname)) { $this->lenses[$classname] = new $prefix_classname(); } } } $source_files = (array) glob(SLIDEDECK2_DIRNAME . '/sources/*/source.php'); foreach ((array) $source_files as $filename) { if (is_readable($filename)) { include_once $filename; $slug = basename(dirname($filename)); $classname = slidedeck2_get_classname_from_filename(dirname($filename)); $prefix_classname = "SlideDeckSource_{$classname}"; if (class_exists($prefix_classname)) { $this->sources[$slug] = new $prefix_classname(); } } } // check if scheduler folder exists if (is_dir(SLIDEDECK3_ADDONS_DIR)) { $addons_directory = $this->recursive_file_exists('slidedeck_scheduler.php', SLIDEDECK3_ADDONS_DIR); if ($addons_directory !== '' && file_exists($addons_directory) && get_option("slidedeck_addon_activate", false)) { // check if scheduler addon is installed and create an instance include_once $addons_directory; SlideDeckPluginScheduler::instance(); } // Get all installed addon information. $addons = $this->Addons->get(); if (isset($addons['slidedeck_scheduler'])) { unset($addons['slidedeck_scheduler']); } // Load all activated addon. foreach ($addons as $slug => $addon) { $addon_option = "slidedeck_" . str_replace("-", "_", $slug) . "_addon_activate"; if (get_option($addon_option, false) && isset($addon['meta']['class']) && !empty($addon['meta']['class']) && isset($addon['meta']['init_file']) && !empty($addon['meta']['init_file'])) { $addon_directory = $this->recursive_file_exists($addon['meta']['init_file'], SLIDEDECK3_ADDONS_DIR); include_once $addon_directory; $addon['meta']['class']::instance(); } } } $this->SlideDeck = new SlideDeck(); $this->add_hooks(); }
/** * Disable cache groups due to a caching discrepancy in BackPress. * * @since 2.7.0 * @see https://buddypress.trac.wordpress.org/ticket/4759 */ public function setup_cache_groups() { wp_cache_add_non_persistent_groups(array('bb_forums', 'bb_query', 'bb_cache_posts_post_ids', 'bb_post')); }
} return $can_clone ? clone( $object ) : $object; } if ( file_exists(WP_CONTENT_DIR . '/object-cache.php') ) { require_once (WP_CONTENT_DIR . '/object-cache.php'); $_wp_using_ext_object_cache = true; } else { require_once (ABSPATH . WPINC . '/cache.php'); $_wp_using_ext_object_cache = false; } wp_cache_init(); if ( function_exists('wp_cache_add_global_groups') ) { wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta')); wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' )); } require (ABSPATH . WPINC . '/plugin.php'); require (ABSPATH . WPINC . '/default-filters.php'); include_once(ABSPATH . WPINC . '/pomo/mo.php'); require_once (ABSPATH . WPINC . '/l10n.php'); if ( !is_blog_installed() && (strpos($_SERVER['PHP_SELF'], 'install.php') === false && !defined('WP_INSTALLING')) ) { if ( defined('WP_SITEURL') ) $link = WP_SITEURL . '/wp-admin/install.php'; elseif (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $link = preg_replace('|/wp-admin/?.*?$|', '/', $_SERVER['PHP_SELF']) . 'wp-admin/install.php'; else $link = preg_replace('|/[^/]+?$|', '/', $_SERVER['PHP_SELF']) . 'wp-admin/install.php'; require_once(ABSPATH . WPINC . '/kses.php');
/** * Instantiation construction * * @uses add_action() * @uses SlideDeckLitePlugin::wp_register_scripts() * @uses SlideDeckLitePlugin::wp_register_styles() */ function __construct() { define('SLIDEDECK2_URL', plugin_dir_url(__FILE__)); define('SLIDEDECK2_PATH', plugin_dir_path(__FILE__)); SlideDeckLitePlugin::load_constants(); $this->friendly_name = SlideDeckLitePlugin::$st_friendly_name; $this->namespace = SlideDeckLitePlugin::$st_namespace; /** * Make this plugin available for translation. * Translations can be added to the /languages/ directory. */ load_plugin_textdomain($this->namespace, false, dirname(plugin_basename(__FILE__)) . '/languages/'); // Load all library files used by this plugin $lib_files = glob(SLIDEDECK2_DIRNAME . '/lib/*.php'); foreach ($lib_files as $filename) { include_once $filename; } // Loop through $cache_groups to add to Non Persistent Cache if (function_exists('wp_cache_add_non_persistent_groups')) { foreach (SlideDeckLitePlugin::$cache_groups as $cache_group) { wp_cache_add_non_persistent_groups(slidedeck2_cache_group($cache_group)); } } // WordPress Pointers helper $this->Pointers = new SlideDeckPointers(); // The Lens primary class include_once SLIDEDECK2_DIRNAME . '/classes/slidedeck-lens.php'; $this->Lens = new SlideDeckLens(); // The Cover primary class if (file_exists(SLIDEDECK2_DIRNAME . '/classes/slidedeck-covers.php')) { include_once SLIDEDECK2_DIRNAME . '/classes/slidedeck-covers.php'; $this->Cover = new SlideDeckCovers(); } // The Lens scaffold include_once SLIDEDECK2_DIRNAME . '/classes/slidedeck-lens-scaffold.php'; // The Deck primary class for Deck types to child from include_once SLIDEDECK2_DIRNAME . '/classes/slidedeck.php'; // Stock Lenses that come with SlideDeck distribution $lens_files = glob(SLIDEDECK2_DIRNAME . '/lenses/*/lens.php'); if (is_dir(SLIDEDECK2_CUSTOM_LENS_DIR)) { if (is_readable(SLIDEDECK2_CUSTOM_LENS_DIR)) { // Get additional uploaded custom Lenses $custom_lens_files = (array) glob(SLIDEDECK2_CUSTOM_LENS_DIR . '/*/lens.php'); // Merge Lenses available and loop through to load $lens_files = array_merge($lens_files, $custom_lens_files); } } // Load all the custom Lens types foreach ((array) $lens_files as $filename) { if (is_readable($filename)) { $classname = slidedeck2_get_classname_from_filename(dirname($filename)); $prefix_classname = "SlideDeckLens_{$classname}"; $slug = basename(dirname($filename)); if (!class_exists($prefix_classname)) { include_once $filename; $this->installed_lenses[] = $slug; } if (class_exists($prefix_classname)) { $this->lenses[$classname] = new $prefix_classname(); } } } $source_files = (array) glob(SLIDEDECK2_DIRNAME . '/sources/*/source.php'); foreach ((array) $source_files as $filename) { if (is_readable($filename)) { include_once $filename; $slug = basename(dirname($filename)); $classname = slidedeck2_get_classname_from_filename(dirname($filename)); $prefix_classname = "SlideDeckSource_{$classname}"; if (class_exists($prefix_classname)) { $this->sources[$slug] = new $prefix_classname(); } } } $this->SlideDeck = new SlideDeck(); $this->add_hooks(); }
function init() { $this->compat = new WPBDP_Compat(); // Register cache groups. wp_cache_add_non_persistent_groups(array('wpbdp pages', 'wpbdp formfields', 'wpbdp submit state', 'wpbdp')); // Register some basic JS resources. add_action('wp_enqueue_scripts', array(&$this, 'register_common_scripts')); add_action('admin_enqueue_scripts', array(&$this, 'register_common_scripts')); // Initialize settings API. $this->settings = new WPBDP_Settings(); $this->formfields = WPBDP_FormFields::instance(); // Install plugin. $this->settings->register_settings(); $this->_register_post_type(); $this->install_or_update_plugin(); if ($manual_upgrade = get_option('wpbdp-manual-upgrade-pending', false)) { $installer = new WPBDP_Installer(); $installer->setup_manual_upgrade(); return; } // Display "Settings" link on Plugins page. $plugin_filename = plugin_basename(__FILE__); add_filter('plugin_action_links_' . $plugin_filename, array(&$this, 'plugin_action_links')); // Initialize APIs. $this->admin = is_admin() ? new WPBDP_Admin() : null; $this->controller = new WPBDP_DirectoryController(); $this->fees = new WPBDP_FeesAPI(); $this->payments = new WPBDP_PaymentsAPI(); $this->listings = new WPBDP_Listings_API(); $this->_register_image_sizes(); add_filter('posts_request', create_function('$x', 'wpbdp_debug($x); return $x;')); // used for debugging add_filter('rewrite_rules_array', array(&$this, '_rewrite_rules')); add_filter('query_vars', array(&$this, '_query_vars')); add_filter('redirect_canonical', array(&$this, '_redirect_canonical'), 10, 2); add_action('template_redirect', array(&$this, '_template_redirect')); add_action('wp_loaded', array(&$this, '_wp_loaded')); add_action('save_post_page', array(&$this, '_invalidate_pages_cache')); add_action('pre_get_posts', array(&$this, '_pre_get_posts')); add_filter('posts_clauses', array(&$this, '_posts_clauses'), 10, 2); add_filter('posts_fields', array(&$this, '_posts_fields'), 10, 2); add_filter('posts_orderby', array(&$this, '_posts_orderby'), 10, 2); add_filter('comments_template', array(&$this, '_comments_template')); add_filter('taxonomy_template', array(&$this, '_category_template')); add_filter('single_template', array(&$this, '_single_template')); add_action('wp', array(&$this, '_meta_setup')); add_action('wp', array(&$this, '_jetpack_compat'), 11, 1); add_action('wp_head', array(&$this, '_handle_broken_plugin_filters'), 0); add_filter('wp_title', array(&$this, '_meta_title'), 10, 3); add_action('wp_head', array(&$this, '_rss_feed')); // Register shortcodes. $shortcodes = $this->get_shortcodes(); foreach ($shortcodes as $shortcode => &$handler) { add_shortcode($shortcode, $handler); } do_action('wpbdp_loaded'); // Expiration hook. add_action('wpbdp_listings_expiration_check', array(&$this, '_notify_expiring_listings'), 0); // Scripts & styles. add_action('wp_enqueue_scripts', array($this, '_enqueue_scripts')); add_action('wp_enqueue_scripts', array(&$this, 'enqueue_css_override'), 30, 0); // Plugin modules initialization. $this->_init_modules(); // AJAX actions. add_action('wp_ajax_wpbdp-file-field-upload', array(&$this, 'ajax_file_field_upload')); add_action('wp_ajax_nopriv_wpbdp-file-field-upload', array(&$this, 'ajax_file_field_upload')); add_action('wp_ajax_wpbdp-listing-submit-image-upload', array(&$this, 'ajax_listing_submit_image_upload')); add_action('wp_ajax_nopriv_wpbdp-listing-submit-image-upload', array(&$this, 'ajax_listing_submit_image_upload')); add_action('wp_ajax_wpbdp-listing-submit-image-delete', array(&$this, 'ajax_listing_submit_image_delete')); add_action('wp_ajax_nopriv_wpbdp-listing-submit-image-delete', array(&$this, 'ajax_listing_submit_image_delete')); // Core sorting options. add_filter('wpbdp_listing_sort_options', array(&$this, 'sortbar_sort_options')); add_filter('wpbdp_query_fields', array(&$this, 'sortbar_query_fields')); add_filter('wpbdp_query_orderby', array(&$this, 'sortbar_orderby')); $this->recaptcha = new WPBDP_reCAPTCHA(); }
public static function setup() { wp_cache_add_non_persistent_groups(array('tribe-events-non-persistent')); }
/** * Restore the current blog, after calling switch_to_blog() * * @see switch_to_blog() * @since MU * * @return bool True on success, false if we're already on the current blog */ function restore_current_blog() { global $wpdb, $wp_roles; if (empty($GLOBALS['_wp_switched_stack'])) { return false; } $blog = array_pop($GLOBALS['_wp_switched_stack']); if ($GLOBALS['blog_id'] == $blog) { /** This filter is documented in wp-includes/ms-blogs.php */ do_action('switch_blog', $blog, $blog); // If we still have items in the switched stack, consider ourselves still 'switched' $GLOBALS['switched'] = !empty($GLOBALS['_wp_switched_stack']); return true; } $wpdb->set_blog_id($blog); $prev_blog_id = $GLOBALS['blog_id']; $GLOBALS['blog_id'] = $blog; $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); if (function_exists('wp_cache_switch_to_blog')) { wp_cache_switch_to_blog($blog); } else { global $wp_object_cache; if (is_object($wp_object_cache) && isset($wp_object_cache->global_groups)) { $global_groups = $wp_object_cache->global_groups; } else { $global_groups = false; } wp_cache_init(); if (function_exists('wp_cache_add_global_groups')) { if (is_array($global_groups)) { wp_cache_add_global_groups($global_groups); } else { wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', ' blog-id-cache')); } wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins')); } } if (did_action('init')) { $wp_roles->reinit(); $current_user = wp_get_current_user(); $current_user->for_blog($blog); } /** This filter is documented in wp-includes/ms-blogs.php */ do_action('switch_blog', $blog, $prev_blog_id); // If we still have items in the switched stack, consider ourselves still 'switched' $GLOBALS['switched'] = !empty($GLOBALS['_wp_switched_stack']); return true; }
{ return admin_url('admin.php') . '?page=' . WPFront_User_Role_Editor_List::MENU_SLUG . '&delete_role='; } public function set_default_url() { return admin_url('admin.php') . '?page=' . WPFront_User_Role_Editor_List::MENU_SLUG . '&nonce=' . wp_create_nonce($this->list_url()) . '&set_default_role='; } public function settings_url() { return admin_url('admin.php') . '?page=' . WPFront_User_Role_Editor_Options::MENU_SLUG; } public function login_redirect_url() { return admin_url('admin.php') . '?page=' . WPFront_User_Role_Editor_Login_Redirect::MENU_SLUG; } public function cache_add($key, $data) { wp_cache_set($key, $data, WPFront_User_Role_Editor::PLUGIN_SLUG); } public function cache_get($key) { $data = wp_cache_get($key, WPFront_User_Role_Editor::PLUGIN_SLUG); if ($data === FALSE) { return NULL; } return $data; } } add_action('admin_init', 'WPFront_User_Role_Editor_Controller_Base::register_ajax_handlers'); wp_cache_add_non_persistent_groups(WPFront_User_Role_Editor::PLUGIN_SLUG); }
/** * Constructor for WP_Theme. * * @param string $theme_dir Directory of the theme within the theme_root. * @param string $theme_root Theme root. * @param WP_Error|null $child If this theme is a parent theme, the child may be passed for validation purposes. */ public function __construct($theme_dir, $theme_root, $child = null) { // Initialize caching on first run. if (!isset(self::$persistently_cache)) { self::$persistently_cache = apply_filters('wp_cache_themes_persistently', false, 'WP_Theme'); if (self::$persistently_cache) { wp_cache_add_global_groups('themes'); if (is_int(self::$persistently_cache)) { self::$cache_expiration = self::$persistently_cache; } } else { wp_cache_add_non_persistent_groups('themes'); } } $this->theme_root = $theme_root; $this->stylesheet = $theme_dir; $theme_file = $this->stylesheet . '/style.css'; $cache = $this->cache_get('theme'); if (is_array($cache)) { foreach (array('errors', 'headers', 'template') as $key) { if (isset($cache[$key])) { $this->{$key} = $cache[$key]; } } if ($this->errors) { return; } if (isset($cache['theme_root_template'])) { $theme_root_template = $cache['theme_root_template']; } } elseif (!file_exists($this->theme_root . '/' . $theme_file)) { $this->headers['Name'] = $this->stylesheet; $this->errors = new WP_Error('theme_no_stylesheet', __('Stylesheet is missing.')); $this->cache_add('theme', array('headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet)); if (!file_exists($this->theme_root)) { // Don't cache this one. $this->errors->add('theme_root_missing', __('ERROR: The themes directory is either empty or doesn’t exist. Please check your installation.')); } return; } elseif (!is_readable($this->theme_root . '/' . $theme_file)) { $this->headers['Name'] = $this->stylesheet; $this->errors = new WP_Error('theme_stylesheet_not_readable', __('Stylesheet is not readable.')); $this->cache_add('theme', array('headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet)); return; } else { $this->headers = get_file_data($this->theme_root . '/' . $theme_file, self::$file_headers, 'theme'); // Default themes always trump their pretenders. // Properly identify default themes that are inside a directory within wp-content/themes. if ($default_theme_slug = array_search($this->headers['Name'], self::$default_themes)) { if (basename($this->stylesheet) != $default_theme_slug) { $this->headers['Name'] .= '/' . $this->stylesheet; } } } // (If template is set from cache, we know it's good.) if (!$this->template && !($this->template = $this->headers['Template'])) { if (file_exists($this->theme_root . '/' . $this->stylesheet . '/index.php')) { $this->template = $this->stylesheet; } else { $this->errors = new WP_Error('theme_no_index', __('Template is missing.')); $this->cache_add('theme', array('headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet)); return; } } // If we got our data from cache, we can assume that 'template' is pointing to the right place. if (!is_array($cache) && $this->template != $this->stylesheet && !file_exists($this->theme_root . '/' . $this->template . '/index.php')) { // If we're in a directory of themes inside /themes, look for the parent nearby. // wp-content/themes/directory-of-themes/* $parent_dir = dirname($this->stylesheet); if ('.' != $parent_dir && file_exists($this->theme_root . '/' . $parent_dir . '/' . $this->template . '/index.php')) { $this->template = $parent_dir . '/' . $this->template; } elseif (($directories = search_theme_directories()) && isset($directories[$this->template])) { // Look for the template in the search_theme_directories() results, in case it is in another theme root. // We don't look into directories of themes, just the theme root. $theme_root_template = $directories[$this->template]['theme_root']; } else { // Parent theme is missing. $this->errors = new WP_Error('theme_no_parent', sprintf(__('The parent theme is missing. Please install the "%s" parent theme.'), $this->template)); $this->cache_add('theme', array('headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template)); return; } } // Set the parent, if we're a child theme. if ($this->template != $this->stylesheet) { // If we are a parent, then there is a problem. Only two generations allowed! Cancel things out. if (is_a($child, 'WP_Theme') && $child->template == $this->stylesheet) { $child->parent = null; $child->errors = new WP_Error('theme_parent_invalid', sprintf(__('The "%s" theme is not a valid parent theme.'), $child->template)); $child->cache_add('theme', array('headers' => $child->headers, 'errors' => $child->errors, 'stylesheet' => $child->stylesheet, 'template' => $child->template)); // The two themes actually reference each other with the Template header. if ($child->stylesheet == $this->template) { $this->errors = new WP_Error('theme_parent_invalid', sprintf(__('The "%s" theme is not a valid parent theme.'), $this->template)); $this->cache_add('theme', array('headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template)); } return; } // Set the parent. Pass the current instance so we can do the crazy checks above and assess errors. $this->parent = new WP_Theme($this->template, isset($theme_root_template) ? $theme_root_template : $this->theme_root, $this); } // We're good. If we didn't retrieve from cache, set it. if (!is_array($cache)) { $cache = array('headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template); // If the parent theme is in another root, we'll want to cache this. Avoids an entire branch of filesystem calls above. if (isset($theme_root_template)) { $cache['theme_root_template'] = $theme_root_template; } $this->cache_add('theme', $cache); } }
function restore_current_blog() { global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $current_user; if (!$switched) { return false; } $blog = array_pop($switched_stack); if ($blog_id == $blog) { return false; } $wpdb->set_blog_id($blog); $prev_blog_id = $blog_id; $blog_id = $blog; $table_prefix = $wpdb->prefix; if (is_object($wp_roles)) { $wpdb->suppress_errors(); if (method_exists($wp_roles, '_init')) { $wp_roles->_init(); } elseif (method_exists($wp_roles, '__construct')) { $wp_roles->__construct(); } $wpdb->suppress_errors(false); } if (is_object($current_user)) { $current_user->_init_caps(); } wp_cache_init(); if (function_exists('wp_cache_add_global_groups')) { wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss')); wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins')); } do_action('switch_blog', $blog_id, $prev_blog_id); $switched = false; return true; }