PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/s2member/includes/classes/systematics.inc.php

https://gitlab.com/Gashler/sg
PHP | 141 lines | 61 code | 26 blank | 54 comment | 33 complexity | 2f2e3b1610714d16ba9144c7b3ea98c1 MD5 | raw file
  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(!defined('WPINC')) // MUST have WordPress.
  18. exit('Do not access this file directly.');
  19. if(!class_exists('c_ws_plugin__s2member_systematics'))
  20. {
  21. /**
  22. * Systematics *(for current page)*.
  23. *
  24. * @package s2Member\Systematics
  25. * @since 3.5
  26. */
  27. class c_ws_plugin__s2member_systematics
  28. {
  29. /**
  30. * Determines if the current page is s2Member Systematic.
  31. *
  32. * @package s2Member\Systematics
  33. * @since 111115
  34. *
  35. * @return bool True if s2Member Systematic, else false.
  36. *
  37. * @note The results of this function are cached staticially.
  38. * Do NOT call upon this until the `init` Hook is fired.
  39. */
  40. public static function is_s2_systematic_use_page()
  41. {
  42. static $is_s2_systematic; // For optimization.
  43. if(isset($is_s2_systematic)) // Already cached statically? Saves time.
  44. return $is_s2_systematic; // Filters will have already been applied here.
  45. $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
  46. if(!empty($_SERVER['QUERY_STRING']) && preg_match('/[\?&]s2member/'.$ci, $_SERVER['QUERY_STRING']) && c_ws_plugin__s2member_utils_conds::is_site_root($_SERVER['REQUEST_URI']))
  47. return ($is_s2_systematic = apply_filters('ws_plugin__s2member_is_s2_systematic_use_page', TRUE, get_defined_vars()));
  48. return ($is_s2_systematic = apply_filters('ws_plugin__s2member_is_s2_systematic_use_page', FALSE, get_defined_vars()));
  49. }
  50. /**
  51. * Determines if the current page is WordPress Systematic.
  52. *
  53. * @package s2Member\Systematics
  54. * @since 111002
  55. *
  56. * @return bool True if WordPress Systematic, else false.
  57. *
  58. * @note The results of this function are cached staticially.
  59. * Do NOT call upon this until the `init` Hook is fired.
  60. */
  61. public static function is_wp_systematic_use_page()
  62. {
  63. static $is_wp_systematic; // For optimization.
  64. if(isset($is_wp_systematic)) // Already cached statically? Saves time.
  65. return $is_wp_systematic; // Filters will have already been applied here.
  66. $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
  67. if(is_admin()) // In the admin area? All administrational pages are considered Systematic.
  68. return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', TRUE, get_defined_vars()));
  69. if(defined('WP_INSTALLING') && WP_INSTALLING) // Installing? All WordPress installs are considered Systematic.
  70. return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', TRUE, get_defined_vars()));
  71. if(defined('APP_REQUEST') && APP_REQUEST) // App request? All WordPress app requests are considered Systematic.
  72. return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', TRUE, get_defined_vars()));
  73. if(defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) // An XML-RPC request? All of these are considered Systematic too.
  74. return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', TRUE, get_defined_vars()));
  75. if((defined('DOING_CRON') && DOING_CRON) || strcasecmp(PHP_SAPI, 'CLI') === 0) // CLI or CRON job.
  76. return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', TRUE, get_defined_vars()));
  77. if(preg_match('/^\/(?:wp-.+?|xmlrpc)\.php$/'.$ci, c_ws_plugin__s2member_utils_urls::parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)))
  78. return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', TRUE, get_defined_vars()));
  79. return ($is_wp_systematic = apply_filters('ws_plugin__s2member_is_wp_systematic_use_page', FALSE, get_defined_vars()));
  80. }
  81. /**
  82. * Determines if the current page is Systematic in any way.
  83. *
  84. * @package s2Member\Systematics
  85. * @since 3.5
  86. *
  87. * @return bool True if Systematic, else false.
  88. *
  89. * @note The results of this function are cached staticially.
  90. * Do NOT call upon this until the `wp` Hook is fired.
  91. */
  92. public static function is_systematic_use_page()
  93. {
  94. static $is_systematic; // For optimization.
  95. if(isset($is_systematic)) // Already cached statically? Saves time.
  96. return $is_systematic; // Filters will have already been applied here.
  97. $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
  98. if(c_ws_plugin__s2member_systematics::is_s2_systematic_use_page()) // An s2Member Systematic Use Page?
  99. return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()));
  100. if(c_ws_plugin__s2member_systematics::is_wp_systematic_use_page()) //* A WordPress Systematic Use Page?
  101. return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()));
  102. if(c_ws_plugin__s2member_utils_conds::bp_is_installed() && (bp_is_register_page() || bp_is_activation_page()))
  103. return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()));
  104. if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'] && is_page($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page']))
  105. return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()));
  106. if($GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page'] && is_page($GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']))
  107. return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()));
  108. if($GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'] && is_page($GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page']))
  109. return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()));
  110. if($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($_lro = c_ws_plugin__s2member_login_redirects::login_redirection_uri(NULL, 'root-returns-false')) && preg_match('/^'.preg_quote($_lro, '/').'$/'.$ci, $_SERVER['REQUEST_URI']))
  111. return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', TRUE, get_defined_vars()));
  112. return ($is_systematic = apply_filters('ws_plugin__s2member_is_systematic_use_page', FALSE, get_defined_vars()));
  113. }
  114. }
  115. }