| @@ -1,327 +1,391 @@ | ||
| 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 | - | |
| 13 | - if ( ! defined( 'WP_FS__SLUG' ) ) { | |
| 14 | - define( 'WP_FS__SLUG', 'freemius' ); | |
| 15 | - } | |
| 16 | - if ( ! defined( 'WP_FS__DEV_MODE' ) ) { | |
| 17 | - define( 'WP_FS__DEV_MODE', false ); | |
| 18 | - } | |
| 19 | - | |
| 20 | - #-------------------------------------------------------------------------------- | |
| 21 | - #region API Connectivity Issues Simulation | |
| 22 | - #-------------------------------------------------------------------------------- | |
| 23 | - | |
| 24 | - if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY' ) ) { | |
| 25 | - define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY', false ); | |
| 26 | - } | |
| 27 | - if ( ! defined( 'WP_FS__SIMULATE_NO_CURL' ) ) { | |
| 28 | - define( 'WP_FS__SIMULATE_NO_CURL', false ); | |
| 29 | - } | |
| 30 | - if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE' ) ) { | |
| 31 | - define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false ); | |
| 32 | - } | |
| 33 | - if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL' ) ) { | |
| 34 | - define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false ); | |
| 35 | - } | |
| 36 | - if ( WP_FS__SIMULATE_NO_CURL ) { | |
| 37 | - define( 'FS_SDK__SIMULATE_NO_CURL', true ); | |
| 38 | - } | |
| 39 | - if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) { | |
| 40 | - define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', true ); | |
| 41 | - } | |
| 42 | - if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) { | |
| 43 | - define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', true ); | |
| 44 | - } | |
| 45 | - | |
| 46 | - #endregion | |
| 47 | - | |
| 48 | - if ( ! defined( 'WP_FS__SIMULATE_FREEMIUS_OFF' ) ) { | |
| 49 | - define( 'WP_FS__SIMULATE_FREEMIUS_OFF', false ); | |
| 50 | - } | |
| 51 | - | |
| 52 | - if ( ! defined( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES' ) ) { | |
| 53 | - /** | |
| 54 | - * @since 1.1.7.3 | |
| 55 | - * @author Vova Feldman (@svovaf) | |
| 56 | - * | |
| 57 | - * I'm not sure if shared servers periodically change IP, or the subdomain of the | |
| 58 | - * Admin dashboard. Also, I've seen sites that have strange loop of switching | |
| 59 | - * between domains on a daily basis. Therefore, to eliminate the risk of | |
| 60 | - * multiple unwanted connectivity test pings, temporary ignore domain or | |
| 61 | - * server IP changes. | |
| 62 | - */ | |
| 63 | - define( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES', false ); | |
| 64 | - } | |
| 65 | - | |
| 66 | - /** | |
| 67 | - * If your dev environment supports custom public network IP setup | |
| 68 | - * like VVV, please update WP_FS__LOCALHOST_IP with your public IP | |
| 69 | - * and uncomment it during dev. | |
| 70 | - */ | |
| 71 | - if ( ! defined( 'WP_FS__LOCALHOST_IP' ) ) { | |
| 72 | - // VVV Utils public network IP. | |
| 73 | - define( 'WP_FS__VVV_DEFAULT_PUBLIC_IP', '192.168.50.4' ); | |
| 74 | - | |
| 75 | -// define( 'WP_FS__LOCALHOST_IP', WP_FS__VVV_DEFAULT_PUBLIC_IP ); | |
| 76 | - } | |
| 77 | - | |
| 78 | - /** | |
| 79 | - * If true and running with secret key, the opt-in process | |
| 80 | - * will skip the email activation process which is invoked | |
| 81 | - * when the email of the context user already exist in Freemius | |
| 82 | - * database (as a security precaution, to prevent sharing user | |
| 83 | - * secret with unauthorized entity). | |
| 84 | - * | |
| 85 | - * IMPORTANT: | |
| 86 | - * AS A SECURITY PRECAUTION, WE VALIDATE THE TIMESTAMP OF THE OPT-IN REQUEST. | |
| 87 | - * THEREFORE, MAKE SURE THAT WHEN USING THIS PARAMETER,YOUR TESTING ENVIRONMENT'S | |
| 88 | - * CLOCK IS SYNCED. | |
| 89 | - */ | |
| 90 | - if ( ! defined( 'WP_FS__SKIP_EMAIL_ACTIVATION' ) ) { | |
| 91 | - define( 'WP_FS__SKIP_EMAIL_ACTIVATION', false ); | |
| 92 | - } | |
| 93 | - | |
| 94 | - | |
| 95 | - #-------------------------------------------------------------------------------- | |
| 96 | - #region Directories | |
| 97 | - #-------------------------------------------------------------------------------- | |
| 98 | - | |
| 99 | - if ( ! defined( 'WP_FS__DIR' ) ) { | |
| 100 | - define( 'WP_FS__DIR', dirname( __FILE__ ) ); | |
| 101 | - } | |
| 102 | - if ( ! defined( 'WP_FS__DIR_INCLUDES' ) ) { | |
| 103 | - define( 'WP_FS__DIR_INCLUDES', WP_FS__DIR . '/includes' ); | |
| 104 | - } | |
| 105 | - if ( ! defined( 'WP_FS__DIR_TEMPLATES' ) ) { | |
| 106 | - define( 'WP_FS__DIR_TEMPLATES', WP_FS__DIR . '/templates' ); | |
| 107 | - } | |
| 108 | - if ( ! defined( 'WP_FS__DIR_ASSETS' ) ) { | |
| 109 | - define( 'WP_FS__DIR_ASSETS', WP_FS__DIR . '/assets' ); | |
| 110 | - } | |
| 111 | - if ( ! defined( 'WP_FS__DIR_CSS' ) ) { | |
| 112 | - define( 'WP_FS__DIR_CSS', WP_FS__DIR_ASSETS . '/css' ); | |
| 113 | - } | |
| 114 | - if ( ! defined( 'WP_FS__DIR_JS' ) ) { | |
| 115 | - define( 'WP_FS__DIR_JS', WP_FS__DIR_ASSETS . '/js' ); | |
| 116 | - } | |
| 117 | - if ( ! defined( 'WP_FS__DIR_IMG' ) ) { | |
| 118 | - define( 'WP_FS__DIR_IMG', WP_FS__DIR_ASSETS . '/img' ); | |
| 119 | - } | |
| 120 | - if ( ! defined( 'WP_FS__DIR_SDK' ) ) { | |
| 121 | - define( 'WP_FS__DIR_SDK', WP_FS__DIR_INCLUDES . '/sdk' ); | |
| 122 | - } | |
| 123 | - | |
| 124 | - #endregion | |
| 125 | - | |
| 126 | - /** | |
| 127 | - * Domain / URL / Address | |
| 128 | - */ | |
| 129 | - define( 'WP_FS__DOMAIN_PRODUCTION', 'wp.freemius.com' ); | |
| 130 | - define( 'WP_FS__ADDRESS_PRODUCTION', 'https://' . WP_FS__DOMAIN_PRODUCTION ); | |
| 131 | - | |
| 132 | - if ( ! defined( 'WP_FS__DOMAIN_LOCALHOST' ) ) { | |
| 133 | - define( 'WP_FS__DOMAIN_LOCALHOST', 'wp.freemius' ); | |
| 134 | - } | |
| 135 | - if ( ! defined( 'WP_FS__ADDRESS_LOCALHOST' ) ) { | |
| 136 | - define( 'WP_FS__ADDRESS_LOCALHOST', 'http://' . WP_FS__DOMAIN_LOCALHOST . ':8080' ); | |
| 137 | - } | |
| 138 | - | |
| 139 | - if ( ! defined( 'WP_FS__TESTING_DOMAIN' ) ) { | |
| 140 | - define( 'WP_FS__TESTING_DOMAIN', 'fswp' ); | |
| 141 | - } | |
| 142 | - | |
| 143 | - #-------------------------------------------------------------------------------- | |
| 144 | - #region HTTP | |
| 145 | - #-------------------------------------------------------------------------------- | |
| 146 | - | |
| 147 | - if ( ! defined( 'WP_FS__IS_HTTP_REQUEST' ) ) { | |
| 148 | - define( 'WP_FS__IS_HTTP_REQUEST', isset( $_SERVER['HTTP_HOST'] ) ); | |
| 149 | - } | |
| 150 | - | |
| 151 | - if ( ! defined( 'WP_FS__IS_HTTPS' ) ) { | |
| 152 | - define( 'WP_FS__IS_HTTPS', ( WP_FS__IS_HTTP_REQUEST && | |
| 153 | - // Checks if CloudFlare's HTTPS (Flexible SSL support). | |
| 154 | - isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && | |
| 155 | - 'https' === strtolower( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) | |
| 156 | - ) || | |
| 157 | - // Check if HTTPS request. | |
| 158 | - ( isset( $_SERVER['HTTPS'] ) && 'on' == $_SERVER['HTTPS'] ) || | |
| 159 | - ( isset( $_SERVER['SERVER_PORT'] ) && 443 == $_SERVER['SERVER_PORT'] ) | |
| 160 | - ); | |
| 161 | - } | |
| 162 | - | |
| 163 | - if ( ! defined( 'WP_FS__IS_POST_REQUEST' ) ) { | |
| 164 | - define( 'WP_FS__IS_POST_REQUEST', ( WP_FS__IS_HTTP_REQUEST && | |
| 165 | - strtoupper( $_SERVER['REQUEST_METHOD'] ) == 'POST' ) ); | |
| 166 | - } | |
| 167 | - | |
| 168 | - if ( ! defined( 'WP_FS__REMOTE_ADDR' ) ) { | |
| 169 | - define( 'WP_FS__REMOTE_ADDR', fs_get_ip() ); | |
| 170 | - } | |
| 171 | - | |
| 172 | - if ( ! defined( 'WP_FS__IS_LOCALHOST' ) ) { | |
| 173 | - if ( defined( 'WP_FS__LOCALHOST_IP' ) ) { | |
| 174 | - define( 'WP_FS__IS_LOCALHOST', ( WP_FS__LOCALHOST_IP === WP_FS__REMOTE_ADDR ) ); | |
| 175 | - } else { | |
| 176 | - define( 'WP_FS__IS_LOCALHOST', WP_FS__IS_HTTP_REQUEST && | |
| 177 | - is_string( WP_FS__REMOTE_ADDR ) && | |
| 178 | - ( substr( WP_FS__REMOTE_ADDR, 0, 4 ) === '127.' || | |
| 179 | - WP_FS__REMOTE_ADDR === '::1' ) | |
| 180 | - ); | |
| 181 | - } | |
| 182 | - } | |
| 183 | - | |
| 184 | - if ( ! defined( 'WP_FS__IS_LOCALHOST_FOR_SERVER' ) ) { | |
| 185 | - define( 'WP_FS__IS_LOCALHOST_FOR_SERVER', ( ! WP_FS__IS_HTTP_REQUEST || | |
| 186 | - false !== strpos( $_SERVER['HTTP_HOST'], 'localhost' ) ) ); | |
| 187 | - } | |
| 188 | - | |
| 189 | - #endregion | |
| 190 | - | |
| 191 | - if ( ! defined( 'WP_FS__IS_PRODUCTION_MODE' ) ) { | |
| 192 | - // By Utils, run with Freemius production servers. | |
| 193 | - define( 'WP_FS__IS_PRODUCTION_MODE', true ); | |
| 194 | - } | |
| 195 | - | |
| 196 | - if ( ! defined( 'WP_FS__ADDRESS' ) ) { | |
| 197 | - define( 'WP_FS__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? WP_FS__ADDRESS_PRODUCTION : WP_FS__ADDRESS_LOCALHOST ) ); | |
| 198 | - } | |
| 199 | - | |
| 200 | - | |
| 201 | - #-------------------------------------------------------------------------------- | |
| 202 | - #region API | |
| 203 | - #-------------------------------------------------------------------------------- | |
| 204 | - | |
| 205 | - if ( ! defined( 'WP_FS__API_ADDRESS_LOCALHOST' ) ) { | |
| 206 | - define( 'WP_FS__API_ADDRESS_LOCALHOST', 'http://api.freemius:8080' ); | |
| 207 | - } | |
| 208 | - if ( ! defined( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST' ) ) { | |
| 209 | - define( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST', 'http://sandbox-api.freemius:8080' ); | |
| 210 | - } | |
| 211 | - | |
| 212 | - // Set API address for local testing. | |
| 213 | - if ( ! WP_FS__IS_PRODUCTION_MODE ) { | |
| 214 | - if ( ! defined( 'FS_API__ADDRESS' ) ) { | |
| 215 | - define( 'FS_API__ADDRESS', WP_FS__API_ADDRESS_LOCALHOST ); | |
| 216 | - } | |
| 217 | - if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) { | |
| 218 | - define( 'FS_API__SANDBOX_ADDRESS', WP_FS__API_SANDBOX_ADDRESS_LOCALHOST ); | |
| 219 | - } | |
| 220 | - } | |
| 221 | - | |
| 222 | - #endregion | |
| 223 | - | |
| 224 | - #-------------------------------------------------------------------------------- | |
| 225 | - #region Checkout | |
| 226 | - #-------------------------------------------------------------------------------- | |
| 227 | - | |
| 228 | - if ( ! defined( 'FS_CHECKOUT__ADDRESS_PRODUCTION' ) ) { | |
| 229 | - define( 'FS_CHECKOUT__ADDRESS_PRODUCTION', 'https://checkout.freemius.com' ); | |
| 230 | - } | |
| 231 | - | |
| 232 | - if ( ! defined( 'FS_CHECKOUT__ADDRESS_LOCALHOST' ) ) { | |
| 233 | - define( 'FS_CHECKOUT__ADDRESS_LOCALHOST', 'http://checkout.freemius:8080' ); | |
| 234 | - } | |
| 235 | - | |
| 236 | - if ( ! defined( 'FS_CHECKOUT__ADDRESS' ) ) { | |
| 237 | - define( 'FS_CHECKOUT__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? FS_CHECKOUT__ADDRESS_PRODUCTION : FS_CHECKOUT__ADDRESS_LOCALHOST ) ); | |
| 238 | - } | |
| 239 | - | |
| 240 | - #endregion | |
| 241 | - | |
| 242 | - define( 'WP_FS___OPTION_PREFIX', 'fs' . ( WP_FS__IS_PRODUCTION_MODE ? '' : '_dbg' ) . '_' ); | |
| 243 | - | |
| 244 | - if ( ! defined( 'WP_FS__ACCOUNTS_OPTION_NAME' ) ) { | |
| 245 | - define( 'WP_FS__ACCOUNTS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'accounts' ); | |
| 246 | - } | |
| 247 | - if ( ! defined( 'WP_FS__API_CACHE_OPTION_NAME' ) ) { | |
| 248 | - define( 'WP_FS__API_CACHE_OPTION_NAME', WP_FS___OPTION_PREFIX . 'api_cache' ); | |
| 249 | - } | |
| 250 | - define( 'WP_FS__OPTIONS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'options' ); | |
| 251 | - | |
| 252 | - /** | |
| 253 | - * Module types | |
| 254 | - * | |
| 255 | - * @since 1.2.2 | |
| 256 | - */ | |
| 257 | - define( 'WP_FS__MODULE_TYPE_PLUGIN', 'plugin' ); | |
| 258 | - define( 'WP_FS__MODULE_TYPE_THEME', 'theme' ); | |
| 259 | - | |
| 260 | - /** | |
| 261 | - * Billing Frequencies | |
| 262 | - */ | |
| 263 | - define( 'WP_FS__PERIOD_ANNUALLY', 'annual' ); | |
| 264 | - define( 'WP_FS__PERIOD_MONTHLY', 'monthly' ); | |
| 265 | - define( 'WP_FS__PERIOD_LIFETIME', 'lifetime' ); | |
| 266 | - | |
| 267 | - /** | |
| 268 | - * Plans | |
| 269 | - */ | |
| 270 | - define( 'WP_FS__PLAN_DEFAULT_PAID', false ); | |
| 271 | - define( 'WP_FS__PLAN_FREE', 'free' ); | |
| 272 | - define( 'WP_FS__PLAN_TRIAL', 'trial' ); | |
| 273 | - | |
| 274 | - /** | |
| 275 | - * Times in seconds | |
| 276 | - */ | |
| 277 | - if ( ! defined( 'WP_FS__TIME_5_MIN_IN_SEC' ) ) { | |
| 278 | - define( 'WP_FS__TIME_5_MIN_IN_SEC', 300 ); | |
| 279 | - } | |
| 280 | - if ( ! defined( 'WP_FS__TIME_10_MIN_IN_SEC' ) ) { | |
| 281 | - define( 'WP_FS__TIME_10_MIN_IN_SEC', 600 ); | |
| 282 | - } | |
| 283 | -// define( 'WP_FS__TIME_15_MIN_IN_SEC', 900 ); | |
| 284 | - if ( ! defined( 'WP_FS__TIME_24_HOURS_IN_SEC' ) ) { | |
| 285 | - define( 'WP_FS__TIME_24_HOURS_IN_SEC', 86400 ); | |
| 286 | - } | |
| 287 | - | |
| 288 | - #-------------------------------------------------------------------------------- | |
| 289 | - #region Debugging | |
| 290 | - #-------------------------------------------------------------------------------- | |
| 291 | - | |
| 292 | - if ( ! defined( 'WP_FS__DEBUG_SDK' ) ) { | |
| 293 | - $debug_mode = get_option( 'fs_debug_mode', null ); | |
| 294 | - | |
| 295 | - if ( $debug_mode === null ) { | |
| 296 | - $debug_mode = false; | |
| 297 | - add_option( 'fs_debug_mode', $debug_mode ); | |
| 298 | - } | |
| 299 | - | |
| 300 | - define( 'WP_FS__DEBUG_SDK', is_numeric( $debug_mode ) ? ( 0 < $debug_mode ) : WP_FS__DEV_MODE ); | |
| 301 | - } | |
| 302 | - | |
| 303 | - if ( ! defined( 'WP_FS__ECHO_DEBUG_SDK' ) ) { | |
| 304 | - define( 'WP_FS__ECHO_DEBUG_SDK', WP_FS__DEV_MODE && ! empty( $_GET['fs_dbg_echo'] ) ); | |
| 305 | - } | |
| 306 | - if ( ! defined( 'WP_FS__LOG_DATETIME_FORMAT' ) ) { | |
| 307 | - define( 'WP_FS__LOG_DATETIME_FORMAT', 'Y-m-d H:i:s' ); | |
| 308 | - } | |
| 309 | - if ( ! defined( 'FS_API__LOGGER_ON' ) ) { | |
| 310 | - define( 'FS_API__LOGGER_ON', WP_FS__DEBUG_SDK ); | |
| 311 | - } | |
| 312 | - | |
| 313 | - if ( WP_FS__ECHO_DEBUG_SDK ) { | |
| 314 | - error_reporting( E_ALL ); | |
| 315 | - } | |
| 316 | - | |
| 317 | - #endregion | |
| 318 | - | |
| 319 | - if ( ! defined( 'WP_FS__SCRIPT_START_TIME' ) ) { | |
| 320 | - define( 'WP_FS__SCRIPT_START_TIME', time() ); | |
| 321 | - } | |
| 322 | - if ( ! defined( 'WP_FS__DEFAULT_PRIORITY' ) ) { | |
| 323 | - define( 'WP_FS__DEFAULT_PRIORITY', 10 ); | |
| 324 | - } | |
| 325 | - if ( ! defined( 'WP_FS__LOWEST_PRIORITY' ) ) { | |
| 326 | - define( 'WP_FS__LOWEST_PRIORITY', 999999999 ); | |
| 327 | - } | |
| 1 | +<?php | |
| 2 | + /** | |
| 3 | + * @package Freemius | |
| 4 | + * @copyright Copyright (c) 2015, Freemius, Inc. | |
| 5 | + * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 | |
| 6 | + * @since 1.0.4 | |
| 7 | + */ | |
| 8 | + | |
| 9 | + if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | + exit; | |
| 11 | + } | |
| 12 | + | |
| 13 | + if ( ! defined( 'WP_FS__SLUG' ) ) { | |
| 14 | + define( 'WP_FS__SLUG', 'freemius' ); | |
| 15 | + } | |
| 16 | + if ( ! defined( 'WP_FS__DEV_MODE' ) ) { | |
| 17 | + define( 'WP_FS__DEV_MODE', false ); | |
| 18 | + } | |
| 19 | + | |
| 20 | + #-------------------------------------------------------------------------------- | |
| 21 | + #region API Connectivity Issues Simulation | |
| 22 | + #-------------------------------------------------------------------------------- | |
| 23 | + | |
| 24 | + if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY' ) ) { | |
| 25 | + define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY', false ); | |
| 26 | + } | |
| 27 | + if ( ! defined( 'WP_FS__SIMULATE_NO_CURL' ) ) { | |
| 28 | + define( 'WP_FS__SIMULATE_NO_CURL', false ); | |
| 29 | + } | |
| 30 | + if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE' ) ) { | |
| 31 | + define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false ); | |
| 32 | + } | |
| 33 | + if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL' ) ) { | |
| 34 | + define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false ); | |
| 35 | + } | |
| 36 | + if ( WP_FS__SIMULATE_NO_CURL ) { | |
| 37 | + define( 'FS_SDK__SIMULATE_NO_CURL', true ); | |
| 38 | + } | |
| 39 | + if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) { | |
| 40 | + define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', true ); | |
| 41 | + } | |
| 42 | + if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) { | |
| 43 | + define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', true ); | |
| 44 | + } | |
| 45 | + | |
| 46 | + #endregion | |
| 47 | + | |
| 48 | + if ( ! defined( 'WP_FS__SIMULATE_FREEMIUS_OFF' ) ) { | |
| 49 | + define( 'WP_FS__SIMULATE_FREEMIUS_OFF', false ); | |
| 50 | + } | |
| 51 | + | |
| 52 | + if ( ! defined( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES' ) ) { | |
| 53 | + /** | |
| 54 | + * @since 1.1.7.3 | |
| 55 | + * @author Vova Feldman (@svovaf) | |
| 56 | + * | |
| 57 | + * I'm not sure if shared servers periodically change IP, or the subdomain of the | |
| 58 | + * admin dashboard. Also, I've seen sites that have strange loop of switching | |
| 59 | + * between domains on a daily basis. Therefore, to eliminate the risk of | |
| 60 | + * multiple unwanted connectivity test pings, temporary ignore domain or | |
| 61 | + * server IP changes. | |
| 62 | + */ | |
| 63 | + define( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES', false ); | |
| 64 | + } | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * If your dev environment supports custom public network IP setup | |
| 68 | + * like VVV, please update WP_FS__LOCALHOST_IP with your public IP | |
| 69 | + * and uncomment it during dev. | |
| 70 | + */ | |
| 71 | + if ( ! defined( 'WP_FS__LOCALHOST_IP' ) ) { | |
| 72 | + // VVV default public network IP. | |
| 73 | + define( 'WP_FS__VVV_DEFAULT_PUBLIC_IP', '192.168.50.4' ); | |
| 74 | + | |
| 75 | +// define( 'WP_FS__LOCALHOST_IP', WP_FS__VVV_DEFAULT_PUBLIC_IP ); | |
| 76 | + } | |
| 77 | + | |
| 78 | + /** | |
| 79 | + * If true and running with secret key, the opt-in process | |
| 80 | + * will skip the email activation process which is invoked | |
| 81 | + * when the email of the context user already exist in Freemius | |
| 82 | + * database (as a security precaution, to prevent sharing user | |
| 83 | + * secret with unauthorized entity). | |
| 84 | + * | |
| 85 | + * IMPORTANT: | |
| 86 | + * AS A SECURITY PRECAUTION, WE VALIDATE THE TIMESTAMP OF THE OPT-IN REQUEST. | |
| 87 | + * THEREFORE, MAKE SURE THAT WHEN USING THIS PARAMETER,YOUR TESTING ENVIRONMENT'S | |
| 88 | + * CLOCK IS SYNCED. | |
| 89 | + */ | |
| 90 | + if ( ! defined( 'WP_FS__SKIP_EMAIL_ACTIVATION' ) ) { | |
| 91 | + define( 'WP_FS__SKIP_EMAIL_ACTIVATION', false ); | |
| 92 | + } | |
| 93 | + | |
| 94 | + | |
| 95 | + #-------------------------------------------------------------------------------- | |
| 96 | + #region Directories | |
| 97 | + #-------------------------------------------------------------------------------- | |
| 98 | + | |
| 99 | + if ( ! defined( 'WP_FS__DIR' ) ) { | |
| 100 | + define( 'WP_FS__DIR', dirname( __FILE__ ) ); | |
| 101 | + } | |
| 102 | + if ( ! defined( 'WP_FS__DIR_INCLUDES' ) ) { | |
| 103 | + define( 'WP_FS__DIR_INCLUDES', WP_FS__DIR . '/includes' ); | |
| 104 | + } | |
| 105 | + if ( ! defined( 'WP_FS__DIR_TEMPLATES' ) ) { | |
| 106 | + define( 'WP_FS__DIR_TEMPLATES', WP_FS__DIR . '/templates' ); | |
| 107 | + } | |
| 108 | + if ( ! defined( 'WP_FS__DIR_ASSETS' ) ) { | |
| 109 | + define( 'WP_FS__DIR_ASSETS', WP_FS__DIR . '/assets' ); | |
| 110 | + } | |
| 111 | + if ( ! defined( 'WP_FS__DIR_CSS' ) ) { | |
| 112 | + define( 'WP_FS__DIR_CSS', WP_FS__DIR_ASSETS . '/css' ); | |
| 113 | + } | |
| 114 | + if ( ! defined( 'WP_FS__DIR_JS' ) ) { | |
| 115 | + define( 'WP_FS__DIR_JS', WP_FS__DIR_ASSETS . '/js' ); | |
| 116 | + } | |
| 117 | + if ( ! defined( 'WP_FS__DIR_IMG' ) ) { | |
| 118 | + define( 'WP_FS__DIR_IMG', WP_FS__DIR_ASSETS . '/img' ); | |
| 119 | + } | |
| 120 | + if ( ! defined( 'WP_FS__DIR_SDK' ) ) { | |
| 121 | + define( 'WP_FS__DIR_SDK', WP_FS__DIR_INCLUDES . '/sdk' ); | |
| 122 | + } | |
| 123 | + | |
| 124 | + #endregion | |
| 125 | + | |
| 126 | + /** | |
| 127 | + * Domain / URL / Address | |
| 128 | + */ | |
| 129 | + define( 'WP_FS__ROOT_DOMAIN_PRODUCTION', 'freemius.com' ); | |
| 130 | + define( 'WP_FS__DOMAIN_PRODUCTION', 'wp.freemius.com' ); | |
| 131 | + define( 'WP_FS__ADDRESS_PRODUCTION', 'https://' . WP_FS__DOMAIN_PRODUCTION ); | |
| 132 | + | |
| 133 | + if ( ! defined( 'WP_FS__DOMAIN_LOCALHOST' ) ) { | |
| 134 | + define( 'WP_FS__DOMAIN_LOCALHOST', 'wp.freemius' ); | |
| 135 | + } | |
| 136 | + if ( ! defined( 'WP_FS__ADDRESS_LOCALHOST' ) ) { | |
| 137 | + define( 'WP_FS__ADDRESS_LOCALHOST', 'http://' . WP_FS__DOMAIN_LOCALHOST . ':8080' ); | |
| 138 | + } | |
| 139 | + | |
| 140 | + if ( ! defined( 'WP_FS__TESTING_DOMAIN' ) ) { | |
| 141 | + define( 'WP_FS__TESTING_DOMAIN', 'fswp' ); | |
| 142 | + } | |
| 143 | + | |
| 144 | + #-------------------------------------------------------------------------------- | |
| 145 | + #region HTTP | |
| 146 | + #-------------------------------------------------------------------------------- | |
| 147 | + | |
| 148 | + if ( ! defined( 'WP_FS__IS_HTTP_REQUEST' ) ) { | |
| 149 | + define( 'WP_FS__IS_HTTP_REQUEST', isset( $_SERVER['HTTP_HOST'] ) && isset( $_SERVER['REQUEST_METHOD'] ) ); | |
| 150 | + } | |
| 151 | + | |
| 152 | + if ( ! defined( 'WP_FS__IS_HTTPS' ) ) { | |
| 153 | + define( 'WP_FS__IS_HTTPS', ( WP_FS__IS_HTTP_REQUEST && | |
| 154 | + // Checks if CloudFlare's HTTPS (Flexible SSL support). | |
| 155 | + isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && | |
| 156 | + 'https' === strtolower( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) | |
| 157 | + ) || | |
| 158 | + // Check if HTTPS request. | |
| 159 | + ( isset( $_SERVER['HTTPS'] ) && 'on' == $_SERVER['HTTPS'] ) || | |
| 160 | + ( isset( $_SERVER['SERVER_PORT'] ) && 443 == $_SERVER['SERVER_PORT'] ) | |
| 161 | + ); | |
| 162 | + } | |
| 163 | + | |
| 164 | + if ( ! defined( 'WP_FS__IS_POST_REQUEST' ) ) { | |
| 165 | + define( 'WP_FS__IS_POST_REQUEST', ( WP_FS__IS_HTTP_REQUEST && | |
| 166 | + strtoupper( $_SERVER['REQUEST_METHOD'] ) == 'POST' ) ); | |
| 167 | + } | |
| 168 | + | |
| 169 | + if ( ! defined( 'WP_FS__REMOTE_ADDR' ) ) { | |
| 170 | + define( 'WP_FS__REMOTE_ADDR', fs_get_ip() ); | |
| 171 | + } | |
| 172 | + | |
| 173 | + if ( ! defined( 'WP_FS__IS_LOCALHOST' ) ) { | |
| 174 | + if ( defined( 'WP_FS__LOCALHOST_IP' ) ) { | |
| 175 | + define( 'WP_FS__IS_LOCALHOST', ( WP_FS__LOCALHOST_IP === WP_FS__REMOTE_ADDR ) ); | |
| 176 | + } else { | |
| 177 | + define( 'WP_FS__IS_LOCALHOST', WP_FS__IS_HTTP_REQUEST && | |
| 178 | + is_string( WP_FS__REMOTE_ADDR ) && | |
| 179 | + ( substr( WP_FS__REMOTE_ADDR, 0, 4 ) === '127.' || | |
| 180 | + WP_FS__REMOTE_ADDR === '::1' ) | |
| 181 | + ); | |
| 182 | + } | |
| 183 | + } | |
| 184 | + | |
| 185 | + if ( ! defined( 'WP_FS__IS_LOCALHOST_FOR_SERVER' ) ) { | |
| 186 | + define( 'WP_FS__IS_LOCALHOST_FOR_SERVER', ( ! WP_FS__IS_HTTP_REQUEST || | |
| 187 | + false !== strpos( $_SERVER['HTTP_HOST'], 'localhost' ) ) ); | |
| 188 | + } | |
| 189 | + | |
| 190 | + #endregion | |
| 191 | + | |
| 192 | + if ( ! defined( 'WP_FS__IS_PRODUCTION_MODE' ) ) { | |
| 193 | + // By default, run with Freemius production servers. | |
| 194 | + define( 'WP_FS__IS_PRODUCTION_MODE', true ); | |
| 195 | + } | |
| 196 | + | |
| 197 | + if ( ! defined( 'WP_FS__ADDRESS' ) ) { | |
| 198 | + define( 'WP_FS__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? WP_FS__ADDRESS_PRODUCTION : WP_FS__ADDRESS_LOCALHOST ) ); | |
| 199 | + } | |
| 200 | + | |
| 201 | + | |
| 202 | + #-------------------------------------------------------------------------------- | |
| 203 | + #region API | |
| 204 | + #-------------------------------------------------------------------------------- | |
| 205 | + | |
| 206 | + if ( ! defined( 'WP_FS__API_ADDRESS_LOCALHOST' ) ) { | |
| 207 | + define( 'WP_FS__API_ADDRESS_LOCALHOST', 'http://api.freemius-local.com:8080' ); | |
| 208 | + } | |
| 209 | + if ( ! defined( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST' ) ) { | |
| 210 | + define( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST', 'http://sandbox-api.freemius:8080' ); | |
| 211 | + } | |
| 212 | + | |
| 213 | + // Set API address for local testing. | |
| 214 | + if ( ! WP_FS__IS_PRODUCTION_MODE ) { | |
| 215 | + if ( ! defined( 'FS_API__ADDRESS' ) ) { | |
| 216 | + define( 'FS_API__ADDRESS', WP_FS__API_ADDRESS_LOCALHOST ); | |
| 217 | + } | |
| 218 | + if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) { | |
| 219 | + define( 'FS_API__SANDBOX_ADDRESS', WP_FS__API_SANDBOX_ADDRESS_LOCALHOST ); | |
| 220 | + } | |
| 221 | + } | |
| 222 | + | |
| 223 | + #endregion | |
| 224 | + | |
| 225 | + #-------------------------------------------------------------------------------- | |
| 226 | + #region Checkout | |
| 227 | + #-------------------------------------------------------------------------------- | |
| 228 | + | |
| 229 | + if ( ! defined( 'FS_CHECKOUT__ADDRESS_PRODUCTION' ) ) { | |
| 230 | + define( 'FS_CHECKOUT__ADDRESS_PRODUCTION', 'https://checkout.freemius.com' ); | |
| 231 | + } | |
| 232 | + | |
| 233 | + if ( ! defined( 'FS_CHECKOUT__ADDRESS_LOCALHOST' ) ) { | |
| 234 | + define( 'FS_CHECKOUT__ADDRESS_LOCALHOST', 'http://checkout.freemius-local.com:8080' ); | |
| 235 | + } | |
| 236 | + | |
| 237 | + if ( ! defined( 'FS_CHECKOUT__ADDRESS' ) ) { | |
| 238 | + define( 'FS_CHECKOUT__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? FS_CHECKOUT__ADDRESS_PRODUCTION : FS_CHECKOUT__ADDRESS_LOCALHOST ) ); | |
| 239 | + } | |
| 240 | + | |
| 241 | + #endregion | |
| 242 | + | |
| 243 | + define( 'WP_FS___OPTION_PREFIX', 'fs' . ( WP_FS__IS_PRODUCTION_MODE ? '' : '_dbg' ) . '_' ); | |
| 244 | + | |
| 245 | + if ( ! defined( 'WP_FS__ACCOUNTS_OPTION_NAME' ) ) { | |
| 246 | + define( 'WP_FS__ACCOUNTS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'accounts' ); | |
| 247 | + } | |
| 248 | + if ( ! defined( 'WP_FS__API_CACHE_OPTION_NAME' ) ) { | |
| 249 | + define( 'WP_FS__API_CACHE_OPTION_NAME', WP_FS___OPTION_PREFIX . 'api_cache' ); | |
| 250 | + } | |
| 251 | + if ( ! defined( 'WP_FS__GDPR_OPTION_NAME' ) ) { | |
| 252 | + define( 'WP_FS__GDPR_OPTION_NAME', WP_FS___OPTION_PREFIX . 'gdpr' ); | |
| 253 | + } | |
| 254 | + define( 'WP_FS__OPTIONS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'options' ); | |
| 255 | + | |
| 256 | + /** | |
| 257 | + * Module types | |
| 258 | + * | |
| 259 | + * @since 1.2.2 | |
| 260 | + */ | |
| 261 | + define( 'WP_FS__MODULE_TYPE_PLUGIN', 'plugin' ); | |
| 262 | + define( 'WP_FS__MODULE_TYPE_THEME', 'theme' ); | |
| 263 | + | |
| 264 | + /** | |
| 265 | + * Billing Frequencies | |
| 266 | + */ | |
| 267 | + define( 'WP_FS__PERIOD_ANNUALLY', 'annual' ); | |
| 268 | + define( 'WP_FS__PERIOD_MONTHLY', 'monthly' ); | |
| 269 | + define( 'WP_FS__PERIOD_LIFETIME', 'lifetime' ); | |
| 270 | + | |
| 271 | + /** | |
| 272 | + * Plans | |
| 273 | + */ | |
| 274 | + define( 'WP_FS__PLAN_DEFAULT_PAID', false ); | |
| 275 | + define( 'WP_FS__PLAN_FREE', 'free' ); | |
| 276 | + define( 'WP_FS__PLAN_TRIAL', 'trial' ); | |
| 277 | + | |
| 278 | + /** | |
| 279 | + * Times in seconds | |
| 280 | + */ | |
| 281 | + if ( ! defined( 'WP_FS__TIME_5_MIN_IN_SEC' ) ) { | |
| 282 | + define( 'WP_FS__TIME_5_MIN_IN_SEC', 300 ); | |
| 283 | + } | |
| 284 | + if ( ! defined( 'WP_FS__TIME_10_MIN_IN_SEC' ) ) { | |
| 285 | + define( 'WP_FS__TIME_10_MIN_IN_SEC', 600 ); | |
| 286 | + } | |
| 287 | +// define( 'WP_FS__TIME_15_MIN_IN_SEC', 900 ); | |
| 288 | + if ( ! defined( 'WP_FS__TIME_12_HOURS_IN_SEC' ) ) { | |
| 289 | + define( 'WP_FS__TIME_12_HOURS_IN_SEC', 43200 ); | |
| 290 | + } | |
| 291 | + if ( ! defined( 'WP_FS__TIME_24_HOURS_IN_SEC' ) ) { | |
| 292 | + define( 'WP_FS__TIME_24_HOURS_IN_SEC', WP_FS__TIME_12_HOURS_IN_SEC * 2 ); | |
| 293 | + } | |
| 294 | + if ( ! defined( 'WP_FS__TIME_WEEK_IN_SEC' ) ) { | |
| 295 | + define( 'WP_FS__TIME_WEEK_IN_SEC', 7 * WP_FS__TIME_24_HOURS_IN_SEC ); | |
| 296 | + } | |
| 297 | + | |
| 298 | + #-------------------------------------------------------------------------------- | |
| 299 | + #region Debugging | |
| 300 | + #-------------------------------------------------------------------------------- | |
| 301 | + | |
| 302 | + if ( ! defined( 'WP_FS__DEBUG_SDK' ) ) { | |
| 303 | + $debug_mode = get_option( 'fs_debug_mode', null ); | |
| 304 | + | |
| 305 | + if ( $debug_mode === null ) { | |
| 306 | + $debug_mode = false; | |
| 307 | + add_option( 'fs_debug_mode', $debug_mode ); | |
| 308 | + } | |
| 309 | + | |
| 310 | + define( 'WP_FS__DEBUG_SDK', is_numeric( $debug_mode ) ? ( 0 < $debug_mode ) : WP_FS__DEV_MODE ); | |
| 311 | + } | |
| 312 | + | |
| 313 | + if ( ! defined( 'WP_FS__ECHO_DEBUG_SDK' ) ) { | |
| 314 | + define( 'WP_FS__ECHO_DEBUG_SDK', WP_FS__DEV_MODE && ! empty( $_GET['fs_dbg_echo'] ) ); | |
| 315 | + } | |
| 316 | + if ( ! defined( 'WP_FS__LOG_DATETIME_FORMAT' ) ) { | |
| 317 | + define( 'WP_FS__LOG_DATETIME_FORMAT', 'Y-m-d H:i:s' ); | |
| 318 | + } | |
| 319 | + if ( ! defined( 'FS_API__LOGGER_ON' ) ) { | |
| 320 | + define( 'FS_API__LOGGER_ON', WP_FS__DEBUG_SDK ); | |
| 321 | + } | |
| 322 | + | |
| 323 | + if ( WP_FS__ECHO_DEBUG_SDK ) { | |
| 324 | + error_reporting( E_ALL ); | |
| 325 | + } | |
| 326 | + | |
| 327 | + #endregion | |
| 328 | + | |
| 329 | + if ( ! defined( 'WP_FS__SCRIPT_START_TIME' ) ) { | |
| 330 | + define( 'WP_FS__SCRIPT_START_TIME', time() ); | |
| 331 | + } | |
| 332 | + if ( ! defined( 'WP_FS__DEFAULT_PRIORITY' ) ) { | |
| 333 | + define( 'WP_FS__DEFAULT_PRIORITY', 10 ); | |
| 334 | + } | |
| 335 | + if ( ! defined( 'WP_FS__LOWEST_PRIORITY' ) ) { | |
| 336 | + define( 'WP_FS__LOWEST_PRIORITY', 999999999 ); | |
| 337 | + } | |
| 338 | + | |
| 339 | + #-------------------------------------------------------------------------------- | |
| 340 | + #region Multisite Network | |
| 341 | + #-------------------------------------------------------------------------------- | |
| 342 | + | |
| 343 | + /** | |
| 344 | + * Do not use this define directly, it will have the wrong value | |
| 345 | + * during plugin uninstall/deletion when the inclusion of the plugin | |
| 346 | + * is triggered due to registration with register_uninstall_hook(). | |
| 347 | + * | |
| 348 | + * Instead, use fs_is_network_admin(). | |
| 349 | + * | |
| 350 | + * @author Vova Feldman (@svovaf) | |
| 351 | + */ | |
| 352 | + if ( ! defined( 'WP_FS__IS_NETWORK_ADMIN' ) ) { | |
| 353 | + define( 'WP_FS__IS_NETWORK_ADMIN', | |
| 354 | + is_multisite() && | |
| 355 | + ( is_network_admin() || | |
| 356 | + ( ( defined( 'DOING_AJAX' ) && DOING_AJAX && | |
| 357 | + ( isset( $_REQUEST['_fs_network_admin'] ) && 'true' === $_REQUEST['_fs_network_admin'] /*|| | |
| 358 | + ( ! empty( $_REQUEST['action'] ) && 'delete-plugin' === $_REQUEST['action'] )*/ ) | |
| 359 | + ) || | |
| 360 | + // Plugin uninstall. | |
| 361 | + defined( 'WP_UNINSTALL_PLUGIN' ) ) | |
| 362 | + ) | |
| 363 | + ); | |
| 364 | + } | |
| 365 | + | |
| 366 | + /** | |
| 367 | + * Do not use this define directly, it will have the wrong value | |
| 368 | + * during plugin uninstall/deletion when the inclusion of the plugin | |
| 369 | + * is triggered due to registration with register_uninstall_hook(). | |
| 370 | + * | |
| 371 | + * Instead, use fs_is_blog_admin(). | |
| 372 | + * | |
| 373 | + * @author Vova Feldman (@svovaf) | |
| 374 | + */ | |
| 375 | + if ( ! defined( 'WP_FS__IS_BLOG_ADMIN' ) ) { | |
| 376 | + define( 'WP_FS__IS_BLOG_ADMIN', is_blog_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_REQUEST['_fs_blog_admin'] ) ) ); | |
| 377 | + } | |
| 378 | + | |
| 379 | + if ( ! defined( 'WP_FS__SHOW_NETWORK_EVEN_WHEN_DELEGATED' ) ) { | |
| 380 | + // Set to true to show network level settings even if delegated to site admins. | |
| 381 | + define( 'WP_FS__SHOW_NETWORK_EVEN_WHEN_DELEGATED', false ); | |
| 382 | + } | |
| 383 | + | |
| 384 | + #endregion | |
| 385 | + | |
| 386 | + if ( ! defined( 'WP_FS__DEMO_MODE' ) ) { | |
| 387 | + define( 'WP_FS__DEMO_MODE', false ); | |
| 388 | + } | |
| 389 | + if ( ! defined( 'FS_SDK__SSLVERIFY' ) ) { | |
| 390 | + define( 'FS_SDK__SSLVERIFY', false ); | |
| 391 | + } | |