| @@ -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,110 +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 | - } | |
| 35 | - | |
| 36 | - if ( self::unapproved_zanox_merchants_exist() ) { | |
| 37 | - dfrapi_admin_messages( 'unapproved_zanox_merchants' ); | |
| 38 | - } | |
| 12 | + public function __construct() { | |
| 39 | 13 | } |
| 40 | 14 | |
| 41 | - static function api_keys_exist() { | |
| 42 | - | |
| 43 | - $configuration = (array) get_option( 'dfrapi_configuration' ); | |
| 44 | - $access_id = false; | |
| 45 | - $secret_key = false; | |
| 46 | - | |
| 47 | - if ( isset( $configuration['access_id'] ) && ( $configuration['access_id'] != '' ) ) { | |
| 48 | - $access_id = $configuration['access_id']; | |
| 49 | - } | |
| 50 | - | |
| 51 | - if ( isset( $configuration['secret_key'] ) && ( $configuration['secret_key'] != '' ) ) { | |
| 52 | - $secret_key = $configuration['secret_key']; | |
| 53 | - } | |
| 54 | - | |
| 55 | - if ( $access_id && $secret_key ) { | |
| 56 | - return true; | |
| 57 | - } | |
| 58 | - | |
| 59 | - 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(); | |
| 60 | 19 | } |
| 61 | - | |
| 62 | - static function network_is_selected() { | |
| 63 | - $networks = (array) get_option( 'dfrapi_networks' ); | |
| 64 | - if ( !empty( $networks['ids'] ) ) { | |
| 65 | - return true; | |
| 66 | - } | |
| 67 | - 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(); | |
| 68 | 25 | } |
| 69 | - | |
| 70 | - static function merchant_is_selected() { | |
| 71 | - $merchants = (array) get_option( 'dfrapi_merchants' ); | |
| 72 | - if ( !empty( $merchants['ids'] ) ) { | |
| 73 | - return true; | |
| 74 | - } | |
| 75 | - 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(); | |
| 76 | 31 | } |
| 77 | - | |
| 78 | - static function usage_over_90_percent() { | |
| 79 | - $percentage = dfrapi_get_api_usage_percentage(); | |
| 80 | - if ( $percentage >= 90 ) { | |
| 81 | - return true; | |
| 82 | - } | |
| 83 | - 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(); | |
| 84 | 37 | } |
| 85 | - | |
| 86 | - static function missing_affiliate_ids() { | |
| 87 | - $networks = get_option( 'dfrapi_networks', array() ); | |
| 88 | - if ( !empty( $networks ) ) { | |
| 89 | - foreach ( $networks['ids'] as $network ) { | |
| 90 | - if ( empty( $network['aid'] ) ) { | |
| 91 | - return true; | |
| 92 | - } | |
| 93 | - } | |
| 94 | - } | |
| 95 | - 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(); | |
| 96 | 43 | } |
| 97 | - | |
| 98 | - static function check_gmt_time() { | |
| 99 | - $gmt_time = gmdate( 'Gis' ); | |
| 100 | - if ( $gmt_time > 80000 && $gmt_time < 82000 ) { | |
| 101 | - return true; | |
| 102 | - } | |
| 103 | - return false; | |
| 104 | - } | |
| 105 | - | |
| 106 | - static function unapproved_zanox_merchants_exist() { | |
| 107 | - global $wpdb; | |
| 108 | - $results = $wpdb->get_results( "SELECT option_name FROM $wpdb->options WHERE option_value = 'dfrapi_unapproved_zanox_merchant' ", OBJECT ); | |
| 109 | - if ( !empty( $results ) ) { | |
| 110 | - return TRUE; | |
| 111 | - } | |
| 112 | - return FALSE; | |
| 113 | - } | |
| 114 | - | |
| 44 | + | |
| 115 | 45 | } // class Dfrapi_Env |
| 116 | 46 | |
| 117 | 47 | } // class_exists check |