Skip to content

Commit

Permalink
Merge pull request #3641 from 10up/fix/3541-php-version-check
Browse files Browse the repository at this point in the history
Fix/3541 PHP Version Check
  • Loading branch information
felipeelia authored Sep 22, 2023
2 parents 1bbade9 + acea3e1 commit b0bb1ec
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions elasticpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,42 @@
exit; // Exit if accessed directly.
}

// Require Composer autoloader if it exists.
if ( file_exists( __DIR__ . '/vendor-prefixed/autoload.php' ) ) {
require_once __DIR__ . '/vendor-prefixed/autoload.php';
}

define( 'EP_URL', plugin_dir_url( __FILE__ ) );
define( 'EP_PATH', plugin_dir_path( __FILE__ ) );
define( 'EP_FILE', plugin_basename( __FILE__ ) );
define( 'EP_VERSION', '4.7.1' );

define( 'EP_PHP_VERSION_MIN', '7.0' );

if ( ! version_compare( phpversion(), EP_PHP_VERSION_MIN, '>=' ) ) {
add_action(
'admin_notices',
function() {
?>
<div class="notice notice-error">
<p>
<?php
echo wp_kses_post(
sprintf(
/* translators: %s: Minimum required PHP version */
__( 'ElasticPress requires PHP version %s or later. Please upgrade PHP or disable the plugin.', 'elasticpress' ),
EP_PHP_VERSION_MIN
)
);
?>
</p>
</div>
<?php
}
);
return;
}

// Require Composer autoloader if it exists.
if ( file_exists( __DIR__ . '/vendor-prefixed/autoload.php' ) ) {
require_once __DIR__ . '/vendor-prefixed/autoload.php';
}

/**
* PSR-4-ish autoloading
*
Expand Down

0 comments on commit b0bb1ec

Please sign in to comment.