| 1 |
<?php |
| 2 |
/** |
| 3 |
* Membership Options Page ( inner processing routines ). |
| 4 |
* |
| 5 |
* Copyright: © 2009-2011 |
| 6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.} |
| 7 |
* ( coded in the USA ) |
| 8 |
* |
| 9 |
* Released under the terms of the GNU General Public License. |
| 10 |
* You should have received a copy of the GNU General Public License, |
| 11 |
* along with this software. In the main directory, see: /licensing/ |
| 12 |
* If not, see: {@link http://www.gnu.org/licenses/}. |
| 13 |
* |
| 14 |
* @package s2Member\Membership_Options_Page |
| 15 |
* @since 3.5 |
| 16 |
*/ |
| 17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"])) |
| 18 |
exit ("Do not access this file directly."); |
| 19 |
/**/ |
| 20 |
if (!class_exists ("c_ws_plugin__s2member_mo_page_in")) |
| 21 |
{ |
| 22 |
/** |
| 23 |
* Membership Options Page ( inner processing routines ). |
| 24 |
* |
| 25 |
* @package s2Member\Membership_Options_Page |
| 26 |
* @since 3.5 |
| 27 |
*/ |
| 28 |
class c_ws_plugin__s2member_mo_page_in |
| 29 |
{ |
| 30 |
/** |
| 31 |
* Forces a redirection to the Membership Options Page for s2Member. |
| 32 |
* |
| 33 |
* This can be used by 3rd party apps that are not aware of which Page is currently set as the Membership Options Page. |
| 34 |
* Example usage: `http://example.com/?s2member_membership_options_page=1` |
| 35 |
* |
| 36 |
* Redirection URLs containing array brackets MUST be URL encoded to get through: ``wp_sanitize_redirect()``. |
| 37 |
* So we pass everything to ``urlencode_deep()``, as an array. It handles this via ``_http_build_query()``. |
| 38 |
* See bug report here: {@link http://core.trac.wordpress.org/ticket/17052} |
| 39 |
* |
| 40 |
* @package s2Member\Membership_Options_Page |
| 41 |
* @since 3.5 |
| 42 |
* |
| 43 |
* @attaches-to ``add_action("init");`` |
| 44 |
* |
| 45 |
* @return null Or exits script execution after redirection w/ `301` status. |
| 46 |
*/ |
| 47 |
public static function /* Real Membership Options Page. */ membership_options_page () |
| 48 |
{ |
| 49 |
do_action ("ws_plugin__s2member_before_membership_options_page", get_defined_vars ()); |
| 50 |
/**/ |
| 51 |
if (!empty ($_GET["s2member_membership_options_page"]) && is_array ($_g = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_GET)))) |
| 52 |
{ |
| 53 |
$args = /* Initialize this to an empty array value. */ array (); |
| 54 |
/**/ |
| 55 |
foreach ($_g as $var => $value) /* Include all of the `_?s2member_` variables. */ |
| 56 |
/* Do NOT include `s2member_membership_options_page`; creates a redirection loop. */ |
| 57 |
if (preg_match ("/^_?s2member_/", $var) && $var !== "s2member_membership_options_page") |
| 58 |
$args[$var] = /* Supports nested arrays. */ $value; |
| 59 |
/**/ |
| 60 |
wp_redirect (add_query_arg (urlencode_deep ($args), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), 301) . exit (); |
| 61 |
} |
| 62 |
/**/ |
| 63 |
do_action ("ws_plugin__s2member_after_membership_options_page", get_defined_vars ()); |
| 64 |
} |
| 65 |
/** |
| 66 |
* Redirects to Membership Options Page w/ MOP Vars. |
| 67 |
* |
| 68 |
* Redirection URLs containing array brackets MUST be URL encoded to get through: ``wp_sanitize_redirect()``. |
| 69 |
* So we pass everything to ``urlencode_deep()``, as an array. It handles this via ``_http_build_query()``. |
| 70 |
* See bug report here: {@link http://core.trac.wordpress.org/ticket/17052} |
| 71 |
* |
| 72 |
* @package s2Member\Membership_Options_Page |
| 73 |
* @since 111101 |
| 74 |
* |
| 75 |
* @param str $seeking_type Seeking content type. One of: `post|page|catg|ptag|file|ruri`. |
| 76 |
* @param str|int $seeking_type_value Seeking content type data. String, or a Post/Page ID. |
| 77 |
* @param str $req_type Access requirement type. One of these values: `level|ccap|sp`. |
| 78 |
* @param str|int $req_type_value Access requirement. String, or a Post/Page ID. |
| 79 |
* @param str $seeking_uri The full URI that access was attempted on. |
| 80 |
* @param str $res_type Restriction type that's preventing access. |
| 81 |
* One of: `post|page|catg|ptag|file|ruri|ccap|sp|sys`. |
| 82 |
* Defaults to ``$seeking_type``. |
| 83 |
* @return bool This function always returns true. |
| 84 |
*/ |
| 85 |
public static function wp_redirect_w_mop_vars ($seeking_type = FALSE, $seeking_type_value = FALSE, $req_type = FALSE, $req_type_value = FALSE, $seeking_uri = FALSE, $res_type = FALSE) |
| 86 |
{ |
| 87 |
do_action ("ws_plugin__s2member_before_wp_redirect_w_mop_vars", get_defined_vars ()); |
| 88 |
/**/ |
| 89 |
$status = /* Allow Filters. Defaults to `301`. */ apply_filters ("ws_plugin__s2member_content_redirect_status", 301, get_defined_vars ()); |
| 90 |
$status = /* Allow Filters. Defaults to `301`. */ apply_filters ("ws_plugin__s2member_wp_redirect_w_mop_vars_status", $status, get_defined_vars ()); |
| 91 |
/**/ |
| 92 |
$seeking_uri = (strlen ((string)$seeking_uri) /* URIs are base64 encoded. */) ? base64_encode ((string)$seeking_uri) : (string)$seeking_uri; |
| 93 |
$seeking_type_value = ((string)$seeking_type /* URIs are base64 encoded. */ === "ruri") ? base64_encode ((string)$seeking_type_value) : (string)$seeking_type_value; |
| 94 |
/**/ |
| 95 |
$res_type = (!(string)$res_type) ? /* Restriction type preventing access. Defaults to ``$seeking_type`` if NOT passed in explicitly. */ (string)$seeking_type : (string)$res_type; |
| 96 |
/**/ |
| 97 |
wp_redirect (add_query_arg (urlencode_deep (array ("_s2member_seeking" => array ("type" => (string)$seeking_type, urlencode ((string)$seeking_type)=> (string)$seeking_type_value, "_uri" => (string)$seeking_uri), "_s2member_req" => array ("type" => (string)$req_type, urlencode ((string)$req_type)=> (string)$req_type_value), "_s2member_res" => array ("type" => (string)$res_type), "s2member_seeking" => (string)$seeking_type . "-" . (string)$seeking_type_value, "s2member_" . urlencode ((string)$req_type) . "_req" => (string)$req_type_value)), get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])), $status); |
| 98 |
/**/ |
| 99 |
do_action ("ws_plugin__s2member_after_wp_redirect_w_mop_vars", get_defined_vars ()); |
| 100 |
/**/ |
| 101 |
return true; /* Always returns true here. */ |
| 102 |
} |
| 103 |
} |
| 104 |
} |
| 105 |
?> |