PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / trunk
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions vtrunk
260909 260829 260814 260805 110710 110731 110812 110815 110912 110913 110915 110926 110927 111002 111003 111011 111017 111029 111105 111206 111216 111220 120213 120219 120301 All 187 releases
s2member / src / includes / classes / systematics-sp.inc.php

systematics-sp.inc.php in s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions trunk, at src/includes/classes/systematics-sp.inc.php

130 lines 7.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // @codingStandardsIgnoreFile
3 /**
4 * Systematics *(for a specific page)*.
5 *
6 * Copyright: © 2009-2011
7 * {@link http://websharks-inc.com/ WebSharks, Inc.}
8 * (coded in the USA)
9 *
10 * Released under the terms of the GNU General Public License.
11 * You should have received a copy of the GNU General Public License,
12 * along with this software. In the main directory, see: /licensing/
13 * If not, see: {@link http://www.gnu.org/licenses/}.
14 *
15 * @package s2Member\Systematics
16 * @since 3.5
17 */
18 if(!defined('WPINC')) // MUST have WordPress.
19 exit('Do not access this file directly.');
20
21 if(!class_exists('c_ws_plugin__s2member_systematics_sp'))
22 {
23 /**
24 * Systematics *(for a specific page)*.
25 *
26 * @package s2Member\Systematics
27 * @since 3.5
28 */
29 class c_ws_plugin__s2member_systematics_sp
30 {
31 /**
32 * Determines if a specific Post/Page ID, or URI, is s2Member Systematic.
33 *
34 * @package s2Member\Systematics
35 * @since 111115
36 *
37 * @param int|string $singular_id Optional. A numeric Post/Page ID in WordPress.
38 * @param string $uri Optional. A request URI to test against.
39 *
40 * @return bool True if s2Member Systematic, else false.
41 */
42 public static function is_s2_systematic_use_specific_page($singular_id = '', $uri = '')
43 {
44 $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
45 $singular_id = ($singular_id && is_numeric($singular_id)) ? (int)$singular_id : FALSE; // Force types.
46 $uri = ($uri && is_string($uri) && ($uri = c_ws_plugin__s2member_utils_urls::parse_uri($uri))) ? $uri : FALSE;
47
48 if($uri && ($_q = c_ws_plugin__s2member_utils_urls::parse_url($uri, PHP_URL_QUERY)) && preg_match('/[\?&]s2member/'.$ci, $_q) && c_ws_plugin__s2member_utils_conds::is_site_root($uri))
49 return ($is_s2_systematic = apply_filters('ws_plugin__s2member_is_s2_systematic_use_specific_page', TRUE, get_defined_vars()));
50
51 return ($is_s2_systematic = apply_filters('ws_plugin__s2member_is_s2_systematic_use_specific_page', FALSE, get_defined_vars()));
52 }
53
54 /**
55 * Determines if a specific Post/Page ID, or URI, is WordPress Systematic.
56 *
57 * @package s2Member\Systematics
58 * @since 111002
59 *
60 * @param int|string $singular_id Optional. A numeric Post/Page ID in WordPress.
61 * @param string $uri Optional. A request URI to test against.
62 *
63 * @return bool True if WordPress Systematic, else false.
64 */
65 public static function is_wp_systematic_use_specific_page($singular_id = '', $uri = '')
66 {
67 $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
68 $singular_id = ($singular_id && is_numeric($singular_id)) ? (int)$singular_id : FALSE; // Force types.
69 $uri = ($uri && is_string($uri) && ($uri = c_ws_plugin__s2member_utils_urls::parse_uri($uri))) ? $uri : FALSE;
70
71 if($uri && preg_match('/\/wp-admin(?:\/|\?|$)/'.$ci, $uri)) // Inside a WordPress administrative area?
72 return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_specific_page', TRUE, get_defined_vars()));
73
74 if($uri && preg_match('/^\/(?:wp-.+?|xmlrpc)\.php$/'.$ci, c_ws_plugin__s2member_utils_urls::parse_url($uri, PHP_URL_PATH)))
75 return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_specific_page', TRUE, get_defined_vars()));
76
77 return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_specific_page', FALSE, get_defined_vars()));
78 }
79
80 /**
81 * Determines if a specific Post/Page ID, or URI, is Systematic in any way.
82 *
83 * @package s2Member\Systematics
84 * @since 3.5
85 *
86 * @param int|string $singular_id Optional. A numeric Post/Page ID in WordPress.
87 * @param string $uri Optional. A request URI to test against.
88 *
89 * @return bool True if Systematic, else false.
90 *
91 * @todo Test URIs against formulated links for Systematic Pages like the Membership Options Page?
92 * Don't think this is required though; as it's already handled in other areas, correct?
93 */
94 public static function is_systematic_use_specific_page($singular_id = '', $uri = '')
95 {
96 global $bp; // If BuddyPress is installed, we'll need this global reference.
97
98 $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
99 $singular_id = ($singular_id && is_numeric($singular_id)) ? (int)$singular_id : FALSE; // Force types.
100 $uri = ($uri && is_string($uri) && ($uri = c_ws_plugin__s2member_utils_urls::parse_uri($uri))) ? $uri : FALSE;
101
102 if(c_ws_plugin__s2member_systematics_sp::is_s2_systematic_use_specific_page($singular_id, $uri))
103 return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_specific_page', TRUE, get_defined_vars()));
104
105 if(c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page($singular_id, $uri))
106 return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_specific_page', TRUE, get_defined_vars()));
107
108 if($uri && c_ws_plugin__s2member_utils_conds::bp_is_installed() && preg_match('/\/(?:'.preg_quote(trim(((function_exists('bp_get_signup_slug')) ? bp_get_signup_slug() : BP_REGISTER_SLUG), '/'), '/').'|'.preg_quote(trim(((function_exists('bp_get_activate_slug')) ? bp_get_activate_slug() : BP_ACTIVATION_SLUG), '/'), '/').')(?:\/|\?|$)/'.$ci, $uri))
109 return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_specific_page', TRUE, get_defined_vars()));
110
111 if($singular_id && c_ws_plugin__s2member_utils_conds::bp_is_installed() && ((!empty($bp->pages->register->id) && $singular_id === (int)$bp->pages->register->id) || (!empty($bp->pages->activate->id) && $singular_id === (int)$bp->pages->activate->id)))
112 return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_specific_page', TRUE, get_defined_vars()));
113
114 if($singular_id && $GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'] && $singular_id === (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'])
115 return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_specific_page', TRUE, get_defined_vars()));
116
117 if($singular_id && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'] && $singular_id === (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'])
118 return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_specific_page', TRUE, get_defined_vars()));
119
120 if($singular_id && $GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'] && $singular_id === (int)$GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'])
121 return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_specific_page', TRUE, get_defined_vars()));
122
123 if($uri && $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, $uri))
124 return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_specific_page', TRUE, get_defined_vars()));
125
126 return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_specific_page', FALSE, get_defined_vars()));
127 }
128 }
129 }
130