| @@ -1,14 +1,14 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /* |
| 3 | 3 | * Plugin Name: Simple Analytics Official |
| 4 | - * Version: 1.8 | |
| 4 | + * Version: 1.21 | |
| 5 | 5 | * Plugin URI: https://docs.simpleanalytics.com/install-simple-analytics-on-wordpress |
| 6 | 6 | * Description: Embed Simple Analytics script in your WordPress website |
| 7 | 7 | * Author: Simple Analytics |
| 8 | 8 | * Author URI: https://simpleanalytics.com/ |
| 9 | 9 | * Requires at least: 2.0.0 |
| 10 | - * Tested up to: 6.0 | |
| 10 | + * Tested up to: 6.5.3 | |
| 11 | 11 | * |
| 12 | 12 | * Text Domain: simple-analytics |
| 13 | 13 | * Domain Path: /lang/ |
| 14 | 14 | * |
| @@ -16,29 +16,26 @@ | ||
| 16 | 16 | * @author Simple Analytics |
| 17 | 17 | * @since 1.0.0 |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | -if (!defined('ABSPATH')) exit; | |
| 21 | - | |
| 22 | -$simpleanalytics_script = 'https://scripts.simpleanalyticscdn.com/latest.js'; | |
| 23 | - | |
| 24 | -function simpleanalytics_warn_not_logging() { | |
| 25 | - echo "<!-- Simple Analytics: Not logging requests from admins -->\n"; | |
| 20 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 21 | + exit; | |
| 26 | 22 | } |
| 27 | 23 | |
| 28 | 24 | function simpleanalytics_noscript() { |
| 29 | - echo '<noscript><img src="https://queue.simpleanalyticscdn.com/noscript.gif" alt="" referrerpolicy="no-referrer-when-downgrade"></noscript>' . "\n"; | |
| 25 | + $domain = get_option( 'simpleanalytics_custom_domain' ) ?: 'queue.simpleanalyticscdn.com'; | |
| 26 | + | |
| 27 | + echo '<noscript><img src="https://' . $domain . '/noscript.gif" alt="" referrerpolicy="no-referrer-when-downgrade"></noscript>' . "\n"; | |
| 30 | 28 | } |
| 31 | 29 | |
| 32 | 30 | function simpleanalytics_init() { |
| 33 | - global $simpleanalytics_script; | |
| 34 | - $is_running = !current_user_can('editor') && !current_user_can('administrator'); | |
| 35 | - if ($is_running) { | |
| 36 | - wp_enqueue_script('simpleanalytics_script', $simpleanalytics_script, array(), null, true); | |
| 37 | - add_action('wp_footer', 'simpleanalytics_noscript', 10); | |
| 38 | - } else { | |
| 39 | - wp_enqueue_script('simpleanalytics_admins', plugins_url('public/js/admins.js', __FILE__), array(), null, true); | |
| 40 | - add_action('wp_footer', 'simpleanalytics_warn_not_logging', 10); | |
| 41 | - } | |
| 31 | + if ( current_user_can( 'editor' ) || current_user_can( 'administrator' ) ) { | |
| 32 | + require_once plugin_dir_path( __FILE__ ) . 'includes/admin.php'; | |
| 33 | + } else { | |
| 34 | + $domain = get_option( 'simpleanalytics_custom_domain' ) ?: 'scripts.simpleanalyticscdn.com'; | |
| 35 | + | |
| 36 | + wp_enqueue_script( 'simpleanalytics_script', "https://$domain/latest.js", array(), null, true ); | |
| 37 | + add_action( 'wp_footer', 'simpleanalytics_noscript', 10 ); | |
| 38 | + } | |
| 42 | 39 | } |
| 43 | 40 | |
| 44 | -add_action('init', 'simpleanalytics_init'); | |
| 41 | +add_action( 'init', 'simpleanalytics_init' ); | |