Plugin Directory

Changeset 3444371


Ignore:
Timestamp:
01/21/2026 07:29:15 PM (4 weeks ago)
Author:
techmix
Message:

1.4.9 released

Location:
wps-visitor-counter
Files:
336 added
8 edited

Legend:

Unmodified
Added
Removed
  • wps-visitor-counter/trunk/readme.txt

    r2557553 r3444371  
    11
    2 === WPS Visitor Counter Plugin ===
     2=== WPS Visitor Counter ===
    33Contributors: arifulislamsobuj, techmix
    4 Tags: website visitor counter, Visitor counter, visitor traffic, traffic statistics, traffic counter, blog stats, blog traffic, traffic count, visitor view count, visitor counter wordpress, visitor counter wp, website hit counter
    5 Requires at least: 3.0.1
    6 Tested up to: 5.7.2
    7 Stable tag: trunk
     4Tags: visitor counter, traffic statistics, website counter, blog stats, hit counter
     5Requires at least: 5.0
     6Tested up to: 6.9
     7Requires PHP: 7.4
     8Stable tag: 1.4.9
    89License: GPLv2 or later
    910
    10 WPS Visitor Counter plugin will display your websites traffic statistics at front end. This Plugin support Widget, Shortcode and Gutenberg Block. Some of the features offered include Today Visitor, Today Hits, Yestarday Visitors, Yestraday Hits, This Month Visitors, This Months Hits, Total Hits, Total Visit, Who's Online and IP Address Visitors.
     11Display website visitor statistics with widget, shortcode, and Gutenberg block support.
    1112
    1213== Description ==
     
    1415WPS Visitor Counter plugin is one of the best visitor counter plugin in wordpress. This plugin will help you to display the number of visitor your website have and its traffic statistics for your WordPress website. We have tried to include all the available data you needed to show in the visitor counter. Here are the items we are showing on our visitor counter:
    1516
    16 <ul><li>Users Today </li>
    17 <li>Users Yesterday </li>
     17<ul><li>Users Today</li>
     18<li>Users Yesterday</li>
    1819<li>Users Last 7 days</li>
    1920<li>Users Last 30 days</li>
    20 <li>Users This Month </li>
     21<li>Users This Month</li>
    2122<li>Users This Year</li>
    22 <li>Total Users </li>
    23 <li>Views Today </li>
     23<li>Total Users</li>
     24<li>Views Today</li>
    2425<li>Views Yesterday</li>
    2526<li>Views Last 7 days</li>
    2627<li>Views Last 30 days</li>
    2728<li>Views This Month</li>
    28 <li>Views This Year </li>
    29 <li>Total views </li>
     29<li>Views This Year</li>
     30<li>Total Views</li>
    3031<li>Who's Online</li>
    31 <li>Your IP Address </li>
    32 <li>Views Today </li>
    33 <li>Total number of views</li>
    34 <li>How many people are currently Online</li>
    35 <li>Your IP Address </li>
     32<li>Your IP Address</li>
    3633<li>Server Time</li></ul>
    3734
    38 You will find all the data authentic and this will help you to get your website traffic stat. Just install the plugin. It will affect just after you install it in your website. Our plugin is compatible for all types of websites and able to run in all versions of wordpress.
     35You will find all the data authentic and this will help you to get your website traffic stats. Just install the plugin. It will take effect just after you install it on your website. Our plugin is compatible for all types of websites and able to run in all versions of WordPress.
    3936= WPS Visitor Counter shortcode =
    4037Use this [wps_visitor_counter] Shortcode anywhere in your website where you want to show visitor counter.
    4138
    4239== gutenberg block supported ==
     40
     41= Translation Support =
     42
     43The plugin is fully internationalized and supports multiple languages. Translation files are located in the /languages/ directory.
     44
     45Currently available languages:
     46* English (default)
     47* Spanish (es_ES) - Complete translation included
     48
     49To create translations for other languages:
     501. Use the wps-visitor-counter.pot file as a template
     512. Create a .po file for your language (e.g., wps-visitor-counter-fr_FR.po)
     523. Translate the strings and compile to .mo format
     534. WordPress will automatically load the appropriate translation file
    4354
    4455== Installation ==
     
    5768= How to add more counter Images? =
    5869
    59 As of now, adding another counter images, you can do to access the folder "styles/image/" on the installation of plugins
     70As of now, to add more counter images, you can access the folder "styles/image/" in the plugin installation directory
    6071
    6172= How to use shortcode? =
    6273
    63 Use this [wps_visitor_counter] Shortcode anywhere in your website where you want to show visitor counter.
     74Use this [wps_visitor_counter] shortcode anywhere in your website where you want to show the visitor counter.
    6475
    65 = Does WPS Visitor Counter Support shortcode? =
    66 Yes. WPS Visitor Counter support shortcode. Just Use this [wps_visitor_counter] Shortcode anywhere in your website where you want to show visitor counter.
     76= Does WPS Visitor Counter support shortcode? =
     77Yes. WPS Visitor Counter supports shortcode. Just use this [wps_visitor_counter] shortcode anywhere in your website where you want to show the visitor counter.
    6778
    68 = Does WPS Visitor Counter plugin gutenberg block supported? =
     79= Does WPS Visitor Counter plugin support Gutenberg blocks? =
    6980
    70 Yes. WPS Visitor Counter plugin gutenberg block supported.
     81Yes. WPS Visitor Counter plugin supports Gutenberg blocks.
    7182
    7283= What is website visitor counter? =
    7384
    74 A website visitor counter is a type of plugin which will help you to tell how much or how many people have visited your website in a certain period of time. Different types of plugins helps you to get different types data analytics support about your website traffic. 
     85A website visitor counter is a type of plugin which will help you to see how many people have visited your website in a certain period of time. Different types of plugins help you to get various data analytics about your website traffic. 
    7586
    7687= How can I track visitors of my website by WPS visitor Counter? =
    7788
    78 No. We can only show your number of visitor visti your website. We cannot help you to track your website visitor. Hope in future update we will include this feature. 
     89No. We can only show the number of visitors to your website. We cannot help you to track individual website visitors. We hope to include this feature in a future update. 
    7990 
    8091
    8192= Is visitor counter is free? =
    8293
    83 Most of the case the website visitor counter is free. But in case of custom modification and for custom features you need to pay for that visitor counter. These custom website visitor counter will give you a overview on Geographical location tracking and IP address locator.
     94In most cases, website visitor counters are free. But for custom modifications and additional features, you may need to pay for enhanced visitor counter plugins. These custom website visitor counters will give you an overview of geographical location tracking and IP address location.
    8495
    8596= Can I use WPS visitor counter in my Wordpress website? =
    8697
    87 Yes. This is absolutely free to use for your wordpress website. just download it and install it to your desired wordpress website.
     98Yes. This is absolutely free to use for your WordPress website. Just download it and install it on your desired WordPress website.
    8899
    89100= Is WPS visitor counter is bug free? =
    90101
    91 Yes. We have tested our plugin every now and then to find bug. Recently this plugin has been test at optimum level for the assurance of the quality of our plugin.
     102Yes. We have tested our plugin regularly to find bugs. Recently this plugin has been tested at optimum level for the assurance of the quality of our plugin.
    92103
    93104= Can we use WPS visitor counter plugin from any country? =
     
    101112= Is this visitor counter works on all versions of wordpress? =
    102113
    103 We are recommend you to use our visitor counter plugin at latest version of wordpress. This will help you to get the best interface and this also makes your website secured.
     114We recommend you to use our visitor counter plugin with the latest version of WordPress. This will help you to get the best interface and this also makes your website secure.
    104115
    105116= Is this works as same as visitor hit counter? =
    106117
    107 Yes. Both of them are same thing in nature and works exactly in same way. But our visitor counter is better than the others hit counter due to secured coding and state of the art testing procedure.
     118Yes. Both of them are the same thing in nature and work exactly the same way. But our visitor counter is better than other hit counters due to secure coding and state-of-the-art testing procedures.
    108119
    109120= Is our visitor counter works on custom made website? =
    110121
    111 No. This is only usable in wordpress. If you need any custom visitor counter than we will make that for you
     122No. This is only usable in WordPress. If you need any custom visitor counter, then we will make that for you
    112123
    113124= Is this website visitor counter online works properly all the time? =
    114125
    115 Yes. In every geological location or for any amount of visitor or in any wordpress site this visitor counter is working in same efficiency
     126Yes. In every geographical location, for any amount of visitors, or on any WordPress site, this visitor counter works with the same efficiency
    116127
    117128== Screenshots ==
     
    124135
    125136
    126 Plug-in is now compatible upto wordpress version 5.2
    127 
    128 
    129137
    130138= 1.1 =
    131139<ul>
    132 <li>We have made some arbitary changes in our plugin</li>
     140<li>We have made some arbitrary changes in our plugin</li>
    133141<li>We have updated some graphical and spelling mistakes</li>
    134142</ul>
     
    142150<ul>
    143151<li>CSS Update</li>
    144 <li>Error FIX</li>
     152<li>Bug fixes</li>
    145153</ul>
    146154
     
    148156<ul>
    149157<li>Add More Options</li>
    150 <li>Change Defult options</li>
     158<li>Change Default options</li>
    151159</ul>
    152160
     
    157165</ul>
    158166
     167= 1.4.9 =
     168* Updated for WordPress 6.9 compatibility
     169* **Security Hardening**: Fixed XSS vulnerabilities, added input sanitization, capability checks, and ABSPATH protection
     170* **SQL Injection Prevention**: Converted all queries to use prepared statements with proper escaping
     171* **Code Quality**: Fixed PHPCS/WPCS violations, added translators comments, proper escaping throughout
     172* **UI Improvements**: Added Settings link to plugin list, display server date+time, removed flagged affiliate content
     173* **Plugin Compliance**: Fixed plugin name, readme tags/description, added proper license headers
     174* **Translation**: Removed discouraged load_plugin_textdomain, improved i18n support
     175
    159176== Arbitrary section ==
    160177
    161178Refer Installation and FAQ section for all required information
    162179
    163 == A brief Markdown Example ==
     180== Support ==
    164181
    165 Ordered list:
    166 
    167 1. Most simple plugin available so far
    168 1. Do not remove developer plugins link
     182For support and feature requests, please visit our website at https://techmix.xyz/
    169183
    170184== Upgrade Notice ==
    171 Upgrade your already installed plug-ins to latest version 1.0
     185= 1.4.9 =
     186Upgrade your already installed plugin to the latest version 1.4.9 for WordPress 6.9 compatibility, enhanced security, and full translation support.
  • wps-visitor-counter/trunk/wps-gutenberg-block.js

    r2118819 r3444371  
    1 ( function( blocks, components, i18n, element ) {
    2     var el = wp.element.createElement,
    3     registerBlockType = wp.blocks.registerBlockType,
    4     blockStyle = { backgroundColor: '#fff', color: '#000' };
     1( function( wp ) {
     2    var registerBlockType = wp.blocks.registerBlockType;
     3    var el = wp.element.createElement;
     4    var __ = wp.i18n.__;
    55
    6 
    7 
    8 
    9 
    10 registerBlockType( 'wps/shortcodeblock', {
    11 
    12     title: 'WPS Visitor Counter Block',
    13 
    14  
    15 
    16     icon: 'screenoptions',
    17 
    18  
    19 
    20     category: 'common',
    21 
    22 
    23 
    24     keywords: [ ],
    25     attributes: {},
    26  
    27 
    28     edit: function( props ) {
    29 
    30         return [
    31 
    32             el( 'p', { style: blockStyle }, 'WPS Visitor Counter Shortcode Block' ),       
    33 
    34         ];
    35 
    36     },
    37 
    38  
    39 
    40     save: function( props ) {
    41 
    42         return null;
    43 
    44     },
    45 
    46 } );
    47 
    48 
    49 
     6    registerBlockType( 'wps/wps-visitor-counter', {
     7        title: __( 'WPS Visitor Counter', 'wps-visitor-counter' ),
     8        icon: 'chart-bar',
     9        category: 'widgets',
     10        keywords: [
     11            __( 'visitor', 'wps-visitor-counter' ),
     12            __( 'counter', 'wps-visitor-counter' ),
     13            __( 'statistics', 'wps-visitor-counter' ),
     14        ],
     15        attributes: {
     16            className: {
     17                type: 'string',
     18                default: '',
     19            },
     20        },
     21        edit: function( props ) {
     22            return el(
     23                'div',
     24                {
     25                    className: props.className,
     26                    style: {
     27                        backgroundColor: '#f8f9fa',
     28                        padding: '20px',
     29                        border: '1px solid #dee2e6',
     30                        borderRadius: '4px',
     31                        textAlign: 'center'
     32                    }
     33                },
     34                el( 'p', { style: { margin: 0, fontWeight: 'bold' } }, __( 'WPS Visitor Counter', 'wps-visitor-counter' ) ),
     35                el( 'p', { style: { margin: '10px 0 0 0', fontSize: '14px', color: '#6c757d' } }, __( 'Visitor counter will be displayed here on the frontend.', 'wps-visitor-counter' ) )
     36            );
     37        },
     38        save: function( props ) {
     39            return el( 'div', { className: props.className }, '[wps_visitor_counter]' );
     40        },
     41    } );
    5042} )(
    51 
    52     window.wp.blocks,
    53 
    54     window.wp.components,
    55 
    56     window.wp.i18n,
    57 
    58     window.wp.element,
    59 
     43    window.wp
    6044);
  • wps-visitor-counter/trunk/wps-visitor-counter-count.php

    r2212754 r3444371  
    11<?php
     2if ( ! defined( 'ABSPATH' ) ) exit;
    23function wps_enqueue_scripts() {
    3         global $wp;
    44        if ( !is_admin() ) {
    5           wp_enqueue_script( 'wps', plugin_dir_url( __FILE__ ) . 'styles/js/custom.js', array( 'jquery' ),'1', false );
    6         $params = array(
    7           'ajaxurl' => admin_url('admin-ajax.php'),
    8           'ajax_nonce' => wp_create_nonce('wps-nonce'),
    9         );
    10         wp_localize_script( 'wps', 'wpspagevisit', $params); 
     5            wp_enqueue_script( 'wps-visitor-counter', plugin_dir_url( __FILE__ ) . 'styles/js/custom.js', array( 'jquery' ), '1.4.9', false );
     6            $params = array(
     7                'ajaxurl' => admin_url('admin-ajax.php'),
     8                'ajax_nonce' => wp_create_nonce('wps-nonce'),
     9            );
     10            wp_localize_script( 'wps-visitor-counter', 'wpspagevisit', $params );
    1111        }
    12        
    13         wp_enqueue_style( 'wps-visitor-style', plugin_dir_url( __FILE__ ).'styles/css/default.css', array(),'2' );
    1412
     13        wp_enqueue_style( 'wps-visitor-style', plugin_dir_url( __FILE__ ) . 'styles/css/default.css', array(), '1.4.9' );
    1514    }
    1615
     
    2524function wps_count_page_visit() {
    2625    check_ajax_referer( 'wps-nonce', 'nonce' );
     26
     27    if ( ! wp_doing_ajax() ) {
     28        wp_die( 'Invalid request' );
     29    }
     30
    2731    global $wpdb;
    28     $ip = wps_getRealIpAddr(); // Getting the user's computer IP
    29     $date = date("Y-m-d"); // Getting the current date
    30     $waktu = time();
    31     $sql = $wpdb->query( $wpdb->prepare("INSERT INTO `". WPS_VC_TABLE_NAME . "`(`ip`, `date`, `views`, `online`) VALUES(%s, %s, %d, %s) ON DUPLICATE KEY UPDATE `views` = `views` +1, `online` = %s;",$ip, $date, 1, $waktu,$waktu ));
    32 wp_die();
     32
     33    $ip    = wps_getRealIpAddr();
     34    $date  = current_time( 'Y-m-d' );
     35    $waktu = current_time( 'timestamp' );
     36
     37    // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Table name is a constant; direct query needed for visitor statistics.
     38    $wpdb->query( $wpdb->prepare( "INSERT INTO `" . WPS_VC_TABLE_NAME . "` (`ip`, `date`, `views`, `online`) VALUES (%s, %s, 1, %d) ON DUPLICATE KEY UPDATE `views` = `views` + 1, `online` = %d", $ip, $date, $waktu, $waktu ) );
     39
     40
     41    wp_die();
    3342}
     43
    3444?>
  • wps-visitor-counter/trunk/wps-visitor-counter-options-general.php

    r2182898 r3444371  
    11<?php
    2 if (!current_user_can('administrator'))  {
    3     wp_die( __('You do not have sufficient permissions to access this page.', 'wps-visitor-counter') );
     2if ( ! defined( 'ABSPATH' ) ) exit;
     3if (!current_user_can('manage_options')) {
     4    wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'wps-visitor-counter' ) );
    45}
    56
     
    1011<div class="wrap">
    1112    <div id="icon-options-general" class="icon32"></div>
    12     <h2><?php _e('Plugin Options WPS Visitor Counter', 'wps-visitor-counter')?></h2><br/>
     13    <h2><?php esc_html_e( 'Plugin Options WPS Visitor Counter', 'wps-visitor-counter' ); ?></h2><br/>
    1314    <div class="wpsvc_plugins_wrap"><!-- start mvc wrap -->
    1415    <div class="wpsvc_right_sidebar"><!-- start right sidebar -->
     
    1819        <div class="wpsvc_plugins_text">
    1920            <div class="wpsvc_option_wrap">
    20                 <h3 class="hndle"><?php _e('Recommended Web Hosting', 'wps-visitor-counter')?></h3>
     21                <h3 class="hndle"><?php esc_html_e( 'Recommended Web Hosting', 'wps-visitor-counter' ); ?></h3>
    2122               
    2223               
    2324                <!----fastcomet----->
    24                 <script type="text/javascript">document.write("<iframe name='banner' src='https://affiliate.fastcomet.com/scripts/banner.php?a_aid=5bd818a517dc6&a_bid=a881856b&w=1&refx2s6d="+encodeURIComponent(encodeURIComponent(document.URL))+"' framespacing='0' frameborder='no' scrolling='no' width='264' height='264' allowtransparency='true'><a href='https://affiliate.fastcomet.com/scripts/click.php?a_aid=5bd818a517dc6&amp;a_bid=a881856b' target='_top'>264x264 Robot Clipart (animated)</a></iframe>");
    2525</script>
    2626<noscript>
     
    2828</noscript>
    2929                <!----fastcomet end----->
    30                 <a href="https://www.a2hosting.com?aid=5bf7c623aa2a9&amp;bid=d6664600" target="_top"><img src="//affiliates.a2hosting.com/accounts/default1/banners/d6664600.jpg" alt="" title="" width="336" height="280" /></a><img style="border:0" src="https://affiliates.a2hosting.com/scripts/imp.php?aid=5bf7c623aa2a9&amp;bid=d6664600" width="1" height="1" alt="" />
    3130               
    3231            </div>
     
    4039                $wps_display_field_arr = explode(",",$wps_display_field);
    4140                ?>
    42                 <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" class="wps_plugin_main_form">
     41                <form method="post" action="<?php echo esc_url_raw( isset( $_SERVER["REQUEST_URI"] ) ? wp_unslash( $_SERVER["REQUEST_URI"] ) : '' ); ?>" class="wps_plugin_main_form">
    4342                    <?php wp_nonce_field('wps_my_front_end_setting'); ?>
    44                 <div><label for="wps_visitor_title"><?php _e('Title:', 'wps-visitor-counter')?> <input class="widefat" id="wps_visitor_titletitle" name="wps_visitor_title" type="text" value="<?php echo esc_html($wps_option_data['visitor_title']);?>" /></label></div>
     43                <div><label for="wps_visitor_title"><?php esc_html_e( 'Title:', 'wps-visitor-counter' ); ?> <input class="widefat" id="wps_visitor_titletitle" name="wps_visitor_title" type="text" value="<?php echo esc_attr($wps_option_data['visitor_title']);?>" /></label></div>
    4544                <?php
    4645wp_enqueue_script('wp-color-picker');
    4746wp_enqueue_style( 'wp-color-picker' );
    4847?>
    49     <div><label for="wps_visitor_font_color"><?php _e('Font Color:', 'wps-visitor-counter')?> </label><input class="widefat" id="wps_visitor_font_color" data-default-color="#000000" name="wps_visitor_font_color" type="text" value="<?php echo esc_html($wps_option_data['font_color']);?>" /></div>
     48    <div><label for="wps_visitor_font_color"><?php esc_html_e( 'Font Color:', 'wps-visitor-counter' ); ?> </label><input class="widefat" id="wps_visitor_font_color" data-default-color="#000000" name="wps_visitor_font_color" type="text" value="<?php echo esc_attr($wps_option_data['font_color']);?>" /></div>
    5049<script type="text/javascript">
    5150                jQuery(document).ready(function($) {   
     
    5453                </script>
    5554
    56     <div><font size='2'><?php _e('To change the font color, select the color with color picker.', 'wps-visitor-counter')?> </font></div>
    57     <div><font size='3'><?php _e('<b>PLugin Options</b>', 'wps-visitor-counter')?></font></div>
     55    <div><font size='2'><?php esc_html_e( 'To change the font color, select the color with color picker.', 'wps-visitor-counter' ); ?> </font></div>
     56    <div><font size='3'><b><?php esc_html_e( 'Plugin Options', 'wps-visitor-counter' ); ?></b></font></div>
    5857    <!-- UPDATE PLAN -->
    59     <div><label for="wps_visitor_user_start">Users Count Start: <input class="widefat" id="wps_visitor_user_start" name="wps_visitor_user_start" type="number" min="0" value="<?php echo esc_html($wps_option_data['user_start']);?>" /></label></div>
     58    <div><label for="wps_visitor_user_start">Users Count Start: <input class="widefat" id="wps_visitor_user_start" name="wps_visitor_user_start" type="number" min="0" value="<?php echo esc_attr($wps_option_data['user_start']);?>" /></label></div>
    6059    <div><font size='2'>Fill in with numbers to start the initial calculation of the user counter, if the empty counter will start from 1</font></div>
    61     <div><label for="wps_visitor_views_start">views Start: <input class="widefat" id="wps_visitor_views_start" name="wps_visitor_views_start" type="number" min="0" value="<?php echo esc_html($wps_option_data['views_start']);?>" /></label></div>
     60    <div><label for="wps_visitor_views_start">views Start: <input class="widefat" id="wps_visitor_views_start" name="wps_visitor_views_start" type="number" min="0" value="<?php echo esc_attr($wps_option_data['views_start']);?>" /></label></div>
    6261    <div><font size='2'>Fill in the numbers to start the initial calculation of the views, if the empty views will start from 1</font></div>
    6362    <!-- END UPDATE -->
    64     <div><label for="wps_visitor_today_user"><?php _e('Enable Users Today display?', 'wps-visitor-counter')?> <input type="checkbox" class="checkbox" <?php if (in_array("today_user", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_today_user" name="wps_visitor_today_user" /></label></div>
    65     <div><label for="wps_visitor_yesterday_user"><?php _e('Enable Users Yesterday display?', 'wps-visitor-counter')?> <input type="checkbox" class="checkbox" <?php if (in_array("yesterday_user", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_yesterday_user" name="wps_visitor_yesterday_user" /></label></div>
    66 
    67     <div><label for="wps_visitor_last7_day_user"><?php _e('Enable Users Last 7 Days display?', 'wps-visitor-counter')?> <input type="checkbox" class="checkbox" <?php if (in_array("last7_day_user", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_last7_day_user" name="wps_visitor_last7_day_user" /></label></div>
    68 
    69     <div><label for="wps_visitor_last30_day_user"><?php _e('Enable Users Last 30 Days display?', 'wps-visitor-counter')?> <input type="checkbox" class="checkbox" <?php if (in_array("last30_day_user", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_last30_day_user" name="wps_visitor_last30_day_user" /></label></div>
    70 
    71     <div><label for="wps_visitor_month_user"><?php _e('Enable Users This Month display?', 'wps-visitor-counter')?> <input type="checkbox" class="checkbox" <?php if (in_array("month_user", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_month_user" name="wps_visitor_month_user" /></label></div>
    72     <div><label for="wps_visitor_year_user"><?php _e('Enable Users This Year display?', 'wps-visitor-counter')?> <input type="checkbox" class="checkbox" <?php if (in_array("year_user", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_year_user" name="wps_visitor_year_user" /></label></div>
    73     <div><label for="wps_visitor_total_user"><?php _e('Enable Total Users display?', 'wps-visitor-counter')?> <input type="checkbox" class="checkbox" <?php if (in_array("total_user", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_total_user" name="wps_visitor_total_user" /></label></div>
    74     <div><label for="wps_visitor_today_view"><?php _e('Enable views Today display?', 'wps-visitor-counter')?> <input type="checkbox" class="checkbox" <?php if (in_array("today_view", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_today_view" name="wps_visitor_today_view" /></label></div>
    75 
    76     <div><label for="wps_visitor_yesterday_view"><?php _e('Enable views Yesterday display?', 'wps-visitor-counter')?> <input type="checkbox" class="checkbox" <?php if (in_array("yesterday_view", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_yesterday_view" name="wps_visitor_yesterday_view" /></label></div>
    77 
    78    
    79     <div><label for="wps_visitor_last7_day_view"><?php _e('Enable views Last 7 Days display?', 'wps-visitor-counter')?> <input type="checkbox" class="checkbox" <?php if (in_array("last7_day_view", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_last7_day_view" name="wps_visitor_last7_day_view" /></label></div>
    80 
    81     <div><label for="wps_visitor_last30_day_view"><?php _e('Enable views Last 30 Days display?', 'wps-visitor-counter')?> <input type="checkbox" class="checkbox" <?php if (in_array("last30_day_view", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_last30_day_view" name="wps_visitor_last30_day_view" /></label></div>
    82 
    83 
    84     <div><label for="wps_visitor_month_view"><?php _e('Enable views This Month display?', 'wps-visitor-counter')?> <input type="checkbox" class="checkbox" <?php if (in_array("month_view", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_month_view" name="wps_visitor_month_view" /></label></div>
    85     <div><label for="wps_visitor_year_view"><?php _e('Enable views This Year display?', 'wps-visitor-counter')?> <input type="checkbox" class="checkbox" <?php if (in_array("year_view", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_year_view" name="wps_visitor_year_view" /></label></div>
    86 
    87 
    88 
    89     <div><label for="wps_visitor_total_view"><?php _e('Enable Total views display?', 'wps-visitor-counter')?> <input type="checkbox" class="checkbox" <?php if (in_array("total_view", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_total_view" name="wps_visitor_total_view" /></label></div>
    90     <div><label for="wps_visitor_online_view"><?php _e('Enable Whos Online display?', 'wps-visitor-counter')?> <input type="checkbox" class="checkbox" <?php if (in_array("online_view", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_online_view" name="wps_visitor_online_view" /></label></div>
    91     <div><label for="wps_visitor_ip_display"><?php _e('Enable IP address display?', 'wps-visitor-counter')?> <input type="checkbox" class="checkbox" <?php if (in_array("ip_display", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_ip_display" name="wps_visitor_ip_display" /></label></div>
    92     <div><label for="wps_visitor_server_time"><?php _e('Enable Server Time display?', 'wps-visitor-counter')?> <input type="checkbox" class="checkbox" <?php if (in_array("server_time", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_server_time" name="wps_visitor_server_time" /></label></div>
    93     <div><label for="wps_visitor_wpsvc_align"><?php _e('Plugins align?', 'wps-visitor-counter')?>
    94     <select class="select" id="wps_visitor_wpsvc_align" name="wps_visitor_wpsvc_align" selected="<?php echo $wps_option_data['visitor_wpsvc_align'];?>">
    95     <option value="left"><?php _e('wps_visitor_wpsvc_align', 'wps-visitor-counter') ?></option>
    96     <option value="left" <?php if($wps_option_data['visitor_wpsvc_align'] == 'left'){echo "selected";}?>><?php _e('Left', 'wps-visitor-counter') ?></option>
    97     <option value="center" <?php if($wps_option_data['visitor_wpsvc_align'] == 'center'){echo "selected";}?>><?php _e('Center', 'wps-visitor-counter') ?></option>
    98     <option value="right" <?php if($wps_option_data['visitor_wpsvc_align'] == 'right'){echo "selected";}?>><?php _e('Right', 'wps-visitor-counter') ?></option>
     63    <div><label for="wps_visitor_today_user"><?php esc_html_e( 'Enable Users Today display?', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" <?php if (in_array("today_user", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_today_user" name="wps_visitor_today_user" /></label></div>
     64    <div><label for="wps_visitor_yesterday_user"><?php esc_html_e( 'Enable Users Yesterday display?', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" <?php if (in_array("yesterday_user", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_yesterday_user" name="wps_visitor_yesterday_user" /></label></div>
     65
     66    <div><label for="wps_visitor_last7_day_user"><?php esc_html_e( 'Enable Users Last 7 Days display?', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" <?php if (in_array("last7_day_user", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_last7_day_user" name="wps_visitor_last7_day_user" /></label></div>
     67
     68    <div><label for="wps_visitor_last30_day_user"><?php esc_html_e( 'Enable Users Last 30 Days display?', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" <?php if (in_array("last30_day_user", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_last30_day_user" name="wps_visitor_last30_day_user" /></label></div>
     69
     70    <div><label for="wps_visitor_month_user"><?php esc_html_e( 'Enable Users This Month display?', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" <?php if (in_array("month_user", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_month_user" name="wps_visitor_month_user" /></label></div>
     71    <div><label for="wps_visitor_year_user"><?php esc_html_e( 'Enable Users This Year display?', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" <?php if (in_array("year_user", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_year_user" name="wps_visitor_year_user" /></label></div>
     72    <div><label for="wps_visitor_total_user"><?php esc_html_e( 'Enable Total Users display?', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" <?php if (in_array("total_user", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_total_user" name="wps_visitor_total_user" /></label></div>
     73    <div><label for="wps_visitor_today_view"><?php esc_html_e( 'Enable views Today display?', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" <?php if (in_array("today_view", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_today_view" name="wps_visitor_today_view" /></label></div>
     74
     75    <div><label for="wps_visitor_yesterday_view"><?php esc_html_e( 'Enable views Yesterday display?', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" <?php if (in_array("yesterday_view", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_yesterday_view" name="wps_visitor_yesterday_view" /></label></div>
     76
     77   
     78    <div><label for="wps_visitor_last7_day_view"><?php esc_html_e( 'Enable views Last 7 Days display?', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" <?php if (in_array("last7_day_view", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_last7_day_view" name="wps_visitor_last7_day_view" /></label></div>
     79
     80    <div><label for="wps_visitor_last30_day_view"><?php esc_html_e( 'Enable views Last 30 Days display?', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" <?php if (in_array("last30_day_view", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_last30_day_view" name="wps_visitor_last30_day_view" /></label></div>
     81
     82
     83    <div><label for="wps_visitor_month_view"><?php esc_html_e( 'Enable views This Month display?', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" <?php if (in_array("month_view", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_month_view" name="wps_visitor_month_view" /></label></div>
     84    <div><label for="wps_visitor_year_view"><?php esc_html_e( 'Enable views This Year display?', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" <?php if (in_array("year_view", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_year_view" name="wps_visitor_year_view" /></label></div>
     85
     86
     87
     88    <div><label for="wps_visitor_total_view"><?php esc_html_e( 'Enable Total views display?', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" <?php if (in_array("total_view", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_total_view" name="wps_visitor_total_view" /></label></div>
     89    <div><label for="wps_visitor_online_view"><?php esc_html_e( 'Enable Whos Online display?', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" <?php if (in_array("online_view", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_online_view" name="wps_visitor_online_view" /></label></div>
     90    <div><label for="wps_visitor_ip_display"><?php esc_html_e( 'Enable IP address display?', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" <?php if (in_array("ip_display", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_ip_display" name="wps_visitor_ip_display" /></label></div>
     91    <div><label for="wps_visitor_server_time"><?php esc_html_e( 'Enable Server Time display?', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" <?php if (in_array("server_time", $wps_display_field_arr)) {echo "checked";} ?> id="wps_visitor_server_time" name="wps_visitor_server_time" /></label></div>
     92    <div><label for="wps_visitor_wpsvc_align"><?php esc_html_e( 'Plugins align?', 'wps-visitor-counter' ); ?>
     93    <select class="select" id="wps_visitor_wpsvc_align" name="wps_visitor_wpsvc_align">
     94    <option value="left"><?php esc_html_e( 'Left', 'wps-visitor-counter' ); ?></option>
     95    <option value="left" <?php if($wps_option_data['visitor_wpsvc_align'] == 'left'){echo "selected";}?>><?php esc_html_e( 'Left', 'wps-visitor-counter' ); ?></option>
     96    <option value="center" <?php if($wps_option_data['visitor_wpsvc_align'] == 'center'){echo "selected";}?>><?php esc_html_e( 'Center', 'wps-visitor-counter' ); ?></option>
     97    <option value="right" <?php if($wps_option_data['visitor_wpsvc_align'] == 'right'){echo "selected";}?>><?php esc_html_e( 'Right', 'wps-visitor-counter' ); ?></option>
    9998    </select></label></div>
    100                     <input type="submit" name="wps_view_setting" class="button-primary" value="<?php _e('Save Changes', 'wps-visitor-counter') ?>" /></form>
     99                    <input type="submit" name="wps_view_setting" class="button-primary" value="<?php echo esc_attr__( 'Save Changes', 'wps-visitor-counter' ); ?>" /></form>
    101100            </div>
    102101        </div>
    103102        <div class="wpsvc_plugins_text">
    104103            <div class="wpsvc_option_wrap">
    105                 <h3 class="hndle"><?php _e('The way of use', 'wps-visitor-counter') ?></h3>
    106                 <p><?php _e('Use this <b>"[wps_visitor_counter]"</b> shortcode or use in your registered widget.', 'wps-visitor-counter') ?></p>
     104                <h3 class="hndle"><?php esc_html_e( 'The way of use', 'wps-visitor-counter' ); ?></h3>
     105                <p><?php esc_html_e( 'Use this "[wps_visitor_counter]" shortcode or use in your registered widget.', 'wps-visitor-counter' ); ?></p>
    107106            </div>
    108107        </div>
    109108        <div class="wpsvc_plugins_text">
    110109            <div class="wpsvc_option_wrap">
    111                 <h3 class="hndle"><?php _e('Reset Plugin Data', 'wps-visitor-counter') ?></h3>
    112                 <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
     110                <h3 class="hndle"><?php esc_html_e( 'Reset Plugin Data', 'wps-visitor-counter' ); ?></h3>
     111                <form method="post" action="<?php echo esc_url_raw( isset( $_SERVER["REQUEST_URI"] ) ? wp_unslash( $_SERVER["REQUEST_URI"] ) : '' ); ?>">
    113112                    <?php wp_nonce_field('wps_table_reset'); ?>
    114113                    <p style="margin-top:20px;" >
    115                     <?php _e('Check for reset', 'wps-visitor-counter'); ?> <input type="checkbox" class="checkbox" id="reset_wpsvc" name="reset_wpsvc" />
    116                     <input type="submit" class="button-primary" value="<?php _e('Reset Data', 'wps-visitor-counter') ?>" />
     114                    <?php esc_html_e( 'Check for reset', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" id="reset_wpsvc" name="reset_wpsvc" />
     115                    <input type="submit" class="button-primary" value="<?php echo esc_attr__( 'Reset Data', 'wps-visitor-counter' ); ?>" />
    117116                    </p>
    118117                </form>
     
    126125    <div class="wpsvc_left_sidebar"><!-- start Left sidebar -->
    127126    <div class="wpsvc_plugins_text">
    128     <div class="wpsvc_option_wrap">
    129         <h3 class="hndle"><?php _e('Google AdSense', 'wps-visitor-counter') ?></h3>
    130         <a href="https://partner.pcloud.com/r/7781" title="pCloud Premium" target="_blank"><img src="https://partner.pcloud.com/media/banners/lifetime/lifetime00572890.jpg" alt="pCloud Premium"/></a>
    131        
    132         <a href="https://www.tubebuddy.com/offertail" title="TubeBuddy" target="_blank"><img src="https://www.tubebuddy.com/assets/images/AffiliateAssets/Banner-728x90.png" alt="TubeBuddy"/></a>
    133        
    134        
    135     </div>
    136127    <div class="wpsvc_option_wrap wps_follow_button">
    137         <h3 class="hndle"><?php _e('Follow us', 'wps-visitor-counter') ?></h3>
    138         <a href="https://www.facebook.com/TechMix365"><img src="<?php echo plugins_url ("counter/fb.png" , __FILE__ );?>" alt=""></a>
    139         <a href="https://twitter.com/TechMix365"><img src="<?php echo plugins_url ("counter/twitter.png" , __FILE__ );?>" alt=""></a>
     128        <h3 class="hndle"><?php esc_html_e( 'Follow us', 'wps-visitor-counter' ); ?></h3>
     129        <a href="https://www.facebook.com/TechMix365"><img src="<?php echo esc_url( plugins_url( 'counter/fb.png', __FILE__ ) ); ?>" alt=""></a>
     130        <a href="https://twitter.com/TechMix365"><img src="<?php echo esc_url( plugins_url( 'counter/twitter.png', __FILE__ ) ); ?>" alt=""></a>
    140131    </div>
    141132    </div>
    142133    <div class="wpsvc_option_wrap">
    143134    <div class="wpsvc_plugins_text">
    144     <h3 class="hndle"><?php _e('Image Counter', 'wps-visitor-counter') ?></h3>
    145     <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
     135    <h3 class="hndle"><?php esc_html_e( 'Image Counter', 'wps-visitor-counter' ); ?></h3>
     136    <form method="post" action="<?php echo esc_url_raw( isset( $_SERVER["REQUEST_URI"] ) ? wp_unslash( $_SERVER["REQUEST_URI"] ) : '' ); ?>">
    146137        <?php wp_nonce_field('wps_my_front_end_style'); ?>
    147138
     
    162153?>
    163154                   
    164                     <p><b>Choose one of the <?php echo $style_name; ?> counter styles below:</b></p>
     155                    <p><b>Choose one of the <?php echo esc_html( $style_name ); ?> counter styles below:</b></p>
    165156                        <table class="form-table">
    166157                        <?php
     
    169160                        <tr>
    170161                        <td>
    171                         <input type="radio" id="img1" name="wps_visitor_counter_style" value="<?php echo 'image/'.$name; ?>" <?php if($wps_option_data['style'] == 'image/'.$name){echo "checked";}?>/>
    172                         <img src='<?php echo plugin_dir_url( __FILE__ );?>styles/<?php echo $style_name . '/' . $name . '/'; ?>11.jpg'>
     162                        <input type="radio" id="img1" name="wps_visitor_counter_style" value="<?php echo esc_attr( 'image/'.$name ); ?>" <?php if($wps_option_data['style'] == 'image/'.$name){echo "checked";}?>/>
     163                        <img src='<?php echo esc_url( plugin_dir_url( __FILE__ ) . 'styles/' . esc_attr( $style_name ) . '/' . esc_attr( $name ) . '/11.jpg' ); ?>' alt="<?php echo esc_attr( $style_name . ' ' . $name ); ?>">
    173164       
    174165                        </td>
     
    209200            }
    210201        ?>   
    211         <p><?php _e('Show powered by <a href="https://techmix.xyz/">WPS Visitor Counter</a>? ', 'wps-visitor-counter'); ?> <input type="checkbox" class="checkbox" id="wps_visitor_counter_attribution" name="wps_visitor_counter_attribution" <?php if($wps_option_data['show_powered_by'] == 1 ){echo "checked";} ?>/></p>
     202        <p><?php esc_html_e( 'Show powered by WPS Visitor Counter? ', 'wps-visitor-counter' ); ?> <input type="checkbox" class="checkbox" id="wps_visitor_counter_attribution" name="wps_visitor_counter_attribution" <?php if($wps_option_data['show_powered_by'] == 1 ){echo "checked";} ?>/></p>
    212203        <p style="margin-top:20px;" >
    213         <input type="submit" name="style_setting" class="button-primary" value="<?php _e('Save Changes', 'wps-visitor-counter') ?>" />
     204        <input type="submit" name="style_setting" class="button-primary" value="<?php echo esc_attr__( 'Save Changes', 'wps-visitor-counter' ); ?>" />
    214205        </p>
    215206    </form>
  • wps-visitor-counter/trunk/wps-visitor-counter-widgets.php

    r2182903 r3444371  
    11<?php
     2if ( ! defined( 'ABSPATH' ) ) exit;
    23class wps_visitor_counter extends WP_Widget{
    34
    4     function __construct(){
    5         $paramitter=array(
    6         'description' => __('Display Visitor Counter and Statistics Traffic in shortcode and widget', 'wps-visitor-counter'), //plugin description
    7         'name' => 'WPS - Visitor Counter'  //title of plugin
     5    public function __construct(){
     6        $widget_ops = array(
     7            'classname' => 'wps_visitor_counter',
     8            'description' => __('Display Visitor Counter and Statistics Traffic in shortcode and widget', 'wps-visitor-counter'),
    89        );
    9 
    10         parent::__construct('wps_visitor_counter', '', $paramitter);
     10        parent::__construct('wps_visitor_counter', __('WPS - Visitor Counter', 'wps-visitor-counter'), $widget_ops);
    1111    }
    1212   
    1313    public function widget($args, $instance){
     14        // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Function returns escaped HTML.
    1415        echo wps_add_visitor_counter();
    1516    }
  • wps-visitor-counter/trunk/wps-visitor-counter.php

    r2558012 r3444371  
    11<?php
    22/*
    3 Plugin Name: WPS Visitor Counter Plugin
     3Plugin Name: WPS Visitor Counter
    44Plugin URI: https://techmix.xyz/downloads/wps-visitor-counter-plugin-for-wordpress/
    55Description: WPS Visitor Counter plugin will display your websites traffic statistics at front end. This Plugin support Widget, Shortcode and Gutenberg Block.
    6 Version: 1.4.8
     6Version: 1.4.9
     7Requires at least: 5.0
     8Tested up to: 6.9
     9Requires PHP: 7.4
     10License: GPLv2 or later
     11License URI: https://www.gnu.org/licenses/gpl-2.0.html
    712Text Domain: wps-visitor-counter
    813Domain Path: /languages
     
    1015Author URI: https://techmix.xyz/
    1116*/
    12 
     17if ( ! defined( 'ABSPATH' ) ) exit;
    1318if ( ! function_exists( 'wps_getRealIpAddr' ) ) {
    1419    function wps_getRealIpAddr() {
    15         foreach (['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR'] as $key){
    16             if(array_key_exists($key, $_SERVER) === true){
    17                 foreach (explode(',', $_SERVER[$key]) as $ip){
    18                     $ip = trim($ip); // just to be safe
    19                     if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false){
    20                         return $ip;
     20        $ip_headers = [
     21            'HTTP_CF_CONNECTING_IP', // Cloudflare
     22            'HTTP_CLIENT_IP',
     23            'HTTP_X_FORWARDED_FOR',
     24            'HTTP_X_FORWARDED',
     25            'HTTP_X_CLUSTER_CLIENT_IP',
     26            'HTTP_FORWARDED_FOR',
     27            'HTTP_FORWARDED',
     28            'REMOTE_ADDR'
     29        ];
     30
     31        foreach ($ip_headers as $key) {
     32            if (!empty($_SERVER[$key])) {
     33                $raw_value = sanitize_text_field( wp_unslash( $_SERVER[ $key ] ) );
     34                foreach (explode(',', $raw_value) as $ip) {
     35                    $ip = trim($ip);
     36                    // Validate IP and exclude private/reserved ranges
     37                    if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false) {
     38                        return sanitize_text_field($ip);
    2139                    }
    2240                }
    2341            }
    2442        }
     43
     44        // Fallback
     45        return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ?? '127.0.0.1' ) );
    2546    }
    2647}
     
    4768function wps_visitor_counter_admin_menu() {
    4869    add_options_page('Plugin Stats WPS', 'WPS Visitor Counter', "manage_options", 'wps_options_general', 'wps_visitor_counter_option');
     70}
     71
     72/**
     73 * Add "Settings" link on Plugins list page.
     74 */
     75function wps_visitor_counter_plugin_action_links( $links ) {
     76    if ( current_user_can( 'manage_options' ) ) {
     77        $settings_url = admin_url( 'options-general.php?page=wps_options_general' );
     78        array_unshift(
     79            $links,
     80            '<a href="' . esc_url( $settings_url ) . '">' . esc_html__( 'Settings', 'wps-visitor-counter' ) . '</a>'
     81        );
     82    }
     83
     84    return $links;
    4985}
    5086
     
    82118add_action('widgets_init', 'wps_visitor_counter_widgets_init');
    83119add_action('admin_menu', 'wps_visitor_counter_admin_menu');
    84 add_action('plugins_loaded', function() {
    85       load_plugin_textdomain( 'wps-visitor-counter', false, basename( dirname( __FILE__ ) ) . '/languages/' );
    86     });
     120add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'wps_visitor_counter_plugin_action_links' );
    87121
    88122
     
    94128function wps_visitor_init() {
    95129        add_shortcode( 'wps_visitor_counter', 'wps_add_visitor_counter' );
    96         /*register_block_type( 'wps/wps-visitor-counter', array(
    97                 'editor_script' => 'wps-visitor-block',
     130
     131        // Register Gutenberg block
     132        if ( function_exists( 'register_block_type' ) ) {
     133            wp_register_script(
     134                'wps-visitor-gutenberg-editor-scripts',
     135                esc_url( plugin_dir_url(__FILE__) . 'wps-gutenberg-block.js' ),
     136                array( 'wp-blocks', 'wp-element', 'wp-editor', 'wp-components', 'wp-i18n' ),
     137                '1.4.9',
     138                true
     139            );
     140
     141            register_block_type( 'wps/wps-visitor-counter', array(
     142                'editor_script' => 'wps-visitor-gutenberg-editor-scripts',
    98143                'render_callback' => 'wps_add_visitor_counter',
    99         ) );*/
    100 
    101 
    102          if ( !function_exists( 'register_block_type' ) ) {
    103 
    104         return;
    105 
    106     }
    107 
    108 
    109 
    110     wp_register_script(
    111 
    112         'wps-visitor-gutenberg-editor_scripts',
    113 
    114         plugin_dir_url(__FILE__) . 'wps-gutenberg-block.js',
    115 
    116         array( 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-editor' )
    117 
    118     );
    119 
    120     register_block_type( 'wps/shortcode-script', array(
    121 
    122         'editor_script' => 'wps-visitor-gutenberg-editor_scripts',
    123 
    124     ));
    125     register_block_type( 'wps/shortcodeblock', array(
    126 
    127     'render_callback' => 'wps_add_visitor_counter'
    128 
    129     ));
    130 
    131    
     144                'attributes' => array(
     145                    'className' => array(
     146                        'type' => 'string',
     147                        'default' => '',
     148                    ),
     149                ),
     150            ));
     151        }
    132152}
    133153
  • wps-visitor-counter/trunk/wps_visitor_counter_views.php

    r2212754 r3444371  
    11<?php
     2if ( ! defined( 'ABSPATH' ) ) exit;
     3    // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Direct queries needed for custom visitor statistics table.
    24    function wps_add_visitor_counter() {
    35        global $wpdb;
     
    2022   
    2123    $ip = wps_getRealIpAddr(); // Getting the user's computer IP
    22     $date = date("Y-m-d"); // Getting the current date
    23     $date_year_month = date("Y-m");
    24     $date_year = date("Y");
    25     $yesterday_date = date('Y-m-d',strtotime("-1 days"));
    26    
    27    
    28     $timeBefore = time() - 300;
     24    $date = current_time('Y-m-d'); // Getting the current date in WordPress timezone (date only)
     25    $server_datetime = current_time( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) ); // Display date + time
     26    $date_year_month = current_time('Y-m');
     27    $date_year = current_time('Y');
     28    $yesterday_timestamp = current_time('timestamp') - 86400; // Subtract one day in seconds.
     29    $yesterday_date = date_i18n('Y-m-d', $yesterday_timestamp);
     30   
     31   
     32    $timeBefore = current_time('timestamp') - 300;
    2933
    3034
     
    3236    //image print
    3337    // UPDATE PLAN
     38    // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Table name is a constant; direct query needed for visitor statistics.
    3439    $user_total = $wpdb->get_var( "SELECT COUNT(`views`) FROM `". WPS_VC_TABLE_NAME . "`" );
    3540    if ($user_start==NULL) {
     
    114119   
    115120    <?php if (in_array("today_user", $wps_display_field_arr)) {
    116         $user_today = $wpdb->get_var( "SELECT COUNT(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` = '$date'" );
     121        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name is a constant, cannot be prepared.
     122        $user_today = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` = %s", $date ) );
    117123
    118124        $wps_return = $wps_return."<div id=\"wpsvcvisit\" ".$style.">".$imgvisit." ".esc_html__('Users Today', 'wps-visitor-counter')." : ".$user_today."</div>";
     
    122128    <?php } ?>
    123129    <?php if (in_array("yesterday_user", $wps_display_field_arr)) {
    124         $user_yesterday = $wpdb->get_var( "SELECT COUNT(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` = '$yesterday_date'" );
     130        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name is a constant, cannot be prepared.
     131        $user_yesterday = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` = %s", $yesterday_date ) );
    125132
    126133
     
    132139
    133140    <?php if (in_array("last7_day_user", $wps_display_field_arr)) {
     141        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name is a constant, cannot be prepared.
    134142        $user_last_7days = $wpdb->get_var( "SELECT COUNT(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` >= DATE(NOW()) - INTERVAL 7 DAY" );
    135143
     
    141149    <?php } ?>
    142150    <?php if (in_array("last30_day_user", $wps_display_field_arr)) {
     151        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name is a constant, cannot be prepared.
    143152        $user_last_30days = $wpdb->get_var( "SELECT COUNT(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` >= DATE(NOW()) - INTERVAL 30 DAY" );
    144153
     
    150159    <?php } ?>
    151160    <?php if (in_array("month_user", $wps_display_field_arr)) {
    152         $user_month = $wpdb->get_var( "SELECT COUNT(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` LIKE '$date_year_month%'" );
     161        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name is a constant, cannot be prepared.
     162        $user_month = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` LIKE %s", $date_year_month . '%' ) );
    153163
    154164
     
    159169    <?php } ?>
    160170    <?php if (in_array("year_user", $wps_display_field_arr)) {
    161         $user_year = $wpdb->get_var( "SELECT COUNT(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` LIKE '$date_year%'" );
     171        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name is a constant, cannot be prepared.
     172        $user_year = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` LIKE %s", $date_year . '%' ) );
    162173
    163174
     
    183194    <?php } ?>
    184195    <?php if (in_array("today_view", $wps_display_field_arr)) {
    185         $views_today= $wpdb->get_var( "SELECT SUM(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` = '$date'" );
     196        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name is a constant, cannot be prepared.
     197        $views_today= $wpdb->get_var( $wpdb->prepare( "SELECT SUM(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` = %s", $date ) );
    186198
    187199
     
    192204    <?php } ?>
    193205    <?php if (in_array("yesterday_view", $wps_display_field_arr)) {
    194         $views_yesterday = $wpdb->get_var( "SELECT SUM(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` = '$yesterday_date'" );
     206        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name is a constant, cannot be prepared.
     207        $views_yesterday = $wpdb->get_var( $wpdb->prepare( "SELECT SUM(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` = %s", $yesterday_date ) );
    195208        if ($views_yesterday=="") {
    196209            $views_yesterday==0;
     
    203216    <?php } ?>
    204217    <?php if (in_array("last7_day_view", $wps_display_field_arr)) {
     218        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name is a constant, cannot be prepared.
    205219        $views_last7_days = $wpdb->get_var( "SELECT SUM(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` >= DATE(NOW()) - INTERVAL 7 DAY" );
    206220
     
    212226    <?php } ?>
    213227    <?php if (in_array("last30_day_view", $wps_display_field_arr)) {
     228        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name is a constant, cannot be prepared.
    214229        $views_last30_days = $wpdb->get_var( "SELECT SUM(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` >= DATE(NOW()) - INTERVAL 30 DAY" );
    215230
     
    221236    <?php } ?>
    222237    <?php if (in_array("month_view", $wps_display_field_arr)) {
    223         $views_month = $wpdb->get_var( "SELECT SUM(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` LIKE '$date_year_month%'" );
     238        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name is a constant, cannot be prepared.
     239        $views_month = $wpdb->get_var( $wpdb->prepare( "SELECT SUM(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` LIKE %s", $date_year_month . '%' ) );
    224240
    225241
     
    232248   
    233249    <?php if (in_array("year_view", $wps_display_field_arr)) {
    234         $views_year = $wpdb->get_var( "SELECT SUM(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` LIKE '$date_year%'" );
     250        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name is a constant, cannot be prepared.
     251        $views_year = $wpdb->get_var( $wpdb->prepare( "SELECT SUM(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `date` LIKE %s", $date_year . '%' ) );
    235252
    236253
     
    241258    <?php } ?>
    242259    <?php if (in_array("total_view", $wps_display_field_arr)) {
     260        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name is a constant, cannot be prepared.
    243261        $totalviews = $wpdb->get_var( "SELECT SUM(`views`) FROM `". WPS_VC_TABLE_NAME . "`" );
    244262         if ($views_start!=NULL) {
     
    252270    <?php } ?>
    253271    <?php if (in_array("online_view", $wps_display_field_arr)) {
    254         $total_online = $wpdb->get_var( "SELECT COUNT(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `online` > '$timeBefore'" );
     272        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name is a constant, cannot be prepared.
     273        $total_online = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(`views`) FROM `". WPS_VC_TABLE_NAME . "` WHERE `online` > %d", $timeBefore ) );
    255274
    256275
     
    273292    <?php if (in_array("server_time", $wps_display_field_arr)) {
    274293
    275 
    276         $wps_return = $wps_return."<div id=\"wpsvcdate\">".$img_visit_year." ".esc_html__('Server Time', 'wps-visitor-counter')." : ".$date."</div>";
     294        $wps_return = $wps_return."<div id=\"wpsvcdate\">".$img_visit_year." ".esc_html__('Server Time', 'wps-visitor-counter')." : ".esc_html( $server_datetime )."</div>";
    277295
    278296
     
    281299    <?php if ($wps_option_data['show_powered_by'] == 1) {
    282300
    283 
    284         $wps_return = $wps_return."<div id=\"wpsvcattribution\" ".$style."><small>Powered By <a href=\"https://techmix.xyz/\" rel=\"nofollow\">WPS Visitor Counter</a></small></div>";
     301        /* translators: %s: Link to plugin website */
     302        $wps_return = $wps_return."<div id=\"wpsvcattribution\" ".$style."><small>".sprintf(__('Powered By %s', 'wps-visitor-counter'), '<a href="https://techmix.xyz/" rel="nofollow">WPS Visitor Counter</a>')."</small></div>";
    285303
    286304
     
    290308    $wps_return = $wps_return."</div>";
    291309    return $wps_return;
     310    // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
    292311    ?>
    293312
  • wps-visitor-counter/trunk/wps_wp_query.php

    r2133014 r3444371  
    11<?php
    22if ( ! defined( 'ABSPATH' ) ) exit;
     3
     4/**
     5 * Get and validate nonce from POST.
     6 *
     7 * @param string $action Nonce action.
     8 * @return bool True if nonce exists and is valid, false otherwise.
     9 */
     10function wps_vc_verify_post_nonce( $action ) {
     11    if ( ! isset( $_POST['_wpnonce'] ) ) {
     12        return false;
     13    }
     14
     15    $nonce = sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) );
     16    return (bool) wp_verify_nonce( $nonce, $action );
     17}
     18
     19// phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verification happens via wps_vc_verify_post_nonce() function.
    320if (isset($_POST['reset_wpsvc'])) {
    4     $retrieved_nonce = $_POST['_wpnonce'];
    5     if (wp_verify_nonce($retrieved_nonce, 'wps_table_reset')) {
     21    if (!current_user_can('manage_options')) {
     22        wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'wps-visitor-counter' ) );
     23    }
     24    if ( wps_vc_verify_post_nonce( 'wps_table_reset' ) ) {
    625        wps_visitor_counter_truncate();
    726    }
     
    928}
    1029if (isset($_POST['style_setting'])) {
    11     $retrieved_nonce = $_POST['_wpnonce'];
    12     if (wp_verify_nonce($retrieved_nonce, 'wps_my_front_end_style')) {
     30    if (!current_user_can('manage_options')) {
     31        wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'wps-visitor-counter' ) );
     32    }
     33    if ( wps_vc_verify_post_nonce( 'wps_my_front_end_style' ) ) {
    1334        $image_styel="";
    1435        $powerd_by= 0 ;
    1536        if (isset($_POST['wps_visitor_counter_style'])) {
    16             $image_styel=sanitize_text_field($_POST['wps_visitor_counter_style']);
     37            $image_styel = sanitize_text_field( wp_unslash( $_POST['wps_visitor_counter_style'] ) );
    1738        }
    1839        if (isset($_POST['wps_visitor_counter_attribution'])) {
     
    2041        }
    2142        $id = 1;
    22         $sql = $wpdb->prepare("UPDATE `".WPS_VC_OPTIONS_TABLE_NAME."` SET `show_powered_by` = %d, `style` = %s WHERE `id` = %d;",$powerd_by,$image_styel,$id);
    23         wps_update_query($sql);
     43        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name cannot be a placeholder.
     44        $prepared_sql = $wpdb->prepare( "UPDATE `" . WPS_VC_OPTIONS_TABLE_NAME . "` SET `show_powered_by` = %d, `style` = %s WHERE `id` = %d;", $powerd_by, $image_styel, $id );
     45        wps_update_query( $prepared_sql );
    2446    }
    2547}
    2648if (isset($_POST['wps_view_setting'])) {
    27     $retrieved_nonce = $_POST['_wpnonce'];
    28     if (wp_verify_nonce($retrieved_nonce, 'wps_my_front_end_setting')) {
     49    if (!current_user_can('manage_options')) {
     50        wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'wps-visitor-counter' ) );
     51    }
     52    if ( wps_vc_verify_post_nonce( 'wps_my_front_end_setting' ) ) {
    2953   
    3054
    3155        $wps_visitor_title="";
    3256        if (isset($_POST['wps_visitor_title'])) {
    33             $wps_visitor_title=sanitize_text_field($_POST['wps_visitor_title']);
     57            $wps_visitor_title = sanitize_text_field( wp_unslash( $_POST['wps_visitor_title'] ) );
    3458        }
    3559        $wps_visitor_font_color= "#ffffff" ;
    3660        if (isset($_POST['wps_visitor_font_color'])) {
    37             $wps_visitor_font_color=sanitize_hex_color($_POST['wps_visitor_font_color']);
     61            $wps_visitor_font_color = sanitize_hex_color( wp_unslash( $_POST['wps_visitor_font_color'] ) );
    3862        }
    3963        if (isset($_POST['wps_visitor_user_start']) && $_POST['wps_visitor_user_start'] != "") {
     
    126150        $wps_visitor_wpsvc_align= "wps_visitor_wpsvc_align" ;
    127151        if (isset($_POST['wps_visitor_wpsvc_align'])) {
    128             $wps_visitor_wpsvc_align = sanitize_text_field($_POST['wps_visitor_wpsvc_align']);
     152            $wps_visitor_wpsvc_align = sanitize_text_field( wp_unslash( $_POST['wps_visitor_wpsvc_align'] ) );
    129153        }
    130154        $id = 1;
    131         $sql = "UPDATE `".WPS_VC_OPTIONS_TABLE_NAME."` SET `";
    132         $sql .= "visitor_title` = %s,";
    133         $sql .= "`font_color` = %s,";
    134         $sql .= "`user_start` = %d,";
    135         $sql .= "`views_start` = %d,";
    136         $sql .= "`display_field` = %s,";
    137         $sql .= "`visitor_wpsvc_align` = %s";
    138         $sql .= "WHERE `id` = %d;";
    139         $sql = $wpdb->prepare($sql,$wps_visitor_title,$wps_visitor_font_color,$wps_visitor_user_start,$wps_visitor_views_start,$wps_display_field_setting,$wps_visitor_wpsvc_align,$id);
    140         wps_update_query($sql);
     155        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name cannot be a placeholder.
     156        $prepared_sql = $wpdb->prepare(
     157            "UPDATE `" . WPS_VC_OPTIONS_TABLE_NAME . "` SET `visitor_title` = %s, `font_color` = %s, `user_start` = %d, `views_start` = %d, `display_field` = %s, `visitor_wpsvc_align` = %s WHERE `id` = %d;", // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
     158            $wps_visitor_title,
     159            $wps_visitor_font_color,
     160            $wps_visitor_user_start,
     161            $wps_visitor_views_start,
     162            $wps_display_field_setting,
     163            $wps_visitor_wpsvc_align,
     164            $id
     165        );
     166        wps_update_query( $prepared_sql );
    141167       
    142168    }
    143169}
     170// phpcs:enable WordPress.Security.NonceVerification.Missing
    144171
    145172
     
    147174function wps_update_query($sql){
    148175    global $wpdb;
    149     $reault = $wpdb->query($sql);
     176    // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,PluginCheck.Security.DirectDB.UnescapedDBParameter -- $sql is prepared by the caller.
     177    $wpdb->query( $sql );
    150178    return true;
    151179}
    152180function wps_visitor_counter_truncate() {
    153181    global $wpdb;
    154     if ( $wpdb->get_var('SHOW TABLES LIKE "' . WPS_VC_TABLE_NAME . '"') == WPS_VC_TABLE_NAME ) {
    155         $sql = "TRUNCATE `". WPS_VC_TABLE_NAME . "`;";
    156         $wpdb->query($sql);
     182    // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Table name is a constant; direct query needed for table operations.
     183    if ( $wpdb->get_var( 'SHOW TABLES LIKE "' . WPS_VC_TABLE_NAME . '"' ) == WPS_VC_TABLE_NAME ) {
     184        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Table name is a constant; TRUNCATE requires direct query.
     185        $wpdb->query( "TRUNCATE `" . WPS_VC_TABLE_NAME . "`;" );
    157186    }
    158187}
     
    160189function wps_visitor_option_data($id){
    161190            global $wpdb;
    162           $sql = $wpdb->prepare("SELECT * FROM `".WPS_VC_OPTIONS_TABLE_NAME."` WHERE `id` = %d",$id);
    163           $result = $wpdb->get_results($sql,ARRAY_A);
     191          // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name cannot be a placeholder.
     192          $prepared_sql = $wpdb->prepare( "SELECT * FROM `" . WPS_VC_OPTIONS_TABLE_NAME . "` WHERE `id` = %d", $id );
     193          // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- $prepared_sql is prepared above; caching not needed for options data.
     194          $result = $wpdb->get_results( $prepared_sql, ARRAY_A );
    164195          return $result[0];
    165196}
    166197function wps_visitor_counter_activation_hook(){
    167198    global $wpdb;
    168     if ( $wpdb->get_var('SHOW TABLES LIKE "' . WPS_VC_TABLE_NAME . '"') != WPS_VC_TABLE_NAME ) {
     199    // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Table name is a constant; direct query needed for table existence check during activation.
     200    if ( $wpdb->get_var( 'SHOW TABLES LIKE "' . WPS_VC_TABLE_NAME . '"' ) != WPS_VC_TABLE_NAME ) {
    169201        $sql = "";
     202        $charset_collate = $wpdb->get_charset_collate();
    170203        $sql = "CREATE TABLE IF NOT EXISTS `". WPS_VC_TABLE_NAME . "` (";
    171         $sql .= "`ip` varchar(20) NOT NULL default '',";
     204        $sql .= "`ip` varchar(45) NOT NULL default '',";
    172205        $sql .= "`date` date NOT NULL,";
    173         $sql .= "`views` int(10) NOT NULL default '1',";
     206        $sql .= "`views` int(10) UNSIGNED NOT NULL default '1',";
    174207        $sql .= "`online` varchar(255) NOT NULL,";
    175208        $sql .= "PRIMARY KEY  (`ip`,`date`)";
    176         $sql .= ") ENGINE=MyISAM DEFAULT CHARSET=latin1;";
    177         $wpdb->query($sql);
    178     }
    179     if ( $wpdb->get_var('SHOW TABLES LIKE "' . WPS_VC_OPTIONS_TABLE_NAME . '"') != WPS_VC_OPTIONS_TABLE_NAME ) {
     209        $sql .= ") ENGINE=InnoDB $charset_collate;";
     210        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,PluginCheck.Security.DirectDB.UnescapedDBParameter -- Table creation during activation requires direct query.
     211    $wpdb->query( $sql );
     212    }
     213    // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Table name is a constant; direct query needed for table existence check during activation.
     214    if ( $wpdb->get_var( 'SHOW TABLES LIKE "' . WPS_VC_OPTIONS_TABLE_NAME . '"' ) != WPS_VC_OPTIONS_TABLE_NAME ) {
    180215        $sql = "";
     216        $charset_collate = $wpdb->get_charset_collate();
    181217        $sql = "CREATE TABLE IF NOT EXISTS `". WPS_VC_OPTIONS_TABLE_NAME . "` (";
    182         $sql .= "`id` INT(10) NOT NULL AUTO_INCREMENT,";
     218        $sql .= "`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,";
    183219        $sql .= "`display_field` VARCHAR(600) NOT NULL default ',today_user,yesterday_user,last7_day_user,last30_day_user,month_user,year_user,total_user,today_view,yesterday_view,last7_day_view,last30_day_view,month_view,year_view,total_view,online_view,ip_display,server_time',";
    184         $sql .= "`show_powered_by` INT(1) NOT NULL DEFAULT '1',";
    185         $sql .= "`font_color` VARCHAR(25) NOT NULL DEFAULT '#000000',";
     220        $sql .= "`show_powered_by` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1',";
     221        $sql .= "`font_color` VARCHAR(7) NOT NULL DEFAULT '#000000',";
    186222        $sql .= "`style` VARCHAR(25) NOT NULL DEFAULT 'text/effect-white',";
    187223        $sql .= "`visitor_title` VARCHAR(255) NOT NULL default 'Our Visitor',";
    188         $sql .= "`user_start` INT(255) NOT NULL DEFAULT '1',";
    189         $sql .= "`views_start` INT(255) NOT NULL DEFAULT '1',";
    190         $sql .= "`visitor_wpsvc_align` VARCHAR(25) NOT NULL DEFAULT 'wps_visitor_wpsvc_align',";
     224        $sql .= "`user_start` INT(10) UNSIGNED NOT NULL DEFAULT '1',";
     225        $sql .= "`views_start` INT(10) UNSIGNED NOT NULL DEFAULT '1',";
     226        $sql .= "`visitor_wpsvc_align` VARCHAR(25) NOT NULL DEFAULT 'center',";
    191227        $sql .= "PRIMARY KEY (`id`)";
    192         $sql .= ") ENGINE=MyISAM DEFAULT CHARSET=latin1;";
    193         $wpdb->query($sql);
    194         $sql = $wpdb->prepare("INSERT INTO `". WPS_VC_OPTIONS_TABLE_NAME . "`(`id`) VALUES (%d)",1);
    195         $wpdb->query($sql);
     228        $sql .= ") ENGINE=InnoDB $charset_collate;";
     229        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,PluginCheck.Security.DirectDB.UnescapedDBParameter -- Table creation during activation requires direct query.
     230    $wpdb->query( $sql );
     231
     232        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Table name cannot be a placeholder.
     233        $prepared_sql = $wpdb->prepare( "INSERT INTO `" . WPS_VC_OPTIONS_TABLE_NAME . "`(`id`) VALUES (%d)", 1 );
     234        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,PluginCheck.Security.DirectDB.UnescapedDBParameter -- $prepared_sql is prepared above; direct query needed for initial data insertion during activation.
     235        $wpdb->query( $prepared_sql );
    196236       
    197237    }
Note: See TracChangeset for help on using the changeset viewer.