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

utils-conds.inc.php in s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions 110815, at includes/classes/utils-conds.inc.php

116 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Conditional utilities.
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\Utilities
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_utils_conds"))
21 {
22 /**
23 * Conditional utilities.
24 *
25 * @package s2Member\Utilities
26 * @since 3.5
27 */
28 class c_ws_plugin__s2member_utils_conds
29 {
30 /**
31 * Determines whether or not BuddyPress is installed.
32 *
33 * @package s2Member\Utilities
34 * @since 110720
35 *
36 * @return bool True if BuddyPress is installed, else false.
37 */
38 public static function bp_is_installed ()
39 {
40 return defined ("BP_VERSION");
41 }
42 /**
43 * Determines whether or not s2Member Pro is installed.
44 *
45 * @package s2Member\Utilities
46 * @since 110720
47 *
48 * @return bool True if s2Member Pro is installed, else false.
49 */
50 public static function pro_is_installed ()
51 {
52 return defined ("WS_PLUGIN__S2MEMBER_PRO_VERSION");
53 }
54 /**
55 * Determines whether or not this is a Multisite Farm;
56 * *( i.e. if ``MULTISITE_FARM == true`` inside `/wp-config.php` )*.
57 *
58 * With s2Member, this option may also indicate a Multisite Blog Farm.
59 * ``$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_file"] === "wp-signup"``.
60 *
61 * @package s2Member\Utilities
62 * @since 3.5
63 *
64 * @return bool True if this is a Multisite Farm, else false.
65 */
66 public static function is_multisite_farm ()
67 {
68 return (is_multisite () && ((is_main_site () && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_file"] === "wp-signup") || (defined ("MULTISITE_FARM") && MULTISITE_FARM)));
69 }
70 /**
71 * Checks if a Post is in a child Category.
72 *
73 * @package s2Member\Utilities
74 * @since 3.5
75 *
76 * @param array $cats An array of Category IDs.
77 * @param int|str $post_id A numeric WordPress® Post ID.
78 * @return bool True if the Post is inside a desendant of at least one of the specified Categories; else false.
79 */
80 public static function in_descendant_category ($cats = FALSE, $post_id = FALSE)
81 {
82 foreach ((array)$cats as $cat)
83 {
84 $descendants = get_term_children ((int)$cat, "category");
85 if ($descendants && in_category ($descendants, $post_id))
86 return true;
87 }
88 /**/
89 return false;
90 }
91 /**
92 * Checks to see if a URL/URI leads to the site root.
93 *
94 * @package s2Member\Utilities
95 * @since 3.5
96 *
97 * @param str $url_or_uri Either a full URL, or a URI to test against.
98 * @return bool True if the URL or URI leads to the site root, else false.
99 */
100 public static function is_site_root ($url_or_uri = FALSE)
101 {
102 if (($parse = @parse_url ($url_or_uri))) /* See: http://php.net/manual/en/function.parse-url.php. */
103 {
104 $parse["path"] = (!empty ($parse["path"])) ? ((strpos ($parse["path"], "/") === 0) ? $parse["path"] : "/" . $parse["path"]) : "/";
105 $parse["path"] = preg_replace ("/\/+/", "/", $parse["path"]); /* Removes multi slashes. */
106 /**/
107 if (empty ($parse["host"]) || strcasecmp ($parse["host"], parse_url (site_url (), PHP_URL_HOST)) === 0)
108 if ($parse["path"] === "/" || rtrim ($parse["path"], "/") === rtrim (parse_url (site_url (), PHP_URL_PATH), "/"))
109 return true;
110 }
111 /**/
112 return false;
113 }
114 }
115 }
116 ?>