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/css-js-in.inc.php +66 -18 260909260917 View file →
@@ -43,15 +43,17 @@
43 43 do_action("ws_plugin__s2member_before_css", get_defined_vars());
44 44
45 45 if(!empty($_GET["ws_plugin__s2member_css"]))
46 46 {
47 - //260905.0009 A page-local WordPress fallback can carry the signed marker miss that caused recovery, avoiding a separate report request.
47 + //260912.0522 A page-local WordPress fallback can carry the signed activation miss that caused recovery, avoiding a separate report request.
48 + //260912.0522 This carrier is compatibility-only for already-cached first-v260909 pages; the current monitor reports Late assets without injecting fallback assets.
48 49 c_ws_plugin__s2member_utils_assets::record_asset_runtime_recovery_suspicion();
49 50
50 51 status_header(200); // 200 OK status header.
51 52
52 53 header("Content-Type: text/css; charset=UTF-8");
53 - header("X-s2Member-Loader: ".((defined('_WS_PLUGIN__S2MEMBER_ONLY')) ? "lightweight" : "wordpress")); //260904.2255 Expose which dynamic loader produced this response for diagnostics.
54 + //260904.2255 Expose which dynamic loader produced this response for diagnostics.
55 + header("X-s2Member-Loader: ".((defined('_WS_PLUGIN__S2MEMBER_ONLY')) ? "s2member-o" : "wordpress")); //260910.0724 Keep that diagnostic identity aligned with the actual endpoint: `s2member-o` maps to s2member-o.php and `wordpress` means the full WordPress route.
54 56 header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("+1 week"))." GMT");
55 57 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
56 58 header("Cache-Control: max-age=604800");
57 59 header("Pragma: public");
@@ -66,10 +68,10 @@
66 68 include_once dirname(dirname(__FILE__))."/s2member.css";
67 69
68 70 do_action("ws_plugin__s2member_during_css", get_defined_vars());
69 71
70 - //260904.2255 Mark the very end of successful dynamic CSS so real pages can verify that the expected Framework/Pro styles arrived.
71 - echo c_ws_plugin__s2member_utils_assets::dynamic_asset_marker_output('css');
72 + //260912.0522 Append the activation-tag snippet after successful dynamic CSS so real pages can confirm that the expected styles became active.
73 + echo c_ws_plugin__s2member_utils_assets::dynamic_activation_tag_snippet('css');
72 74
73 75 exit(); // Clean exit.
74 76 }
75 77 do_action("ws_plugin__s2member_after_css", get_defined_vars());
@@ -92,15 +94,17 @@
92 94 do_action("ws_plugin__s2member_before_js_w_globals", get_defined_vars());
93 95
94 96 if(!empty($_GET["ws_plugin__s2member_js_w_globals"]))
95 97 {
96 - //260905.0009 A page-local WordPress fallback can carry the signed marker miss that caused recovery, avoiding a separate report request.
98 + //260912.0522 A page-local WordPress fallback can carry the signed activation miss that caused recovery, avoiding a separate report request.
99 + //260912.0522 This carrier is compatibility-only for already-cached first-v260909 pages; the current monitor reports Late assets without injecting fallback assets.
97 100 c_ws_plugin__s2member_utils_assets::record_asset_runtime_recovery_suspicion();
98 101
99 102 status_header(200); // 200 OK status header.
100 103
101 104 header("Content-Type: application/x-javascript; charset=UTF-8");
102 - header("X-s2Member-Loader: ".((defined('_WS_PLUGIN__S2MEMBER_ONLY')) ? "lightweight" : "wordpress")); //260904.2255 Expose which dynamic loader produced this response for diagnostics.
105 + //260904.2255 Expose which dynamic loader produced this response for diagnostics.
106 + header("X-s2Member-Loader: ".((defined('_WS_PLUGIN__S2MEMBER_ONLY')) ? "s2member-o" : "wordpress")); //260910.0724 Keep that diagnostic identity aligned with the actual endpoint: `s2member-o` maps to s2member-o.php and `wordpress` means the full WordPress route.
103 107 header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("+1 week"))." GMT");
104 108 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
105 109 header("Cache-Control: max-age=604800");
106 110 header("Pragma: public");
@@ -207,10 +211,10 @@
207 211 include_once dirname(dirname(__FILE__))."/s2member.min.js";
208 212
209 213 do_action("ws_plugin__s2member_during_js_w_globals", get_defined_vars());
210 214
211 - //260904.2255 Mark the very end of successful dynamic JavaScript so a late page check can detect blocked or interrupted delivery.
212 - echo c_ws_plugin__s2member_utils_assets::dynamic_asset_marker_output('js');
215 + //260912.0522 Append the activation-tag snippet after successful dynamic JavaScript so real pages can confirm that the expected script became active.
216 + echo c_ws_plugin__s2member_utils_assets::dynamic_activation_tag_snippet('js');
213 217
214 218 exit(); // Clean exit.
215 219 }
216 220 do_action("ws_plugin__s2member_after_js_w_globals", get_defined_vars());
@@ -226,18 +230,62 @@
226 230 * @return string JavaScript variable declarations.
227 231 */
228 232 public static function current_user_js_globals($for_inline = FALSE)
229 233 {
230 - $g = "var S2MEMBER_CURRENT_USER_IS_LOGGED_IN = ".((S2MEMBER_CURRENT_USER_IS_LOGGED_IN) ? "true" : "false").",";
231 - $g .= "S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER = ".((S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER) ? "true" : "false").",";
232 - $g .= "S2MEMBER_CURRENT_USER_FIRST_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_FIRST_NAME)."',";
233 - $g .= "S2MEMBER_CURRENT_USER_LAST_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_LAST_NAME)."',";
234 - $g .= "S2MEMBER_CURRENT_USER_LOGIN = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_LOGIN)."',";
235 - $g .= "S2MEMBER_CURRENT_USER_EMAIL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_EMAIL)."',";
236 - $g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED = ".S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED.",";
237 - $g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED = ".((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED) ? "true" : "false").",";
238 - $g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY = ".S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY.",";
239 - $g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS = ".S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS.";";
234 + $required_constants = array(
235 + 'S2MEMBER_CURRENT_USER_IS_LOGGED_IN', 'S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER', 'S2MEMBER_CURRENT_USER_FIRST_NAME', 'S2MEMBER_CURRENT_USER_LAST_NAME',
236 + 'S2MEMBER_CURRENT_USER_LOGIN', 'S2MEMBER_CURRENT_USER_EMAIL', 'S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED', 'S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED',
237 + 'S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY', 'S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS',
238 + );
239 + $constants_ready = TRUE;
240 + foreach($required_constants as $constant)
241 + if(!defined($constant))
242 + {
243 + $constants_ready = FALSE;
244 + break;
245 + }
246 +
247 + if($constants_ready)
248 + {
249 + $is_logged_in = (bool)S2MEMBER_CURRENT_USER_IS_LOGGED_IN;
250 + $is_member = (bool)S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER;
251 + $first_name = (string)S2MEMBER_CURRENT_USER_FIRST_NAME;
252 + $last_name = (string)S2MEMBER_CURRENT_USER_LAST_NAME;
253 + $login = (string)S2MEMBER_CURRENT_USER_LOGIN;
254 + $email = (string)S2MEMBER_CURRENT_USER_EMAIL;
255 + $downloads_allowed = (int)S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED;
256 + $downloads_unlimited = (bool)S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED;
257 + $downloads_currently = (int)S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY;
258 + $downloads_allowed_days = (int)S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS;
259 + }
260 + else
261 + {
262 + //260913.0036 Another plugin may print login-page scripts before s2Member's normal init-priority constants setup; derive only the values this inline JavaScript needs without changing initialization order.
263 + $user = (is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID)) ? $user : FALSE;
264 + $level = c_ws_plugin__s2member_user_access::user_access_level($user);
265 + $downloads = c_ws_plugin__s2member_files::user_downloads($user);
266 + $is_logged_in = (bool)$user;
267 + $is_member = (bool)($user && $level >= 1);
268 + $first_name = ($user) ? (string)$user->first_name : '';
269 + $last_name = ($user) ? (string)$user->last_name : '';
270 + $login = ($user) ? (string)$user->user_login : '';
271 + $email = ($user) ? (string)$user->user_email : '';
272 + $downloads_allowed = (!empty($downloads['allowed'])) ? (int)$downloads['allowed'] : 0;
273 + $downloads_unlimited = $downloads_allowed >= 999999999;
274 + $downloads_currently = (!empty($downloads['currently'])) ? (int)$downloads['currently'] : 0;
275 + $downloads_allowed_days = (!empty($downloads['allowed_days'])) ? (int)$downloads['allowed_days'] : 0;
276 + }
277 +
278 + $g = "var S2MEMBER_CURRENT_USER_IS_LOGGED_IN = ".(($is_logged_in) ? "true" : "false").",";
279 + $g .= "S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER = ".(($is_member) ? "true" : "false").",";
280 + $g .= "S2MEMBER_CURRENT_USER_FIRST_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq($first_name)."',";
281 + $g .= "S2MEMBER_CURRENT_USER_LAST_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq($last_name)."',";
282 + $g .= "S2MEMBER_CURRENT_USER_LOGIN = '".c_ws_plugin__s2member_utils_strings::esc_js_sq($login)."',";
283 + $g .= "S2MEMBER_CURRENT_USER_EMAIL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq($email)."',";
284 + $g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED = ".$downloads_allowed.",";
285 + $g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED = ".(($downloads_unlimited) ? "true" : "false").",";
286 + $g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY = ".$downloads_currently.",";
287 + $g .= "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS = ".$downloads_allowed_days.";";
240 288
241 289 //260903.0437 Inline data is HTML, not an external JS response; neutralize any user-controlled closing-script sequence before WordPress prints it.
242 290 return ($for_inline) ? str_ireplace('</', '<\/', $g) : $g;
243 291 }