| Server IP : 89.39.208.18 / Your IP : 216.73.217.74 Web Server : LiteSpeed System : User : ( ) PHP Version : 7.4.33 Disable Function : eval,./,ln,passthru,dl,system,exec,popen,shell_exec,posix_getpwuid,posix_uname,ftp_exec,posix_uname,posix_getpwuid,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,get_current_user,getmyuid,getmygid,listen,chgrp,apache_note,apache_setenv,apache_child_terminate,closelog,debugger_off,debugge_on,ini_restore,netscript,escapeshellarg,cmd,backtick,virtual,show_sourc,show_source,pclose,pcntl_exec,datasec,old_offset,ctrl_dir,ini_alter,leak,listen,chgrp,apache_setenv,define_syslog_variables,root,diskfreespace,disk_free_space,disk_total_space,posix_kill,getmyuid,getmygid,apache_child_terminate,php_ini_scanned_files,ls,ps_aux,chown,getrusage,posixc,posame,chgrp,posix_setuid,posix_setsid,posix_setgid,apache_note,apache_setenv,x_getuid,e_ini_file,nfo,SQL,mysql_li,t_dbs,filegroup,highlight_file,ilegetcontents,get_dir,popen,popens,pfsockopen,dos_conv,apache_get_modules,crack_check,crack_closedict,rar_open,bzopen,bzread,bzwrite,shellcode,posix_isatty,posix_getservbyname,escapeshellarg,hypot,pg_host,pos,posix_access,inurl,posix_times,posix_mknod,pclose,ps_fill,symlink,id,escapeshellcmd,php_uname,phpinfo MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home3/mahyarcake/./www/wp-content/plugins/wp-statistics/includes/ |
Upload File : |
<?php
namespace WP_STATISTICS;
class Frontend
{
public function __construct()
{
# Enable ShortCode in Widget
add_filter('widget_text', 'do_shortcode');
# Add the honey trap code in the footer.
add_action('wp_footer', array($this, 'add_honeypot'));
# Enqueue scripts & styles
add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
# Register and enqueue check online users scripts
add_action('wp_enqueue_scripts', array($this, 'enqueue_styles'));
# Print out the WP Statistics HTML comment
add_action('wp_head', array($this, 'print_out_plugin_html'));
# Check to show hits in posts/pages
if (Option::get('show_hits')) {
add_filter('the_content', array($this, 'show_hits'));
}
}
/**
* 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 '<a href="' . esc_html($post_url) . '" style="display: none;"> </a>';
}
}
/**
* Enqueue Scripts
*/
public function enqueue_scripts()
{
wp_enqueue_script('wp-statistics-tracker', WP_STATISTICS_URL . 'assets/js/tracker.js', [], WP_STATISTICS_VERSION, ['in_footer' => true]);
$params = array(
Hits::$rest_hits_key => 'yes',
);
/**
* Merge parameters
*/
$params = array_merge($params, Helper::getHitsDefaultParams());
/**
* Build request URL
*/
$hitRequestUrl = add_query_arg($params, get_rest_url(null, RestAPI::$namespace . '/' . Api\v2\Hit::$endpoint));
$keepOnlineRequestUrl = add_query_arg($params, get_rest_url(null, RestAPI::$namespace . '/' . Api\v2\CheckUserOnline::$endpoint));
$jsArgs = array(
'hitRequestUrl' => $hitRequestUrl,
'keepOnlineRequestUrl' => $keepOnlineRequestUrl,
'option' => [
'dntEnabled' => Option::get('do_not_track'),
'cacheCompatibility' => Option::get('use_cache_plugin')
],
);
wp_localize_script('wp-statistics-tracker', 'WP_Statistics_Tracker_Object', $jsArgs);
}
/**
* Enqueue Styles
*/
public function enqueue_styles()
{
// 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);
}
}
/*
* Print out the WP Statistics HTML comment
*/
public function print_out_plugin_html()
{
if (apply_filters('wp_statistics_html_comment', true)) {
echo '<!-- Analytics by WP Statistics v' . WP_STATISTICS_VERSION . ' - ' . WP_STATISTICS_SITE . ' -->' . "\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
/**
* 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 = '<p>' . sprintf(__('Views: %s', 'wp-statistics'), $hits) . '</p>';
// 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;