/** * Enqueues JS file for theme integration. * * Be sure s2Member's API Constants are already defined before firing this. * * @package s2Member\CSS_JS * @since 3.5 * * @attaches-to ``add_action('wp_print_scripts');`` * * @return null After enqueuing JS for theme integration. */ public static function add_js_w_globals() { global $pagenow; // Need this for comparisons. do_action('ws_plugin__s2member_before_add_js_w_globals', get_defined_vars()); if (!is_admin() && c_ws_plugin__s2member_css_js_themes::lazy_load_css_js() || is_user_admin() && $pagenow === 'profile.php' && !current_user_can('edit_users')) { $s2o = $GLOBALS['WS_PLUGIN__']['s2member']['c']['s2o_url']; if (is_user_logged_in()) { $md5 = WS_PLUGIN__S2MEMBER_API_CONSTANTS_MD5; // An MD5 hash based on global key => values. // The MD5 hash allows the script to be cached in the browser until the globals happen to change. // For instance, the global variables may change when a User who is logged-in changes their Profile. wp_enqueue_script('ws-plugin--s2member', $s2o . '?ws_plugin__s2member_js_w_globals=' . urlencode($md5) . '&qcABC=1', array('jquery'), c_ws_plugin__s2member_utilities::ver_checksum(), TRUE); } else { // This essentially creates 2 versions of the script. One while logged in & another when not. wp_enqueue_script('ws-plugin--s2member', $s2o . '?ws_plugin__s2member_js_w_globals=1&qcABC=1', array('jquery'), c_ws_plugin__s2member_utilities::ver_checksum(), TRUE); } do_action('ws_plugin__s2member_during_add_js_w_globals', get_defined_vars()); } do_action('ws_plugin__s2member_after_add_js_w_globals', get_defined_vars()); }
/** * Enqueues JS file for theme integration. * * Be sure s2Member's API Constants are already defined before firing this. * * @package s2Member\CSS_JS * @since 3.5 * * @attaches-to ``add_action("wp_print_scripts");`` * * @return null After enqueuing JS for theme integration. */ public static function add_js_w_globals() { global $pagenow; do_action("ws_plugin__s2member_before_add_js_w_globals", get_defined_vars()); if (!is_admin() && c_ws_plugin__s2member_css_js_themes::lazy_load_css_js() || is_user_admin() && $pagenow === "profile.php" && !current_user_can("edit_users")) { $s2o = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["s2o_url"]; if (is_user_logged_in()) { $md5 = WS_PLUGIN__S2MEMBER_API_CONSTANTS_MD5; // The MD5 hash allows the script to be cached in the browser until the globals happen to change. // For instance, the global variables may change when a User who is logged-in changes their Profile. wp_enqueue_script("ws-plugin--s2member", $s2o . "?ws_plugin__s2member_js_w_globals=" . urlencode($md5) . "&qcABC=1", array("jquery"), c_ws_plugin__s2member_utilities::ver_checksum(), TRUE); } else { // This essentially creates 2 versions of the script. One while logged in & another when not. wp_enqueue_script("ws-plugin--s2member", $s2o . "?ws_plugin__s2member_js_w_globals=1&qcABC=1", array("jquery"), c_ws_plugin__s2member_utilities::ver_checksum(), TRUE); } do_action("ws_plugin__s2member_during_add_js_w_globals", get_defined_vars()); } do_action("ws_plugin__s2member_after_add_js_w_globals", get_defined_vars()); return; }