Skip to content

Instantly share code, notes, and snippets.

@ramiy
Last active February 16, 2018 09:48
Show Gist options
  • Save ramiy/1ee976796fca4f2701aefaa5763188f4 to your computer and use it in GitHub Desktop.
Save ramiy/1ee976796fca4f2701aefaa5763188f4 to your computer and use it in GitHub Desktop.
Check for required PHP version
public function admin_notice_minimum_php_version() {
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
$message = sprintf(
/* translators: 1: Plugin Name 2: PHP 3: Required PHP version */
esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'text-domain' ),
'<strong>' . esc_html__( 'Plugin Name', 'text-domain' ) . '</strong>',
'<strong>' . esc_html__( 'PHP', 'text-domain' ) . '</strong>',
'5.4'
);
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
}
if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
add_action( 'admin_notices', 'admin_notice_minimum_php_version' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment