Source Code Documentation


s2member\includes\classes\systematics.inc.php


  1. <?php
  2. /**
  3. * Systematics *(for current page)*.
  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\Systematics
  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_systematics"))
  21. {
  22. /**
  23. * Systematics *(for current page)*.
  24. *
  25. * @package s2Member\Systematics
  26. * @since 3.5
  27. */
  28. class c_ws_plugin__s2member_systematics
  29. {
  30. /**
  31. * Determines if the current page is s2Member® Systematic.
  32. *
  33. * @package s2Member\Systematics
  34. * @since 111115
  35. *
  36. * @return bool True if s2Member® Systematic, else false.
  37. *
  38. * @note The results of this function are cached staticially.
  39. * Do NOT call upon this until the `init` Hook is fired.
  40. */
  41. public static function is_s2_systematic_use_page ()
  42. {
  43. static $is_s2_systematic; // For optimization.
  44.  
  45. if (isset ($is_s2_systematic)) // Already cached statically? Saves time.
  46. {
  47. return $is_s2_systematic; // Filters will have already been applied here.
  48. }
  49. else if (!empty ($_SERVER["QUERY_STRING"]) && preg_match ("/[\?&]s2member/", $_SERVER["QUERY_STRING"]) && c_ws_plugin__s2member_utils_conds::is_site_root ($_SERVER["REQUEST_URI"]))
  50. {
  51. return ($is_s2_systematic = apply_filters ("ws_plugin__s2member_is_s2_systematic_use_page", true, get_defined_vars ()));
  52. }
  53. else // Otherwise, we return false (it's NOT an s2Member® Systematic Use Page).
  54. return ($is_s2_systematic = apply_filters ("ws_plugin__s2member_is_s2_systematic_use_page", false, get_defined_vars ()));
  55. }
  56. /**
  57. * Determines if the current page is WordPress® Systematic.
  58. *
  59. * @package s2Member\Systematics
  60. * @since 111002
  61. *
  62. * @return bool True if WordPress® Systematic, else false.
  63. *
  64. * @note The results of this function are cached staticially.
  65. * Do NOT call upon this until the `init` Hook is fired.
  66. */
  67. public static function is_wp_systematic_use_page ()
  68. {
  69. static $is_wp_systematic; // For optimization.
  70.  
  71. if (isset ($is_wp_systematic)) // Already cached statically? Saves time.
  72. {
  73. return $is_wp_systematic; // Filters will have already been applied here.
  74. }
  75. else if (is_admin ()) // In the admin area? All administrational pages are considered Systematic.
  76. {
  77. return ($is_wp_systematic = apply_filters ("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars ()));
  78. }
  79. else if (defined ("WP_INSTALLING") && WP_INSTALLING) // Installing? All WordPress® installs are considered Systematic.
  80. {
  81. return ($is_wp_systematic = apply_filters ("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars ()));
  82. }
  83. else if (defined ("APP_REQUEST") && APP_REQUEST) // App request? All WordPress® app requests are considered Systematic.
  84. {
  85. return ($is_wp_systematic = apply_filters ("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars ()));
  86. }
  87. else if (defined ("XMLRPC_REQUEST") && XMLRPC_REQUEST) // An XML-RPC request? All of these are considered Systematic too.
  88. {
  89. return ($is_wp_systematic = apply_filters ("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars ()));
  90. }
  91. else if ((defined ("DOING_CRON") && DOING_CRON) || strcasecmp (PHP_SAPI, "CLI") === 0) // CLI or CRON job.
  92. {
  93. return ($is_wp_systematic = apply_filters ("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars ()));
  94. }
  95. else if (preg_match ("/^\/(?:wp-.+?|xmlrpc)\.php$/", c_ws_plugin__s2member_utils_urls::parse_url ($_SERVER["REQUEST_URI"], PHP_URL_PATH)))
  96. {
  97. return ($is_wp_systematic = apply_filters ("ws_plugin__s2member_is_wp_systematic_use_page", true, get_defined_vars ()));
  98. }
  99. else // Otherwise, we return false (it's NOT a WordPress® Systematic Use Page).
  100. return ($is_wp_systematic = apply_filters ("ws_plugin__s2member_is_wp_systematic_use_page", false, get_defined_vars ()));
  101. }
  102. /**
  103. * Determines if the current page is Systematic in any way.
  104. *
  105. * @package s2Member\Systematics
  106. * @since 3.5
  107. *
  108. * @return bool True if Systematic, else false.
  109. *
  110. * @note The results of this function are cached staticially.
  111. * Do NOT call upon this until the `wp` Hook is fired.
  112. */
  113. public static function is_systematic_use_page ()
  114. {
  115. static $is_systematic; // For optimization.
  116.  
  117. if (isset ($is_systematic)) // Already cached statically? Saves time.
  118. {
  119. return $is_systematic; // Filters will have already been applied here.
  120. }
  121. else if (c_ws_plugin__s2member_systematics::is_s2_systematic_use_page /* An s2Member® Systematic Use Page? */ ())
  122. {
  123. return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
  124. }
  125. else if (c_ws_plugin__s2member_systematics::is_wp_systematic_use_page /* A WordPress® Systematic Use Page? */ ())
  126. {
  127. return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
  128. }
  129. else if (c_ws_plugin__s2member_utils_conds::bp_is_installed () && (bp_is_register_page () || bp_is_activation_page ()))
  130. {
  131. return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
  132. }
  133. else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && is_page ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]))
  134. {
  135. return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
  136. }
  137. else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && is_page ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]))
  138. {
  139. return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
  140. }
  141. else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && is_page ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]))
  142. {
  143. return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
  144. }
  145. else if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($_lro = c_ws_plugin__s2member_login_redirects::login_redirection_uri (false, "root-returns-false")) && preg_match ("/^" . preg_quote ($_lro, "/") . "$/", $_SERVER["REQUEST_URI"]))
  146. {
  147. return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", true, get_defined_vars ()));
  148. }
  149. else // Otherwise, we return false (it's NOT a Systematic Use Page in any way).
  150. return ($is_systematic = apply_filters ("ws_plugin__s2member_is_systematic_use_page", false, get_defined_vars ()));
  151. }
  152. }
  153. }
  154. ?>

s2member\includes\classes\systematics.inc.php

Source Code Documentation