PluginProbe
Datafeedr API / 1.4.3
Datafeedr API v1.4.3
1.4.3 1.4.2 1.0.125 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.3 1.0.30 1.0.31 1.0.32 All 182 releases
← All changes | classes/class-dfrapi-env.php +27 -72 1.0.3 → 1.4.3 View file →
@@ -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,85 +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 - }
12 + public function __construct() {
31 13 }
32 14
33 - static function api_keys_exist() {
34 -
35 - $configuration = (array) get_option( 'dfrapi_configuration' );
36 - $access_id = false;
37 - $secret_key = false;
38 -
39 - if ( isset( $configuration['access_id'] ) && ( $configuration['access_id'] != '' ) ) {
40 - $access_id = $configuration['access_id'];
41 - }
42 -
43 - if ( isset( $configuration['secret_key'] ) && ( $configuration['secret_key'] != '' ) ) {
44 - $secret_key = $configuration['secret_key'];
45 - }
46 -
47 - if ( $access_id && $secret_key ) {
48 - return true;
49 - }
50 -
51 - 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();
52 19 }
53 -
54 - static function network_is_selected() {
55 - $networks = (array) get_option( 'dfrapi_networks' );
56 - if ( !empty( $networks['ids'] ) ) {
57 - return true;
58 - }
59 - 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();
60 25 }
61 -
62 - static function merchant_is_selected() {
63 - $merchants = (array) get_option( 'dfrapi_merchants' );
64 - if ( !empty( $merchants['ids'] ) ) {
65 - return true;
66 - }
67 - 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();
68 31 }
69 -
70 - static function usage_over_90_percent() {
71 - $percentage = dfrapi_get_api_usage_percentage();
72 - if ( $percentage >= 90 ) {
73 - return true;
74 - }
75 - 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();
76 37 }
77 -
78 - static function missing_affiliate_ids() {
79 - $networks = get_option( 'dfrapi_networks', array() );
80 - if ( !empty( $networks ) ) {
81 - foreach ( $networks['ids'] as $network ) {
82 - if ( empty( $network['aid'] ) ) {
83 - return true;
84 - }
85 - }
86 - }
87 - 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();
88 43 }
89 -
44 +
90 45 } // class Dfrapi_Env
91 46
92 47 } // class_exists check