| 1 |
<?php |
| 2 |
/* |
| 3 |
* Plugin Name: Simple Analytics Official |
| 4 |
* Version: 1.17 |
| 5 |
* Plugin URI: https://docs.simpleanalytics.com/install-simple-analytics-on-wordpress |
| 6 |
* Description: Embed Simple Analytics script in your WordPress website |
| 7 |
* Author: Simple Analytics |
| 8 |
* Author URI: https://simpleanalytics.com/ |
| 9 |
* Requires at least: 2.0.0 |
| 10 |
* Tested up to: 6.4.2 |
| 11 |
* |
| 12 |
* Text Domain: simple-analytics |
| 13 |
* Domain Path: /lang/ |
| 14 |
* |
| 15 |
* @package WordPress |
| 16 |
* @author Simple Analytics |
| 17 |
* @since 1.0.0 |
| 18 |
*/ |
| 19 |
|
| 20 |
if ( ! defined( 'ABSPATH' ) ) { |
| 21 |
exit; |
| 22 |
} |
| 23 |
|
| 24 |
function simpleanalytics_noscript() { |
| 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"; |
| 28 |
} |
| 29 |
|
| 30 |
function simpleanalytics_init() { |
| 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 |
} |
| 39 |
} |
| 40 |
|
| 41 |
add_action( 'init', 'simpleanalytics_init' ); |
| 42 |
|