Example #1
0
    do_action("ws_plugin__s2member_config_hooks_loaded");
    /*
    Load a possible Pro module, if/when available.
    */
    if (apply_filters("ws_plugin__s2member_load_pro", true) && file_exists(dirname(__FILE__) . "-pro/pro-module.php")) {
        include_once dirname(__FILE__) . "-pro/pro-module.php";
        if (is_dir(WP_PLUGIN_DIR . "/codestyling-localization") && !is_dir(dirname(__FILE__) . "/s2member-pro") && function_exists("symlink")) {
            // Removing this for now. It causes problems during upgrades.
            //@symlink(dirname(__FILE__)."-pro", dirname(__FILE__)."/s2member-pro"); // For CS localization compatibility.
            //@chmod(dirname(__FILE__)."/s2member-pro", 0755);
        }
    }
    /*
    Configure options and their defaults.
    */
    ws_plugin__s2member_configure_options_and_their_defaults();
    /*
    Function includes.
    */
    include_once dirname(__FILE__) . "/includes/funcs.inc.php";
    /*
    Include Shortcodes.
    */
    include_once dirname(__FILE__) . "/includes/codes.inc.php";
    /*
    Hooks after loaded.
    */
    do_action("ws_plugin__s2member_loaded");
    do_action("ws_plugin__s2member_after_loaded");
} else {
    if (is_admin()) {
Example #2
0
 /**
  * Saves all options from any menu page.
  *
  * Can also be self-verified; and configured extensively with function parameters.
  *
  * @package s2Member\Menu_Pages
  * @since 3.5
  *
  * @param null|array $new_options Optional. Force feed an array of new options. Defaults to ``$_POST`` vars.
  *   If ``$new_options`` are passed in, be SURE that you've already applied ``stripslashes_deep()``.
  * @param bool       $verified Optional. Defaults to false. If true, ``wp_verify_nonce()`` is skipped in this routine.
  * @param bool       $update_other Optional. Defaults to true. If false, other option-dependent routines will not be processed.
  * @param bool|array $display_notices Optional. Defaults to true. Can be false, or an array of certain notices that can be displayed.
  * @param bool|array $enqueue_notices Optional. Defaults to false. Can be true, or an array of certain notices that should be enqueued.
  * @param bool       $request_refresh Optional. Defaults to false. If true, resulting `success` notice will include a link to refresh the menu page.
  *
  * @return bool True if all s2Member options were updated successfully, else false.
  */
 public static function update_all_options($new_options = NULL, $verified = FALSE, $update_other = TRUE, $display_notices = TRUE, $enqueue_notices = FALSE, $request_refresh = FALSE)
 {
     $updated_all_options = FALSE;
     // Initializing this variable here makes it an available reference-variable to Hooks/Filters.
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_before_update_all_options', get_defined_vars());
     // If you use this Hook, be sure to use ``wp_verify_nonce()``.
     unset($__refs, $__v);
     // Housekeeping.
     if ($verified || !empty($_POST['ws_plugin__s2member_options_save']) && ($nonce = $_POST['ws_plugin__s2member_options_save']) && wp_verify_nonce($nonce, 'ws-plugin--s2member-options-save')) {
         $options = $GLOBALS['WS_PLUGIN__']['s2member']['o'];
         // Acquire the full existing configuration options array here.
         $new_options = is_array($new_options) ? $new_options : (!empty($_POST) && is_array($_POST) ? stripslashes_deep($_POST) : array());
         $new_options = c_ws_plugin__s2member_utils_strings::trim_deep($new_options);
         foreach ($new_options as $key => $value) {
             // Find all keys contained within ``$new_options`` matching `^ws_plugin__s2member_`.
             if (strpos($key, 'ws_plugin__s2member_') === 0) {
                 // A relevant ``$new_options`` key matching `^ws_plugin__s2member_`?
                 if ($key === 'ws_plugin__s2member_configured') {
                     // s2Member is now configured (according to these options)?
                     ($GLOBALS['WS_PLUGIN__']['s2member']['c']['configured'] = $value) . update_option('ws_plugin__s2member_configured', $value);
                 } else {
                     if (!is_array($value) || is_array($value) && array_shift($value) === 'update-signal') {
                         // Updating an array?
                         $options[preg_replace('/^' . preg_quote('ws_plugin__s2member_', '/') . '/', '', $key)] = $value;
                     }
                 }
             }
         }
         unset($key, $value);
         // Unset these utility variables now. This prevents bleeding vars into Hooks/Filters that are of no use.
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action('ws_plugin__s2member_during_update_all_options', get_defined_vars());
         unset($__refs, $__v);
         // Housekeeping.
         $options = ws_plugin__s2member_configure_options_and_their_defaults($options = array_merge($options, array('options_version' => (string) ($options['options_version'] + 0.001))));
         update_option('ws_plugin__s2member_options', $options) . (is_multisite() && is_main_site() ? update_site_option('ws_plugin__s2member_options', $options) : NULL) . update_option('ws_plugin__s2member_cache', array());
         if ($update_other === TRUE || in_array('auto_eot_system', (array) $update_other)) {
             // Handle the Auto-EOT System now (enable/disable).
             $options['auto_eot_system_enabled'] == 1 ? c_ws_plugin__s2member_auto_eots::add_auto_eot_system() : c_ws_plugin__s2member_auto_eots::delete_auto_eot_system();
         }
         if (($display_notices === TRUE || in_array('success', (array) $display_notices)) && ($notice = '<strong>Options saved.' . ($request_refresh ? ' Please <a href="' . esc_attr($_SERVER['REQUEST_URI']) . '">refresh</a>.' : '') . '</strong>')) {
             $enqueue_notices === TRUE || in_array('success', (array) $enqueue_notices) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, '*:*') : c_ws_plugin__s2member_admin_notices::display_admin_notice($notice);
         }
         if (empty($_GET['page']) || $_GET['page'] !== 'ws-plugin--s2member-mms-ops') {
             if (!$options['membership_options_page'] && ($display_notices === TRUE || in_array('page-conflict-warnings', (array) $display_notices)) && ($notice = '<strong>NOTE:</strong> s2Member security restrictions will NOT be enforced until you\'ve configured a Membership Options Page. See: <strong>s2Member → General Options → Membership Options Page</strong>.')) {
                 $enqueue_notices === TRUE || in_array('page-conflict-warnings', (array) $enqueue_notices) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, '*:*', TRUE) : c_ws_plugin__s2member_admin_notices::display_admin_notice($notice, TRUE);
             }
             if ($options['login_welcome_page'] && $options['login_welcome_page'] === $options['membership_options_page'] && ($display_notices === TRUE || in_array('page-conflict-warnings', (array) $display_notices)) && ($notice = '<strong>s2Member:</strong> Your Login Welcome Page is the same as your Membership Options Page. Please correct this. See: <strong>s2Member → General Options → Login Welcome Page</strong>.')) {
                 $enqueue_notices === TRUE || in_array('page-conflict-warnings', (array) $enqueue_notices) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, '*:*', TRUE) : c_ws_plugin__s2member_admin_notices::display_admin_notice($notice, TRUE);
             }
             if ($options['membership_options_page'] && (string) get_option('page_on_front') === $options['membership_options_page'] && ($display_notices === TRUE || in_array('page-conflict-warnings', (array) $display_notices)) && ($notice = '<strong>s2Member:</strong> Your Membership Options Page is currently configured as your Home Page (i.e., static page) for WordPress. This causes internal conflicts with s2Member. Your Membership Options Page MUST stand alone. Please correct this. See: <strong>WordPress → Reading Options</strong>. Or change: <strong>s2Member → General Options → Membership Options Page</strong>.')) {
                 $enqueue_notices === TRUE || in_array('page-conflict-warnings', (array) $enqueue_notices) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, '*:*', TRUE) : c_ws_plugin__s2member_admin_notices::display_admin_notice($notice, TRUE);
             }
             if ($options['login_welcome_page'] && (string) get_option('page_on_front') === $options['login_welcome_page'] && ($display_notices === TRUE || in_array('page-conflict-warnings', (array) $display_notices)) && ($notice = '<strong>s2Member:</strong> Your Login Welcome Page is currently configured as your Home Page (i.e., static page) for WordPress. This causes internal conflicts with s2Member. Your Login Welcome Page MUST stand alone. Please correct this. See: <strong>WordPress → Reading Options</strong>. Or change: <strong>s2Member → General Options → Login Welcome Page</strong>.')) {
                 $enqueue_notices === TRUE || in_array('page-conflict-warnings', (array) $enqueue_notices) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, '*:*', TRUE) : c_ws_plugin__s2member_admin_notices::display_admin_notice($notice, TRUE);
             }
             if ($options['membership_options_page'] && (string) get_option('page_for_posts') === $options['membership_options_page'] && ($display_notices === TRUE || in_array('page-conflict-warnings', (array) $display_notices)) && ($notice = '<strong>s2Member:</strong> Your Membership Options Page is currently configured as your Posts Page (i.e., static page) for WordPress. This causes internal conflicts with s2Member. Your Membership Options Page MUST stand alone. Please correct this. See: <strong>WordPress → Reading Options</strong>. Or change: <strong>s2Member → General Options → Membership Options Page</strong>.')) {
                 $enqueue_notices === TRUE || in_array('page-conflict-warnings', (array) $enqueue_notices) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, '*:*', TRUE) : c_ws_plugin__s2member_admin_notices::display_admin_notice($notice, TRUE);
             }
             if ($options['login_welcome_page'] && (string) get_option('page_for_posts') === $options['login_welcome_page'] && ($display_notices === TRUE || in_array('page-conflict-warnings', (array) $display_notices)) && ($notice = '<strong>s2Member:</strong> Your Login Welcome Page is currently configured as your Posts Page (i.e., static page) for WordPress. This causes internal conflicts with s2Member. Your Login Welcome Page MUST stand alone. Please correct this. See: <strong>WordPress → Reading Options</strong>. Or change: <strong>s2Member → General Options → Login Welcome Page</strong>.')) {
                 $enqueue_notices === TRUE || in_array('page-conflict-warnings', (array) $enqueue_notices) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, '*:*', TRUE) : c_ws_plugin__s2member_admin_notices::display_admin_notice($notice, TRUE);
             }
             if ($options['file_download_limit_exceeded_page'] && $options['file_download_limit_exceeded_page'] === $options['membership_options_page'] && ($display_notices === TRUE || in_array('page-conflict-warnings', (array) $display_notices)) && ($notice = '<strong>s2Member:</strong> Your Download Limit Exceeded Page is the same as your Membership Options Page. Please correct this. See: <strong>s2Member → Download Options</strong>.')) {
                 $enqueue_notices === TRUE || in_array('page-conflict-warnings', (array) $enqueue_notices) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, '*:*', TRUE) : c_ws_plugin__s2member_admin_notices::display_admin_notice($notice, TRUE);
             }
         }
         $updated_all_options = TRUE;
         // Flag indicating this routine was processed successfully; and that all s2Member options have been updated successfully.
     }
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_after_update_all_options', get_defined_vars());
     unset($__refs, $__v);
     // Housekeeping.
     return apply_filters('ws_plugin__s2member_update_all_options', $updated_all_options ? TRUE : FALSE, get_defined_vars());
 }
 /**
  * Saves all options from any menu page.
  * 
  * Can also be self-verified; and configured extensively with function parameters.
  *
  * @package s2Member\Menu_Pages
  * @since 3.5
  *
  * @param array $new_options Optional. Force feed an array of new options. Defaults to ``$_POST`` vars.
  * 	If ``$new_options`` are passed in, be SURE that you've already applied ``stripslashes_deep()``.
  * @param bool $verified Optional. Defaults to false. If true, ``wp_verify_nonce()`` is skipped in this routine.
  * @param bool $update_other Optional. Defaults to true. If false, other option-dependent routines will not be processed.
  * @param bool|array $display_notices Optional. Defaults to true. Can be false, or an array of certain notices that can be displayed.
  * @param bool|array $enqueue_notices Optional. Defaults to false. Can be true, or an array of certain notices that should be enqueued.
  * @param bool $request_refresh Optional. Defaults to false. If true, resulting `success` notice will include a link to refresh the menu page.
  * @return bool True if all s2Member options were updated successfully, else false.
  */
 public static function update_all_options($new_options = FALSE, $verified = FALSE, $update_other = TRUE, $display_notices = TRUE, $enqueue_notices = FALSE, $request_refresh = FALSE)
 {
     $updated_all_options = false;
     /* Initialize this to a value of false. Initializing this variable here makes it an available reference-variable to Hooks/Filters. */
     /**/
     eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
     do_action("ws_plugin__s2member_before_update_all_options", get_defined_vars());
     /* If you use this Hook, be sure to use ``wp_verify_nonce()``. */
     unset($__refs, $__v);
     /* Unset defined __refs, __v. */
     /**/
     if ($verified || !empty($_POST["ws_plugin__s2member_options_save"]) && ($nonce = $_POST["ws_plugin__s2member_options_save"]) && wp_verify_nonce($nonce, "ws-plugin--s2member-options-save")) {
         $options = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"];
         /* Acquire the full existing configuration options array here. */
         /**/
         $new_options = is_array($new_options) ? $new_options : (!empty($_POST) && is_array($_POST) ? stripslashes_deep($_POST) : array());
         $new_options = c_ws_plugin__s2member_utils_strings::trim_deep($new_options);
         /**/
         foreach ($new_options as $key => $value) {
             /* Find all keys contained within ``$new_options`` matching `^ws_plugin__s2member_`. */
             if (strpos($key, "ws_plugin__s2member_") === 0) {
                 /* A relevant ``$new_options`` key matching `^ws_plugin__s2member_`? */
                 /**/
                 if ($key === "ws_plugin__s2member_configured") {
                     /* s2Member is now configured ( according to these options )? */
                     ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"] = $value) . update_option("ws_plugin__s2member_configured", $value);
                 } else {
                     if (!is_array($value) || is_array($value) && array_shift($value) === "update-signal") {
                         $options[preg_replace("/^" . preg_quote("ws_plugin__s2member_", "/") . "/", "", $key)] = $value;
                     }
                 }
             }
         }
         /**/
         unset($key, $value);
         /* Unset these utility variables now. This prevents bleeding vars into Hooks/Filters that are of no use. */
         /**/
         eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
         do_action("ws_plugin__s2member_during_update_all_options", get_defined_vars());
         /* If you use this Hook, be sure to use ``wp_verify_nonce()``. */
         unset($__refs, $__v);
         /* Unset defined __refs, __v. */
         /**/
         $options = ws_plugin__s2member_configure_options_and_their_defaults($options = array_merge($options, array("options_version" => (string) ($options["options_version"] + 0.001))));
         update_option("ws_plugin__s2member_options", $options) . (is_multisite() && is_main_site() ? update_site_option("ws_plugin__s2member_options", $options) : null) . update_option("ws_plugin__s2member_cache", array());
         /**/
         if ($update_other === true || in_array("auto_eot_system", (array) $update_other)) {
             /* Handle the Auto-EOT System now ( enable/disable ). */
             $options["auto_eot_system_enabled"] == 1 ? c_ws_plugin__s2member_auto_eots::add_auto_eot_system() : c_ws_plugin__s2member_auto_eots::delete_auto_eot_system();
         }
         /**/
         if (($display_notices === true || in_array("success", (array) $display_notices)) && ($notice = '<strong>Options saved.' . ($request_refresh ? ' Please <a href="' . esc_attr($_SERVER["REQUEST_URI"]) . '">refresh</a>.' : '') . '</strong>')) {
             $enqueue_notices === true || in_array("success", (array) $enqueue_notices) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, "*:*") : c_ws_plugin__s2member_admin_notices::display_admin_notice($notice);
         }
         /**/
         if (empty($_GET["page"]) || $_GET["page"] !== "ws-plugin--s2member-mms-ops") {
             if (!$options["membership_options_page"] && ($display_notices === true || in_array("page-conflict-warnings", (array) $display_notices)) && ($notice = '<strong>NOTE:</strong> s2Member security restrictions will NOT be enforced until you\'ve configured a Membership Options Page. See: <code>s2Member -> General Options -> Membership Options Page</code>.')) {
                 $enqueue_notices === true || in_array("page-conflict-warnings", (array) $enqueue_notices) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, "*:*", true) : c_ws_plugin__s2member_admin_notices::display_admin_notice($notice, true);
             }
             /**/
             if ($options["login_welcome_page"] && $options["login_welcome_page"] === $options["membership_options_page"] && ($display_notices === true || in_array("page-conflict-warnings", (array) $display_notices)) && ($notice = '<strong>s2Member:</strong> Your Login Welcome Page is the same as your Membership Options Page. Please correct this. See: <code>s2Member -> General Options -> Login Welcome Page</code>.')) {
                 $enqueue_notices === true || in_array("page-conflict-warnings", (array) $enqueue_notices) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, "*:*", true) : c_ws_plugin__s2member_admin_notices::display_admin_notice($notice, true);
             }
             /**/
             if ($options["membership_options_page"] && (string) get_option("page_on_front") === $options["membership_options_page"] && ($display_notices === true || in_array("page-conflict-warnings", (array) $display_notices)) && ($notice = '<strong>s2Member:</strong> Your Membership Options Page is currently configured as your Home Page ( i.e. static page ) for WordPress®. This causes internal conflicts with s2Member. Your Membership Options Page MUST stand alone. Please correct this. See: <code>WordPress® -> Reading Options</code>. Or change: <code>s2Member -> General Options -> Membership Options Page</code>.')) {
                 $enqueue_notices === true || in_array("page-conflict-warnings", (array) $enqueue_notices) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, "*:*", true) : c_ws_plugin__s2member_admin_notices::display_admin_notice($notice, true);
             }
             /**/
             if ($options["login_welcome_page"] && (string) get_option("page_on_front") === $options["login_welcome_page"] && ($display_notices === true || in_array("page-conflict-warnings", (array) $display_notices)) && ($notice = '<strong>s2Member:</strong> Your Login Welcome Page is currently configured as your Home Page ( i.e. static page ) for WordPress®. This causes internal conflicts with s2Member. Your Login Welcome Page MUST stand alone. Please correct this. See: <code>WordPress® -> Reading Options</code>. Or change: <code>s2Member -> General Options -> Login Welcome Page</code>.')) {
                 $enqueue_notices === true || in_array("page-conflict-warnings", (array) $enqueue_notices) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, "*:*", true) : c_ws_plugin__s2member_admin_notices::display_admin_notice($notice, true);
             }
             /**/
             if ($options["membership_options_page"] && (string) get_option("page_for_posts") === $options["membership_options_page"] && ($display_notices === true || in_array("page-conflict-warnings", (array) $display_notices)) && ($notice = '<strong>s2Member:</strong> Your Membership Options Page is currently configured as your Posts Page ( i.e. static page ) for WordPress®. This causes internal conflicts with s2Member. Your Membership Options Page MUST stand alone. Please correct this. See: <code>WordPress® -> Reading Options</code>. Or change: <code>s2Member -> General Options -> Membership Options Page</code>.')) {
                 $enqueue_notices === true || in_array("page-conflict-warnings", (array) $enqueue_notices) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, "*:*", true) : c_ws_plugin__s2member_admin_notices::display_admin_notice($notice, true);
             }
             /**/
             if ($options["login_welcome_page"] && (string) get_option("page_for_posts") === $options["login_welcome_page"] && ($display_notices === true || in_array("page-conflict-warnings", (array) $display_notices)) && ($notice = '<strong>s2Member:</strong> Your Login Welcome Page is currently configured as your Posts Page ( i.e. static page ) for WordPress®. This causes internal conflicts with s2Member. Your Login Welcome Page MUST stand alone. Please correct this. See: <code>WordPress® -> Reading Options</code>. Or change: <code>s2Member -> General Options -> Login Welcome Page</code>.')) {
                 $enqueue_notices === true || in_array("page-conflict-warnings", (array) $enqueue_notices) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, "*:*", true) : c_ws_plugin__s2member_admin_notices::display_admin_notice($notice, true);
             }
             /**/
             if ($options["file_download_limit_exceeded_page"] && $options["file_download_limit_exceeded_page"] === $options["membership_options_page"] && ($display_notices === true || in_array("page-conflict-warnings", (array) $display_notices)) && ($notice = '<strong>s2Member:</strong> Your Download Limit Exceeded Page is the same as your Membership Options Page. Please correct this. See: <code>s2Member -> Download Options</code>.')) {
                 $enqueue_notices === true || in_array("page-conflict-warnings", (array) $enqueue_notices) ? c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, "*:*", true) : c_ws_plugin__s2member_admin_notices::display_admin_notice($notice, true);
             }
         }
         /**/
         $updated_all_options = true;
         /* Flag indicating this routine was processed successfully; and that all s2Member options have been updated successfully.*/
     }
     /**/
     eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
     do_action("ws_plugin__s2member_after_update_all_options", get_defined_vars());
     /* If you use this Hook, be sure to use ``wp_verify_nonce()``. */
     unset($__refs, $__v);
     /* Unset defined __refs, __v. */
     /**/
     return apply_filters("ws_plugin__s2member_update_all_options", $updated_all_options ? true : false, get_defined_vars());
 }