| 1 |
<?php |
| 2 |
// @codingStandardsIgnoreFile |
| 3 |
/** |
| 4 |
* CSS/JS loading handlers for s2Member (inner processing routines). |
| 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\CSS_JS |
| 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_css_js_in")) |
| 22 |
{ |
| 23 |
/** |
| 24 |
* CSS/JS loading handlers for s2Member (inner processing routines). |
| 25 |
* |
| 26 |
* @package s2Member\CSS_JS |
| 27 |
* @since 3.5 |
| 28 |
*/ |
| 29 |
class c_ws_plugin__s2member_css_js_in |
| 30 |
{ |
| 31 |
/** |
| 32 |
* Outputs CSS for theme integration. |
| 33 |
* |
| 34 |
* @package s2Member\CSS_JS |
| 35 |
* @since 3.5 |
| 36 |
* |
| 37 |
* @attaches-to ``add_action("init");`` |
| 38 |
* |
| 39 |
* @return null Or exits script execution after loading CSS. |
| 40 |
*/ |
| 41 |
public static function css() |
| 42 |
{ |
| 43 |
do_action("ws_plugin__s2member_before_css", get_defined_vars()); |
| 44 |
|
| 45 |
if(!empty($_GET["ws_plugin__s2member_css"])) |
| 46 |
{ |
| 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. |
| 49 |
c_ws_plugin__s2member_utils_assets::record_asset_runtime_recovery_suspicion(); |
| 50 |
|
| 51 |
status_header(200); // 200 OK status header. |
| 52 |
|
| 53 |
header("Content-Type: text/css; charset=UTF-8"); |
| 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. |
| 56 |
header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("+1 week"))." GMT"); |
| 57 |
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
| 58 |
header("Cache-Control: max-age=604800"); |
| 59 |
header("Pragma: public"); |
| 60 |
|
| 61 |
while(@ob_end_clean()) ; // Clean output buffers. |
| 62 |
|
| 63 |
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]; |
| 64 |
$i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]."/src/images"; |
| 65 |
|
| 66 |
ob_start("c_ws_plugin__s2member_utils_assets::compress_css"); |
| 67 |
|
| 68 |
include_once dirname(dirname(__FILE__))."/s2member.css"; |
| 69 |
|
| 70 |
do_action("ws_plugin__s2member_during_css", get_defined_vars()); |
| 71 |
|
| 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'); |
| 74 |
|
| 75 |
exit(); // Clean exit. |
| 76 |
} |
| 77 |
do_action("ws_plugin__s2member_after_css", get_defined_vars()); |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* Outputs JS for theme integration. |
| 82 |
* |
| 83 |
* Be sure s2Member's API Constants are already defined before firing this. |
| 84 |
* |
| 85 |
* @package s2Member\CSS_JS |
| 86 |
* @since 3.5 |
| 87 |
* |
| 88 |
* @attaches-to ``add_action("init");`` |
| 89 |
* |
| 90 |
* @return null Or exits script execution after loading JS w/Globals. |
| 91 |
*/ |
| 92 |
public static function js_w_globals() |
| 93 |
{ |
| 94 |
do_action("ws_plugin__s2member_before_js_w_globals", get_defined_vars()); |
| 95 |
|
| 96 |
if(!empty($_GET["ws_plugin__s2member_js_w_globals"])) |
| 97 |
{ |
| 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. |
| 100 |
c_ws_plugin__s2member_utils_assets::record_asset_runtime_recovery_suspicion(); |
| 101 |
|
| 102 |
status_header(200); // 200 OK status header. |
| 103 |
|
| 104 |
header("Content-Type: application/x-javascript; charset=UTF-8"); |
| 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. |
| 107 |
header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("+1 week"))." GMT"); |
| 108 |
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
| 109 |
header("Cache-Control: max-age=604800"); |
| 110 |
header("Pragma: public"); |
| 111 |
|
| 112 |
while(@ob_end_clean()) ; // Clean output buffers. |
| 113 |
|
| 114 |
include_once dirname(dirname(__FILE__))."/jquery/jquery.sprintf/jquery.sprintf.min.js"; |
| 115 |
|
| 116 |
echo "\n"; // Add a line break before writing JavaScript Globals to file. |
| 117 |
|
| 118 |
if(apply_filters('ws_plugin__s2member_js_api_constants_enable', false)) { |
| 119 |
echo "var S2MEMBER_VERSION = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_VERSION)."',"; |
| 120 |
|
| 121 |
echo "S2MEMBER_CURRENT_USER_LOGIN_COUNTER = ".S2MEMBER_CURRENT_USER_LOGIN_COUNTER.","; |
| 122 |
|
| 123 |
echo "S2MEMBER_CURRENT_USER_IS_LOGGED_IN = ".((S2MEMBER_CURRENT_USER_IS_LOGGED_IN) ? "true" : "false").","; |
| 124 |
echo "S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER = ".((S2MEMBER_CURRENT_USER_IS_LOGGED_IN_AS_MEMBER) ? "true" : "false").","; |
| 125 |
|
| 126 |
echo "S2MEMBER_CURRENT_USER_ACCESS_LEVEL = ".S2MEMBER_CURRENT_USER_ACCESS_LEVEL.","; |
| 127 |
echo "S2MEMBER_CURRENT_USER_ACCESS_LABEL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_ACCESS_LABEL)."',"; |
| 128 |
|
| 129 |
echo "S2MEMBER_CURRENT_USER_SUBSCR_ID = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_SUBSCR_ID)."',"; |
| 130 |
echo "S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_SUBSCR_OR_WP_ID)."',"; |
| 131 |
echo "S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY)."',"; |
| 132 |
echo "S2MEMBER_CURRENT_USER_CUSTOM = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_CUSTOM)."',"; |
| 133 |
|
| 134 |
echo "S2MEMBER_CURRENT_USER_REGISTRATION_TIME = ".S2MEMBER_CURRENT_USER_REGISTRATION_TIME.","; |
| 135 |
echo "S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME = ".S2MEMBER_CURRENT_USER_PAID_REGISTRATION_TIME.","; |
| 136 |
|
| 137 |
echo "S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS = ".S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS.","; |
| 138 |
echo "S2MEMBER_CURRENT_USER_REGISTRATION_DAYS = ".S2MEMBER_CURRENT_USER_REGISTRATION_DAYS.","; |
| 139 |
|
| 140 |
echo "S2MEMBER_CURRENT_USER_DISPLAY_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_DISPLAY_NAME)."',"; |
| 141 |
echo "S2MEMBER_CURRENT_USER_FIRST_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_FIRST_NAME)."',"; |
| 142 |
echo "S2MEMBER_CURRENT_USER_LAST_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_LAST_NAME)."',"; |
| 143 |
|
| 144 |
echo "S2MEMBER_CURRENT_USER_LOGIN = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_LOGIN)."',"; |
| 145 |
echo "S2MEMBER_CURRENT_USER_EMAIL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_EMAIL)."',"; |
| 146 |
echo "S2MEMBER_CURRENT_USER_IP = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_IP)."',"; |
| 147 |
echo "S2MEMBER_CURRENT_USER_REGISTRATION_IP = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_REGISTRATION_IP)."',"; |
| 148 |
|
| 149 |
echo "S2MEMBER_CURRENT_USER_ID = ".S2MEMBER_CURRENT_USER_ID.","; |
| 150 |
echo "S2MEMBER_CURRENT_USER_FIELDS = ".S2MEMBER_CURRENT_USER_FIELDS.","; |
| 151 |
|
| 152 |
echo "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED = ".S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED.","; |
| 153 |
echo "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED = ".((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED) ? "true" : "false").","; |
| 154 |
echo "S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY = ".S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY.","; |
| 155 |
echo "S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS = ".S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS.","; |
| 156 |
|
| 157 |
echo "S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID = ".S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_ID.","; |
| 158 |
echo "S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID = ".S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_ID.","; |
| 159 |
echo "S2MEMBER_LOGIN_WELCOME_PAGE_ID = ".S2MEMBER_LOGIN_WELCOME_PAGE_ID.","; |
| 160 |
|
| 161 |
echo "S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_PROFILE_MODIFICATION_PAGE_URL)."',"; |
| 162 |
echo "S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_FILE_DOWNLOAD_LIMIT_EXCEEDED_PAGE_URL)."',"; |
| 163 |
echo "S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL)."',"; |
| 164 |
echo "S2MEMBER_LOGIN_WELCOME_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_LOGIN_WELCOME_PAGE_URL)."',"; |
| 165 |
echo "S2MEMBER_LOGOUT_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_LOGOUT_PAGE_URL)."',"; |
| 166 |
echo "S2MEMBER_LOGIN_PAGE_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_LOGIN_PAGE_URL)."',"; |
| 167 |
|
| 168 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++) |
| 169 |
{ |
| 170 |
if(defined(($S2MEMBER_LEVELn_LABEL = "S2MEMBER_LEVEL".$n."_LABEL"))) |
| 171 |
echo $S2MEMBER_LEVELn_LABEL." = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(constant($S2MEMBER_LEVELn_LABEL))."',"; |
| 172 |
} |
| 173 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++) |
| 174 |
{ |
| 175 |
if(defined(($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED = "S2MEMBER_LEVEL".$n."_FILE_DOWNLOADS_ALLOWED"))) |
| 176 |
echo $S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED." = ".constant($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED).","; |
| 177 |
} |
| 178 |
for($n = 0; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++) |
| 179 |
{ |
| 180 |
if(defined(($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS = "S2MEMBER_LEVEL".$n."_FILE_DOWNLOADS_ALLOWED_DAYS"))) |
| 181 |
echo $S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS." = ".constant($S2MEMBER_LEVELn_FILE_DOWNLOADS_ALLOWED_DAYS).","; |
| 182 |
} |
| 183 |
echo "S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_FILE_DOWNLOAD_INLINE_EXTENSIONS)."',"; |
| 184 |
|
| 185 |
echo "S2MEMBER_REG_EMAIL_FROM_NAME = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_REG_EMAIL_FROM_NAME)."',"; |
| 186 |
echo "S2MEMBER_REG_EMAIL_FROM_EMAIL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_REG_EMAIL_FROM_EMAIL)."',"; |
| 187 |
|
| 188 |
echo "S2MEMBER_PAYPAL_NOTIFY_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_NOTIFY_URL)."',"; |
| 189 |
echo "S2MEMBER_PAYPAL_RETURN_URL = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_RETURN_URL)."',"; |
| 190 |
|
| 191 |
echo "S2MEMBER_PAYPAL_BUSINESS = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_BUSINESS)."',"; |
| 192 |
echo "S2MEMBER_PAYPAL_ENDPOINT = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_ENDPOINT)."',"; |
| 193 |
echo "S2MEMBER_PAYPAL_API_ENDPOINT = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_PAYPAL_API_ENDPOINT)."',"; |
| 194 |
|
| 195 |
echo "S2MEMBER_VALUE_FOR_PP_INV = Math.round (new Date ().getTime ()) + '~".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_IP)."',"; |
| 196 |
echo "S2MEMBER_VALUE_FOR_PP_INV_GEN = s2member_value_for_pp_inv_gen = function(){ var invoice = '', formatSeed = function(seed, reqWidth) { seed = parseInt(seed, 10).toString (16); if (reqWidth < seed.length) return seed.slice (seed.length - reqWidth); else if (reqWidth > seed.length) return Array(1 + (reqWidth - seed.length)).join ('0') + seed; return seed; }; if (typeof S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED === 'undefined') S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED = Math.floor (Math.random () * 0x75bcd15); S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED++; invoice = formatSeed(parseInt(new Date ().getTime () / 1000, 10), 8); invoice += formatSeed(S2MEMBER_VALUE_FOR_PP_INV_GEN_UNIQUE_SEED, 5); invoice += '~' + S2MEMBER_CURRENT_USER_IP; return invoice; },"; |
| 197 |
|
| 198 |
echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0 = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0)."',"; |
| 199 |
echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0 = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0)."',"; |
| 200 |
|
| 201 |
echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1 = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1)."',"; |
| 202 |
echo "S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1 = '".c_ws_plugin__s2member_utils_strings::esc_js_sq(S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1)."';"; |
| 203 |
|
| 204 |
} else // Expose only what is needed by the s2Member application itself; for the current user. |
| 205 |
echo self::current_user_js_globals(); |
| 206 |
|
| 207 |
$u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]; |
| 208 |
$i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]."/src/images"; |
| 209 |
|
| 210 |
echo "\n"; // Add a line break before inclusion. |
| 211 |
include_once dirname(dirname(__FILE__))."/s2member.min.js"; |
| 212 |
|
| 213 |
do_action("ws_plugin__s2member_during_js_w_globals", get_defined_vars()); |
| 214 |
|
| 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'); |
| 217 |
|
| 218 |
exit(); // Clean exit. |
| 219 |
} |
| 220 |
do_action("ws_plugin__s2member_after_js_w_globals", get_defined_vars()); |
| 221 |
} |
| 222 |
|
| 223 |
/** |
| 224 |
* Returns the current-user JavaScript globals required by s2Member's frontend application. |
| 225 |
* |
| 226 |
* @package s2Member\CSS_JS |
| 227 |
* @since 260903.0437 |
| 228 |
* |
| 229 |
* @param bool $for_inline Escape HTML-closing sequences for safe inline-script output. |
| 230 |
* @return string JavaScript variable declarations. |
| 231 |
*/ |
| 232 |
public static function current_user_js_globals($for_inline = FALSE) |
| 233 |
{ |
| 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.";"; |
| 288 |
|
| 289 |
//260903.0437 Inline data is HTML, not an external JS response; neutralize any user-controlled closing-script sequence before WordPress prints it. |
| 290 |
return ($for_inline) ? str_ireplace('</', '<\/', $g) : $g; |
| 291 |
} |
| 292 |
} |
| 293 |
} |
| 294 |
|