Created
September 29, 2019 00:11
-
-
Save helgatheviking/7fd60a8eddf195bdd1b8057a0342e88e to your computer and use it in GitHub Desktop.
Add Wordpress upgrade notice to plugins screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Include the upgrade notice that will fire when 2.0.0 is released. | |
* This must be added before version 2.0.0 is released. | |
* | |
* @param array $plugin_data information about the plugin | |
* @param array $r response from the server about the new version | |
*/ | |
function your_update_notice( $plugin_data, $r ) { | |
// Bail if the update notice is not relevant (new version is not yet 2.0 or we're already on 2.0) | |
if ( version_compare( '2.0.0', $plugin_data['new_version'], '>' ) || version_compare( '2.0.0', $plugin_data['Version'], '<=' ) ) { | |
return; | |
} | |
$update_notice = '</p><div class="wc_plugin_upgrade_notice">'; | |
// translators: placeholders are opening and closing tags. Leads to docs on version 2.0.0 | |
$update_notice .= sprintf( __( 'Warning! Version 2.0.0 is a major update and will break ALL THE THINGZ! Before updating, please test and update your custom templates with version 2.0.0 on a staging site. %sLearn more about the changes in version 2.0.0 »%s', 'your-plugin-text-domain' ), '<a href="https://docs.yoursite.com/document/major-frakking-update/">', '</a>' ); | |
$update_notice .= '</div><p class="dummy" style="display:none">'; | |
echo wp_kses_post( $update_notice ); | |
} | |
add_action( 'in_plugin_update_message-your-plugin-folder/your-plugin-file.php', 'your_update_notice', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment