Skip to content

Instantly share code, notes, and snippets.

@xenioushk
Last active June 30, 2025 20:40
Show Gist options
  • Select an option

  • Save xenioushk/fec09ec057c98a2f94ac509648a550ae to your computer and use it in GitHub Desktop.

Select an option

Save xenioushk/fec09ec057c98a2f94ac509648a550ae to your computer and use it in GitHub Desktop.
Check the required PHP Version and display notice
// Define minimum PHP version requirement
// Our required minimum php version is 8.2.10
define( 'BAFIEADDON_MIN_PHP_VERSION', '8.2.10' );
// Check PHP version before loading anything else
if ( version_compare( PHP_VERSION, BAFIEADDON_MIN_PHP_VERSION, '<' ) ) {
add_action( 'admin_notices', function () {
$message = sprintf(
/* translators: 1: Plugin name, 2: Required PHP version, 3: Current PHP version */
esc_html__( '%1$s requires PHP version %2$s or higher. You are running PHP version %3$s. Please upgrade your PHP version.', 'baf-import-export-addon' ),
'<strong>BWL Advanced FAQ Import/Export Addon</strong>',
BAFIEADDON_MIN_PHP_VERSION,
PHP_VERSION
);
printf( '<div class="notice notice-error"><p>%s</p></div>', wp_kses_post( $message ) );
});
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment