Source Code Documentation


pro\s2member-pro\includes\classes\gateways\google\google-menu-pages.inc.php


  1. <?php
  2. /**
  3. * Google® Menu Pages.
  4. *
  5. * Copyright: © 2009-2011
  6. * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
  7. * (coded in the USA)
  8. *
  9. * This WordPress® plugin (s2Member Pro) is comprised of two parts:
  10. *
  11. * o (1) Its PHP code is licensed under the GPL license, as is WordPress®.
  12. * You should have received a copy of the GNU General Public License,
  13. * along with this software. In the main directory, see: /licensing/
  14. * If not, see: {@link http://www.gnu.org/licenses/}.
  15. *
  16. * o (2) All other parts of (s2Member Pro); including, but not limited to:
  17. * the CSS code, some JavaScript code, images, and design;
  18. * are licensed according to the license purchased.
  19. * See: {@link http://www.s2member.com/prices/}
  20. *
  21. * Unless you have our prior written consent, you must NOT directly or indirectly license,
  22. * sub-license, sell, resell, or provide for free; part (2) of the s2Member Pro Module;
  23. * or make an offer to do any of these things. All of these things are strictly
  24. * prohibited with part (2) of the s2Member Pro Module.
  25. *
  26. * Your purchase of s2Member Pro includes free lifetime upgrades via s2Member.com
  27. * (i.e. new features, bug fixes, updates, improvements); along with full access
  28. * to our video tutorial library: {@link http://www.s2member.com/videos/}
  29. *
  30. * @package s2Member\Menu_Pages
  31. * @since 1.5
  32. */
  33. if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
  34. exit ("Do not access this file directly.");
  35.  
  36. if (!class_exists ("c_ws_plugin__s2member_pro_google_menu_pages"))
  37. {
  38. /**
  39. * Google® Menu Pages.
  40. *
  41. * @package s2Member\Menu_Pages
  42. * @since 1.5
  43. */
  44. class c_ws_plugin__s2member_pro_google_menu_pages
  45. {
  46. /**
  47. * Add the pages for this Payment Gateway.
  48. *
  49. * @package s2Member\Menu_Pages
  50. * @since 1.5
  51. *
  52. * @attaches-to ``add_filter("ws_plugin__s2member_during_add_admin_options_add_divider_4");``
  53. *
  54. * @param bool $add_divider Expects a boolean value, passed through by the Filter.
  55. * @param array $vars Expects an array of defined variables passed through by the Filter.
  56. * @return bool Passes back the original value of ``$add_divider``.
  57. */
  58. public static function google_admin_options ($add_divider = TRUE, $vars = FALSE)
  59. {
  60. add_submenu_page ($vars["menu"], "", '<span style="display:block; margin:1px 0 1px -5px; padding:0; height:1px; line-height:1px; background:#CCCCCC;"></span>', "create_users", "#");
  61. add_submenu_page ($vars["menu"], "s2Member Pro / Google® Options", "Google® Options", "create_users", "ws-plugin--s2member-pro-google-ops", "c_ws_plugin__s2member_pro_google_menu_pages::google_ops_page");
  62. add_submenu_page ($vars["menu"], "s2Member Pro / Google® Buttons", "Google® Buttons", "create_users", "ws-plugin--s2member-pro-google-buttons", "c_ws_plugin__s2member_pro_google_menu_pages::google_buttons_page");
  63.  
  64. return $add_divider; // Now add the divider.
  65. }
  66. /**
  67. * Builds the documentation for Scripting / API Constants related to this Payment Gateway.
  68. *
  69. * @package s2Member\Menu_Pages
  70. * @since 1.5
  71. *
  72. * @attaches-to ``add_action("ws_plugin__s2member_during_scripting_page_during_left_sections_during_list_of_api_constants");``
  73. *
  74. * @param array $vars Expects an array of defined variables passed through by the Action Hook.
  75. * @return null
  76. */
  77. public static function google_scripting_page_api_constants ($vars = FALSE)
  78. {
  79. include_once dirname (dirname (dirname (dirname (__FILE__)))) . "/menu-pages/google-s-api-c.inc.php";
  80.  
  81. return /* Return for uniformity. */;
  82. }
  83. /**
  84. * Builds the options panel for this Payment Gateway.
  85. *
  86. * @package s2Member\Menu_Pages
  87. * @since 1.5
  88. *
  89. * @return null
  90. */
  91. public static function google_ops_page ()
  92. {
  93. c_ws_plugin__s2member_menu_pages::update_all_options (); // Updates options.
  94.  
  95. $logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"];
  96.  
  97. if (!is_dir ($logs_dir) && is_writable (dirname (c_ws_plugin__s2member_utils_dirs::strip_dir_app_data ($logs_dir))))
  98. mkdir ($logs_dir, 0777, true) . clearstatcache ();
  99.  
  100. $htaccess = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"] . "/.htaccess";
  101. $htaccess_contents = trim (c_ws_plugin__s2member_utilities::evl (file_get_contents ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir_htaccess"])));
  102.  
  103. if (is_dir ($logs_dir) && is_writable ($logs_dir) && !file_exists ($htaccess))
  104. file_put_contents ($htaccess, $htaccess_contents) . clearstatcache ();
  105.  
  106. if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"]) // Logging enabled?
  107. {
  108. if (!is_dir ($logs_dir)) // If the security-enabled logs directory does not exist yet.
  109. c_ws_plugin__s2member_admin_notices::display_admin_notice ('The security-enabled logs directory (<code>' . esc_html (c_ws_plugin__s2member_utils_dirs::doc_root_path ($logs_dir)) . '</code>) does not exist. Please create this directory manually &amp; make it writable (chmod 777).', true);
  110.  
  111. else if (!is_writable ($logs_dir)) // If the logs directory is not writable yet.
  112. c_ws_plugin__s2member_admin_notices::display_admin_notice ('Permissions error. The security-enabled logs directory (<code>' . esc_html (c_ws_plugin__s2member_utils_dirs::doc_root_path ($logs_dir)) . '</code>) is not writable. Please make this directory writable (chmod 777).', true);
  113.  
  114. if (!file_exists ($htaccess)) // If the .htaccess file has not been created yet.
  115. c_ws_plugin__s2member_admin_notices::display_admin_notice ('The .htaccess protection file (<code>' . esc_html (c_ws_plugin__s2member_utils_dirs::doc_root_path ($htaccess)) . '</code>) does not exist. Please create this file manually. Inside your .htaccess file, add this:<br /><pre>' . esc_html ($htaccess_contents) . '</pre>', true);
  116.  
  117. else if (!preg_match ("/deny from all/i", file_get_contents ($htaccess))) // Else if the .htaccess file does not offer the required protection.
  118. c_ws_plugin__s2member_admin_notices::display_admin_notice ('Unprotected. The .htaccess protection file (<code>' . esc_html (c_ws_plugin__s2member_utils_dirs::doc_root_path ($htaccess)) . '</code>) does not contain <code>deny from all</code>. Inside your .htaccess file, add this:<br /><pre>' . esc_html ($htaccess_contents) . '</pre>', true);
  119. }
  120.  
  121. include_once dirname (dirname (dirname (dirname (__FILE__)))) . "/menu-pages/google-ops.inc.php";
  122.  
  123. return /* Return for uniformity. */;
  124. }
  125. /**
  126. * Builds the Buttons panel for this Payment Gateway.
  127. *
  128. * @package s2Member\Menu_Pages
  129. * @since 1.5
  130. *
  131. * @return null
  132. */
  133. public static function google_buttons_page ()
  134. {
  135. if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_id"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_key"])
  136. c_ws_plugin__s2member_admin_notices::display_admin_notice ('Please configure <code>s2Member -› Google® Options</code> first. Once all of your Google® Options have been configured, return to this page &amp; generate your Google® Checkout Button(s).', true);
  137.  
  138. include_once dirname (dirname (dirname (dirname (__FILE__)))) . "/menu-pages/google-buttons.inc.php";
  139.  
  140. return /* Return for uniformity. */;
  141. }
  142. }
  143. }
  144. ?>

pro\s2member-pro\includes\classes\gateways\google\google-menu-pages.inc.php

Source Code Documentation