PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 261001
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v261001
261001 260927 260917 260913 260909 260829 260814 260805 110710 110731 110812 110815 110912 110913 110915 110926 110927 111002 111003 111011 111017 111029 111105 111206 111216 All 191 releases
← All changes | src/includes/classes/menu-pages.inc.php +82 -4 260913 → 261001 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
@@ -297,11 +373,11 @@
297 373 wp_enqueue_script('thickbox');
298 374 wp_enqueue_script('media-upload');
299 375 wp_enqueue_script('jquery-ui-core');
300 376 wp_enqueue_script('jquery-sprintf', $GLOBALS['WS_PLUGIN__']['s2member']['c']['dir_url'].'/src/includes/jquery/jquery.sprintf/jquery.sprintf.min.js', array('jquery'), c_ws_plugin__s2member_utilities::ver_checksum());
301 - wp_enqueue_script('jquery-json-ps', $GLOBALS['WS_PLUGIN__']['s2member']['c']['dir_url'].'/src/includes/jquery/jquery.json-ps/jquery.json-ps.min.js', array('jquery'), c_ws_plugin__s2member_utilities::ver_checksum());
302 377 wp_enqueue_script('jquery-ui-effects', $GLOBALS['WS_PLUGIN__']['s2member']['c']['dir_url'].'/src/includes/jquery/jquery.ui-effects/jquery.ui-effects.min.js', array('jquery', 'jquery-ui-core'), c_ws_plugin__s2member_utilities::ver_checksum());
303 - wp_enqueue_script('ws-plugin--s2member-menu-pages', admin_url('admin.php?ws_plugin__s2member_menu_pages_js='.urlencode(mt_rand()), is_ssl() ? 'https' : 'http'), array('jquery', 'thickbox', 'media-upload', 'jquery-sprintf', 'jquery-json-ps', 'jquery-ui-core', 'jquery-ui-effects', 'password-strength-meter'), c_ws_plugin__s2member_utilities::ver_checksum());
378 + //260928.0402 Use WordPress's registered JSON2 compatibility script instead of shipping a duplicate JSON parser.
379 + wp_enqueue_script('ws-plugin--s2member-menu-pages', admin_url('admin.php?ws_plugin__s2member_menu_pages_js='.urlencode(mt_rand()), is_ssl() ? 'https' : 'http'), array('jquery', 'thickbox', 'media-upload', 'jquery-sprintf', 'json2', 'jquery-ui-core', 'jquery-ui-effects', 'password-strength-meter'), c_ws_plugin__s2member_utilities::ver_checksum());
304 380
305 381 do_action('ws_plugin__s2member_during_add_admin_scripts', get_defined_vars());
306 382 }
307 383 do_action('ws_plugin__s2member_after_add_admin_scripts', get_defined_vars());
@@ -473,9 +549,10 @@
473 549 $error = TRUE;
474 550 }
475 551 if(!empty($error))
476 552 c_ws_plugin__s2member_admin_notices::display_admin_notice('Unknown error when attempting to archive log files. Please check directory permissions.', TRUE);
477 - else c_ws_plugin__s2member_admin_notices::display_admin_notice('All log files have been archived succesfully.');
553 + else
554 + c_ws_plugin__s2member_admin_notices::display_admin_notice('All log files have been archived successfully.');
478 555 }
479 556 }
480 557
481 558 /**
@@ -500,9 +577,10 @@
500 577 if(!unlink($log_dir_file)) $error = TRUE;
501 578 }
502 579 if(!empty($error))
503 580 c_ws_plugin__s2member_admin_notices::display_admin_notice('Unknown error when attempting to delete log files. Please check directory permissions.', TRUE);
504 - else c_ws_plugin__s2member_admin_notices::display_admin_notice('All log files have been deleted succesfully.');
581 + else
582 + c_ws_plugin__s2member_admin_notices::display_admin_notice('All log files have been deleted successfully.');
505 583 }
506 584 }
507 585
508 586 /**