public static function wp_settings_as($wp_dir = FALSE, $o_file = FALSE) { if ($wp_dir && is_dir($wp_dir) && is_readable($wp_settings = $wp_dir . "/wp-settings.php") && $o_file && file_exists($o_file) && ($_wp_settings = trim(file_get_contents($wp_settings)))) { $wp_shortinit_section = "/if *\\( *SHORTINIT *\\)[\r\n\t\\s ]*\\{?[\r\n\t\\s ]*return false;[\r\n\t\\s ]*\\}?[\r\n\t\\s ]*/"; if (preg_match($wp_shortinit_section, $_wp_settings) && ($_wp_settings_parts = preg_split($wp_shortinit_section, $_wp_settings, 2)) && ($_wp_settings = trim($_wp_settings_parts[1])) && ($_wp_settings = "<?php\n" . $_wp_settings)) { if ($_wp_settings = str_replace("__FILE__", "'" . str_replace("'", "\\'", $wp_settings) . "'", $_wp_settings)) { $mu_plugins_section = "/[\r\n\t\\s ]+foreach *\\( *wp_get_mu_plugins *\\( *\\) *as *\\\$mu_plugin *\\)[\r\n\t\\s ]*\\{?[\r\n\t\\s ]*include_once *\\( *\\\$mu_plugin *\\);[\r\n\t\\s ]*\\}?[\r\n\t\\s ]*unset *\\( *\\\$mu_plugin *\\);/"; $mu_plugins_replace = "\n\n" . c_ws_plugin__s2member_utils_s2o::esc_ds(trim(c_ws_plugin__s2member_utils_s2o::evl(file_get_contents(dirname(dirname(__FILE__)) . "/templates/cfg-files/s2o-mu-plugins.php")))) . "\n"; if (($_wp_settings = preg_replace($mu_plugins_section, $mu_plugins_replace, $_wp_settings, 1, $mu_plugins_replaced)) && $mu_plugins_replaced) { $nw_plugins_section = "/[\r\n\t\\s ]+foreach *\\( *wp_get_active_network_plugins *\\( *\\) *as *\\\$network_plugin *\\)[\r\n\t\\s ]*\\{?[\r\n\t\\s ]*include_once *\\( *\\\$network_plugin *\\);[\r\n\t\\s ]*\\}?[\r\n\t\\s ]*unset *\\( *\\\$network_plugin *\\);/"; $nw_plugins_replace = "\n\n" . c_ws_plugin__s2member_utils_s2o::esc_ds(trim(c_ws_plugin__s2member_utils_s2o::evl(file_get_contents(dirname(dirname(__FILE__)) . "/templates/cfg-files/s2o-nw-plugins.php")))) . "\n"; if (($_wp_settings = preg_replace($nw_plugins_section, $nw_plugins_replace, $_wp_settings, 1, $nw_plugins_replaced)) && $nw_plugins_replaced) { $st_plugins_section = "/[\r\n\t\\s ]+foreach *\\( *wp_get_active_and_valid_plugins *\\( *\\) *as *\\\$plugin *\\)[\r\n\t\\s ]*\\{?[\r\n\t\\s ]*include_once *\\( *\\\$plugin *\\);[\r\n\t\\s ]*\\}?[\r\n\t\\s ]*unset *\\( *\\\$plugin *\\);/"; $st_plugins_replace = "\n\n" . c_ws_plugin__s2member_utils_s2o::esc_ds(trim(c_ws_plugin__s2member_utils_s2o::evl(file_get_contents(dirname(dirname(__FILE__)) . "/templates/cfg-files/s2o-st-plugins.php")))) . "\n"; if (($_wp_settings = preg_replace($st_plugins_section, $st_plugins_replace, $_wp_settings, 1, $st_plugins_replaced)) && $st_plugins_replaced) { $th_funcs_section = "/[\r\n\t\\s ]+if *\\( *\\! *defined *\\( *['\"]WP_INSTALLING['\"] *\\) *\\|\\| *['\"]wp-activate.php['\"] *\\=\\=\\= *\\\$pagenow *\\)[\r\n\t\\s ]*\\{[\r\n\t\\s ]*if *\\( *TEMPLATEPATH *\\!\\=\\= *STYLESHEETPATH *&& *file_exists *\\( *STYLESHEETPATH *\\. *['\"]\\/functions\\.php['\"] *\\) *\\)[\r\n\t\\s ]*\\{?[\r\n\t\\s ]*include *\\( *STYLESHEETPATH *\\. *['\"]\\/functions\\.php['\"] *\\);[\r\n\t\\s ]*\\}?[\r\n\t\\s ]*if *\\( *file_exists *\\( *TEMPLATEPATH *\\. *['\"]\\/functions\\.php['\"] *\\) *\\)[\r\n\t\\s ]*\\{?[\r\n\t\\s ]*include *\\( *TEMPLATEPATH *\\. *['\"]\\/functions\\.php['\"] *\\);[\r\n\t\\s ]*\\}?[\r\n\t\\s ]*\\}/"; $th_funcs_replace = "\n\n" . c_ws_plugin__s2member_utils_s2o::esc_ds(trim(c_ws_plugin__s2member_utils_s2o::evl(file_get_contents(dirname(dirname(__FILE__)) . "/templates/cfg-files/s2o-th-funcs.php")))) . "\n"; if (($_wp_settings = preg_replace($th_funcs_section, $th_funcs_replace, $_wp_settings, 1, $th_funcs_replaced)) && $th_funcs_replaced) { if ($_wp_settings = str_replace("__FILE__", '"' . str_replace('"', '\\"', $o_file) . '"', $_wp_settings)) { if ($_wp_settings = trim($_wp_settings)) { // WordPress, with s2Member only. return $wp_settings_as = $_wp_settings; } // After ``SHORTINIT``. } } } } } } } } return false; }
/** * WordPress settings, after ``SHORTINIT`` section. * * @package s2Member\Utilities * @since 110912 * * @param string $wp_dir WordPress directory path. * @param string $o_file Location of calling `*-o.php` file. * * @return string|bool WordPress settings, else false on failure. */ public static function wp_settings_as($wp_dir = '', $o_file = '') { if ($wp_dir && is_dir($wp_dir) && is_readable($wp_settings = $wp_dir . '/wp-settings.php') && $o_file && is_file($o_file) && ($_wp_settings = trim(file_get_contents($wp_settings)))) { $wp_shortinit_section = '/if\\s*\\(\\s*SHORTINIT\\s*\\)[' . "\r\n\t" . '\\s]*\\{?[' . "\r\n\t" . '\\s]*return\\s+false;[' . "\r\n\t" . '\\s]*\\}?[' . "\r\n\t" . '\\s]*/'; // Run ``preg_match()`` to confirm existence. if (preg_match($wp_shortinit_section, $_wp_settings) && ($_wp_settings_parts = preg_split($wp_shortinit_section, $_wp_settings, 2)) && ($_wp_settings = trim($_wp_settings_parts[1])) && ($_wp_settings = '<?php' . "\n" . $_wp_settings)) { if ($_wp_settings = str_replace('__FILE__', "'" . str_replace("'", "'", $wp_settings) . "'", $_wp_settings)) { $mu_plugins_section = '/[' . "\r\n\t" . '\\s]+foreach\\s*\\(\\s*wp_get_mu_plugins\\s*\\(\\s*\\)\\s*as\\s*\\$mu_plugin\\s*\\)[' . "\r\n\t" . '\\s]*\\{?[' . "\r\n\t" . '\\s]*include_once\\s*\\(\\s*\\$mu_plugin\\s*\\)\\s*;[' . "\r\n\t" . '\\s]*\\}?[' . "\r\n\t" . '\\s]*unset\\s*\\(\\s*\\$mu_plugin\\s*\\)\\s*;/'; $mu_plugins_replace = "\n\n" . c_ws_plugin__s2member_utils_s2o::esc_ds(trim(c_ws_plugin__s2member_utils_s2o::evl(file_get_contents(dirname(dirname(__FILE__)) . '/templates/cfg-files/s2o-mu-plugins.php')))) . "\n"; if (($_wp_settings = preg_replace($mu_plugins_section, $mu_plugins_replace, $_wp_settings, 1, $mu_plugins_replaced)) && $mu_plugins_replaced) { $nw_plugins_section = '/[' . "\r\n\t" . '\\s]+foreach\\s*\\(\\s*wp_get_active_network_plugins\\s*\\(\\s*\\)\\s*as\\s*\\$network_plugin\\s*\\)[' . "\r\n\t" . '\\s]*\\{?[' . "\r\n\t" . '\\s]*wp_register_plugin_realpath\\s*\\(\\s*\\$network_plugin\\s*\\)\\s*;[' . "\r\n\t" . '\\s]*include_once\\s*\\(\\s*\\$network_plugin\\s*\\)\\s*;[' . "\r\n\t" . '\\s]*\\}?[' . "\r\n\t" . '\\s]*unset\\s*\\(\\s*\\$network_plugin\\s*\\)\\s*;/'; $nw_plugins_replace = "\n\n" . c_ws_plugin__s2member_utils_s2o::esc_ds(trim(c_ws_plugin__s2member_utils_s2o::evl(file_get_contents(dirname(dirname(__FILE__)) . '/templates/cfg-files/s2o-nw-plugins.php')))) . "\n"; if (($_wp_settings = preg_replace($nw_plugins_section, $nw_plugins_replace, $_wp_settings, 1, $nw_plugins_replaced)) && $nw_plugins_replaced) { $st_plugins_section = '/[' . "\r\n\t" . '\\s]+foreach\\s*\\(\\s*wp_get_active_and_valid_plugins\\s*\\(\\s*\\)\\s*as\\s*\\$plugin\\s*\\)[' . "\r\n\t" . '\\s]*\\{?[' . "\r\n\t" . '\\s]*wp_register_plugin_realpath\\s*\\(\\s*\\$plugin\\s*\\)\\s*;[' . "\r\n\t" . '\\s]*include_once\\s*\\(\\s*\\$plugin\\s*\\)\\s*;[' . "\r\n\t" . '\\s]*\\}?[' . "\r\n\t" . '\\s ]*unset\\s*\\(\\s*\\$plugin\\s*\\)\\s*;/'; $st_plugins_replace = "\n\n" . c_ws_plugin__s2member_utils_s2o::esc_ds(trim(c_ws_plugin__s2member_utils_s2o::evl(file_get_contents(dirname(dirname(__FILE__)) . '/templates/cfg-files/s2o-st-plugins.php')))) . "\n"; if (($_wp_settings = preg_replace($st_plugins_section, $st_plugins_replace, $_wp_settings, 1, $st_plugins_replaced)) && $st_plugins_replaced) { $th_funcs_section = '/[' . "\r\n\t" . '\\s]+if\\s*\\(\\s*\\!\\s*defined\\s*\\(\\s*[\'"]WP_INSTALLING[\'"]\\s*\\)\\s*\\|\\|\\s*[\'"]wp\\-activate\\.php[\'"]\\s*\\=\\=\\=\\s*\\$pagenow\\s*\\)[' . "\r\n\t" . '\\s]*\\{[' . "\r\n\t" . '\\s]*if\\s*\\(\\s*TEMPLATEPATH\\s*\\!\\=\\=\\s*STYLESHEETPATH\\s*&&\\s*file_exists\\s*\\(\\s*STYLESHEETPATH\\s*\\.\\s*[\'"]\\/functions\\.php[\'"]\\s*\\)\\s*\\)[' . "\r\n\t" . '\\s]*\\{?[' . "\r\n\t" . '\\s]*include\\s*\\(\\s*STYLESHEETPATH\\s*\\.\\s*[\'"]\\/functions\\.php[\'"]\\s*\\);[' . "\r\n\t" . '\\s]*\\}?[' . "\r\n\t" . '\\s]*if\\s*\\(\\s*file_exists\\s*\\(\\s*TEMPLATEPATH\\s*\\.\\s*[\'"]\\/functions\\.php[\'"]\\s*\\)\\s*\\)[' . "\r\n\t" . '\\s]*\\{?[' . "\r\n\t" . '\\s]*include\\s*\\(\\s*TEMPLATEPATH\\s*\\.\\s*[\'"]\\/functions\\.php[\'"]\\s*\\);[' . "\r\n\t" . '\\s]*\\}?[' . "\r\n\t" . '\\s]*\\}/'; $th_funcs_replace = "\n\n" . c_ws_plugin__s2member_utils_s2o::esc_ds(trim(c_ws_plugin__s2member_utils_s2o::evl(file_get_contents(dirname(dirname(__FILE__)) . '/templates/cfg-files/s2o-th-funcs.php')))) . "\n"; if (($_wp_settings = preg_replace($th_funcs_section, $th_funcs_replace, $_wp_settings, 1, $th_funcs_replaced)) && $th_funcs_replaced) { if ($_wp_settings = str_replace('__FILE__', '"' . str_replace('"', '\\"', $o_file) . '"', $_wp_settings)) { if ($_wp_settings = trim($_wp_settings)) { // WordPress, with s2Member only. return $wp_settings_as = $_wp_settings; } // After ``SHORTINIT``. } } } } } } } } return FALSE; }
* * Copyright: © 2009-2011 * {@link http://www.websharks-inc.com/ WebSharks, Inc.} * (coded in the USA) * * Released under the terms of the GNU General Public License. * You should have received a copy of the GNU General Public License, * along with this software. In the main directory, see: /licensing/ * If not, see: {@link http://www.gnu.org/licenses/}. * * @package s2Member * @since 110912 */ include_once dirname(__FILE__) . "/includes/classes/utils-s2o.inc.php"; if ($ws_plugin__s2member_o["wp_dir"] = c_ws_plugin__s2member_utils_s2o::wp_dir(dirname(__FILE__), dirname($_SERVER["SCRIPT_FILENAME"]))) { if ($ws_plugin__s2member_o["wp_settings_as"] = c_ws_plugin__s2member_utils_s2o::wp_settings_as($ws_plugin__s2member_o["wp_dir"], __FILE__)) { /** * Short initialization mode for WordPress. * * @package s2Member * @since 110912 * * @var bool */ define("SHORTINIT", true); /** * Flag indicating only s2Member is being loaded. * * @package s2Member * @since 110912 *
* Copyright: © 2009-2011 * {@link http://websharks-inc.com/ WebSharks, Inc.} * (coded in the USA) * * Released under the terms of the GNU General Public License. * You should have received a copy of the GNU General Public License, * along with this software. In the main directory, see: /licensing/ * If not, see: {@link http://www.gnu.org/licenses/}. * * @package s2Member * @since 110912 */ define('_WS_PLUGIN__S2MEMBER_ONLY', TRUE); include_once dirname(__FILE__) . '/includes/classes/utils-s2o.inc.php'; if ($ws_plugin__s2member_o['wp_dir'] = c_ws_plugin__s2member_utils_s2o::wp_dir(dirname(__FILE__), dirname($_SERVER['SCRIPT_FILENAME']))) { if ($ws_plugin__s2member_o['wp_settings_as'] = c_ws_plugin__s2member_utils_s2o::wp_settings_as($ws_plugin__s2member_o['wp_dir'], __FILE__)) { /** * Short initialization mode for WordPress. * * @package s2Member * @since 110912 * * @var bool */ define('SHORTINIT', TRUE); /** * Flag indicating only s2Member is being loaded. * * @package s2Member * @since 110912 *