| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly | |
| 3 | +defined( 'ABSPATH' ) || exit; | |
| 4 | 4 | |
| 5 | 5 | if ( ! class_exists( 'Dfrapi_Env' ) ) { |
| 6 | 6 | |
| 7 | 7 | /** |
| @@ -8,97 +8,40 @@ | ||
| 8 | 8 | * Check environment and print errors.. |
| 9 | 9 | */ |
| 10 | 10 | class Dfrapi_Env { |
| 11 | 11 | |
| 12 | - function __construct() { | |
| 13 | - | |
| 14 | - // Cascading Errors | |
| 15 | - if ( !self::api_keys_exist() ) { | |
| 16 | - dfrapi_admin_messages( 'missing_api_keys' ); | |
| 17 | - } elseif ( !self::network_is_selected() ) { | |
| 18 | - dfrapi_admin_messages( 'missing_network_ids' ); | |
| 19 | - } elseif ( !self::merchant_is_selected() ) { | |
| 20 | - dfrapi_admin_messages( 'missing_merchant_ids' ); | |
| 21 | - } | |
| 22 | - | |
| 23 | - // Non-cascading Errors | |
| 24 | - if ( self::usage_over_90_percent() ) { | |
| 25 | - dfrapi_admin_messages( 'usage_over_90_percent' ); | |
| 26 | - } | |
| 27 | - | |
| 28 | - if ( self::missing_affiliate_ids() ) { | |
| 29 | - dfrapi_admin_messages( 'missing_affiliate_ids' ); | |
| 30 | - } | |
| 31 | - | |
| 32 | - if ( self::check_gmt_time() ) { | |
| 33 | - dfrapi_admin_messages( 'database_rotation' ); | |
| 34 | - } | |
| 12 | + public function __construct() { | |
| 35 | 13 | } |
| 36 | 14 | |
| 37 | - static function api_keys_exist() { | |
| 38 | - | |
| 39 | - $configuration = (array) get_option( 'dfrapi_configuration' ); | |
| 40 | - $access_id = false; | |
| 41 | - $secret_key = false; | |
| 42 | - | |
| 43 | - if ( isset( $configuration['access_id'] ) && ( $configuration['access_id'] != '' ) ) { | |
| 44 | - $access_id = $configuration['access_id']; | |
| 45 | - } | |
| 46 | - | |
| 47 | - if ( isset( $configuration['secret_key'] ) && ( $configuration['secret_key'] != '' ) ) { | |
| 48 | - $secret_key = $configuration['secret_key']; | |
| 49 | - } | |
| 50 | - | |
| 51 | - if ( $access_id && $secret_key ) { | |
| 52 | - return true; | |
| 53 | - } | |
| 54 | - | |
| 55 | - return false; | |
| 15 | + public static function api_keys_exist(): bool { | |
| 16 | + _deprecated_function( __METHOD__, '1.3.0', 'dfrapi_datafeedr_api_keys_exist()' ); | |
| 17 | + | |
| 18 | + return dfrapi_datafeedr_api_keys_exist(); | |
| 56 | 19 | } |
| 57 | - | |
| 58 | - static function network_is_selected() { | |
| 59 | - $networks = (array) get_option( 'dfrapi_networks' ); | |
| 60 | - if ( !empty( $networks['ids'] ) ) { | |
| 61 | - return true; | |
| 62 | - } | |
| 63 | - return false; | |
| 20 | + | |
| 21 | + public static function network_is_selected(): bool { | |
| 22 | + _deprecated_function( __METHOD__, '1.3.0', 'dfrapi_user_has_selected_networks()' ); | |
| 23 | + | |
| 24 | + return dfrapi_user_has_selected_networks(); | |
| 64 | 25 | } |
| 65 | - | |
| 66 | - static function merchant_is_selected() { | |
| 67 | - $merchants = (array) get_option( 'dfrapi_merchants' ); | |
| 68 | - if ( !empty( $merchants['ids'] ) ) { | |
| 69 | - return true; | |
| 70 | - } | |
| 71 | - return false; | |
| 26 | + | |
| 27 | + public static function merchant_is_selected(): bool { | |
| 28 | + _deprecated_function( __METHOD__, '1.3.0', 'dfrapi_user_has_selected_merchants()' ); | |
| 29 | + | |
| 30 | + return dfrapi_user_has_selected_merchants(); | |
| 72 | 31 | } |
| 73 | - | |
| 74 | - static function usage_over_90_percent() { | |
| 75 | - $percentage = dfrapi_get_api_usage_percentage(); | |
| 76 | - if ( $percentage >= 90 ) { | |
| 77 | - return true; | |
| 78 | - } | |
| 79 | - return false; | |
| 32 | + | |
| 33 | + public static function usage_over_90_percent(): bool { | |
| 34 | + _deprecated_function( __METHOD__, '1.3.0', 'dfrapi_api_usage_over_90_percent()' ); | |
| 35 | + | |
| 36 | + return dfrapi_api_usage_over_90_percent(); | |
| 80 | 37 | } |
| 81 | - | |
| 82 | - static function missing_affiliate_ids() { | |
| 83 | - $networks = get_option( 'dfrapi_networks', array() ); | |
| 84 | - if ( !empty( $networks ) ) { | |
| 85 | - foreach ( $networks['ids'] as $network ) { | |
| 86 | - if ( empty( $network['aid'] ) ) { | |
| 87 | - return true; | |
| 88 | - } | |
| 89 | - } | |
| 90 | - } | |
| 91 | - return false; | |
| 38 | + | |
| 39 | + public static function missing_affiliate_ids(): bool { | |
| 40 | + _deprecated_function( __METHOD__, '1.3.0', 'dfrapi_user_is_missing_affiliate_ids()' ); | |
| 41 | + | |
| 42 | + return dfrapi_user_is_missing_affiliate_ids(); | |
| 92 | 43 | } |
| 93 | - | |
| 94 | - static function check_gmt_time() { | |
| 95 | - $gmt_time = gmdate( 'Gis' ); | |
| 96 | - if ( $gmt_time > 80000 && $gmt_time < 82000 ) { | |
| 97 | - return true; | |
| 98 | - } | |
| 99 | - return false; | |
| 100 | - } | |
| 101 | - | |
| 44 | + | |
| 102 | 45 | } // class Dfrapi_Env |
| 103 | 46 | |
| 104 | 47 | } // class_exists check |