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 / admin-lockouts.inc.php

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

128 lines 6.0 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 ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"] /* Now check for these WordPress® functionality Constants too. */
45 && (!defined ("XMLRPC_REQUEST") || !XMLRPC_REQUEST) && (!defined ("APP_REQUEST") || !APP_REQUEST) && (!defined ("DOING_AJAX") || !DOING_AJAX)/**/
46 && !current_user_can ("edit_posts")) /* And only if the current User is unable to edit Posts; otherwise we allow them in. */
47 if (apply_filters ("ws_plugin__s2member_admin_lockout", true, get_defined_vars ())) /* Give Filters a chance too. */
48 {
49 if ($special_redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url ())
50 wp_redirect($special_redirection_url); /* Special Redirection. */
51 /**/
52 else /* Else we use the Login Welcome Page configured for s2Member. */
53 wp_redirect(get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
54 /**/
55 exit (); /* Clean exit. */
56 }
57 /**/
58 do_action ("ws_plugin__s2member_after_admin_lockouts", get_defined_vars ());
59 /**/
60 return; /* Return for uniformity. */
61 }
62 /**
63 * Filters administrative menu bars.
64 *
65 * @package s2Member\Admin_Lockouts
66 * @since 3.5
67 *
68 * @attaches-to ``add_action("admin_bar_menu");``
69 *
70 * @param obj $wp_admin_bar Expects the ``$wp_admin_bar``, by reference; passed in by the Action Hook.
71 * @return null After modifying ``$wp_admin_var``.
72 */
73 public static function filter_admin_menu_bar (&$wp_admin_bar = FALSE)
74 {
75 do_action ("ws_plugin__s2member_before_filter_admin_menu_bar", get_defined_vars ());
76 /**/
77 if (is_object ($wp_admin_bar) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"] /* Now check functionality Constants too. */
78 && (!defined ("XMLRPC_REQUEST") || !XMLRPC_REQUEST) && (!defined ("APP_REQUEST") || !APP_REQUEST) && (!defined ("DOING_AJAX") || !DOING_AJAX)/**/
79 && !current_user_can ("edit_posts")) /* And only if the current User is unable to edit Posts; otherwise we allow them in. */
80 if (apply_filters ("ws_plugin__s2member_admin_lockout", true, get_defined_vars ())) /* Give Filters a chance too. */
81 {
82 if ($special_redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url ())
83 $lwp = $special_redirection_url;
84 /**/
85 else /* Else we use the Login Welcome Page configured for s2Member. */
86 $lwp = get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]);
87 /**/
88 if (isset ($wp_admin_bar->menu->{"my-account-with-avatar"})) /* Profile. */
89 {
90 if (isset ($wp_admin_bar->menu->{"my-account-with-avatar"}["href"]))
91 $wp_admin_bar->menu->{"my-account-with-avatar"}["href"] = $lwp;
92 /**/
93 if (isset ($wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"edit-profile"}["href"]))
94 $wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"edit-profile"}["href"] = $lwp;
95 /*
96 Backward compatibility ( {"edit-my-profile"} ), prior to WordPress® 3.2. */
97 if (isset ($wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"edit-my-profile"}["href"]))
98 $wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"edit-my-profile"}["href"] = $lwp;
99 /*
100 Backward compatibility ( ["children"]->{"dashboard"} ), prior to WordPress® 3.2. */
101 if (isset ($wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"dashboard"}))
102 unset($wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"dashboard"});
103 }
104 /**/
105 if (isset ($wp_admin_bar->menu->{"dashboard"})) /* Dashboard menu, we don't need this. */
106 unset($wp_admin_bar->menu->{"dashboard"}); /* Removes this entire menu from the bar. */
107 /**/
108 if (isset ($wp_admin_bar->menu->{"my-blogs"}["href"])) /* Deals with multiple Blog drop-down. */
109 {
110 $wp_admin_bar->menu->{"my-blogs"}["href"] = "#"; /* Void this link out by converting to `#`. */
111 /**/
112 if (isset ($wp_admin_bar->menu->{"my-blogs"}["children"]) && is_object ($wp_admin_bar->menu->{"my-blogs"}["children"]))
113 foreach ($wp_admin_bar->menu->{"my-blogs"}["children"] as &$blog) /* Modify other Blog links in drop-down. */
114 if (is_array ($blog) && isset ($blog["href"], $blog["children"]) && is_object ($blog["children"]))
115 {
116 $blog["href"] = preg_replace ("/\/wp-admin/", "", $blog["href"]);
117 unset($blog["children"]); /* Cause all we need is the link. */
118 }
119 }
120 }
121 /**/
122 do_action ("ws_plugin__s2member_after_filter_admin_menu_bar", get_defined_vars ());
123 /**/
124 return; /* Return for uniformity. */
125 }
126 }
127 }
128 ?>