| @@ -4,15 +4,17 @@ | ||
| 4 | 4 | Plugin URI: https://www.datafeedr.com |
| 5 | 5 | Description: Connect to the Datafeedr API and configure your API settings. |
| 6 | 6 | Author: datafeedr.com |
| 7 | 7 | Author URI: https://www.datafeedr.com |
| 8 | +Text Domain: datafeedr-api | |
| 8 | 9 | License: GPL v3 |
| 10 | +Requires PHP: 7.4 | |
| 9 | 11 | Requires at least: 3.8 |
| 10 | -Tested up to: 5.7-alpha | |
| 11 | -Version: 1.0.125 | |
| 12 | +Tested up to: 7.1 | |
| 13 | +Version: 1.4.3 | |
| 12 | 14 | |
| 13 | 15 | Datafeedr API Plugin |
| 14 | -Copyright (C) 2021, Datafeedr - [email protected] | |
| 16 | +Copyright (C) 2026, Datafeedr - [email protected] | |
| 15 | 17 | |
| 16 | 18 | This program is free software: you can redistribute it and/or modify |
| 17 | 19 | it under the terms of the GNU General Public License as published by |
| 18 | 20 | the Free Software Foundation, either version 3 of the License, or |
| @@ -26,24 +28,122 @@ | ||
| 26 | 28 | You should have received a copy of the GNU General Public License |
| 27 | 29 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 28 | 30 | */ |
| 29 | 31 | |
| 30 | -if ( defined( 'DATAFEEDR_DEV' ) && true === DATAFEEDR_DEV ) { | |
| 32 | +defined( 'ABSPATH' ) || exit; | |
| 31 | 33 | |
| 32 | - add_action( 'admin_notices', 'dfrapi_development_version_notice' ); | |
| 33 | - function dfrapi_development_version_notice() { | |
| 34 | - $class = 'notice notice-error'; | |
| 35 | - $title = 'WARNING!!!'; | |
| 36 | - $message = 'You are now using a development version of the Datafeedr API plugin. Things WILL BREAK. We do NOT recommend using this version of the plugin! You have been warned.'; | |
| 37 | - echo sprintf( | |
| 38 | - '<div class="%1$s"><p><strong>%2$s</strong><br />%3$s</p></div>', | |
| 39 | - esc_attr( $class ), | |
| 40 | - esc_html( $title ), | |
| 41 | - esc_html( $message ) | |
| 42 | - ); | |
| 34 | +/** | |
| 35 | + * Define constants. | |
| 36 | + */ | |
| 37 | +define( 'DFRAPI_VERSION', '1.4.3' ); | |
| 38 | +define( 'DFRAPI_URL', plugin_dir_url( __FILE__ ) ); // https://example.com/wp-content/plugins/datafeedr-api/ | |
| 39 | +define( 'DFRAPI_PATH', plugin_dir_path( __FILE__ ) ); // /absolute/path/to/wp-content/plugins/datafeedr-api/ | |
| 40 | +define( 'DFRAPI_BASENAME', plugin_basename( __FILE__ ) ); // datafeedr-api/datafeedr-api.php | |
| 41 | +define( 'DFRAPI_PLUGIN_FILE', __FILE__ ); // /absolute/path/to/wp-content/plugins/datafeedr-api/datafeedr-api.php | |
| 42 | +define( 'DFRAPI_DOMAIN', 'datafeedr-api' ); // Deprecated as of 2022-02-10 14:18:51 | |
| 43 | +define( 'DFRAPI_HOME_URL', 'https://www.datafeedr.com' ); | |
| 44 | +define( 'DFRAPI_KEYS_URL', 'https://datafeedr.me/api' ); | |
| 45 | +define( 'DFRAPI_USER_URL', 'https://datafeedr.me/dashboard' ); | |
| 46 | +define( 'DFRAPI_HELP_URL', 'https://datafeedr.me/contact' ); | |
| 47 | +define( 'DFRAPI_BUG_REPORTS_URL', 'https://datafeedr.me/docs' ); | |
| 48 | +define( 'DFRAPI_QNA_URL', 'https://datafeedr.me/docs' ); | |
| 49 | +define( 'DFRAPI_DOCS_URL', 'https://datafeedr.me/docs' ); | |
| 50 | +define( 'DFRAPI_DOCS_SEARCH_URL', 'https://datafeedrapi.helpscoutdocs.com/search?query=' ); | |
| 51 | +define( 'DFRAPI_REPORT_BUG_URL', 'https://datafeedr.me/contact' ); | |
| 52 | +define( 'DFRAPI_ASK_QUESTION_URL', 'https://datafeedr.me/contact' ); | |
| 53 | +define( 'DFRAPI_EMAIL_US_URL', 'https://datafeedr.me/contact' ); | |
| 54 | +define( 'DFRAPI_SUPPORT_EMAIL', '[email protected]' ); | |
| 55 | +define( 'DFRAPI_COMPLEX_QUERY_SCORE', 10000 ); | |
| 56 | +define( 'DFRAPI_EXCESSIVE_MERCHANT_COUNT', 1000 ); | |
| 57 | + | |
| 58 | +/** | |
| 59 | + * Compatibility Check. | |
| 60 | + * | |
| 61 | + * @param bool $network_wide | |
| 62 | + * | |
| 63 | + * @return void | |
| 64 | + */ | |
| 65 | +function dfrapi_register_activation( bool $network_wide ) { | |
| 66 | + | |
| 67 | + // Check that minimum WordPress requirement has been met. | |
| 68 | + $version = get_bloginfo( 'version' ); | |
| 69 | + if ( version_compare( $version, '3.8', '<' ) ) { | |
| 70 | + deactivate_plugins( DFRAPI_BASENAME ); | |
| 71 | + wp_die( __( | |
| 72 | + 'The Datafeedr API Plugin could not be activated because it requires WordPress version 3.8 or greater. Please upgrade your installation of WordPress.', | |
| 73 | + 'datafeedr-api' | |
| 74 | + ) ); | |
| 43 | 75 | } |
| 44 | 76 | |
| 45 | - include( 'datafeedr-api-v2.php' ); | |
| 77 | + // Check that plugin is not being activated at the Network level on Multisite sites. | |
| 78 | + if ( $network_wide && is_multisite() ) { | |
| 79 | + deactivate_plugins( DFRAPI_BASENAME ); | |
| 80 | + wp_die( __( | |
| 81 | + 'The Datafeedr API plugin cannot be activated at the Network-level. Please activate the Datafeedr API plugin at the Site-level instead.', | |
| 82 | + 'datafeedr-api' | |
| 83 | + ) ); | |
| 84 | + } | |
| 85 | +} | |
| 46 | 86 | |
| 47 | -} else { | |
| 48 | - include( 'datafeedr-api-v1.php' ); | |
| 87 | +register_activation_hook( __FILE__, 'dfrapi_register_activation' ); | |
| 88 | + | |
| 89 | +/** | |
| 90 | + * Load Functions | |
| 91 | + */ | |
| 92 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/functions/global.php'; | |
| 93 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/functions/upgrade.php'; | |
| 94 | + | |
| 95 | +/** | |
| 96 | + * Load Libraries | |
| 97 | + */ | |
| 98 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/libraries/datafeedr.php'; | |
| 99 | + | |
| 100 | +/** | |
| 101 | + * Load files only if we're in the WordPress Admin Area of the site. | |
| 102 | + */ | |
| 103 | +if ( is_admin() ) { | |
| 104 | + | |
| 105 | + // Core admin functions. | |
| 106 | + require_once dirname( DFRAPI_PLUGIN_FILE ) . '/functions/admin.php'; | |
| 107 | + | |
| 108 | + // Load required classes. | |
| 109 | + require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-dfrapi-env.php'; // Checks environment for any problems. | |
| 110 | + require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-dfrapi-configuration.php'; // Configuration page. | |
| 111 | + require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-dfrapi-networks.php'; // Networks page. | |
| 112 | + require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-dfrapi-merchants.php'; // Merchants page. | |
| 113 | + require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-dfrapi-tools.php'; // Tools page. | |
| 114 | + require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-dfrapi-export.php'; // Export page. | |
| 115 | + require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-dfrapi-import.php'; // Import page. | |
| 116 | + require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-dfrapi-account.php'; // Account page. | |
| 117 | + require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-dfrapi-help.php'; // Help tabs. | |
| 118 | + require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-dfrapi-initialize.php'; | |
| 49 | 119 | } |
| 120 | + | |
| 121 | +/** | |
| 122 | + * Load Classes | |
| 123 | + */ | |
| 124 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-datafeedr-plugin-dependency.php'; | |
| 125 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-datafeedr-cron.php'; | |
| 126 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-datafeedr-timer.php'; | |
| 127 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-datafeedr-currency.php'; | |
| 128 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-datafeedr-price.php'; | |
| 129 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-datafeedr-image-importer.php'; | |
| 130 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-dfrapi-image-data.php'; | |
| 131 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-dfrapi-image-uploader.php'; | |
| 132 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/classes/class-dfrapi-searchform.php'; // Search Form. | |
| 133 | + | |
| 134 | +/** | |
| 135 | + * Global Hooks | |
| 136 | + */ | |
| 137 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/hooks/global/emails.php'; | |
| 138 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/hooks/global/affiliate-ids.php'; | |
| 139 | + | |
| 140 | +/** | |
| 141 | + * Load Admin Hooks | |
| 142 | + */ | |
| 143 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/hooks/admin/admin-notices.php'; | |
| 144 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/hooks/admin/ajax.php'; | |
| 145 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/hooks/admin/debug-information.php'; | |
| 146 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/hooks/admin/enqueue-scripts.php'; | |
| 147 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/hooks/admin/interface.php'; | |
| 148 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/hooks/admin/merchants.php'; | |
| 149 | +require_once dirname( DFRAPI_PLUGIN_FILE ) . '/hooks/admin/networks.php'; | |