Skip to content

Commit

Permalink
fix(php): added a php version check
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarshall511 committed Sep 18, 2023
1 parent ef96fde commit 08fb976
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions windows-azure-storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,49 @@
define( 'MSFT_AZURE_PLUGIN_LEGACY_MEDIA_URL', get_admin_url( get_current_blog_id(), 'media-upload.php' ) );
define( 'MSFT_AZURE_PLUGIN_VERSION', '4.3.5' );

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

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

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

if ( ! was_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 */
__( 'Microsoft Azure Storage for WordPress requires PHP version %s or later. Please upgrade PHP or disable the plugin.', 'windows-azure-storage' ),
esc_html( was_minimum_php_requirement() )
)
);
?>
</p>
</div>
<?php
}
);
return;
}

require_once MSFT_AZURE_PLUGIN_PATH . 'windows-azure-storage-settings.php';
require_once MSFT_AZURE_PLUGIN_PATH . 'windows-azure-storage-dialog.php';
require_once MSFT_AZURE_PLUGIN_PATH . 'windows-azure-storage-util.php';
Expand Down

0 comments on commit 08fb976

Please sign in to comment.