PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 260814
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v260814
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 / src / includes / classes / login-redirects-r.inc.php

login-redirects-r.inc.php in s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions 260814, at src/includes/classes/login-redirects-r.inc.php

101 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // @codingStandardsIgnoreFile
3 /**
4 * Login redirect removals.
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\Login_Redirects
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_login_redirects_r'))
22 {
23 /**
24 * Login redirect removals.
25 *
26 * @package s2Member\Login_Redirects
27 * @since 3.5
28 */
29 class c_ws_plugin__s2member_login_redirects_r
30 {
31 /**
32 * Handles completely empty ``login_redirect`` values.
33 *
34 * @attaches-to ``add_filter('login_redirect');``
35 *
36 * @package s2Member\Login_Redirects
37 * @since 110926
38 *
39 * @param string $redirect_to Expects the current ``$redirect_to`` passed in by the Filter.
40 * @return string A non-empty string value. s2Member will NEVER allow this to be completely empty.
41 */
42 public static function _empty_login_redirect_filter($redirect_to)
43 {
44 return $redirect_to ? $redirect_to : admin_url ();
45 }
46
47 /**
48 * Handles HTTP/HTTPS ``login_redirect`` values.
49 *
50 * @attaches-to ``add_filter('login_redirect');``
51 *
52 * @package s2Member\Login_Redirects
53 * @since 130819
54 *
55 * @param string $redirect_to Expects the current ``$redirect_to`` passed in by the Filter.
56 * @return string Updated `redirect_to` value.
57 */
58 public static function _http_login_redirect_filter($redirect_to)
59 {
60 $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
61
62 if(apply_filters('ws_plugin__s2member_login_redirection_always_http', force_ssl_admin() && stripos(get_option('siteurl'), 'https://') !== 0))
63 if($redirect_to && is_string($redirect_to) && strpos($redirect_to, 'wp-admin') === FALSE)
64 {
65 $redirect_to = preg_replace('/^https\:\/\//i', 'http://', $redirect_to);
66 if(stripos($redirect_to, 'http://') !== 0) // Force full URL.
67 {
68 $redirect_uri = $redirect_to; // e.g., `/path/with/?query=args`
69 $home_path = trim((string)@parse_url(home_url('/'), PHP_URL_PATH), '/');
70 $http_home_base = trim(preg_replace('/\/'.preg_quote($home_path, '/').'\/$/'.$ci, '', home_url('/', 'http')), '/');
71 $redirect_to = $http_home_base.'/'.ltrim($redirect_uri, '/');
72 }
73 }
74 return $redirect_to;
75 }
76
77 /**
78 * Removes all other ``login_redirect`` Filters to prevent conflicts with s2Member.
79 *
80 * @attaches-to ``add_action('init');``
81 *
82 * @package s2Member\Login_Redirects
83 * @since 3.5
84 */
85 public static function remove_login_redirect_filters()
86 {
87 do_action('ws_plugin__s2member_before_remove_login_redirect_filters', get_defined_vars ());
88
89 if (!apply_filters('ws_plugin__s2member_allow_other_login_redirect_filters', false, get_defined_vars ()))
90 {
91 remove_all_filters('login_redirect'); // Remove all others.
92 do_action('ws_plugin__s2member_during_remove_login_redirect_filters', get_defined_vars ());
93 }
94 add_filter('login_redirect', 'c_ws_plugin__s2member_login_redirects_r::_empty_login_redirect_filter');
95 add_filter('login_redirect', 'c_ws_plugin__s2member_login_redirects_r::_http_login_redirect_filter');
96
97 do_action('ws_plugin__s2member_after_remove_login_redirect_filters', get_defined_vars ());
98 }
99 }
100 }
101