芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/optimyar/wp-content/plugins/wp-statistics/includes/class-wp-statistics-frontend.php
1], Helper::getHitsDefaultParams()); /** * Handle the bypass ad blockers * * @todo This should be refactored in a service related to option. note that all the options with same functionality should be updated. */ if (Option::get('bypass_ad_blockers', false)) { // AJAX params $requestUrl = get_site_url(); $hitParams = array_merge($params, ['action' => 'wp_statistics_hit_record']); $onlineParams = array_merge($params, ['action' => 'wp_statistics_online_check']); } else { // REST params $requestUrl = get_rest_url(null, RestAPI::$namespace); $hitParams = array_merge($params, ['endpoint' => Api\v2\Hit::$endpoint]); $onlineParams = array_merge($params, ['endpoint' => Api\v2\CheckUserOnline::$endpoint]); } /** * Build the parameters */ $jsArgs = array( 'requestUrl' => $requestUrl, 'ajaxUrl' => admin_url('admin-ajax.php'), 'hitParams' => $hitParams, 'onlineParams' => $onlineParams, 'option' => [ 'userOnline' => Option::get('useronline'), 'consentLevel' => Option::get('consent_level_integration', 'disabled'), 'dntEnabled' => Option::get('do_not_track'), 'bypassAdBlockers' => Option::get('bypass_ad_blockers', false), 'isWpConsentApiActive' => WpConsentApi::isWpConsentApiActive(), 'trackAnonymously' => Helper::shouldTrackAnonymously(), 'isPreview' => is_preview(), ], 'jsCheckTime' => apply_filters('wp_statistics_js_check_time_interval', 60000), 'isLegacyEventLoaded' => Assets::isScriptEnqueued('event'), // Check if the legacy event.js script is already loaded ); if (defined('WP_DEBUG') && WP_DEBUG) { $jsArgs['isConsoleVerbose'] = true; } Assets::script('tracker', 'js/tracker.js', [], $jsArgs, true, Option::get('bypass_ad_blockers', false)); } // Load Chart.js library if (Helper::isAdminBarShowing()) { Assets::script('chart.js', 'js/chartjs/chart.umd.min.js', [], [], true, false, null, '4.4.4'); Assets::script('mini-chart', 'js/mini-chart.js', [], [], true); Assets::style('front', 'css/frontend.min.css'); } } /* * Print out the WP Statistics HTML comment */ public function print_out_plugin_html() { if (apply_filters('wp_statistics_html_comment', true)) { echo '' . "\n"; } } /** * Show Hits in After WordPress the_content * * @param $content * @return string */ public function show_hits($content) { // Get post ID $post_id = get_the_ID(); // Check post ID if (!$post_id) { return $content; } // Check post type $post_type = get_post_type($post_id); // Get post hits $viewsModel = new ViewsModel(); $hits = $viewsModel->countViews([ 'resource_type' => $post_type, 'post_id' => $post_id, 'date' => 'total', 'post_type' => '', ]); $hits_html = '
' . sprintf(__('Views: %s', 'wp-statistics'), $hits) . '
'; // Check hits position if (Option::get('display_hits_position') == 'before_content') { return $hits_html . $content; } elseif (Option::get('display_hits_position') == 'after_content') { return $content . $hits_html; } else { return $content; } } } new Frontend;