last_checked = 0; set_site_transient( $name, $cached ); } } wp_update_plugins(); wp_update_themes(); } /** * The updates WordPress already knows about, as it shows them on its own * Updates screen: which plugin or theme, the version it has and the version * on offer. No download address is returned. * * @return array{plugins: array>, themes: array>} */ public static function pending_updates() { self::load_includes(); $out = array( 'plugins' => array(), 'themes' => array(), ); $plugin_updates = get_site_transient( 'update_plugins' ); if ( $plugin_updates && ! empty( $plugin_updates->response ) ) { $installed = get_plugins(); foreach ( $plugin_updates->response as $file => $data ) { if ( ! isset( $installed[ $file ] ) ) { continue; } $out['plugins'][] = array( 'plugin' => (string) $file, 'name' => (string) $installed[ $file ]['Name'], 'current' => (string) $installed[ $file ]['Version'], 'available' => isset( $data->new_version ) ? (string) $data->new_version : '', ); } } $theme_updates = get_site_transient( 'update_themes' ); if ( $theme_updates && ! empty( $theme_updates->response ) ) { foreach ( $theme_updates->response as $slug => $data ) { $theme = wp_get_theme( $slug ); if ( ! $theme->exists() ) { continue; } $out['themes'][] = array( 'theme' => (string) $slug, 'name' => (string) $theme->get( 'Name' ), 'current' => (string) $theme->get( 'Version' ), 'available' => isset( $data['new_version'] ) ? (string) $data['new_version'] : '', ); } } return $out; } }