Created
March 4, 2019 11:33
-
-
Save DigitalEssence/52fa271a4117af252fa940b769c66191 to your computer and use it in GitHub Desktop.
WordPress - Debug Pending Updates
This file contains hidden or 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
| /** | |
| * Debug Pending Updates | |
| * Displays hidden plugin and theme updates on update-core screen. | |
| */ | |
| function debug_pending_updates() { | |
| // Rough safety nets | |
| if ( ! is_user_logged_in() || ! current_user_can( 'update_plugins' ) || ! current_user_can( 'update_themes' ) ) return; | |
| $output = ""; | |
| // Check plugins | |
| $plugin_updates = get_site_transient( 'update_plugins' ); | |
| if ( $plugin_updates && ! empty( $plugin_updates->response ) ) { | |
| foreach ( $plugin_updates->response as $plugin => $details ) { | |
| $output .= "<p><strong>Plugin</strong> <u>$plugin</u> is reporting an available update.</p>"; | |
| } | |
| } | |
| // Check themes | |
| wp_update_themes(); | |
| $theme_updates = get_site_transient( 'update_themes' ); | |
| if ( $theme_updates && ! empty( $theme_updates->response ) ) { | |
| foreach ( $theme_updates->response as $theme => $details ) { | |
| $output .= "<p><strong>Theme</strong> <u>$theme</u> is reporting an available update.</p>"; | |
| } | |
| } | |
| if ( empty( $output ) ) $output = "No pending updates found in the database."; | |
| echo "<h2>Pending updates</h2>" . $output; | |
| } | |
| add_action( 'core_upgrade_preamble', 'debug_pending_updates' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment