| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
die( 'You are not allowed to call this page directly.' ); |
| 4 |
} |
| 5 |
|
| 6 |
class FrmFormTemplateApi extends FrmFormApi { |
| 7 |
|
| 8 |
/** |
| 9 |
* @var string |
| 10 |
*/ |
| 11 |
protected static $code_option_name = 'frm_free_license_code'; |
| 12 |
|
| 13 |
/** |
| 14 |
* @var string |
| 15 |
*/ |
| 16 |
private static $base_api_url = 'https://formidableforms.com/wp-json/form-templates/v1/'; |
| 17 |
|
| 18 |
/** |
| 19 |
* @var string|null |
| 20 |
*/ |
| 21 |
protected static $free_license; |
| 22 |
|
| 23 |
/** |
| 24 |
* @var int |
| 25 |
*/ |
| 26 |
protected $new_days = 30; |
| 27 |
|
| 28 |
/** |
| 29 |
* @var string |
| 30 |
*/ |
| 31 |
protected $cache_timeout = '+12 hours'; |
| 32 |
|
| 33 |
/** |
| 34 |
* @since 3.06 |
| 35 |
* |
| 36 |
* @return void |
| 37 |
*/ |
| 38 |
protected function set_cache_key() { |
| 39 |
$this->cache_key = 'frm_form_templates_l'; |
| 40 |
|
| 41 |
if ( ! empty( $this->license ) ) { |
| 42 |
$this->cache_key .= md5( $this->license ); |
| 43 |
} else { |
| 44 |
$this->cache_key .= '01fd72122f4a90f15684915c729d4368'; |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* @since 3.06 |
| 50 |
* |
| 51 |
* @return string |
| 52 |
*/ |
| 53 |
protected function api_url() { |
| 54 |
$url = self::$base_api_url . 'list'; |
| 55 |
|
| 56 |
if ( empty( $this->license ) ) { |
| 57 |
$url .= '?l=RlJFRVRFTVBMQVRFUyEhIQ%3D%3D&v=' . FrmAppHelper::plugin_version(); |
| 58 |
} |
| 59 |
|
| 60 |
return $url; |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* @since 3.06 |
| 65 |
* |
| 66 |
* @return string[] |
| 67 |
*/ |
| 68 |
protected function skip_categories() { |
| 69 |
return array(); |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* Set the free license code option value. |
| 74 |
* |
| 75 |
* @since 6.25 |
| 76 |
* |
| 77 |
* @param string $code The license code to set. |
| 78 |
* |
| 79 |
* @return void |
| 80 |
*/ |
| 81 |
public static function set_free_license_code( $code ) { |
| 82 |
update_option( self::$code_option_name, $code, false ); |
| 83 |
} |
| 84 |
|
| 85 |
/** |
| 86 |
* Get the free license code option value. |
| 87 |
* |
| 88 |
* @since 6.25 |
| 89 |
* |
| 90 |
* @return false|string The license code, or false if not set. |
| 91 |
*/ |
| 92 |
public static function get_free_license_code() { |
| 93 |
return get_option( self::$code_option_name ); |
| 94 |
} |
| 95 |
|
| 96 |
/** |
| 97 |
* AJAX Hook for signing free users up for a template API key |
| 98 |
* |
| 99 |
* @return void |
| 100 |
*/ |
| 101 |
public static function signup() { |
| 102 |
_deprecated_function( __METHOD__, '6.20' ); |
| 103 |
} |
| 104 |
|
| 105 |
/** |
| 106 |
* @return string |
| 107 |
*/ |
| 108 |
public function get_free_license() { |
| 109 |
_deprecated_function( __METHOD__, '6.20' ); |
| 110 |
return ''; |
| 111 |
} |
| 112 |
|
| 113 |
/** |
| 114 |
* Check to make sure the free code is being used. |
| 115 |
* |
| 116 |
* @since 4.09.02 |
| 117 |
* |
| 118 |
* @return bool |
| 119 |
*/ |
| 120 |
public function has_free_access() { |
| 121 |
_deprecated_function( __METHOD__, '6.20' ); |
| 122 |
return true; |
| 123 |
} |
| 124 |
} |
| 125 |
|