| 1 |
<?php |
| 2 |
/** |
| 3 |
* Update version notice for Forumax |
| 4 |
*/ |
| 5 |
|
| 6 |
if ( ! defined( 'ABSPATH' ) ) { |
| 7 |
exit; |
| 8 |
} |
| 9 |
|
| 10 |
/** |
| 11 |
* Display backup warning notice on the plugins page for Forumax update |
| 12 |
* |
| 13 |
* @param array $plugin_data Plugin metadata. |
| 14 |
* @param stdClass $response Response metadata. |
| 15 |
*/ |
| 16 |
function forumax_update_version_notice( $plugin_data, $response ) { |
| 17 |
// Plugin current version |
| 18 |
$current_version = defined( 'FORUMAX_VERSION' ) ? FORUMAX_VERSION : ''; |
| 19 |
$new_version = isset( $response->new_version ) ? $response->new_version : ''; |
| 20 |
|
| 21 |
if ( empty( $current_version ) || empty( $new_version ) ) { |
| 22 |
return; |
| 23 |
} |
| 24 |
|
| 25 |
// Only show notice if current version is less than 2.1.0 |
| 26 |
if ( version_compare( $current_version, '2.1.0', '>=' ) ) { |
| 27 |
return; |
| 28 |
} |
| 29 |
|
| 30 |
$slug = isset( $response->slug ) ? $response->slug : 'forumax'; |
| 31 |
$plugin_file = isset( $response->plugin ) ? $response->plugin : ''; |
| 32 |
$changelog_link = 'https://forumax.spider-themes.net/changelog/'; |
| 33 |
$active = ! empty( $plugin_file ) && is_plugin_active( $plugin_file ) ? 'active' : ''; |
| 34 |
?> |
| 35 |
<div class="frmx-update-notice"> |
| 36 |
<hr class="frmx-major-update-warning__separator" /> |
| 37 |
<div class="frmx-major-update-warning"> |
| 38 |
<div class="frmx-major-update-warning__icon"> |
| 39 |
<span class="dashicons dashicons-warning"></span> |
| 40 |
</div> |
| 41 |
<div> |
| 42 |
<div class="frmx-major-update-warning__title"> |
| 43 |
<?php echo esc_html__( 'Important: Please Backup Before Updating', 'forumax' ); ?> |
| 44 |
</div> |
| 45 |
<div class="frmx-major-update-warning__message"> |
| 46 |
<div> |
| 47 |
<?php |
| 48 |
printf( |
| 49 |
esc_html__( 'Forumax v%s brings minor upgrades and enhancements across the plugin. To keep your site safe, make sure you create a complete backup before updating.', 'forumax' ), |
| 50 |
'2.1.0' |
| 51 |
); |
| 52 |
?> |
| 53 |
</div> |
| 54 |
<div> |
| 55 |
<?php esc_html_e( 'We highly recommend updating on a staging environment before applying it to your live site.', 'forumax' ); ?> |
| 56 |
</div> |
| 57 |
<a href="<?php echo esc_url( $changelog_link ); ?>" target="_blank" class="frmx-changelog-btn"><?php esc_html_e( 'View the changelogs', 'forumax' ); ?></a> |
| 58 |
</div> |
| 59 |
</div> |
| 60 |
</div> |
| 61 |
</div> |
| 62 |
<?php |
| 63 |
} |
| 64 |
|
| 65 |
if ( defined( 'FORUMAX_FILE' ) ) { |
| 66 |
$basename = plugin_basename( FORUMAX_FILE ); |
| 67 |
add_action( 'in_plugin_update_message-' . $basename, 'forumax_update_version_notice', 10, 2 ); |
| 68 |
|
| 69 |
/** |
| 70 |
* Also hook into bbp-core/forumax.php to handle cases where the plugin is |
| 71 |
* recognized by the bbp-core slug on WordPress.org. |
| 72 |
*/ |
| 73 |
if ( 'bbp-core/forumax.php' !== $basename ) { |
| 74 |
add_action( 'in_plugin_update_message-bbp-core/forumax.php', 'forumax_update_version_notice', 10, 2 ); |
| 75 |
} |
| 76 |
} |