AJAX
5 months ago
Admin_Page
5 months ago
Click_Tracking
5 months ago
ColumnOptions
6 months ago
Cron
9 months ago
Custom_WordPress_Columns
8 months ago
Data_Pruning
5 months ago
Date_Picker
5 months ago
Date_Range
5 months ago
Ecommerce
5 months ago
Email_Reports
5 months ago
Examiner
11 months ago
Favicon
5 months ago
Form_Submissions
5 months ago
Integrations
6 months ago
Interval
1 year ago
Journey
5 months ago
Migrations
5 months ago
Models
5 months ago
Overview
5 months ago
Public_API
5 months ago
Rows
5 months ago
Statistics
5 months ago
Tables
5 months ago
Utils
5 months ago
Views
5 months ago
WooCommerceOrderMetaBox
5 months ago
Admin_Bar_Stats.php
5 months ago
Appearance.php
1 year ago
Campaign_Builder.php
5 months ago
Capability_Manager.php
1 year ago
Chart.php
9 months ago
Chart_Data.php
1 year ago
Click_Tracking.php
1 year ago
Cron_Job.php
5 months ago
Cron_Manager.php
5 months ago
Current_Traffic_Finder.php
1 year ago
Dashboard_Options.php
6 months ago
Dashboard_Widget.php
2 years ago
Database.php
8 months ago
Database_Manager.php
5 months ago
Empty_Report_Option.php
2 years ago
Env.php
6 months ago
Examiner_Config.php
11 months ago
FetchFaviconsJob.php
5 months ago
Filters.php
5 months ago
Geo_Database_Health_Check_Job.php
9 months ago
Geo_Database_Manager.php
6 months ago
Geoposition.php
1 year ago
Icon_Directory.php
6 months ago
Icon_Directory_Factory.php
2 years ago
Illuminate_Builder.php
10 months ago
Independent_Analytics.php
5 months ago
Interrupt.php
1 year ago
Known_Referrers.php
6 months ago
MainWP.php
1 year ago
Map.php
9 months ago
Map_Data.php
1 year ago
Migration_Fixer_Job.php
5 months ago
Patch.php
1 year ago
Payload_Validator.php
9 months ago
Plugin_Conflict_Detector.php
6 months ago
Plugin_Group.php
6 months ago
Plugin_Group_Option.php
2 years ago
Query.php
1 year ago
Query_Taps.php
5 months ago
Quick_Stats.php
11 months ago
REST_API.php
6 months ago
Real_Time.php
5 months ago
Report.php
1 year ago
Report_Finder.php
6 months ago
Report_Options_Parser.php
9 months ago
Resource_Identifier.php
9 months ago
Settings.php
6 months ago
Sort_Configuration.php
9 months ago
Tables.php
8 months ago
Track_Resource_Changes.php
1 year ago
View_Counter.php
6 months ago
Views_Over_Time_Finder.php
1 year ago
VisitorSaltRefreshInterval.php
6 months ago
WP_Option_Cache_Bust.php
2 years ago
Plugin_Conflict_Detector.php
233 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP; |
| 4 | |
| 5 | use IAWP\Utils\String_Util; |
| 6 | /** @internal */ |
| 7 | class Plugin_Conflict_Detector |
| 8 | { |
| 9 | private $plugin; |
| 10 | private $error; |
| 11 | public function __construct() |
| 12 | { |
| 13 | $check = $this->run_conflict_check(); |
| 14 | if (!\is_null($check)) { |
| 15 | $this->plugin = $check['plugin']; |
| 16 | $this->error = $check['error']; |
| 17 | } |
| 18 | } |
| 19 | /** |
| 20 | * Did the health check pass? |
| 21 | * |
| 22 | * @return bool |
| 23 | */ |
| 24 | public function has_conflict() : bool |
| 25 | { |
| 26 | return !empty($this->error); |
| 27 | } |
| 28 | /** |
| 29 | * Returns the plugin name, if any |
| 30 | * |
| 31 | * @return string|null |
| 32 | */ |
| 33 | public function get_plugin() : ?string |
| 34 | { |
| 35 | return $this->plugin; |
| 36 | } |
| 37 | /** |
| 38 | * Returns the health check error, if any |
| 39 | * |
| 40 | * @return string|null |
| 41 | */ |
| 42 | public function get_error() : ?string |
| 43 | { |
| 44 | return $this->error; |
| 45 | } |
| 46 | public function plugin_requiring_logged_in_tracking() |
| 47 | { |
| 48 | if (\is_plugin_active('woocommerce/woocommerce.php')) { |
| 49 | return 'WooCommerce'; |
| 50 | } elseif (\is_plugin_active('surecart/surecart.php')) { |
| 51 | return 'SureCart'; |
| 52 | } elseif (\is_plugin_active('paid-memberships-pro/paid-memberships-pro.php')) { |
| 53 | return 'Paid Memberships Pro'; |
| 54 | } elseif (\is_plugin_active('ultimate-member/ultimate-member.php')) { |
| 55 | return 'Ultimate Member'; |
| 56 | } elseif (\is_plugin_active('simple-membership/simple-wp-membership.php')) { |
| 57 | return 'Simple WordPress Membership'; |
| 58 | } elseif (\is_plugin_active('members/members.php')) { |
| 59 | return 'Members plugin'; |
| 60 | } |
| 61 | return \false; |
| 62 | } |
| 63 | /** |
| 64 | * @return string|null Returns a string error message if the health check fails |
| 65 | */ |
| 66 | private function run_conflict_check() : ?array |
| 67 | { |
| 68 | if (\is_plugin_active('disable-wp-rest-api/disable-wp-rest-api.php')) { |
| 69 | return ['plugin' => 'disable-wp-rest-api', 'error' => \__('The "Disable WP REST API" plugin needs to be deactivated because Independent Analytics uses the REST API to record visits.', 'independent-analytics')]; |
| 70 | } |
| 71 | if (\is_plugin_active('all-in-one-wp-security-and-firewall/wp-security.php')) { |
| 72 | $settings = \get_option('aio_wp_security_configs', []); |
| 73 | if (\is_array($settings) && \array_key_exists('aiowps_disallow_unauthorized_rest_requests', $settings)) { |
| 74 | if ($settings['aiowps_disallow_unauthorized_rest_requests'] == 1) { |
| 75 | return ['plugin' => 'wp-security', 'error' => \__('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')]; |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | if (\is_plugin_active('disable-json-api/disable-json-api.php')) { |
| 80 | $settings = \get_option('disable_rest_api_options', []); |
| 81 | if (\is_array($settings) && \array_key_exists('roles', $settings)) { |
| 82 | if ($settings['roles']['none']['default_allow'] == \false) { |
| 83 | if ($settings['roles']['none']['allow_list']['/iawp/search'] == \false) { |
| 84 | return ['plugin' => 'disable-json-api', 'error' => \__('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')]; |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | if (\is_plugin_active('disable-xml-rpc-api/disable-xml-rpc-api.php')) { |
| 90 | $settings = \get_option('dsxmlrpc-settings'); |
| 91 | if (\is_array($settings) && \array_key_exists('json-rest-api', $settings)) { |
| 92 | if ($settings['json-rest-api'] == 1) { |
| 93 | return ['plugin' => 'disable-xml-rpc-api', 'error' => \__('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')]; |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | if (\is_plugin_active('wpo-tweaks/wpo-tweaks.php')) { |
| 98 | return ['plugin' => 'wpo-tweaks', 'error' => \__('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')]; |
| 99 | } |
| 100 | if (\is_plugin_active('all-in-one-intranet/basic_all_in_one_intranet.php')) { |
| 101 | return ['plugin' => 'basic_all_in_one_intranet', 'error' => \__('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')]; |
| 102 | } |
| 103 | if (\is_plugin_active('wp-security-hardening/wp-hardening.php')) { |
| 104 | $settings = \get_option('whp_fixer_option'); |
| 105 | if (\is_array($settings) && \array_key_exists('disable_json_api', $settings)) { |
| 106 | if ($settings['disable_json_api'] != 'off') { |
| 107 | return ['plugin' => 'wp-hardening', 'error' => \__('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')]; |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | if (\is_plugin_active('wp-rest-api-authentication/miniorange-api-authentication.php')) { |
| 112 | $settings = \get_option('mo_api_authentication_protectedrestapi_route_whitelist'); |
| 113 | if (\is_array($settings) && \in_array('/iawp/search', $settings)) { |
| 114 | return ['plugin' => 'miniorange-api-authentication', 'error' => \__('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')]; |
| 115 | } |
| 116 | } |
| 117 | if (\is_plugin_active('ninjafirewall/ninjafirewall.php')) { |
| 118 | $settings = \get_option('nfw_options'); |
| 119 | if (\is_array($settings) && \array_key_exists('no_restapi', $settings)) { |
| 120 | if ($settings['no_restapi'] == 1) { |
| 121 | return ['plugin' => 'ninjafirewall', 'error' => \__('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')]; |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | if (\is_plugin_active('wp-cerber/wp-cerber.php')) { |
| 126 | // This option has been renamed before. If there's an issue in here, check that it wasn't renamed again. |
| 127 | $settings = \get_option('cerber_configuration'); |
| 128 | if (!\is_array($settings)) { |
| 129 | $settings = \get_option('cerber-hardening'); |
| 130 | } |
| 131 | if (\is_array($settings) && \array_key_exists('norest', $settings)) { |
| 132 | if ($settings['norest'] === '1') { |
| 133 | if (\is_array($settings['restwhite']) && !\in_array('iawp', $settings['restwhite']) || \is_string($settings['restwhite']) && !String_Util::str_contains($settings['restwhite'], 'iawp')) { |
| 134 | return ['plugin' => 'wp-cerber', 'error' => \__('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')]; |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | if (\is_plugin_active('wp-simple-firewall/icwp-wpsf.php')) { |
| 140 | // This option has been renamed before. If there's an issue in here, check that it wasn't renamed again. |
| 141 | $settings = \get_option('icwp_wpsf_opts_all'); |
| 142 | if (!\is_array($settings)) { |
| 143 | $settings = \get_option('icwp_wpsf_opts_free'); |
| 144 | } |
| 145 | if (\is_array($settings) && \array_key_exists('lockdown', $settings)) { |
| 146 | if (\array_key_exists('disable_anonymous_restapi', $settings['lockdown'])) { |
| 147 | if ($settings['lockdown']['disable_anonymous_restapi'] == 'Y') { |
| 148 | if (\array_key_exists('api_namespace_exclusions', $settings['lockdown'])) { |
| 149 | if (!\in_array('iawp', $settings['lockdown']['api_namespace_exclusions'])) { |
| 150 | return ['plugin' => 'icwp-wpsf', 'error' => \__('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')]; |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | if (\is_plugin_active('wp-hide-security-enhancer/wp-hide.php')) { |
| 158 | $settings = \get_option('wph_settings'); |
| 159 | if (\is_array($settings) && \array_key_exists('module_settings', $settings)) { |
| 160 | if (\array_key_exists('disable_json_rest_v2', $settings['module_settings'])) { |
| 161 | if ($settings['module_settings']['disable_json_rest_v2'] == 'yes') { |
| 162 | return ['plugin' => 'wp-hide', 'error' => \__('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')]; |
| 163 | } |
| 164 | } |
| 165 | if (\array_key_exists('block_json_rest', $settings['module_settings'])) { |
| 166 | if ($settings['module_settings']['block_json_rest'] == 'yes' || $settings['module_settings']['block_json_rest'] == 'non-logged-in') { |
| 167 | return ['plugin' => 'wp-hide', 'error' => \__('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')]; |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | if (\is_plugin_active('admin-site-enhancements/admin-site-enhancements.php')) { |
| 173 | $settings = \get_option('admin_site_enhancements'); |
| 174 | if (\is_array($settings) && \array_key_exists('disable_rest_api', $settings)) { |
| 175 | if ($settings['disable_rest_api']) { |
| 176 | return ['plugin' => 'admin-site-enhancements', 'error' => \__('The "Admin and Site Enhancements" plugin is blocking the REST API, which Independent Analytics needs to record views. Please visit the Tools > Enhancements menu, click on the "Disable Components" section, and deselect the "Disable REST API" setting to allow Independent Analytics to track your visitors.', 'independent-analytics')]; |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | if (\is_plugin_active('admin-site-enhancements-pro/admin-site-enhancements.php')) { |
| 181 | $settings = \get_option('admin_site_enhancements'); |
| 182 | if (\is_array($settings) && \array_key_exists('disable_rest_api', $settings)) { |
| 183 | if ($settings['disable_rest_api']) { |
| 184 | if (\is_string($settings['disable_rest_api_excluded_routes']) && !String_Util::str_contains($settings['disable_rest_api_excluded_routes'], 'iawp/search')) { |
| 185 | return ['plugin' => 'admin-site-enhancements', 'error' => \__('The "Admin and Site Enhancements Pro" plugin is blocking the REST API, which Independent Analytics needs to record views. Please visit the Tools > Enhancements menu, click on the "Disable Components" section, and then click the "Expand" link under "Disable REST API." You can then enter "iawp/search" into the textarea to whitelist the route used by Independent Analytics.', 'independent-analytics')]; |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | if (\is_plugin_active('autoptimize/autoptimize.php')) { |
| 191 | if (\get_option('autoptimize_js_aggregate') == 'on' && \get_option('autoptimize_js_include_inline') == 'on') { |
| 192 | return ['plugin' => 'autoptimize', 'error' => \__('A setting in the "Autoptimize" plugin is preventing Independent Analytics from tracking visitors. Please visit the Settings > Autoptimize menu and uncheck the "Also aggregate inline JS" option.', 'independent-analytics')]; |
| 193 | } |
| 194 | } |
| 195 | if (\is_plugin_active('patchstack/patchstack.php')) { |
| 196 | if (\get_option('patchstack_json_is_disabled') == '1') { |
| 197 | return ['plugin' => 'patchstack', 'error' => \__('The Patchstack Security plugin has disabled the REST API, which Independent Analytics needs to record visitors. Please login to the Patchstack app, navigate to the Hardening menu for this site, and turn off the "Restrict WP REST API access" option.', 'independent-analytics')]; |
| 198 | } |
| 199 | } |
| 200 | if (\is_plugin_active('rest-api-toolbox/rest-api-toolbox.php')) { |
| 201 | $settings = \get_option('rest-api-toolbox-settings-general'); |
| 202 | if (\is_array($settings) && \array_key_exists('disable-rest-api', $settings)) { |
| 203 | if ($settings['disable-rest-api'] == '1') { |
| 204 | return ['plugin' => 'rest-api-toolbox', 'error' => \__('The REST API Toolbox plugin has disabled the REST API, which Independent Analytics needs to record visitors. Please visit the Settings > REST API Toolbox menu and uncheck the "Disable REST API" option to allow Independent Analytics to track your visitors.', 'independent-analytics')]; |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | if (\is_plugin_active('minify-html-markup/minify-html.php')) { |
| 209 | // Note: both options enabled by default before anything is saved in the DB. `false` is unset, `no` is saved as no |
| 210 | if (\get_option('minify_html_active') !== 'no' && \get_option('minify_javascript') !== 'no') { |
| 211 | return ['plugin' => 'minify-html-markup', 'error' => \__('The Minify HTML plugin is preventing Independent Analytics from tracking visitors. Please visit the Settings > Minify HTML menu and disable the option called "Minify inline JavaScript" to resume tracking.', 'independent-analytics')]; |
| 212 | } |
| 213 | } |
| 214 | if (\is_plugin_active('falcon/falcon.php')) { |
| 215 | $settings = \get_option('falcon'); |
| 216 | $show_warning = \false; |
| 217 | // Note: REST API is disabled by default without any options saved in the DB |
| 218 | if ($settings === \false) { |
| 219 | $show_warning = \true; |
| 220 | } |
| 221 | if (\is_array($settings) && \array_key_exists('features', $settings)) { |
| 222 | if (\in_array('no_rest_api', $settings['features'])) { |
| 223 | $show_warning = \true; |
| 224 | } |
| 225 | } |
| 226 | if ($show_warning) { |
| 227 | return ['plugin' => 'falcon', 'error' => \__('The Falcon plugin has disabled the REST API for anonymous visitors, which Independent Analytics needs to record stats. Please visit the Settings > Falcon menu, open the Security section, and uncheck the "Disable REST API for unauthenticated requests" option to allow Independent Analytics to record stats.', 'independent-analytics')]; |
| 228 | } |
| 229 | } |
| 230 | return null; |
| 231 | } |
| 232 | } |
| 233 |