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