AJAX
10 months ago
Admin_Page
11 months ago
Click_Tracking
1 year ago
Custom_WordPress_Columns
1 year ago
Data_Pruning
1 year ago
Date_Picker
1 year ago
Date_Range
11 months ago
Ecommerce
1 year ago
Email_Reports
11 months ago
Examiner
11 months ago
Filter_Lists
1 year ago
Form_Submissions
11 months ago
Integrations
1 year ago
Interval
1 year ago
Menu_Bar_Stats
1 year ago
Migrations
1 year ago
Models
10 months ago
Overview
11 months ago
Public_API
1 year ago
Rows
10 months ago
Statistics
11 months ago
Tables
11 months ago
Utils
11 months ago
Appearance.php
1 year ago
Campaign_Builder.php
1 year ago
Capability_Manager.php
1 year ago
Chart.php
1 year ago
Chart_Data.php
1 year ago
Click_Tracking.php
1 year ago
Cron_Job.php
1 year ago
Cron_Manager.php
1 year ago
Current_Traffic_Finder.php
1 year ago
Dashboard_Options.php
11 months ago
Dashboard_Widget.php
2 years ago
Database.php
1 year ago
Database_Manager.php
11 months ago
Empty_Report_Option.php
2 years ago
Env.php
1 year ago
Examiner_Config.php
11 months ago
Filters.php
1 year ago
Geo_Database_Background_Job.php
1 year ago
Geo_Database_Manager.php
11 months ago
Geoposition.php
1 year ago
Icon_Directory.php
2 years ago
Icon_Directory_Factory.php
2 years ago
Illuminate_Builder.php
10 months ago
Independent_Analytics.php
11 months ago
Interrupt.php
1 year ago
Known_Referrers.php
11 months ago
MainWP.php
1 year ago
Map.php
1 year ago
Map_Data.php
1 year ago
Migration_Fixer_Job.php
1 year ago
Patch.php
1 year ago
Payload_Validator.php
1 year ago
Plugin_Conflict_Detector.php
11 months ago
Plugin_Group.php
1 year ago
Plugin_Group_Option.php
2 years ago
Query.php
1 year ago
Query_Taps.php
11 months ago
Quick_Stats.php
11 months ago
REST_API.php
11 months ago
Real_Time.php
1 year ago
Report.php
1 year ago
Report_Finder.php
1 year ago
Report_Options_Parser.php
1 year ago
Resource_Identifier.php
1 year ago
Settings.php
11 months ago
Sort_Configuration.php
1 year ago
Tables.php
1 year ago
Track_Resource_Changes.php
1 year ago
View.php
11 months ago
View_Counter.php
1 year ago
Views_Over_Time_Finder.php
1 year ago
WP_Option_Cache_Bust.php
2 years ago
Plugin_Conflict_Detector.php
211 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/wordpress-wpo-tweaks.php')) { |
| 98 | return ['plugin' => 'wordpress-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 | return null; |
| 209 | } |
| 210 | } |
| 211 |