Source Code Documentation


s2member\includes\classes\css-js-themes.inc.php


  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 /* Not in the admin. */ (!is_admin ())
  45. {
  46. $s2o = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["s2o_url"];
  47.  
  48. wp_enqueue_style ("ws-plugin--s2member", $s2o . "?ws_plugin__s2member_css=1&qcABC=1", array (), c_ws_plugin__s2member_utilities::ver_checksum (), "all");
  49.  
  50. do_action ("ws_plugin__s2member_during_add_css", get_defined_vars ());
  51. }
  52. do_action ("ws_plugin__s2member_after_add_css", get_defined_vars ());
  53.  
  54. return /* Return for uniformity. */;
  55. }
  56. /**
  57. * Enqueues JS file for theme integration.
  58. *
  59. * Be sure s2Member's API Constants are already defined before firing this.
  60. *
  61. * @package s2Member\CSS_JS
  62. * @since 3.5
  63. *
  64. * @attaches-to ``add_action("wp_print_scripts");``
  65. *
  66. * @return null After enqueuing JS for theme integration.
  67. */
  68. public static function add_js_w_globals ()
  69. {
  70. global /* Need this for comparisons. */ $pagenow;
  71.  
  72. do_action ("ws_plugin__s2member_before_add_js_w_globals", get_defined_vars ());
  73.  
  74. if (!is_admin () || (is_user_admin () && $pagenow === "profile.php" && !current_user_can ("edit_users")))
  75. {
  76. $s2o = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["s2o_url"];
  77.  
  78. if /* Separate version for logged-in Users/Members. */ (is_user_logged_in ())
  79. {
  80. $md5 = /* An MD5 hash based on global key => values. */ WS_PLUGIN__S2MEMBER_API_CONSTANTS_MD5;
  81. // The MD5 hash allows the script to be cached in the browser until the globals happen to change.
  82. // For instance, the global variables may change when a User who is logged-in changes their Profile.
  83. wp_enqueue_script ("ws-plugin--s2member", $s2o . "?ws_plugin__s2member_js_w_globals=" . urlencode ($md5) . "&qcABC=1", array ("jquery", "password-strength-meter"), c_ws_plugin__s2member_utilities::ver_checksum ());
  84. }
  85. else // Else if they are not logged in, we distinguish the JavaScript file by NOT including $md5.
  86. { // This essentially creates 2 versions of the script. One while logged in & another when not.
  87. wp_enqueue_script ("ws-plugin--s2member", $s2o . "?ws_plugin__s2member_js_w_globals=1&qcABC=1", array ("jquery", "password-strength-meter"), c_ws_plugin__s2member_utilities::ver_checksum ());
  88. }
  89. do_action ("ws_plugin__s2member_during_add_js_w_globals", get_defined_vars ());
  90. }
  91. do_action ("ws_plugin__s2member_after_add_js_w_globals", get_defined_vars ());
  92.  
  93. return /* Return for uniformity. */;
  94. }
  95. }
  96. }
  97. ?>

s2member\includes\classes\css-js-themes.inc.php

Source Code Documentation