Plugin Directory

Changeset 2939166 for wp-slimstat


Ignore:
Timestamp:
07/16/2023 01:26:02 PM (3 years ago)
Author:
mostafa.s1990
Message:

Update to version 5.0.6 from GitHub

Location:
wp-slimstat
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wp-slimstat/tags/5.0.6/admin/index.php

    r2893473 r2939166  
    211211        // Dashboard Widgets
    212212        if (wp_slimstat::$settings['add_dashboard_widgets'] == 'on') {
    213             $temp = strlen(sanitize_url(wp_unslash($_SERVER['REQUEST_URI']))) - 10;
    214 
    215             if (strpos($_SERVER['REQUEST_URI'], 'index.php') !== false || ($temp >= 0 && strpos($_SERVER['REQUEST_URI'], '/wp-admin/', $temp) !== false)) {
     213            $request_length = strlen(sanitize_url(wp_unslash($_SERVER['REQUEST_URI'])));
     214            $temp           = $request_length - 10;
     215
     216            if (strpos($_SERVER['REQUEST_URI'], 'index.php') !== false || ($temp >= 0 && $temp <= $request_length && strpos($_SERVER['REQUEST_URI'], '/wp-admin/', $temp) !== false)) {
    216217                add_action('admin_enqueue_scripts', array(__CLASS__, 'wp_slimstat_enqueue_scripts'));
    217218                add_action('admin_enqueue_scripts', array(__CLASS__, 'wp_slimstat_stylesheet'));
    218219            }
    219 
    220220
    221221            add_action('wp_dashboard_setup', array(__CLASS__, 'add_dashboard_widgets'));
     
    243243            wp_schedule_event(time(), 'twicedaily', 'wp_slimstat_purge');
    244244        }
     245
     246        self::initFeedback();
    245247    }
    246248    // END: init
     
    895897        $tag = current_filter();
    896898
    897         if (!empty($tag)) {
     899        if (!empty($tag) && current_user_can('manage_options') && wp_verify_nonce($_POST['security'], 'meta-box-order')) {
    898900            $tag                         = str_replace('wp_ajax_slimstat_', '', $tag);
    899901            wp_slimstat::$settings[$tag] = 'no';
     
    914916        $my_wpdb     = apply_filters('slimstat_custom_wpdb', $GLOBALS['wpdb']);
    915917        $pageview_id = intval($_POST['pageview_id']);
     918
     919        // Delete page view if user has enough access
     920        $current_user_can_delete = (current_user_can(wp_slimstat::$settings['capability_can_admin']) && !is_network_admin());
     921        if (!$current_user_can_delete || !wp_verify_nonce($_POST['security'], 'meta-box-order')) {
     922            return;
     923        }
    916924        $my_wpdb->query("DELETE ts FROM {$GLOBALS[ 'wpdb' ]->prefix}slim_stats ts WHERE ts.id = $pageview_id");
    917925        exit();
     
    11041112    }
    11051113    // END: _create_table
     1114
     1115    /**
     1116     * Init FeedbackBird widget a third-party service to get feedbacks from users
     1117     *
     1118     * @url https://feedbackbird.io
     1119     *
     1120     * @return void
     1121     */
     1122    private static function initFeedback()
     1123    {
     1124        add_action('admin_enqueue_scripts', function () {
     1125            $screen = get_current_screen();
     1126
     1127            if (stristr($screen->id, 'slimview')) {
     1128                wp_enqueue_script('feedbackbird-app-script', 'https://cdn.jsdelivr.net/gh/feedbackbird/assets@master/wp/app.js?uid=01H5FBKA9Z5M2VJWQXZSX4Q7MS');
     1129                wp_add_inline_script('feedbackbird-app-script', sprintf('var feedbackBirdObject = %s;', json_encode([
     1130                    'user_email' => function_exists('wp_get_current_user') ? wp_get_current_user()->user_email : '',
     1131                    'meta'       => [
     1132                        'php_version'    => PHP_VERSION,
     1133                        'active_plugins' => array_map(function ($plugin, $pluginPath) {
     1134                            return [
     1135                                'name'    => $plugin['Name'],
     1136                                'version' => $plugin['Version'],
     1137                                'status'  => is_plugin_active($pluginPath) ? 'active' : 'deactivate',
     1138                            ];
     1139                        }, get_plugins(), array_keys(get_plugins())),
     1140                    ]
     1141                ])));
     1142
     1143                add_filter('script_loader_tag', function ($tag, $handle, $src) {
     1144                    if ('feedbackbird-app-script' === $handle) {
     1145                        return preg_replace('/^<script /i', '<script type="module" crossorigin="crossorigin" ', $tag);
     1146                    }
     1147                    return $tag;
     1148                }, 10, 3);
     1149            }
     1150        });
     1151    }
    11061152}
    11071153// END: class declaration
  • wp-slimstat/tags/5.0.6/admin/view/right-now.php

    r2891987 r2939166  
    2828wp_slimstat_db::$debug_message = '';
    2929$all_results                   = wp_slimstat_db::get_recent(wp_slimstat_reports::$reports['slim_p7_02']['callback_args']);
     30
     31// Backward compatibility
     32if (!$all_results) {
     33    $all_results = array();
     34}
     35
    3036$results                       = array_slice(
    3137    $all_results,
  • wp-slimstat/tags/5.0.6/admin/view/wp-slimstat-reports.php

    r2916675 r2939166  
    580580                    'type'    => 'recent',
    581581                    'columns' => 'searchterms',
    582                     'where'   => 'content_type LIKE "%search%" AND searchterms <> "" AND searchterms IS NOT NULL',
     582                    'where'   => 'content_type LIKE "%%search%%" AND searchterms <> "" AND searchterms IS NOT NULL',
    583583                    'raw'     => array('wp_slimstat_db', 'get_recent')
    584584                ),
     
    655655                    'type'    => 'top',
    656656                    'columns' => 'searchterms',
    657                     'where'   => 'content_type LIKE "%search%" AND searchterms <> "" AND searchterms IS NOT NULL',
     657                    'where'   => 'content_type LIKE "%%search%%" AND searchterms <> "" AND searchterms IS NOT NULL',
    658658                    'raw'     => array('wp_slimstat_db', 'get_top')
    659659                ),
     
    15271527    {
    15281528        $countries     = wp_slimstat_db::get_top('country');
     1529       
     1530        // Backward compatibility
     1531        if (!$countries) {
     1532            $countries = array();
     1533        }
     1534
    15291535        $recent_visits = wp_slimstat_db::get_recent('location', '', '', true, '', 'city');
    15301536
  • wp-slimstat/tags/5.0.6/readme.txt

    r2916675 r2939166  
    66Requires PHP: 7.4+
    77Tested up to: 6.2
    8 Stable tag: 5.0.5.1
     8Stable tag: 5.0.6
    99
    1010== Description ==
     
    4949
    5050== Changelog ==
     51= 5.0.6 =
     52* [New] Integrated a Feedback button powered by [FeedbackBird!](https://feedbackbird.io/) in the admin area to gather user feedback.
     53* [Fix] Resolve STRPOS error when enqueuing scripts.
     54* [Fix] Ensure backward compatibility for null values.
     55* [Fix] Fix broken access in delete_pageView and notices_handler functions.
     56* [Fix] Resolve escaping issue with literal '%' character in wpdb->prepare().
     57
    5158= 5.0.5.1 =
    5259* [Fix] Backward compatibility
  • wp-slimstat/tags/5.0.6/wp-slimstat.php

    r2916675 r2939166  
    44Plugin URI: https://wp-slimstat.com/
    55Description: The leading web analytics plugin for WordPress
    6 Version: 5.0.5.1
     6Version: 5.0.6
    77Author: Jason Crouse, VeronaLabs
    88Text Domain: wp-slimstat
  • wp-slimstat/trunk/admin/index.php

    r2893473 r2939166  
    211211        // Dashboard Widgets
    212212        if (wp_slimstat::$settings['add_dashboard_widgets'] == 'on') {
    213             $temp = strlen(sanitize_url(wp_unslash($_SERVER['REQUEST_URI']))) - 10;
    214 
    215             if (strpos($_SERVER['REQUEST_URI'], 'index.php') !== false || ($temp >= 0 && strpos($_SERVER['REQUEST_URI'], '/wp-admin/', $temp) !== false)) {
     213            $request_length = strlen(sanitize_url(wp_unslash($_SERVER['REQUEST_URI'])));
     214            $temp           = $request_length - 10;
     215
     216            if (strpos($_SERVER['REQUEST_URI'], 'index.php') !== false || ($temp >= 0 && $temp <= $request_length && strpos($_SERVER['REQUEST_URI'], '/wp-admin/', $temp) !== false)) {
    216217                add_action('admin_enqueue_scripts', array(__CLASS__, 'wp_slimstat_enqueue_scripts'));
    217218                add_action('admin_enqueue_scripts', array(__CLASS__, 'wp_slimstat_stylesheet'));
    218219            }
    219 
    220220
    221221            add_action('wp_dashboard_setup', array(__CLASS__, 'add_dashboard_widgets'));
     
    243243            wp_schedule_event(time(), 'twicedaily', 'wp_slimstat_purge');
    244244        }
     245
     246        self::initFeedback();
    245247    }
    246248    // END: init
     
    895897        $tag = current_filter();
    896898
    897         if (!empty($tag)) {
     899        if (!empty($tag) && current_user_can('manage_options') && wp_verify_nonce($_POST['security'], 'meta-box-order')) {
    898900            $tag                         = str_replace('wp_ajax_slimstat_', '', $tag);
    899901            wp_slimstat::$settings[$tag] = 'no';
     
    914916        $my_wpdb     = apply_filters('slimstat_custom_wpdb', $GLOBALS['wpdb']);
    915917        $pageview_id = intval($_POST['pageview_id']);
     918
     919        // Delete page view if user has enough access
     920        $current_user_can_delete = (current_user_can(wp_slimstat::$settings['capability_can_admin']) && !is_network_admin());
     921        if (!$current_user_can_delete || !wp_verify_nonce($_POST['security'], 'meta-box-order')) {
     922            return;
     923        }
    916924        $my_wpdb->query("DELETE ts FROM {$GLOBALS[ 'wpdb' ]->prefix}slim_stats ts WHERE ts.id = $pageview_id");
    917925        exit();
     
    11041112    }
    11051113    // END: _create_table
     1114
     1115    /**
     1116     * Init FeedbackBird widget a third-party service to get feedbacks from users
     1117     *
     1118     * @url https://feedbackbird.io
     1119     *
     1120     * @return void
     1121     */
     1122    private static function initFeedback()
     1123    {
     1124        add_action('admin_enqueue_scripts', function () {
     1125            $screen = get_current_screen();
     1126
     1127            if (stristr($screen->id, 'slimview')) {
     1128                wp_enqueue_script('feedbackbird-app-script', 'https://cdn.jsdelivr.net/gh/feedbackbird/assets@master/wp/app.js?uid=01H5FBKA9Z5M2VJWQXZSX4Q7MS');
     1129                wp_add_inline_script('feedbackbird-app-script', sprintf('var feedbackBirdObject = %s;', json_encode([
     1130                    'user_email' => function_exists('wp_get_current_user') ? wp_get_current_user()->user_email : '',
     1131                    'meta'       => [
     1132                        'php_version'    => PHP_VERSION,
     1133                        'active_plugins' => array_map(function ($plugin, $pluginPath) {
     1134                            return [
     1135                                'name'    => $plugin['Name'],
     1136                                'version' => $plugin['Version'],
     1137                                'status'  => is_plugin_active($pluginPath) ? 'active' : 'deactivate',
     1138                            ];
     1139                        }, get_plugins(), array_keys(get_plugins())),
     1140                    ]
     1141                ])));
     1142
     1143                add_filter('script_loader_tag', function ($tag, $handle, $src) {
     1144                    if ('feedbackbird-app-script' === $handle) {
     1145                        return preg_replace('/^<script /i', '<script type="module" crossorigin="crossorigin" ', $tag);
     1146                    }
     1147                    return $tag;
     1148                }, 10, 3);
     1149            }
     1150        });
     1151    }
    11061152}
    11071153// END: class declaration
  • wp-slimstat/trunk/admin/view/right-now.php

    r2891987 r2939166  
    2828wp_slimstat_db::$debug_message = '';
    2929$all_results                   = wp_slimstat_db::get_recent(wp_slimstat_reports::$reports['slim_p7_02']['callback_args']);
     30
     31// Backward compatibility
     32if (!$all_results) {
     33    $all_results = array();
     34}
     35
    3036$results                       = array_slice(
    3137    $all_results,
  • wp-slimstat/trunk/admin/view/wp-slimstat-reports.php

    r2916675 r2939166  
    580580                    'type'    => 'recent',
    581581                    'columns' => 'searchterms',
    582                     'where'   => 'content_type LIKE "%search%" AND searchterms <> "" AND searchterms IS NOT NULL',
     582                    'where'   => 'content_type LIKE "%%search%%" AND searchterms <> "" AND searchterms IS NOT NULL',
    583583                    'raw'     => array('wp_slimstat_db', 'get_recent')
    584584                ),
     
    655655                    'type'    => 'top',
    656656                    'columns' => 'searchterms',
    657                     'where'   => 'content_type LIKE "%search%" AND searchterms <> "" AND searchterms IS NOT NULL',
     657                    'where'   => 'content_type LIKE "%%search%%" AND searchterms <> "" AND searchterms IS NOT NULL',
    658658                    'raw'     => array('wp_slimstat_db', 'get_top')
    659659                ),
     
    15271527    {
    15281528        $countries     = wp_slimstat_db::get_top('country');
     1529       
     1530        // Backward compatibility
     1531        if (!$countries) {
     1532            $countries = array();
     1533        }
     1534
    15291535        $recent_visits = wp_slimstat_db::get_recent('location', '', '', true, '', 'city');
    15301536
  • wp-slimstat/trunk/readme.txt

    r2916675 r2939166  
    66Requires PHP: 7.4+
    77Tested up to: 6.2
    8 Stable tag: 5.0.5.1
     8Stable tag: 5.0.6
    99
    1010== Description ==
     
    4949
    5050== Changelog ==
     51= 5.0.6 =
     52* [New] Integrated a Feedback button powered by [FeedbackBird!](https://feedbackbird.io/) in the admin area to gather user feedback.
     53* [Fix] Resolve STRPOS error when enqueuing scripts.
     54* [Fix] Ensure backward compatibility for null values.
     55* [Fix] Fix broken access in delete_pageView and notices_handler functions.
     56* [Fix] Resolve escaping issue with literal '%' character in wpdb->prepare().
     57
    5158= 5.0.5.1 =
    5259* [Fix] Backward compatibility
  • wp-slimstat/trunk/wp-slimstat.php

    r2916675 r2939166  
    44Plugin URI: https://wp-slimstat.com/
    55Description: The leading web analytics plugin for WordPress
    6 Version: 5.0.5.1
     6Version: 5.0.6
    77Author: Jason Crouse, VeronaLabs
    88Text Domain: wp-slimstat
Note: See TracChangeset for help on using the changeset viewer.