AJAX
2 years ago
Date_Range
2 years ago
Interval
3 years ago
Menu_Bar_Stats
2 years ago
Migrations
2 years ago
Models
2 years ago
Queries
2 years ago
Statistics
2 years ago
Tables
2 years ago
Utils
2 years ago
Campaign_Builder.php
2 years ago
Capability_Manager.php
3 years ago
Chart.php
3 years ago
Chart_Geo.php
2 years ago
Chart_SVG.php
3 years ago
City_To_Country_Converter.php
3 years ago
Dashboard_Options.php
3 years ago
Dashboard_Widget.php
3 years ago
Email_Chart.php
2 years ago
Email_Reports.php
2 years ago
Env.php
2 years ago
Filters.php
3 years ago
Geo_Database_Background_Job.php
2 years ago
Geo_Database_Downloader.php
2 years ago
Geoposition.php
2 years ago
Icon_Directory.php
2 years ago
Icon_Directory_Factory.php
2 years ago
Illuminate_Builder.php
3 years ago
Independent_Analytics.php
2 years ago
Interrupt.php
2 years ago
Known_Referrers.php
3 years ago
Plugin_Conflict_Detector.php
2 years ago
Query.php
2 years ago
Quick_Stats.php
2 years ago
REST_API.php
2 years ago
Real_Time.php
2 years ago
Reset_Database.php
3 years ago
Resource_Identifier.php
3 years ago
Settings.php
2 years ago
Sort_Configuration.php
3 years ago
Track_Resource_Changes.php
3 years ago
View.php
2 years ago
View_Counter.php
2 years ago
WP_Option_Cache_Bust.php
2 years ago
WooCommerce_Order.php
2 years ago
Plugin_Conflict_Detector.php
102 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP_SCOPED\IAWP; |
| 4 | |
| 5 | class Plugin_Conflict_Detector |
| 6 | { |
| 7 | private $error; |
| 8 | public function __construct() |
| 9 | { |
| 10 | $this->error = $this->run_conflict_check(); |
| 11 | } |
| 12 | /** |
| 13 | * Did the health check pass? |
| 14 | * |
| 15 | * @return bool |
| 16 | */ |
| 17 | public function has_conflict() : bool |
| 18 | { |
| 19 | return empty($this->error); |
| 20 | } |
| 21 | /** |
| 22 | * Returns the health check error, if any |
| 23 | * |
| 24 | * @return string|null |
| 25 | */ |
| 26 | public function get_error() : ?string |
| 27 | { |
| 28 | return $this->error; |
| 29 | } |
| 30 | /** |
| 31 | * @return string|null Returns a string error message if the health check fails |
| 32 | */ |
| 33 | private function run_conflict_check() : ?string |
| 34 | { |
| 35 | $active_plugins = \get_option('active_plugins'); |
| 36 | if (\in_array('disable-wp-rest-api/disable-wp-rest-api.php', $active_plugins)) { |
| 37 | return \__('The "Disable WP REST API" plugin needs to be deactivated because Independent Analytics uses the REST API to record visits.', 'independent-analytics'); |
| 38 | } |
| 39 | if (\in_array('all-in-one-wp-security-and-firewall/wp-security.php', $active_plugins)) { |
| 40 | $settings = \get_option('aio_wp_security_configs', []); |
| 41 | if (\array_key_exists('aiowps_disallow_unauthorized_rest_requests', $settings)) { |
| 42 | if ($settings['aiowps_disallow_unauthorized_rest_requests'] == 1) { |
| 43 | return \__('The "All In One WP Security" plugin is blocking REST API requests, which Independent Analytics needs to record views. Please disable this setting via the WP Security > Miscellaneous menu.', 'independent-analytics'); |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | if (\in_array('disable-json-api/disable-json-api.php', $active_plugins)) { |
| 48 | $settings = \get_option('disable_rest_api_options', []); |
| 49 | if (\array_key_exists('roles', $settings)) { |
| 50 | if ($settings['roles']['none']['default_allow'] == \false) { |
| 51 | if ($settings['roles']['none']['allow_list']['/iawp/search'] == \false) { |
| 52 | return \__('The "Disable REST API" plugin is blocking REST API requests for unauthenticated users, which Independent Analytics needs to record views. Please enable the /iawp/search route, so Independent Analytics can track your visitors.', 'independent-analytics'); |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | if (\in_array('disable-xml-rpc-api/disable-xml-rpc-api.php', $active_plugins)) { |
| 58 | $settings = \get_option('dsxmlrpc-settings'); |
| 59 | if (\array_key_exists('json-rest-api', $settings)) { |
| 60 | if ($settings['json-rest-api'] == 1) { |
| 61 | return \__('The "Disable XML-RPC-API" plugin is blocking REST API requests, which Independent Analytics needs to record views. Please visit the Security Settings menu and turn off the "Disable JSON REST API" option, so Independent Analytics can track your visitors.', 'independent-analytics'); |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | if (\in_array('wpo-tweaks/wordpress-wpo-tweaks.php', $active_plugins)) { |
| 66 | return \__('The "WPO Tweaks & Optimizations" plugin needs to be deactivated because it is disabling the REST API, which Independent Analytics uses to record visits.', 'independent-analytics'); |
| 67 | } |
| 68 | if (\in_array('all-in-one-intranet/basic_all_in_one_intranet.php', $active_plugins)) { |
| 69 | return \__('The "All-In-One Intranet" plugin needs to be deactivated because it is disabling the REST API, which Independent Analytics uses to record visits. You may want to try the "My Private Site" plugin instead.', 'independent-analytics'); |
| 70 | } |
| 71 | if (\in_array('wp-security-hardening/wp-hardening.php', $active_plugins)) { |
| 72 | $settings = \get_option('whp_fixer_option'); |
| 73 | if ($settings['disable_json_api']) { |
| 74 | return \__('The "WP Hardening" plugin is blocking the REST API, which Independent Analytics needs to record views. Please visit the WP Hardening > Security Fixers menu and turn off the "Disable WP API JSON" option, so Independent Analytics can track your visitors.', 'independent-analytics'); |
| 75 | } |
| 76 | } |
| 77 | if (\in_array('wp-rest-api-authentication/miniorange-api-authentication.php', $active_plugins)) { |
| 78 | $settings = \get_option('mo_api_authentication_protectedrestapi_route_whitelist'); |
| 79 | if (\in_array('/iawp/search', $settings)) { |
| 80 | return \__('The "WordPress REST API Authentication" plugin is blocking the REST API, which Independent Analytics needs to record views. Please visit the miniOrange API Authentication > Protected REST APIs menu and uncheck the "/iawp/search" box to allow Independent Analytics to track your visitors.', 'independent-analytics'); |
| 81 | } |
| 82 | } |
| 83 | if (\in_array('perfmatters/perfmatters.php', $active_plugins)) { |
| 84 | $settings = \get_option('perfmatters_options'); |
| 85 | if (\array_key_exists('disable_rest_api', $settings)) { |
| 86 | if ($settings['disable_rest_api'] != '') { |
| 87 | return \__('The "Perfmatters" plugin is blocking the REST API, which Independent Analytics needs to record views. Please visit the Settings > Perfmatters menu and change the "Disable REST API" setting to "Default (enabled)" to allow Independent Analytics to track your visitors.', 'independent-analytics'); |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | if (\in_array('ninjafirewall/ninjafirewall.php', $active_plugins)) { |
| 92 | $settings = \get_option('nfw_options'); |
| 93 | if (\array_key_exists('no_restapi', $settings)) { |
| 94 | if ($settings['no_restapi'] == 1) { |
| 95 | return \__('The "NinjaFirewall" plugin is blocking the REST API, which Independent Analytics needs to record views. Please visit the NinjaFirewall > Firewall Policies menu and uncheck the "Block any access to the API" checkbox to allow Independent Analytics to track your visitors.', 'independent-analytics'); |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | return null; |
| 100 | } |
| 101 | } |
| 102 |