| 1 |
<?php |
| 2 |
/** |
| 3 |
* CSS/JS integrations with theme. |
| 4 |
* |
| 5 |
* Copyright: © 2009-2011 |
| 6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.} |
| 7 |
* ( coded in the USA ) |
| 8 |
* |
| 9 |
* Released under the terms of the GNU General Public License. |
| 10 |
* You should have received a copy of the GNU General Public License, |
| 11 |
* along with this software. In the main directory, see: /licensing/ |
| 12 |
* If not, see: {@link http://www.gnu.org/licenses/}. |
| 13 |
* |
| 14 |
* @package s2Member\CSS_JS |
| 15 |
* @since 3.5 |
| 16 |
*/ |
| 17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"])) |
| 18 |
exit ("Do not access this file directly."); |
| 19 |
/**/ |
| 20 |
if (!class_exists ("c_ws_plugin__s2member_css_js_themes")) |
| 21 |
{ |
| 22 |
/** |
| 23 |
* CSS/JS integrations with theme. |
| 24 |
* |
| 25 |
* @package s2Member\CSS_JS |
| 26 |
* @since 3.5 |
| 27 |
*/ |
| 28 |
class c_ws_plugin__s2member_css_js_themes |
| 29 |
{ |
| 30 |
/** |
| 31 |
* Enqueues CSS file for theme integration. |
| 32 |
* |
| 33 |
* @package s2Member\CSS_JS |
| 34 |
* @since 3.5 |
| 35 |
* |
| 36 |
* @attaches-to: ``add_action("wp_print_styles");`` |
| 37 |
* |
| 38 |
* @return null After enqueuing CSS for theme integration. |
| 39 |
*/ |
| 40 |
public static function add_css () |
| 41 |
{ |
| 42 |
do_action ("ws_plugin__s2member_before_add_css", get_defined_vars ()); |
| 43 |
/**/ |
| 44 |
if (!is_admin ()) /* Not in the admin. */ |
| 45 |
{ |
| 46 |
wp_enqueue_style ("ws-plugin--s2member", site_url ("/?ws_plugin__s2member_css=1&qcABC=1"), array (), c_ws_plugin__s2member_utilities::ver_checksum (), "all"); |
| 47 |
/**/ |
| 48 |
do_action ("ws_plugin__s2member_during_add_css", get_defined_vars ()); |
| 49 |
} |
| 50 |
/**/ |
| 51 |
do_action ("ws_plugin__s2member_after_add_css", get_defined_vars ()); |
| 52 |
/**/ |
| 53 |
return; /* Return for uniformity. */ |
| 54 |
} |
| 55 |
/** |
| 56 |
* Enqueues JS file for theme integration. |
| 57 |
* |
| 58 |
* Be sure s2Member's API Constants are already defined before firing this. |
| 59 |
* |
| 60 |
* @package s2Member\CSS_JS |
| 61 |
* @since 3.5 |
| 62 |
* |
| 63 |
* @attaches-to: ``add_action("wp_print_scripts");`` |
| 64 |
* |
| 65 |
* @return null After enqueuing JS for theme integration. |
| 66 |
*/ |
| 67 |
public static function add_js_w_globals () |
| 68 |
{ |
| 69 |
global $pagenow; /* Need this for comparisons. */ |
| 70 |
/**/ |
| 71 |
do_action ("ws_plugin__s2member_before_add_js_w_globals", get_defined_vars ()); |
| 72 |
/**/ |
| 73 |
if (!is_admin () || (is_user_admin () && $pagenow === "profile.php" && !current_user_can ("edit_users"))) |
| 74 |
{ |
| 75 |
if (is_user_logged_in ()) /* Separate version for logged-in Users/Members. */ |
| 76 |
{ |
| 77 |
$md5 = WS_PLUGIN__S2MEMBER_API_CONSTANTS_MD5; /* An MD5 hash based on global key => values. */ |
| 78 |
/* The MD5 hash allows the script to be cached in the browser until the globals happen to change. */ |
| 79 |
/* For instance, the global variables may change when a User who is logged-in changes their Profile. */ |
| 80 |
wp_enqueue_script ("ws-plugin--s2member", site_url ("/?ws_plugin__s2member_js_w_globals=" . urlencode ($md5) . "&qcABC=1"), array ("jquery", "password-strength-meter"), c_ws_plugin__s2member_utilities::ver_checksum ()); |
| 81 |
} |
| 82 |
else /* Else if they are not logged in, we distinguish the JavaScript file by NOT including $md5. */ |
| 83 |
{ /* This essentially creates 2 versions of the script. One while logged in & another when not. */ |
| 84 |
wp_enqueue_script ("ws-plugin--s2member", site_url ("/?ws_plugin__s2member_js_w_globals=1&qcABC=1"), array ("jquery", "password-strength-meter"), c_ws_plugin__s2member_utilities::ver_checksum ()); |
| 85 |
} |
| 86 |
/**/ |
| 87 |
do_action ("ws_plugin__s2member_during_add_js_w_globals", get_defined_vars ()); |
| 88 |
} |
| 89 |
/**/ |
| 90 |
do_action ("ws_plugin__s2member_after_add_js_w_globals", get_defined_vars ()); |
| 91 |
/**/ |
| 92 |
return; /* Return for uniformity. */ |
| 93 |
} |
| 94 |
} |
| 95 |
} |
| 96 |
?> |