Файловый менеджер - Редактировать - /home/kunzqhe/photostocker/2/tracking.tar
Назад
class-tracking.php 0000644 00000014613 15152512113 0010163 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\Tracking */ /** * This class handles the tracking routine. */ class WPSEO_Tracking implements WPSEO_WordPress_Integration { /** * The tracking option name. * * @var string */ protected $option_name = 'wpseo_tracking_last_request'; /** * The limit for the option. * * @var int */ protected $threshold = 0; /** * The endpoint to send the data to. * * @var string */ protected $endpoint = ''; /** * The current time. * * @var int */ private $current_time; /** * WPSEO_Tracking constructor. * * @param string $endpoint The endpoint to send the data to. * @param int $threshold The limit for the option. */ public function __construct( $endpoint, $threshold ) { if ( ! $this->tracking_enabled() ) { return; } $this->endpoint = $endpoint; $this->threshold = $threshold; $this->current_time = time(); } /** * Registers all hooks to WordPress. */ public function register_hooks() { if ( ! $this->tracking_enabled() ) { return; } // Send tracking data on `admin_init`. add_action( 'admin_init', [ $this, 'send' ], 1 ); // Add an action hook that will be triggered at the specified time by `wp_schedule_single_event()`. add_action( 'wpseo_send_tracking_data_after_core_update', [ $this, 'send' ] ); // Call `wp_schedule_single_event()` after a WordPress core update. add_action( 'upgrader_process_complete', [ $this, 'schedule_tracking_data_sending' ], 10, 2 ); } /** * Schedules a new sending of the tracking data after a WordPress core update. * * @param bool|WP_Upgrader $upgrader Optional. WP_Upgrader instance or false. * Depending on context, it might be a Theme_Upgrader, * Plugin_Upgrader, Core_Upgrade, or Language_Pack_Upgrader. * instance. Default false. * @param array $data Array of update data. * * @return void */ public function schedule_tracking_data_sending( $upgrader = false, $data = [] ) { // Return if it's not a WordPress core update. if ( ! $upgrader || ! isset( $data['type'] ) || $data['type'] !== 'core' ) { return; } /* * To uniquely identify the scheduled cron event, `wp_next_scheduled()` * needs to receive the same arguments as those used when originally * scheduling the event otherwise it will always return false. */ if ( ! wp_next_scheduled( 'wpseo_send_tracking_data_after_core_update', true ) ) { /* * Schedule sending of data tracking 6 hours after a WordPress core * update. Pass a `true` parameter for the callback `$force` argument. */ wp_schedule_single_event( ( time() + ( HOUR_IN_SECONDS * 6 ) ), 'wpseo_send_tracking_data_after_core_update', true ); } } /** * Sends the tracking data. * * @param bool $force Whether to send the tracking data ignoring the two * weeks time treshhold. Default false. */ public function send( $force = false ) { if ( ! $this->should_send_tracking( $force ) ) { return; } // Set a 'content-type' header of 'application/json'. $tracking_request_args = [ 'headers' => [ 'content-type:' => 'application/json', ], ]; $collector = $this->get_collector(); $request = new WPSEO_Remote_Request( $this->endpoint, $tracking_request_args ); $request->set_body( $collector->get_as_json() ); $request->send(); update_option( $this->option_name, $this->current_time, 'yes' ); } /** * Determines whether to send the tracking data. * * Returns false if tracking is disabled or the current page is one of the * admin plugins pages. Returns true when there's no tracking data stored or * the data was sent more than two weeks ago. The two weeks interval is set * when instantiating the class. * * @param bool $ignore_time_treshhold Whether to send the tracking data ignoring * the two weeks time treshhold. Default false. * * @return bool True when tracking data should be sent. */ protected function should_send_tracking( $ignore_time_treshhold = false ) { global $pagenow; // Only send tracking on the main site of a multi-site instance. This returns true on non-multisite installs. if ( is_network_admin() || ! is_main_site() ) { return false; } // Because we don't want to possibly block plugin actions with our routines. if ( in_array( $pagenow, [ 'plugins.php', 'plugin-install.php', 'plugin-editor.php' ], true ) ) { return false; } $last_time = get_option( $this->option_name ); // When tracking data haven't been sent yet or when sending data is forced. if ( ! $last_time || $ignore_time_treshhold ) { return true; } return $this->exceeds_treshhold( $this->current_time - $last_time ); } /** * Checks if the given amount of seconds exceeds the set threshold. * * @param int $seconds The amount of seconds to check. * * @return bool True when seconds is bigger than threshold. */ protected function exceeds_treshhold( $seconds ) { return ( $seconds > $this->threshold ); } /** * Returns the collector for collecting the data. * * @return WPSEO_Collector The instance of the collector. */ public function get_collector() { $collector = new WPSEO_Collector(); $collector->add_collection( new WPSEO_Tracking_Default_Data() ); $collector->add_collection( new WPSEO_Tracking_Server_Data() ); $collector->add_collection( new WPSEO_Tracking_Theme_Data() ); $collector->add_collection( new WPSEO_Tracking_Plugin_Data() ); $collector->add_collection( new WPSEO_Tracking_Settings_Data() ); return $collector; } /** * See if we should run tracking at all. * * @return bool True when we can track, false when we can't. */ private function tracking_enabled() { // Check if we're allowing tracking. $tracking = WPSEO_Options::get( 'tracking' ); if ( $tracking === false ) { return false; } // Save this state. if ( $tracking === null ) { /** * Filter: 'wpseo_enable_tracking' - Enables the data tracking of Yoast SEO Premium and add-ons. * * @api string $is_enabled The enabled state. Default is false. */ $tracking = apply_filters( 'wpseo_enable_tracking', false ); WPSEO_Options::set( 'tracking', $tracking ); } if ( $tracking === false ) { return false; } if ( wp_get_environment_type() !== 'production' ) { return false; } return true; } } class-tracking-settings-data.php 0000644 00000012104 15152512113 0012721 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\Tracking */ /** * Collects anonymized settings data. */ class WPSEO_Tracking_Settings_Data implements WPSEO_Collection { /** * The options that need to be anonymized before they can be sent elsewhere. * * @var array All of the option_names which need to be * anonymized before they can be sent elsewhere. */ private $anonymous_settings = [ 'baiduverify', 'googleverify', 'msverify', 'yandexverify', 'myyoast-oauth', 'website_name', 'alternate_website_name', 'company_logo', 'company_name', 'person_name', 'person_logo', 'person_logo_id', 'company_logo_id', 'facebook_site', 'instagram_url', 'linkedin_url', 'myspace_url', 'og_default_image', 'og_default_image_id', 'og_frontpage_title', 'og_frontpage_desc', 'og_frontpage_image', 'og_frontpage_image_id', 'open_graph_frontpage_title', 'open_graph_frontpage_desc', 'open_graph_frontpage_image', 'open_graph_frontpage_image_id', 'pinterest_url', 'pinterestverify', 'twitter_site', 'youtube_url', 'wikipedia_url', 'semrush_tokens', 'zapier_api_key', ]; /** * The options we want to track. * * @var array The option_names for the options we want to track. */ private $include_list = [ 'ms_defaults_set', 'version', 'disableadvanced_meta', 'ryte_indexability', 'baiduverify', 'googleverify', 'msverify', 'yandexverify', 'site_type', 'has_multiple_authors', 'environment_type', 'content_analysis_active', 'keyword_analysis_active', 'enable_admin_bar_menu', 'enable_cornerstone_content', 'enable_xml_sitemap', 'enable_text_link_counter', 'show_onboarding_notice', 'first_activated_on', 'myyoast-oauth', 'dynamic_permalinks', 'website_name', 'alternate_website_name', 'company_logo', 'company_name', 'company_or_person', 'person_name', 'forcerewritetitle', 'separator', 'title-home-wpseo', 'title-author-wpseo', 'title-archive-wpseo', 'title-search-wpseo', 'title-404-wpseo', 'metadesc-home-wpseo', 'metadesc-author-wpseo', 'metadesc-archive-wpseo', 'rssbefore', 'rssafter', 'noindex-author-wpseo', 'noindex-author-noposts-wpseo', 'noindex-archive-wpseo', 'disable-author', 'disable-date', 'disable-post_format', 'disable-attachment', 'breadcrumbs-404crumb', 'breadcrumbs-display-blog-page', 'breadcrumbs-boldlast', 'breadcrumbs-archiveprefix', 'breadcrumbs-enable', 'breadcrumbs-home', 'breadcrumbs-prefix', 'breadcrumbs-searchprefix', 'breadcrumbs-sep', 'person_logo', 'person_logo_id', 'company_logo_id', 'company_or_person_user_id', 'stripcategorybase', 'noindex-post', 'display-metabox-pt-post', 'noindex-page', 'display-metabox-pt-page', 'noindex-attachment', 'display-metabox-pt-attachment', 'display-metabox-tax-category', 'noindex-tax-category', 'display-metabox-tax-post_tag', 'noindex-tax-post_tag', 'display-metabox-tax-post_format', 'noindex-tax-post_format', 'taxonomy-category-ptparent', 'taxonomy-post_tag-ptparent', 'taxonomy-post_format-ptparent', 'breadcrumbs-blog-remove', 'hideeditbox-post', 'hideeditbox-page', 'hideeditbox-attachment', 'hideeditbox-tax-category', 'hideeditbox-tax-post_tag', 'hideeditbox-tax-post_format', 'facebook_site', 'instagram_url', 'linkedin_url', 'myspace_url', 'og_default_image', 'og_default_image_id', 'og_frontpage_title', 'og_frontpage_desc', 'og_frontpage_image', 'og_frontpage_image_id', 'open_graph_frontpage_title', 'open_graph_frontpage_desc', 'open_graph_frontpage_image', 'open_graph_frontpage_image_id', 'opengraph', 'pinterest_url', 'pinterestverify', 'twitter', 'twitter_site', 'twitter_card_type', 'youtube_url', 'wikipedia_url', 'indexables_indexing_completed', 'semrush_integration_active', 'semrush_tokens', 'semrush_country_code', 'enable_enhanced_slack_sharing', 'zapier_integration_active', 'zapier_api_key', 'enable_metabox_insights', 'enable_link_suggestions', 'workouts', ]; /** * Returns the collection data. * * @return array The collection data. */ public function get() { /** * Filter: 'wpseo_tracking_settings_include_list' - Allow filtering the settings included in tracking. * * @api string $include_list the list with included setting names. */ $this->include_list = apply_filters( 'wpseo_tracking_settings_include_list', $this->include_list ); $options = WPSEO_Options::get_all(); // Returns the settings of which the keys intersect with the values of the include list. $options = array_intersect_key( $options, array_flip( $this->include_list ) ); return [ 'settings' => $this->anonymize_settings( $options ), ]; } /** * Anonimizes the WPSEO_Options array by replacing all $anonymous_settings values to 'used'. * * @param array $settings The settings. * * @return array The anonymized settings. */ private function anonymize_settings( $settings ) { foreach ( $this->anonymous_settings as $setting ) { if ( ! empty( $settings[ $setting ] ) ) { $settings[ $setting ] = 'used'; } } return $settings; } } class-tracking-default-data.php 0000644 00000001605 15152512113 0012511 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\Tracking */ /** * Represents the default data. */ class WPSEO_Tracking_Default_Data implements WPSEO_Collection { /** * Returns the collection data. * * @return array The collection data. */ public function get() { return [ 'siteTitle' => get_option( 'blogname' ), '@timestamp' => (int) date( 'Uv' ), 'wpVersion' => $this->get_wordpress_version(), 'homeURL' => home_url(), 'adminURL' => admin_url(), 'isMultisite' => is_multisite(), 'siteLanguage' => get_bloginfo( 'language' ), 'gmt_offset' => get_option( 'gmt_offset' ), 'timezoneString' => get_option( 'timezone_string' ), ]; } /** * Returns the WordPress version. * * @return string The version. */ protected function get_wordpress_version() { global $wp_version; return $wp_version; } } class-tracking-server-data.php 0000644 00000003705 15152512113 0012376 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\Tracking */ /** * Represents the server data. */ class WPSEO_Tracking_Server_Data implements WPSEO_Collection { /** * Returns the collection data. * * @return array The collection data. */ public function get() { return [ 'server' => $this->get_server_data(), ]; } /** * Returns the values with server details. * * @return array Array with the value. */ protected function get_server_data() { $server_data = []; // Validate if the server address is a valid IP-address. $ipaddress = isset( $_SERVER['SERVER_ADDR'] ) ? filter_var( wp_unslash( $_SERVER['SERVER_ADDR'] ), FILTER_VALIDATE_IP ) : ''; if ( $ipaddress ) { $server_data['ip'] = $ipaddress; $server_data['Hostname'] = gethostbyaddr( $ipaddress ); } $server_data['os'] = php_uname(); $server_data['PhpVersion'] = PHP_VERSION; $server_data['CurlVersion'] = $this->get_curl_info(); $server_data['PhpExtensions'] = $this->get_php_extensions(); return $server_data; } /** * Returns details about the curl version. * * @return array|null The curl info. Or null when curl isn't available.. */ protected function get_curl_info() { if ( ! function_exists( 'curl_version' ) ) { return null; } $curl = curl_version(); $ssl_support = true; if ( ! $curl['features'] && CURL_VERSION_SSL ) { $ssl_support = false; } return [ 'version' => $curl['version'], 'sslSupport' => $ssl_support, ]; } /** * Returns a list with php extensions. * * @return array Returns the state of the php extensions. */ protected function get_php_extensions() { return [ 'imagick' => extension_loaded( 'imagick' ), 'filter' => extension_loaded( 'filter' ), 'bcmath' => extension_loaded( 'bcmath' ), 'pcre' => extension_loaded( 'pcre' ), 'xml' => extension_loaded( 'xml' ), 'pdo_mysql' => extension_loaded( 'pdo_mysql' ), ]; } } class-tracking-theme-data.php 0000644 00000001720 15152512113 0012165 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\Tracking */ /** * Represents the theme data. */ class WPSEO_Tracking_Theme_Data implements WPSEO_Collection { /** * Returns the collection data. * * @return array The collection data. */ public function get() { $theme = wp_get_theme(); return [ 'theme' => [ 'name' => $theme->get( 'Name' ), 'url' => $theme->get( 'ThemeURI' ), 'version' => $theme->get( 'Version' ), 'author' => [ 'name' => $theme->get( 'Author' ), 'url' => $theme->get( 'AuthorURI' ), ], 'parentTheme' => $this->get_parent_theme( $theme ), ], ]; } /** * Returns the name of the parent theme. * * @param WP_Theme $theme The theme object. * * @return string|null The name of the parent theme or null. */ private function get_parent_theme( WP_Theme $theme ) { if ( is_child_theme() ) { return $theme->get( 'Template' ); } return null; } } class-tracking-plugin-data.php 0000644 00000002311 15152512113 0012356 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\Tracking */ /** * Represents the plugin data. */ class WPSEO_Tracking_Plugin_Data implements WPSEO_Collection { /** * Returns the collection data. * * @return array The collection data. */ public function get() { return [ 'plugins' => $this->get_plugin_data(), ]; } /** * Returns all plugins. * * @return array The formatted plugins. */ protected function get_plugin_data() { if ( ! function_exists( 'get_plugin_data' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $plugins = wp_get_active_and_valid_plugins(); $plugins = array_map( 'get_plugin_data', $plugins ); $plugins = array_map( [ $this, 'format_plugin' ], $plugins ); $plugin_data = []; foreach ( $plugins as $plugin ) { $plugin_key = sanitize_title( $plugin['name'] ); $plugin_data[ $plugin_key ] = $plugin; } return $plugin_data; } /** * Formats the plugin array. * * @param array $plugin The plugin details. * * @return array The formatted array. */ protected function format_plugin( array $plugin ) { return [ 'name' => $plugin['Name'], 'version' => $plugin['Version'], ]; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка