PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 111105
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v111105
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 111105, at includes/classes/admin-lockouts.inc.php

121 lines 5.4 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") /* Give Filters a chance here too. */)
45 if (apply_filters ("ws_plugin__s2member_admin_lockout", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"], get_defined_vars ()))
46 {
47 if ($redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url ())
48 wp_redirect($redirection_url) . exit (); /* 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"])) . exit ();
52 }
53 /**/
54 do_action ("ws_plugin__s2member_after_admin_lockouts", get_defined_vars ());
55 /**/
56 return; /* Return for uniformity. */
57 }
58 /**
59 * Filters administrative menu bar for Users/Members.
60 *
61 * @package s2Member\Admin_Lockouts
62 * @since 3.5
63 *
64 * @attaches-to ``add_action("admin_bar_menu");``
65 *
66 * @param obj $wp_admin_bar Expects the ``$wp_admin_bar``, by reference; passed in by the Action Hook.
67 * @return null After modifying ``$wp_admin_var``.
68 */
69 public static function filter_admin_menu_bar (&$wp_admin_bar = FALSE)
70 {
71 global $current_site, $current_blog; /* In support of Multisite Networking. */
72 /**/
73 do_action ("ws_plugin__s2member_before_filter_admin_menu_bar", get_defined_vars ());
74 /**/
75 if (is_object ($wp_admin_bar) && !current_user_can ("edit_posts") /* Always for Users/Members. */)
76 {
77 if (isset /* Does it have this? */ ($wp_admin_bar->menu->{"wp-logo"}))
78 unset /* Ditch this. */($wp_admin_bar->menu->{"wp-logo"});
79 /**/
80 if (isset /* Does it have this? */ ($wp_admin_bar->menu->{"site-name"}["href"]))
81 $wp_admin_bar->menu->{"site-name"}["href"] = /* Modify this to. */ site_url ("/");
82 /**/
83 if (isset /* Does it have this? */ ($wp_admin_bar->menu->{"site-name"}["children"]))
84 unset /* Ditch this. */($wp_admin_bar->menu->{"site-name"}["children"]);
85 /**/
86 if (isset /* Before WordPress® 3.3-beta2. */ ($wp_admin_bar->menu->{"dashboard"}))
87 unset /* Ditch this. */($wp_admin_bar->menu->{"dashboard"});
88 /**/
89 if (isset /* Does it have this? */ ($wp_admin_bar->menu->{"my-sites"}))
90 unset /* Ditch this. */($wp_admin_bar->menu->{"my-sites"});
91 /**/
92 if (isset /* Before WordPress® 3.3-beta2. */ ($wp_admin_bar->menu->{"my-blogs"}))
93 unset /* Ditch this. */($wp_admin_bar->menu->{"my-blogs"});
94 }
95 /**/
96 if (is_object ($wp_admin_bar) && !current_user_can ("edit_posts") /* If locking Users/Members out of `/wp-admin/` areas. */)
97 if (apply_filters ("ws_plugin__s2member_admin_lockout", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["force_admin_lockouts"], get_defined_vars ()))
98 {
99 $lwp = c_ws_plugin__s2member_login_redirects::login_redirection_url ();
100 $lwp = (!$lwp) ? get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]) : $lwp;
101 /**/
102 if (isset /* Does it have this? */ ($wp_admin_bar->menu->{"my-account"}["href"]))
103 $wp_admin_bar->menu->{"my-account"}["href"] = /* Modify this to. */ $lwp;
104 /**/
105 if (isset /* Before WordPress® 3.3-beta2. */ ($wp_admin_bar->menu->{"my-account-with-avatar"}["href"]))
106 $wp_admin_bar->menu->{"my-account-with-avatar"}["href"] = /* Modify this to. */ $lwp;
107 /**/
108 if (isset /* Does it have this? */ ($wp_admin_bar->menu->{"my-account"}["children"]->{"edit-profile"}["href"]))
109 $wp_admin_bar->menu->{"my-account"}["children"]->{"edit-profile"}["href"] = /* Modify this to. */ $lwp;
110 /**/
111 if (isset /* Before WordPress® 3.3-beta2. */ ($wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"edit-profile"}["href"]))
112 $wp_admin_bar->menu->{"my-account-with-avatar"}["children"]->{"edit-profile"}["href"] = /* Modify this to. */ $lwp;
113 }
114 /**/
115 do_action ("ws_plugin__s2member_after_filter_admin_menu_bar", get_defined_vars ());
116 /**/
117 return; /* Return for uniformity. */
118 }
119 }
120 }
121 ?>