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

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

117 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Locks Users/Members out of admin panels.
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\Admin_Lockouts
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_admin_lockouts"))
21 {
22 /**
23 * Locks Users/Members out of admin panels.
24 *
25 * @package s2Member\Admin_Lockouts
26 * @since 3.5
27 */
28 class c_ws_plugin__s2member_admin_lockouts
29 {
30 /**
31 * Locks Users/Members out of admin panels.
32 *
33 * @package s2Member\Admin_Lockouts
34 * @since 3.5
35 *
36 * @attaches-to ``add_action("admin_init");``
37 *
38 * @return null Or exits script execution after redirection.
39 */
40 public static function admin_lockout () /* Prevents admin access. */
41 {
42 do_action ("ws_plugin__s2member_before_admin_lockouts", get_defined_vars ());
43 /**/
44 if ((!defined ("DOING_AJAX") || !DOING_AJAX) && !current_user_can ("edit_posts") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"])
45 if (apply_filters ("ws_plugin__s2member_admin_lockout", true, get_defined_vars ()) /* Give Filters a chance here too. */)
46 {
47 if ($redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url ())
48 wp_redirect ($redirection_url); /* Special Redirection. */
49 /**/
50 else /* Else we use the Login Welcome Page configured for s2Member. */
51 wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
52 /**/
53 exit (); /* Clean exit. */
54 }
55 /**/
56 do_action ("ws_plugin__s2member_after_admin_lockouts", get_defined_vars ());
57 /**/
58 return; /* Return for uniformity. */
59 }
60 /**
61 * Filters administrative menu bars.
62 *
63 * @package s2Member\Admin_Lockouts
64 * @since 3.5
65 *
66 * @attaches-to ``add_action("admin_bar_menu");``
67 *
68 * @param obj $wp_admin_bar Expects the ``$wp_admin_bar``, by reference; passed in by the Action Hook.
69 * @return null After modifying ``$wp_admin_var``.
70 */
71 public static function filter_admin_menu_bar (&$wp_admin_bar = FALSE)
72 {
73 global $current_site, $current_blog; /* In support of Multisite Networking. */
74 /**/
75 do_action ("ws_plugin__s2member_before_filter_admin_menu_bar", get_defined_vars ());
76 /**/
77 if (is_object ($wp_admin_bar) && !current_user_can ("edit_posts"))
78 {
79 if (isset ($wp_admin_bar->menu->{"dashboard"})) /* We don't need this. */
80 unset ($wp_admin_bar->menu->{"dashboard"}); /* Remove this entire menu. */
81 /**/
82 if (is_multisite () && !c_ws_plugin__s2member_utils_conds::is_multisite_farm () && isset ($wp_admin_bar->menu->{"my-blogs"}))
83 {
84 $wp_admin_bar->menu->{"my-blogs"}["href"] = "#"; /* Void this link out by converting to `#`. */
85 /**/
86 if (isset ($wp_admin_bar->menu->{"my-blogs"}["children"]) && is_object ($wp_admin_bar->menu->{"my-blogs"}["children"]))
87 foreach ($wp_admin_bar->menu->{"my-blogs"}["children"] as &$blog) /* Modify other Blog links in drop-down. */
88 if (is_array ($blog) && isset ($blog["href"], $blog["children"]) && is_object ($blog["children"]))
89 {
90 $blog["href"] = preg_replace ("/\/wp-admin/", "", $blog["href"]);
91 unset ($blog["children"]); /* Cause all we need is the link. */
92 }
93 }
94 /**/
95 if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"] && apply_filters ("ws_plugin__s2member_admin_lockout", true, get_defined_vars ()))
96 {
97 $lwp = c_ws_plugin__s2member_login_redirects::login_redirection_url ($user);
98 $lwp = (!$lwp) ? get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]) : $lwp;
99 /**/
100 if (isset ($wp_admin_bar->menu->{"my-account-with-avatar"})) /* Profile. */
101 {
102 if (isset ($wp_admin_bar->menu->{"my-account-with-avatar"}["href"]))
103 $wp_admin_bar->menu->{"my-account-with-avatar"}["href"] = $lwp;
104 /**/
105 if (isset ($wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"edit-profile"}["href"]))
106 $wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"edit-profile"}["href"] = $lwp;
107 }
108 }
109 }
110 /**/
111 do_action ("ws_plugin__s2member_after_filter_admin_menu_bar", get_defined_vars ());
112 /**/
113 return; /* Return for uniformity. */
114 }
115 }
116 }
117 ?>