Skip to content

Commit

Permalink
Merge pull request #60 from 10up/fix/56-php-version-check
Browse files Browse the repository at this point in the history
Fix/56 PHP Version Check
  • Loading branch information
Sidsector9 authored Oct 17, 2023
2 parents 5a9ad67 + a613fe7 commit 857415a
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions newrelic-reporting-for-wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,49 @@
define( 'WP_NR_BASENAME', plugin_basename( __FILE__ ) );
}

/**
* Get the minimum version of PHP required by this plugin.
*
* @return string Minimum version required.
*/
function wp_nr_minimum_php_requirement() {
return '7.3.11';
}

/**
* Checks whether PHP installation meets the minimum requirements
*
* @return bool True if meets minimum requirements, false otherwise.
*/
function wp_nr_site_meets_php_requirements() {

return version_compare( phpversion(), wp_nr_minimum_php_requirement(), '>=' );
}

if ( ! wp_nr_site_meets_php_requirements() ) {
add_action(
'admin_notices',
function() {
?>
<div class="notice notice-error">
<p>
<?php
echo wp_kses_post(
sprintf(
/* translators: %s: Minimum required PHP version */
__( 'New Relic Reporting for WordPress requires PHP version %s or later. Please upgrade PHP or disable the plugin.', 'wp-newrelic' ),
esc_html( wp_nr_minimum_php_requirement() )
)
);
?>
</p>
</div>
<?php
}
);
return;
}

/**
* Check if plugin is network active.
*
Expand Down

0 comments on commit 857415a

Please sign in to comment.