Skip to content

Commit 259b410

Browse files
authored
Merge pull request #274 from plausible/fix_get_plugin_data
Fixed: call to undefined function get_plugin_data() on some instances.
2 parents 831b484 + 0a0d177 commit 259b410

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/Actions.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,15 @@ public function __construct() {
2828
* @return void
2929
*/
3030
public function maybe_insert_version_meta_tag() {
31-
$version = $this->get_plugin_version();
3231
$running_tests = array_key_exists( 'plausible_verification', $_GET );
3332

34-
if ( $version && $running_tests ) {
33+
if ( ! $running_tests ) {
34+
return;
35+
}
36+
37+
$version = $this->get_plugin_version();
38+
39+
if ( $version ) {
3540
echo "<meta name='plausible-analytics-version' content='$version' />\n";
3641
}
3742
}
@@ -40,6 +45,10 @@ public function maybe_insert_version_meta_tag() {
4045
* Retrieves the plugin's current version.
4146
*/
4247
private function get_plugin_version() {
48+
if ( ! function_exists( 'get_plugin_data' ) ) {
49+
require_once ABSPATH . 'wp-admin/includes/plugin.php';
50+
}
51+
4352
static $data = null;
4453

4554
if ( $data === null ) {

0 commit comments

Comments
 (0)