Skip to content

Commit

Permalink
Added: <meta> tag to frontend to indicate plugin presence.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan0sz committed May 21, 2024
1 parent a3e0a03 commit 9a23f5c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plausible-analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}

// Define plugin version here for convenience.
define( 'PLAUSIBLE_ANALYTICS_VERSION', '2.0.5' );
define( 'PLAUSIBLE_ANALYTICS_VERSION', '2.0.8' );
define( 'PLAUSIBLE_ANALYTICS_PLUGIN_FILE', __FILE__ );
define( 'PLAUSIBLE_ANALYTICS_PLUGIN_BASENAME', plugin_basename( PLAUSIBLE_ANALYTICS_PLUGIN_FILE ) );
define( 'PLAUSIBLE_ANALYTICS_PLUGIN_DIR', plugin_dir_path( PLAUSIBLE_ANALYTICS_PLUGIN_FILE ) );
Expand Down
13 changes: 13 additions & 0 deletions src/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,23 @@ class Actions {
* @return void
*/
public function __construct() {
add_action( 'wp_head', [ $this, 'insert_version_meta_tag' ] );
add_action( 'wp_enqueue_scripts', [ $this, 'maybe_register_assets' ] );
add_action( 'admin_bar_menu', [ $this, 'admin_bar_node' ], 100 );
}

/**
* This <meta> tag "tells" the Plausible API which version of the plugin is used, to allow tailored error messages, specific to the plugin
* version or whether the plugin is used or not.
*
* @return void
*/
public function insert_version_meta_tag() {
$version = PLAUSIBLE_ANALYTICS_VERSION;

echo "<meta name='plausible-analytics-version' content='$version' />\n";
}

/**
* Register Assets.
*
Expand Down

0 comments on commit 9a23f5c

Please sign in to comment.