should_show_modal()) { $this->enqueue_assets(); add_action('admin_footer', [$this, 'render_modal_template']); } } /** * Checks if the modal should be displayed */ private function should_show_modal() { if (!current_user_can('install_plugins')) return false; if (false !== advset_option('advset_tracksettings_choice', false)) return false; $t = get_option('advset_tracksettings_asklater', 0); if (!($t < (time() - (60 * 60)))) return false; if ($t > 0) delete_option('advset_tracksettings_asklater'); return true; } /** * Enqueues required scripts and styles */ public function enqueue_assets() { wp_enqueue_script( 'advset-tracking-modal', plugins_url('assets/tracksettings-optin-modal.js', __FILE__), ['jquery', 'wp-a11y'], filemtime(plugin_dir_path(__FILE__) . 'assets/tracksettings-optin-modal.js'), true ); wp_localize_script('advset-tracking-modal', 'advsetTracking', [ 'ajax_url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('tracking_choice_nonce') ]); } /** * Renders the modal dialog template */ public function render_modal_template() { $title = __('Help to improve Advanced Settings', 'advset-tracking'); $text = sprintf(__("The Advanced Settings plugin is currently being fundamentally revised. If you let us know which features you use, we can take this into account. We only collect yes/no information about what features you use, nothing else.\n\nOtherwise, we won't know what you're using and we might remove a feature you actually need. You can change this setting later at any time under %s > %s.\n\nDo you agree to let us know which features you use?", 'advset-tracking'), 'options-general.php?page=advanced-settings&tab=admin-advset', __('Settings'), __('Advanced')); $lang = substr(get_user_locale(), 0, 2); ?>



', $text); ?>


 
consent() === false) { return false; } // Collect stored data $data_stored = []; foreach ([ 'advset_scripts', 'advset_tracked_scripts', 'advset_tracked_styles', 'advset_styles', 'advset_remove_filters', 'advset_post_types', 'advset_advset', 'advset_code', 'advset_system', 'advset_tracksettings_asklater', ] as $option) { $data_stored[$option] = get_option($option, null); } // Anonymize data (tranform data to yes/no informations) $handler_boolean = function($value) { return (string) $value === '1'; }; $handler_numeric = function($value) { return $value > 0; }; $handler_string = function($value) { return $value !== ''; }; $handler_array = function($value) { return is_array($value) && !empty($value); }; $handlers = [ //'advset_tracked_scripts' => [], 'advset_scripts' => [ 'jquery_remove_migrate' => $handler_boolean, 'jquery_cnd' => $handler_boolean, 'remove_script_type' => $handler_boolean, 'track_enqueued_scripts' => $handler_boolean, 'track_merge_removed_scripts' => $handler_boolean, 'track_merged_scripts_footer' => $handler_boolean, //'remove_enqueued_script_hoverintent-js', //'remove_enqueued_script_admin-bar', ], //'advset_tracked_styles' => [], 'advset_styles' => [ 'track_enqueued_styles' => $handler_boolean, 'track_merge_removed_styles' => $handler_boolean, //'remove_enqueued_style_dashicons', //'remove_enqueued_style_admin-bar', //'remove_enqueued_style_wp-block-navigation', //'remove_enqueued_style_twentytwentyfive-style', ], 'advset_remove_filters' => function($value) { $used = []; foreach ($value as $cat => $hooks) { if (!empty($hooks)) { $used[$cat] = $hooks; } } return empty($used) ? false : $used; }, 'advset_post_types' => $handler_array, 'advset_advset' => [ 'show_deprecated_features' => $handler_boolean, 'advset_tracksettings_choice' => $handler_boolean, ], 'advset_code' => [ 'facebook_og_metas' => $handler_boolean, 'remove_menu' => $handler_boolean, 'remove_default_wp_favicon' => $handler_boolean, 'favicon' => $handler_boolean, 'description' => $handler_boolean, 'single_metas' => $handler_boolean, 'remove_generator' => $handler_boolean, 'remove_wlw' => $handler_boolean, 'remove_rsd' => $handler_boolean, 'remove_shortlink' => $handler_boolean, 'config_wp_title' => $handler_boolean, 'excerpt_limit' => $handler_numeric, 'excerpt_more_text' => $handler_string, 'remove_wptexturize' => $handler_boolean, 'remove_pingbacks_trackbacks_count' => $handler_boolean, 'author_bio' => $handler_boolean, 'author_bio_html' => $handler_boolean, 'compress' => $handler_boolean, 'remove_comments' => $handler_boolean, 'analytics' => $handler_string, 'feedburner' => $handler_string, ], 'advset_system' => [ 'hide_update_message' => $handler_boolean, 'dashboard_logo' => $handler_string, 'remove_default_wp_widgets' => $handler_boolean, 'remove_widget_system' => $handler_boolean, 'remove_comments_system' => $handler_boolean, 'disable_auto_save' => $handler_boolean, 'disable_author_pages' => $handler_boolean, 'auto_thumbs' => $handler_boolean, 'jpeg_quality' => $handler_numeric, 'max_image_size_w' => $handler_numeric, 'max_image_size_h' => $handler_numeric, 'core_upgrade_skip_new_bundled' => $handler_boolean, 'prevent_auto_core_update_send_email' => $handler_boolean, 'prevent_auto_plugin_update_send_email' => $handler_boolean, 'prevent_auto_theme_update_send_email' => $handler_boolean, 'show_query_num' => $handler_boolean, 'add_thumbs' => $handler_boolean, 'protect_emails' => $handler_boolean, 'protect_emails_method' => function($value) { return in_array($value, ['entities', 'javascript']) ? $value : false; }, ], 'advset_tracksettings_asklater' => $handler_boolean, ]; $data_anonymized = []; $data = ['url' => home_url(), 'stored' => &$data_stored, 'anonymized' => &$data_anonymized]; foreach ($handlers as $option_name => $option_handler) { $value = $data_stored[$option_name]; if ($value === null) { continue; } if ($option_handler instanceof Closure) { $r = $option_handler($value); if ($r === true) { $data_anonymized[$option_name] = 1; } elseif (!is_bool($r)) { $data_anonymized[$option_name] = $r; } } if (is_array($option_handler)) { $result_option = []; foreach ($option_handler as $field_name => $field_handler) { if (isset($value[$field_name]) && ($r = $field_handler($value[$field_name]))) { if ($r === true) { $result_option[$field_name] = 1; } elseif (!is_bool($r)) { $result_option[$field_name] = $r; } } } if (!empty($result_option)) { $data_anonymized[$option_name] = $result_option; } } } // Send data try { @file_get_contents('https://advsettracking.ehtmlu.com/', false, stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => 'Content-Type: application/x-www-form-urlencoded', 'content' => http_build_query([ 'data' => json_encode($data), ]) ] ])); } catch(Exception $e) {} return true; } }