' . "\n"; } } /** * Footer Action */ public function add_honeypot() { if (Option::get('use_honeypot') && Option::get('honeypot_postid') > 0) { $post_url = get_permalink(Option::get('honeypot_postid')); echo ' '; } } /** * Enqueue Scripts */ public function enqueue_scripts() { // Load Admin Bar Css if (AdminBar::show_admin_bar() and is_admin_bar_showing()) { wp_enqueue_style('wp-statistics', WP_STATISTICS_URL . 'assets/css/frontend.min.css', true, WP_STATISTICS_VERSION); } } /* * Inline Js */ public function add_inline_rest_js() { if (Option::get('use_cache_plugin')) { // WP Statistics HTML comment $this->html_comment(); // Prepare Params $params = array_merge(array( '_' => time(), '_wpnonce' => wp_create_nonce('wp_rest'), Hits::$rest_hits_key => 'yes', ), self::set_default_params()); // Return Script echo '' . "\n"; } } /* * Set Default Params Rest Api */ public static function set_default_params() { return Helper::getHitsDefaultParams(); } /** * 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; } // Get post hits $hits = wp_statistics_pages('total', "", $post_id); $hits_html = '

' . sprintf(__('Hits: %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;