AJAX
2 years ago
Admin_Page
2 years ago
Date_Range
2 years ago
Interval
2 years ago
Menu_Bar_Stats
2 years ago
Migrations
2 years ago
Models
2 years ago
Public_API
2 years ago
Rows
2 years ago
Statistics
2 years ago
Tables
2 years ago
Utils
2 years ago
Campaign_Builder.php
2 years ago
Capability_Manager.php
2 years ago
Chart.php
2 years ago
Chart_Geo.php
2 years ago
Cron_Manager.php
2 years ago
Current_Traffic_Finder.php
2 years ago
Dashboard_Options.php
2 years ago
Dashboard_Widget.php
2 years ago
Database_Manager.php
2 years ago
Email_Chart.php
2 years ago
Email_Reports.php
2 years ago
Empty_Report_Option.php
2 years ago
Env.php
2 years ago
Filters.php
2 years ago
Geo_Database_Background_Job.php
2 years ago
Geo_Database_Manager.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
2 years ago
Independent_Analytics.php
2 years ago
Interrupt.php
2 years ago
Known_Referrers.php
2 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
Report.php
2 years ago
Report_Finder.php
2 years ago
Report_Options_Parser.php
2 years ago
Resource_Identifier.php
2 years ago
Settings.php
2 years ago
Sort_Configuration.php
2 years ago
Track_Resource_Changes.php
2 years ago
View.php
2 years ago
View_Counter.php
2 years ago
Visitors_Over_Time_Finder.php
2 years ago
WP_Option_Cache_Bust.php
2 years ago
WooCommerce_Order.php
2 years ago
WooCommerce_Referrer_Meta_Box.php
2 years ago
Plugin_Conflict_Detector.php
145 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP_SCOPED\IAWP; |
| 4 | |
| 5 | use IAWP_SCOPED\IAWP\Utils\String_Util; |
| 6 | /** @internal */ |
| 7 | class Plugin_Conflict_Detector |
| 8 | { |
| 9 | private $error; |
| 10 | public function __construct() |
| 11 | { |
| 12 | $this->error = $this->run_conflict_check(); |
| 13 | } |
| 14 | /** |
| 15 | * Did the health check pass? |
| 16 | * |
| 17 | * @return bool |
| 18 | */ |
| 19 | public function has_conflict() : bool |
| 20 | { |
| 21 | return empty($this->error); |
| 22 | } |
| 23 | /** |
| 24 | * Returns the health check error, if any |
| 25 | * |
| 26 | * @return string|null |
| 27 | */ |
| 28 | public function get_error() : ?string |
| 29 | { |
| 30 | return $this->error; |
| 31 | } |
| 32 | /** |
| 33 | * @return string|null Returns a string error message if the health check fails |
| 34 | */ |
| 35 | private function run_conflict_check() : ?string |
| 36 | { |
| 37 | $active_plugins = \get_option('active_plugins'); |
| 38 | if (\in_array('disable-wp-rest-api/disable-wp-rest-api.php', $active_plugins)) { |
| 39 | return \__('The "Disable WP REST API" plugin needs to be deactivated because Independent Analytics uses the REST API to record visits.', 'independent-analytics'); |
| 40 | } |
| 41 | if (\in_array('all-in-one-wp-security-and-firewall/wp-security.php', $active_plugins)) { |
| 42 | $settings = \get_option('aio_wp_security_configs', []); |
| 43 | if (\array_key_exists('aiowps_disallow_unauthorized_rest_requests', $settings)) { |
| 44 | if ($settings['aiowps_disallow_unauthorized_rest_requests'] == 1) { |
| 45 | 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'); |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | if (\in_array('disable-json-api/disable-json-api.php', $active_plugins)) { |
| 50 | $settings = \get_option('disable_rest_api_options', []); |
| 51 | if (\array_key_exists('roles', $settings)) { |
| 52 | if ($settings['roles']['none']['default_allow'] == \false) { |
| 53 | if ($settings['roles']['none']['allow_list']['/iawp/search'] == \false) { |
| 54 | 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'); |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | if (\in_array('disable-xml-rpc-api/disable-xml-rpc-api.php', $active_plugins)) { |
| 60 | $settings = \get_option('dsxmlrpc-settings'); |
| 61 | if (\array_key_exists('json-rest-api', $settings)) { |
| 62 | if ($settings['json-rest-api'] == 1) { |
| 63 | 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'); |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | if (\in_array('wpo-tweaks/wordpress-wpo-tweaks.php', $active_plugins)) { |
| 68 | 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'); |
| 69 | } |
| 70 | if (\in_array('all-in-one-intranet/basic_all_in_one_intranet.php', $active_plugins)) { |
| 71 | 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'); |
| 72 | } |
| 73 | if (\in_array('wp-security-hardening/wp-hardening.php', $active_plugins)) { |
| 74 | $settings = \get_option('whp_fixer_option'); |
| 75 | if (\array_key_exists('disable_json_api', $settings)) { |
| 76 | if ($settings['disable_json_api']) { |
| 77 | 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'); |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | if (\in_array('wp-rest-api-authentication/miniorange-api-authentication.php', $active_plugins)) { |
| 82 | $settings = \get_option('mo_api_authentication_protectedrestapi_route_whitelist'); |
| 83 | if (\in_array('/iawp/search', $settings)) { |
| 84 | 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'); |
| 85 | } |
| 86 | } |
| 87 | if (\in_array('perfmatters/perfmatters.php', $active_plugins)) { |
| 88 | $settings = \get_option('perfmatters_options'); |
| 89 | if (\array_key_exists('disable_rest_api', $settings)) { |
| 90 | if ($settings['disable_rest_api'] != '') { |
| 91 | 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'); |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | if (\in_array('ninjafirewall/ninjafirewall.php', $active_plugins)) { |
| 96 | $settings = \get_option('nfw_options'); |
| 97 | if (\array_key_exists('no_restapi', $settings)) { |
| 98 | if ($settings['no_restapi'] == 1) { |
| 99 | 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'); |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | if (\in_array('wp-cerber/wp-cerber.php', $active_plugins)) { |
| 104 | $settings = \get_option('cerber-hardening'); |
| 105 | if (\array_key_exists('norest', $settings)) { |
| 106 | if ($settings['norest'] === '1') { |
| 107 | if (!String_Util::str_contains($settings['restwhite'], 'iawp')) { |
| 108 | return \__('The "WP Cerber" plugin is blocking the REST API, which Independent Analytics needs to record views. Please visit the WP Cerber > Dashboard > Hardening menu and add "iawp" to your allowed namespaces. This will keep the REST API locked down while allowing requests for Independent Analytics.', 'independent-analytics'); |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | if (\in_array('wp-simple-firewall/icwp-wpsf.php', $active_plugins)) { |
| 114 | $settings = \get_option('icwp_wpsf_opts_free'); |
| 115 | if (\array_key_exists('lockdown', $settings)) { |
| 116 | if (\array_key_exists('disable_anonymous_restapi', $settings['lockdown'])) { |
| 117 | if ($settings['lockdown']['disable_anonymous_restapi'] == 'Y') { |
| 118 | if (\array_key_exists('api_namespace_exclusions', $settings['lockdown'])) { |
| 119 | if (!\in_array('iawp', $settings['lockdown']['api_namespace_exclusions'])) { |
| 120 | return \__('The "Shield Security" plugin is blocking the REST API, which Independent Analytics needs to record views. Please visit the Shield Security > Config > Lockdown menu and add "iawp" to your allowed namespaces. This will keep the REST API locked down while allowing requests for Independent Analytics.', 'independent-analytics'); |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | if (\in_array('wp-hide-security-enhancer/wp-hide.php', $active_plugins)) { |
| 128 | $settings = \get_option('wph_settings'); |
| 129 | if (\array_key_exists('module_settings', $settings)) { |
| 130 | if (\array_key_exists('disable_json_rest_v2', $settings['module_settings'])) { |
| 131 | if ($settings['module_settings']['disable_json_rest_v2'] == 'yes') { |
| 132 | return \__('The "WP Hide" plugin is blocking the REST API, which Independent Analytics needs to record views. Please visit the WP Hide > Rewrite URLs menu and switch the "Disable JSON REST V2 service" option to "No."', 'independent-analytics'); |
| 133 | } |
| 134 | } |
| 135 | if (\array_key_exists('block_json_rest', $settings['module_settings'])) { |
| 136 | if ($settings['module_settings']['block_json_rest'] == 'yes' || $settings['module_settings']['block_json_rest'] == 'non-logged-in') { |
| 137 | return \__('The "WP Hide" plugin is blocking the REST API, which Independent Analytics needs to record views. Please visit the WP Hide > Rewrite URLs menu and switch the "Block any JSON REST calls" option to "No."', 'independent-analytics'); |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | return null; |
| 143 | } |
| 144 | } |
| 145 |