PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 260917
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v260917
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
← All changes | src/includes/classes/menu-pages.inc.php +77 -1 260814260917 View file →
@@ -133,8 +133,84 @@
133 133 return apply_filters('ws_plugin__s2member_update_all_options', (($updated_all_options) ? TRUE : FALSE), get_defined_vars());
134 134 }
135 135
136 136 /**
137 + * Displays shared End-of-Term demotion-role settings on gateway option pages.
138 + *
139 + * @package s2Member\Menu_Pages
140 + * @since 260916.2004
141 + *
142 + * @return null
143 + */
144 + public static function eot_demotion_options()
145 + {
146 + $demotion_to_role = (string)$GLOBALS['WS_PLUGIN__']['s2member']['o']['eot_demotion_to_role'];
147 + $demotion_from = (string)$GLOBALS['WS_PLUGIN__']['s2member']['o']['eot_demotion_from'];
148 + $demotion_disabled = ($GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_eot_behavior'] === 'delete');
149 +
150 + //260917.0003 Keep Demote From/To visible but disabled when EOT behavior is Delete; JavaScript mirrors this immediately when the behavior selector changes.
151 + echo '<tr class="ws-plugin--s2member-eot-demotion-option-row"'.(($demotion_disabled) ? ' style="opacity:0.5;"' : '').'>'."\n";
152 + echo '<th><label for="ws-plugin--s2member-eot-demotion-from">Demote From:</label></th>'."\n";
153 + echo '</tr>'."\n";
154 + echo '<tr class="ws-plugin--s2member-eot-demotion-option-row"'.(($demotion_disabled) ? ' style="opacity:0.5;"' : '').'>'."\n";
155 + echo '<td>'."\n";
156 + echo '<select name="ws_plugin__s2member_eot_demotion_from" id="ws-plugin--s2member-eot-demotion-from"'.(($demotion_disabled) ? ' disabled="disabled"' : '').'>'."\n";
157 + echo '<option value="s2member_level"'.(($demotion_from === 's2member_level') ? ' selected="selected"' : '').'>s2Member Level role (preserve other WordPress roles)</option>'."\n";
158 + echo '<option value="all"'.(($demotion_from === 'all') ? ' selected="selected"' : '').'>All WordPress roles (legacy behavior)</option>'."\n";
159 + echo '</select><br />'."\n";
160 + echo '<em>These settings are used only when Membership End-of-Term Behavior is set to Demote.</em><br /><br />'."\n";
161 + //260916.2004 Explain the fresh-install behavior, legacy compatibility, and capability caveat without treating Subscriber/Level 0 as a role users are demoted from.
162 + echo '<em>New installations remove only the user\'s <code>s2member_levelN</code> role at EOT and preserve other WordPress roles; upgraded installations retain the legacy all-role replacement until you change this setting. Preserved roles also preserve their existing capabilities, so roles such as Editor/Author/Contributor or custom roles may continue to grant s2Member access.</em>'."\n";
163 + echo '</td>'."\n";
164 + echo '</tr>'."\n";
165 + echo '<tr class="ws-plugin--s2member-eot-demotion-option-row"'.(($demotion_disabled) ? ' style="opacity:0.5;"' : '').'>'."\n";
166 + echo '<th><label for="ws-plugin--s2member-eot-demotion-to-role">Demote To Role:</label></th>'."\n";
167 + echo '</tr>'."\n";
168 + echo '<tr class="ws-plugin--s2member-eot-demotion-option-row"'.(($demotion_disabled) ? ' style="opacity:0.5;"' : '').'>'."\n";
169 + echo '<td>'."\n";
170 + //260916.2345 Group Subscriber and s2Member Levels first, then list other registered roles by slug so larger role lists stay predictable and easier to scan.
171 + global $wp_roles;
172 + if(!is_object($wp_roles))
173 + $wp_roles = new WP_Roles();
174 + $level_roles = $other_roles = array();
175 + foreach((array)$wp_roles->roles as $role_slug => $role_data)
176 + {
177 + if(in_array($role_slug, array('administrator', 'editor', 'author', 'contributor', 's2member_pending_deletion'), TRUE))
178 + continue;
179 + $role_name = !empty($role_data['name']) ? translate_user_role($role_data['name']) : $role_slug;
180 + if($role_slug === 'subscriber')
181 + $level_roles[0] = array($role_slug, $role_name);
182 + else if(preg_match('/^s2member_level([1-9][0-9]*)$/', $role_slug, $m))
183 + $level_roles[(int)$m[1]] = array($role_slug, $role_name);
184 + else
185 + $other_roles[$role_slug] = $role_name;
186 + }
187 + ksort($level_roles, SORT_NUMERIC);
188 + ksort($other_roles, SORT_STRING);
189 + echo '<select name="ws_plugin__s2member_eot_demotion_to_role" id="ws-plugin--s2member-eot-demotion-to-role"'.(($demotion_disabled) ? ' disabled="disabled"' : '').'>'."\n";
190 + if($level_roles)
191 + {
192 + echo '<optgroup label="s2Member Levels">'."\n";
193 + foreach($level_roles as $role)
194 + echo '<option value="'.esc_attr($role[0]).'"'.(($demotion_to_role === $role[0]) ? ' selected="selected"' : '').'>'.esc_html($role[1]).' ('.esc_html($role[0]).')</option>'."\n";
195 + echo '</optgroup>'."\n";
196 + }
197 + if($other_roles)
198 + {
199 + echo '<optgroup label="Other Roles">'."\n";
200 + foreach($other_roles as $role_slug => $role_name)
201 + echo '<option value="'.esc_attr($role_slug).'"'.(($demotion_to_role === $role_slug) ? ' selected="selected"' : '').'>'.esc_html($role_name).' ('.esc_html($role_slug).')</option>'."\n";
202 + echo '</optgroup>'."\n";
203 + }
204 + echo '</select><br />'."\n";
205 + echo '<em>Select the WordPress role to assign when s2Member demotes a member at EOT. Subscriber is the default.</em><br /><br />'."\n";
206 + echo '<em>WordPress\'s elevated default roles and s2Member\'s Pending Deletion role are intentionally not available here. Any role selected here keeps the capabilities assigned to it. If those capabilities grant s2Member access, the member may still be able to access protected content after EOT.</em><br /><br />'."\n";
207 + echo '<em>Developers who need a role not available here can use <code>ws_plugin__s2member_force_demotion_role</code>; see <a href="https://s2member.com/kb-article/how-do-i-specify-the-demotion-role-upon-eot/" target="_blank" rel="noopener noreferrer external">How do I specify the demotion role upon EOT?</a></em>'."\n";
208 + echo '</td>'."\n";
209 + echo '</tr>'."\n";
210 + }
211 +
212 + /**
137 213 * Adds option menus / sub-menus.
138 214 *
139 215 * @package s2Member\Menu_Pages
140 216 * @since 3.5
@@ -972,9 +1048,9 @@
972 1048 // Sanitize display names
973 1049 $name_hdr = str_replace(array("\r\n", "\r", "\n"), ' ', (string) $name);
974 1050 $name_hdr = str_replace('"', "'", $name_hdr);
975 1051
976 - $sitename = wp_parse_url(home_url(), PHP_URL_HOST);
1052 + $sitename = c_ws_plugin__s2member_utils_urls::parse_url(home_url(), PHP_URL_HOST);
977 1053 $sitename = is_string($sitename) ? strtolower($sitename) : '';
978 1054 if (strpos($sitename, 'www.') === 0) $sitename = substr($sitename, 4);
979 1055
980 1056 $default_from_email = 'wordpress@'.$sitename;