/** * @package s2Member\Database * @since 130625 * * @attaches-to ``add_action("init");`` */ public static function wait_timeout() { global $wpdb; // Global database object reference. if (c_ws_plugin__s2member_systematics::is_s2_systematic_use_page() || !empty($_SERVER["QUERY_STRING"]) && preg_match("/[\\?&]s2member/", $_SERVER["QUERY_STRING"])) { $increase_wait_timeout = TRUE; } if (empty($increase_wait_timeout) && !empty($_POST)) { foreach (array_keys($_POST) as $post_key) { if (strpos($post_key, "s2member") === 0) { $increase_wait_timeout = TRUE; break; } } } if (!empty($increase_wait_timeout)) { $wpdb->query("SET SESSION `wait_timeout` = 300"); } }
/** * Lazy load CSS/JS files? * * @package s2Member\CSS_JS * @since 131028 * * @return boolean TRUE if we should load; else FALSE. */ public static function lazy_load_css_js() { static $load; // Static cache var. if (isset($load)) { return $load; } $null = NULL; // Needed below in earlier versions of WP. if (!$GLOBALS['WS_PLUGIN__']['s2member']['o']['lazy_load_css_js']) { $load = TRUE; } else { if (c_ws_plugin__s2member_systematics::is_s2_systematic_use_page()) { $load = TRUE; } else { if (!empty($_GET[apply_filters('ws_plugin__s2member_check_force_ssl_get_var_name', 's2-ssl', array())])) { $load = TRUE; } else { if (c_ws_plugin__s2member_utils_conds::bp_is_installed() && (bp_is_register_page() || bp_is_activation_page() || bp_is_user_profile())) { $load = TRUE; } else { if (is_singular() && ($post = get_post($null)) && (stripos($post->post_content, 's2member') !== FALSE || stripos($post->post_content, '[s2') !== FALSE)) { $load = TRUE; } else { if (preg_match('/\\/wp\\-signup\\.php|\\/wp\\-login\\.php|\\/wp\\-admin\\/(?:user\\/)?profile\\.php|[?&]s2member/', $_SERVER['REQUEST_URI'])) { $load = TRUE; } } } } } } if (!isset($load)) { $load = FALSE; } // Make sure it's set; always. return $load = apply_filters('ws_plugin__s2member_lazy_load_css_js', $load); }
/** * Lazy load CSS/JS files? * * @package s2Member\CSS_JS * @since 131028 * * @return boolean TRUE if we should load; else FALSE. */ public static function lazy_load_css_js() { static $load; // Static cache var. if (isset($load)) { return $load; } if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["lazy_load_css_js"]) { $load = TRUE; } else { if (c_ws_plugin__s2member_systematics::is_s2_systematic_use_page()) { $load = TRUE; } else { if (!empty($_GET[apply_filters("ws_plugin__s2member_check_force_ssl_get_var_name", "s2-ssl", array())])) { $load = TRUE; } else { if (c_ws_plugin__s2member_utils_conds::bp_is_installed() && (bp_is_register_page() || bp_is_activation_page() || bp_is_user_profile())) { $load = TRUE; } else { if (is_singular() && ($post = get_post(NULL)) && (stripos($post->post_content, "s2member") !== FALSE || stripos($post->post_content, "[s2") !== FALSE)) { $load = TRUE; } else { if (preg_match("/\\/wp\\-signup\\.php" . "|\\/wp\\-login\\.php" . "|\\/wp\\-admin\\/(?:user\\/)?profile\\.php" . "|[?&]s2member/", $_SERVER["REQUEST_URI"])) { $load = TRUE; } } } } } } if (!isset($load)) { $load = FALSE; } // Make sure it's set; always. return $load = apply_filters("ws_plugin__s2member_lazy_load_css_js", $load); }
/** * Determines if the current page is Systematic in any way. * * @package s2Member\Systematics * @since 3.5 * * @return bool True if Systematic, else false. * * @note The results of this function are cached staticially. * Do NOT call upon this until the `wp` Hook is fired. */ public static function is_systematic_use_page() { static $is_systematic; /* For optimization. */ /**/ if (isset($is_systematic)) { return $is_systematic; /* Filters will have already been applied here. */ } else { if (c_ws_plugin__s2member_systematics::is_s2_systematic_use_page()) { return $is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars()); } else { if (c_ws_plugin__s2member_systematics::is_wp_systematic_use_page()) { return $is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars()); } else { if (c_ws_plugin__s2member_utils_conds::bp_is_installed() && (bp_is_register_page() || bp_is_activation_page())) { return $is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars()); } else { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && is_page($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"])) { return $is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars()); } else { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && is_page($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])) { return $is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars()); } else { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && is_page($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"])) { return $is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars()); } else { if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($_lro = c_ws_plugin__s2member_login_redirects::login_redirection_uri(false, "root-returns-false")) && preg_match("/^" . preg_quote($_lro, "/") . "\$/", $_SERVER["REQUEST_URI"])) { return $is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars()); } else { /* Otherwise, we return false ( it's NOT a Systematic Use Page in any way ). */ return $is_systematic = apply_filters("ws_plugin__s2member_is_systematic_use_page", false, get_defined_vars()); } } } } } } } } }
/** * Determines if the current page is Systematic in any way. * * @package s2Member\Systematics * @since 3.5 * * @return bool True if Systematic, else false. * * @note The results of this function are cached staticially. * Do NOT call upon this until the `wp` Hook is fired. */ public static function is_systematic_use_page() { static $is_systematic; // For optimization. if (isset($is_systematic)) { // Already cached statically? Saves time. return $is_systematic; } // Filters will have already been applied here. $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i'; if (c_ws_plugin__s2member_systematics::is_s2_systematic_use_page()) { // An s2Member Systematic Use Page? return $is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()); } if (c_ws_plugin__s2member_systematics::is_wp_systematic_use_page()) { //* A WordPress Systematic Use Page? return $is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()); } if (c_ws_plugin__s2member_utils_conds::bp_is_installed() && (bp_is_register_page() || bp_is_activation_page())) { return $is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()); } if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'] && is_page($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'])) { return $is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()); } if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'] && is_page($GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])) { return $is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()); } if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'] && is_page($GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'])) { return $is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()); } if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($_lro = c_ws_plugin__s2member_login_redirects::login_redirection_uri(NULL, 'root-returns-false')) && preg_match('/^' . preg_quote($_lro, '/') . '$/' . $ci, $_SERVER['REQUEST_URI'])) { return $is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()); } return $is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', FALSE, get_defined_vars()); }
/** * Defines no-cache constants for various WordPress plugins. * * This is compatible with Quick Cache, W3 Total Cache, and also with WP Super Cache. * Quick Cache uses: ``QUICK_CACHE_ALLOWED``, and other plugins use: ``DONOTCACHEPAGE``. * W3 Total Cache is also known to be compatible with ``DONOTCACHEOBJECT`` and ``DONOTCACHEDB``. * * Disallow caching if the ``$no_cache`` parameter is passed in as ``true``, by other routines. * In addition, always disallow caching for logged in users, and GET requests with: `/?s2member` Systematics. * For clarity on s2Member Systematics, see: {@link s2Member\Systematics\c_ws_plugin__s2member_systematics::is_s2_systematic_use_page()}. * * However, this routine will ALWAYS obey the `?qcAC` query string parameter. * This Quick Cache parameter explicitly allows caching to occur. * * @package s2Member\No_Cache * @since 3.5 * * @also-called-by Other routines within s2Member. * * @param bool $no_cache Optional. Defaults to false. If true, force no-cache if at all possible. * @return bool This function will always return `true`. */ public static function no_cache_constants($no_cache = FALSE) { static $once; // We only need to set these constants once. foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_before_no_cache_constants", get_defined_vars()); unset($__refs, $__v); if (!$once && empty($_GET["qcAC"]) && ($no_cache || is_user_logged_in() && (!defined("QUICK_CACHE_WHEN_LOGGED_IN") || !QUICK_CACHE_WHEN_LOGGED_IN) || c_ws_plugin__s2member_systematics::is_s2_systematic_use_page())) { /** * No-cache DB queries for plugins. * * @package s2Member\No_Cache * @since 111115 * * @var bool */ if (!defined("DONOTCACHEDB")) { define("DONOTCACHEDB", true); } /** * No-cache Page for plugins. * * @package s2Member\No_Cache * @since 3.5 * * @var bool */ if (!defined("DONOTCACHEPAGE")) { define("DONOTCACHEPAGE", true); } /** * No-cache Objects for plugins. * * @package s2Member\No_Cache * @since 111115 * * @var bool */ if (!defined("DONOTCACHEOBJECT")) { define("DONOTCACHEOBJECT", true); } /** * No-cache anything for Quick Cache plugin. * * @package s2Member\No_Cache * @since 3.5 * * @var bool */ if (!defined("QUICK_CACHE_ALLOWED")) { define("QUICK_CACHE_ALLOWED", false); } $once = true; // Only need to set these constants one time. c_ws_plugin__s2member_no_cache::$headers = true; do_action("ws_plugin__s2member_during_no_cache_constants", get_defined_vars()); } do_action("ws_plugin__s2member_after_no_cache_constants", get_defined_vars()); return true; // Always return true. }
/** * Defines no-cache constants for various WordPress plugins. * * This is compatible with Quick Cache, W3 Total Cache, and also with WP Super Cache. * Quick Cache uses: ``QUICK_CACHE_ALLOWED``, and other plugins use: ``DONOTCACHEPAGE``. * W3 Total Cache is also known to be compatible with ``DONOTCACHEOBJECT`` and ``DONOTCACHEDB``. * * Disallow caching if the ``$no_cache`` parameter is passed in as ``true``, by other routines. * In addition, always disallow caching for logged in users, and GET requests with: `/?s2member` Systematics. * For clarity on s2Member Systematics, see: {@link s2Member\Systematics\c_ws_plugin__s2member_systematics::is_s2_systematic_use_page()}. * * However, this routine will ALWAYS obey the `?qcAC` query string parameter. * This Quick Cache parameter explicitly allows caching to occur. * * @package s2Member\No_Cache * @since 3.5 * * @also-called-by Other routines within s2Member. * * @param bool $no_cache Optional. Defaults to false. If true, force no-cache if at all possible. * * @return bool This function will always return `true`. */ public static function no_cache_constants($no_cache = FALSE) { static $once; // We only need to set these constants once. foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_before_no_cache_constants', get_defined_vars()); unset($__refs, $__v); // Housekeeping. if (!$once && (empty($_GET['qcAC']) || !filter_var($_GET['qcAC'], FILTER_VALIDATE_BOOLEAN)) && ($no_cache === TRUE || $no_cache === 'restricted' && (!defined('ZENCACHE_WHEN_LOGGED_IN') || !ZENCACHE_WHEN_LOGGED_IN) && (!defined('QUICK_CACHE_WHEN_LOGGED_IN') || !QUICK_CACHE_WHEN_LOGGED_IN) || is_user_logged_in() && (!defined('ZENCACHE_WHEN_LOGGED_IN') || !ZENCACHE_WHEN_LOGGED_IN) && (!defined('QUICK_CACHE_WHEN_LOGGED_IN') || !QUICK_CACHE_WHEN_LOGGED_IN) || c_ws_plugin__s2member_systematics::is_s2_systematic_use_page())) { /** * No-cache DB queries for plugins. * * @package s2Member\No_Cache * @since 111115 * * @var bool */ if (!defined('DONOTCACHEDB')) { define('DONOTCACHEDB', TRUE); } /** * No-cache Page for plugins. * * @package s2Member\No_Cache * @since 3.5 * * @var bool */ if (!defined('DONOTCACHEPAGE')) { define('DONOTCACHEPAGE', TRUE); } /** * No-cache Objects for plugins. * * @package s2Member\No_Cache * @since 111115 * * @var bool */ if (!defined('DONOTCACHEOBJECT')) { define('DONOTCACHEOBJECT', TRUE); } /** * No-cache anything for ZenCache plugin. * * @package s2Member\No_Cache * @since 3.5 * * @var bool */ if (!defined('ZENCACHE_ALLOWED')) { define('ZENCACHE_ALLOWED', FALSE); } /** * No-cache anything for Quick Cache plugin. * * @package s2Member\No_Cache * @since 3.5 * * @var bool */ if (!defined('QUICK_CACHE_ALLOWED')) { define('QUICK_CACHE_ALLOWED', FALSE); } $once = TRUE; // Set these one time only. c_ws_plugin__s2member_no_cache::$headers = TRUE; do_action('ws_plugin__s2member_during_no_cache_constants', get_defined_vars()); } do_action('ws_plugin__s2member_after_no_cache_constants', get_defined_vars()); return TRUE; // Always return true. }