/freemius/config.php

  1. <?php 
  2. /** 
  3. * @package Freemius 
  4. * @copyright Copyright (c) 2015, Freemius, Inc. 
  5. * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License 
  6. * @since 1.0.4 
  7. */ 
  8.  
  9. if ( ! defined( 'ABSPATH' ) ) { 
  10. exit; 
  11.  
  12. if ( ! defined( 'WP_FS__SLUG' ) ) { 
  13. define( 'WP_FS__SLUG', 'freemius' ); 
  14. if ( ! defined( 'WP_FS__DEV_MODE' ) ) { 
  15. define( 'WP_FS__DEV_MODE', false ); 
  16.  
  17. #-------------------------------------------------------------------------------- 
  18. #region API Connectivity Issues Simulation 
  19. #-------------------------------------------------------------------------------- 
  20.  
  21. if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY' ) ) { 
  22. define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY', false ); 
  23. if ( ! defined( 'WP_FS__SIMULATE_NO_CURL' ) ) { 
  24. define( 'WP_FS__SIMULATE_NO_CURL', false ); 
  25. if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE' ) ) { 
  26. define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false ); 
  27. if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL' ) ) { 
  28. define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false ); 
  29. if ( WP_FS__SIMULATE_NO_CURL ) { 
  30. define( 'FS_SDK__SIMULATE_NO_CURL', true ); 
  31. if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) { 
  32. define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', true ); 
  33. if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) { 
  34. define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', true ); 
  35.  
  36. #endregion 
  37.  
  38. if ( ! defined( 'WP_FS__SIMULATE_FREEMIUS_OFF' ) ) { 
  39. define( 'WP_FS__SIMULATE_FREEMIUS_OFF', false ); 
  40.  
  41. if ( ! defined( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES' ) ) { 
  42. /** 
  43. * @since 1.1.7.3 
  44. * @author Vova Feldman (@svovaf) 
  45. * 
  46. * I'm not sure if shared servers periodically change IP, or the subdomain of the 
  47. * admin dashboard. Also, I've seen sites that have strange loop of switching 
  48. * between domains on a daily basis. Therefore, to eliminate the risk of 
  49. * multiple unwanted connectivity test pings, temporary ignore domain or 
  50. * server IP changes. 
  51. */ 
  52. define( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES', false ); 
  53.  
  54. /** 
  55. * If your dev environment supports custom public network IP setup 
  56. * like VVV, please update WP_FS__LOCALHOST_IP with your public IP 
  57. * and uncomment it during dev. 
  58. */ 
  59. if ( ! defined( 'WP_FS__LOCALHOST_IP' ) ) { 
  60. // VVV default public network IP. 
  61. define( 'WP_FS__VVV_DEFAULT_PUBLIC_IP', '192.168.50.4' ); 
  62.  
  63. // define( 'WP_FS__LOCALHOST_IP', WP_FS__VVV_DEFAULT_PUBLIC_IP ); 
  64.  
  65. /** 
  66. * If true and running with secret key, the opt-in process 
  67. * will skip the email activation process which is invoked 
  68. * when the email of the context user already exist in Freemius 
  69. * database (as a security precaution, to prevent sharing user 
  70. * secret with unauthorized entity). 
  71. * 
  72. * IMPORTANT: 
  73. * AS A SECURITY PRECAUTION, WE VALIDATE THE TIMESTAMP OF THE OPT-IN REQUEST. 
  74. * THEREFORE, MAKE SURE THAT WHEN USING THIS PARAMETER, YOUR TESTING ENVIRONMENT'S 
  75. * CLOCK IS SYNCED. 
  76. */ 
  77. if ( ! defined( 'WP_FS__SKIP_EMAIL_ACTIVATION' ) ) { 
  78. define( 'WP_FS__SKIP_EMAIL_ACTIVATION', false ); 
  79.  
  80.  
  81. #-------------------------------------------------------------------------------- 
  82. #region Directories 
  83. #-------------------------------------------------------------------------------- 
  84.  
  85. if ( ! defined( 'WP_FS__DIR' ) ) { 
  86. define( 'WP_FS__DIR', dirname( __FILE__ ) ); 
  87. if ( ! defined( 'WP_FS__DIR_INCLUDES' ) ) { 
  88. define( 'WP_FS__DIR_INCLUDES', WP_FS__DIR . '/includes' ); 
  89. if ( ! defined( 'WP_FS__DIR_TEMPLATES' ) ) { 
  90. define( 'WP_FS__DIR_TEMPLATES', WP_FS__DIR . '/templates' ); 
  91. if ( ! defined( 'WP_FS__DIR_ASSETS' ) ) { 
  92. define( 'WP_FS__DIR_ASSETS', WP_FS__DIR . '/assets' ); 
  93. if ( ! defined( 'WP_FS__DIR_CSS' ) ) { 
  94. define( 'WP_FS__DIR_CSS', WP_FS__DIR_ASSETS . '/css' ); 
  95. if ( ! defined( 'WP_FS__DIR_JS' ) ) { 
  96. define( 'WP_FS__DIR_JS', WP_FS__DIR_ASSETS . '/js' ); 
  97. if ( ! defined( 'WP_FS__DIR_IMG' ) ) { 
  98. define( 'WP_FS__DIR_IMG', WP_FS__DIR_ASSETS . '/img' ); 
  99. if ( ! defined( 'WP_FS__DIR_SDK' ) ) { 
  100. define( 'WP_FS__DIR_SDK', WP_FS__DIR_INCLUDES . '/sdk' ); 
  101.  
  102. #endregion 
  103.  
  104. /** 
  105. * Domain / URL / Address 
  106. */ 
  107. define( 'WP_FS__DOMAIN_PRODUCTION', 'wp.freemius.com' ); 
  108. define( 'WP_FS__ADDRESS_PRODUCTION', 'https://' . WP_FS__DOMAIN_PRODUCTION ); 
  109.  
  110. if ( ! defined( 'WP_FS__DOMAIN_LOCALHOST' ) ) { 
  111. define( 'WP_FS__DOMAIN_LOCALHOST', 'wp.freemius' ); 
  112. if ( ! defined( 'WP_FS__ADDRESS_LOCALHOST' ) ) { 
  113. define( 'WP_FS__ADDRESS_LOCALHOST', 'http://' . WP_FS__DOMAIN_LOCALHOST . ':8080' ); 
  114.  
  115. if ( ! defined( 'WP_FS__TESTING_DOMAIN' ) ) { 
  116. define( 'WP_FS__TESTING_DOMAIN', 'fswp' ); 
  117.  
  118. #-------------------------------------------------------------------------------- 
  119. #region HTTP 
  120. #-------------------------------------------------------------------------------- 
  121.  
  122. if ( ! defined( 'WP_FS__IS_HTTP_REQUEST' ) ) { 
  123. define( 'WP_FS__IS_HTTP_REQUEST', isset( $_SERVER['HTTP_HOST'] ) ); 
  124.  
  125. if ( ! defined( 'WP_FS__IS_HTTPS' ) ) { 
  126. define( 'WP_FS__IS_HTTPS', ( WP_FS__IS_HTTP_REQUEST && 
  127. // Checks if CloudFlare's HTTPS (Flexible SSL support). 
  128. isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 
  129. 'https' === strtolower( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) 
  130. ) || 
  131. // Check if HTTPS request. 
  132. ( isset( $_SERVER['HTTPS'] ) && 'on' == $_SERVER['HTTPS'] ) || 
  133. ( isset( $_SERVER['SERVER_PORT'] ) && 443 == $_SERVER['SERVER_PORT'] ) 
  134. ); 
  135.  
  136. if ( ! defined( 'WP_FS__IS_POST_REQUEST' ) ) { 
  137. define( 'WP_FS__IS_POST_REQUEST', ( WP_FS__IS_HTTP_REQUEST && 
  138. strtoupper( $_SERVER['REQUEST_METHOD'] ) == 'POST' ) ); 
  139.  
  140. if ( ! defined( 'WP_FS__REMOTE_ADDR' ) ) { 
  141. define( 'WP_FS__REMOTE_ADDR', fs_get_ip() ); 
  142.  
  143. if ( ! defined( 'WP_FS__IS_LOCALHOST' ) ) { 
  144. if ( defined( 'WP_FS__LOCALHOST_IP' ) ) { 
  145. define( 'WP_FS__IS_LOCALHOST', ( WP_FS__LOCALHOST_IP === WP_FS__REMOTE_ADDR ) ); 
  146. } else { 
  147. define( 'WP_FS__IS_LOCALHOST', WP_FS__IS_HTTP_REQUEST && 
  148. is_string( WP_FS__REMOTE_ADDR ) && 
  149. ( substr( WP_FS__REMOTE_ADDR, 0, 4 ) === '127.' || 
  150. WP_FS__REMOTE_ADDR === '::1' ) 
  151. ); 
  152.  
  153. if ( ! defined( 'WP_FS__IS_LOCALHOST_FOR_SERVER' ) ) { 
  154. define( 'WP_FS__IS_LOCALHOST_FOR_SERVER', ( ! WP_FS__IS_HTTP_REQUEST || 
  155. false !== strpos( $_SERVER['HTTP_HOST'], 'localhost' ) ) ); 
  156.  
  157. #endregion 
  158.  
  159. if ( ! defined( 'WP_FS__IS_PRODUCTION_MODE' ) ) { 
  160. // By default, run with Freemius production servers. 
  161. define( 'WP_FS__IS_PRODUCTION_MODE', true ); 
  162.  
  163. if ( ! defined( 'WP_FS__ADDRESS' ) ) { 
  164. define( 'WP_FS__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? WP_FS__ADDRESS_PRODUCTION : WP_FS__ADDRESS_LOCALHOST ) ); 
  165.  
  166.  
  167. #-------------------------------------------------------------------------------- 
  168. #region API 
  169. #-------------------------------------------------------------------------------- 
  170.  
  171. if ( ! defined( 'WP_FS__API_ADDRESS_LOCALHOST' ) ) { 
  172. define( 'WP_FS__API_ADDRESS_LOCALHOST', 'http://api.freemius:8080' ); 
  173. if ( ! defined( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST' ) ) { 
  174. define( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST', 'http://sandbox-api.freemius:8080' ); 
  175.  
  176. // Set API address for local testing. 
  177. if ( ! WP_FS__IS_PRODUCTION_MODE ) { 
  178. if ( ! defined( 'FS_API__ADDRESS' ) ) { 
  179. define( 'FS_API__ADDRESS', WP_FS__API_ADDRESS_LOCALHOST ); 
  180. if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) { 
  181. define( 'FS_API__SANDBOX_ADDRESS', WP_FS__API_SANDBOX_ADDRESS_LOCALHOST ); 
  182.  
  183. #endregion 
  184.  
  185. define( 'WP_FS___OPTION_PREFIX', 'fs' . ( WP_FS__IS_PRODUCTION_MODE ? '' : '_dbg' ) . '_' ); 
  186.  
  187. if ( ! defined( 'WP_FS__ACCOUNTS_OPTION_NAME' ) ) { 
  188. define( 'WP_FS__ACCOUNTS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'accounts' ); 
  189. if ( ! defined( 'WP_FS__API_CACHE_OPTION_NAME' ) ) { 
  190. define( 'WP_FS__API_CACHE_OPTION_NAME', WP_FS___OPTION_PREFIX . 'api_cache' ); 
  191. define( 'WP_FS__OPTIONS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'options' ); 
  192.  
  193. /** 
  194. * Billing Frequencies 
  195. */ 
  196. define( 'WP_FS__PERIOD_ANNUALLY', 'annual' ); 
  197. define( 'WP_FS__PERIOD_MONTHLY', 'monthly' ); 
  198. define( 'WP_FS__PERIOD_LIFETIME', 'lifetime' ); 
  199.  
  200. /** 
  201. * Plans 
  202. */ 
  203. define( 'WP_FS__PLAN_DEFAULT_PAID', false ); 
  204. define( 'WP_FS__PLAN_FREE', 'free' ); 
  205. define( 'WP_FS__PLAN_TRIAL', 'trial' ); 
  206.  
  207. /** 
  208. * Times in seconds 
  209. */ 
  210. if ( ! defined( 'WP_FS__TIME_5_MIN_IN_SEC' ) ) { 
  211. define( 'WP_FS__TIME_5_MIN_IN_SEC', 300 ); 
  212. if ( ! defined( 'WP_FS__TIME_10_MIN_IN_SEC' ) ) { 
  213. define( 'WP_FS__TIME_10_MIN_IN_SEC', 600 ); 
  214. // define( 'WP_FS__TIME_15_MIN_IN_SEC', 900 ); 
  215. if ( ! defined( 'WP_FS__TIME_24_HOURS_IN_SEC' ) ) { 
  216. define( 'WP_FS__TIME_24_HOURS_IN_SEC', 86400 ); 
  217.  
  218. #-------------------------------------------------------------------------------- 
  219. #region Debugging 
  220. #-------------------------------------------------------------------------------- 
  221.  
  222. if ( ! defined( 'WP_FS__DEBUG_SDK' ) ) { 
  223. $debug_mode = get_option( 'fs_debug_mode', null ); 
  224.  
  225. if ( $debug_mode === null ) { 
  226. $debug_mode = false; 
  227. add_option( 'fs_debug_mode', $debug_mode ); 
  228.  
  229. define( 'WP_FS__DEBUG_SDK', is_numeric( $debug_mode ) ? ( 0 < $debug_mode ) : WP_FS__DEV_MODE ); 
  230.  
  231. if ( ! defined( 'WP_FS__ECHO_DEBUG_SDK' ) ) { 
  232. define( 'WP_FS__ECHO_DEBUG_SDK', WP_FS__DEV_MODE && ! empty( $_GET['fs_dbg_echo'] ) ); 
  233. if ( ! defined( 'WP_FS__LOG_DATETIME_FORMAT' ) ) { 
  234. define( 'WP_FS__LOG_DATETIME_FORMAT', 'Y-m-d H:i:s' ); 
  235. if ( ! defined( 'FS_API__LOGGER_ON' ) ) { 
  236. define( 'FS_API__LOGGER_ON', WP_FS__DEBUG_SDK ); 
  237.  
  238. if ( WP_FS__ECHO_DEBUG_SDK ) { 
  239. error_reporting( E_ALL ); 
  240.  
  241. #endregion 
  242.  
  243. if ( ! defined( 'WP_FS__SCRIPT_START_TIME' ) ) { 
  244. define( 'WP_FS__SCRIPT_START_TIME', time() ); 
  245. if ( ! defined( 'WP_FS__DEFAULT_PRIORITY' ) ) { 
  246. define( 'WP_FS__DEFAULT_PRIORITY', 10 ); 
  247. if ( ! defined( 'WP_FS__LOWEST_PRIORITY' ) ) { 
  248. define( 'WP_FS__LOWEST_PRIORITY', 999999999 ); 
.