wp/wp-admin/includes/update.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
--- a/wp/wp-admin/includes/update.php	Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-admin/includes/update.php	Wed Sep 21 18:19:35 2022 +0200
@@ -240,23 +240,25 @@
 		$cur->current = '';
 	}
 
-	if ( ! isset( $cur->url ) ) {
-		$cur->url = '';
-	}
-
 	if ( ! isset( $cur->response ) ) {
 		$cur->response = '';
 	}
 
+	// Include an unmodified $wp_version.
+	require ABSPATH . WPINC . '/version.php';
+
+	$is_development_version = preg_match( '/alpha|beta|RC/', $wp_version );
+
+	if ( $is_development_version ) {
+		return sprintf(
+			/* translators: 1: WordPress version number, 2: URL to WordPress Updates screen. */
+			__( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ),
+			get_bloginfo( 'version', 'display' ),
+			network_admin_url( 'update-core.php' )
+		);
+	}
+
 	switch ( $cur->response ) {
-		case 'development':
-			return sprintf(
-				/* translators: 1: WordPress version number, 2: URL to WordPress Updates screen. */
-				__( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ),
-				get_bloginfo( 'version', 'display' ),
-				network_admin_url( 'update-core.php' )
-			);
-
 		case 'upgrade':
 			return sprintf(
 				'<strong><a href="%s">%s</a></strong>',
@@ -433,7 +435,24 @@
 	);
 
 	$plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
-	$details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $response->slug . '&section=changelog&TB_iframe=true&width=600&height=800' );
+	$plugin_slug = isset( $response->slug ) ? $response->slug : $response->id;
+
+	if ( isset( $response->slug ) ) {
+		$details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_slug . '&section=changelog' );
+	} elseif ( isset( $response->url ) ) {
+		$details_url = $response->url;
+	} else {
+		$details_url = $plugin_data['PluginURI'];
+	}
+
+	$details_url = add_query_arg(
+		array(
+			'TB_iframe' => 'true',
+			'width'     => 600,
+			'height'    => 800,
+		),
+		$details_url
+	);
 
 	/** @var WP_Plugins_List_Table $wp_list_table */
 	$wp_list_table = _get_list_table(
@@ -459,8 +478,8 @@
 			'<td colspan="%s" class="plugin-update colspanchange">' .
 			'<div class="update-message notice inline %s notice-alt"><p>',
 			$active_class,
-			esc_attr( $response->slug . '-update' ),
-			esc_attr( $response->slug ),
+			esc_attr( $plugin_slug . '-update' ),
+			esc_attr( $plugin_slug ),
 			esc_attr( $file ),
 			esc_attr( $wp_list_table->get_column_count() ),
 			$notice_type
@@ -1046,6 +1065,22 @@
 }
 
 /**
+ * Checks whether auto-updates are forced for an item.
+ *
+ * @since 5.6.0
+ *
+ * @param string    $type   The type of update being checked: 'theme' or 'plugin'.
+ * @param bool|null $update Whether to update. The value of null is internally used
+ *                          to detect whether nothing has hooked into this filter.
+ * @param object    $item   The update offer.
+ * @return bool True if auto-updates are forced for `$item`, false otherwise.
+ */
+function wp_is_auto_update_forced_for_item( $type, $update, $item ) {
+	/** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
+	return apply_filters( "auto_update_{$type}", $update, $item );
+}
+
+/**
  * Determines the appropriate auto-update message to be displayed.
  *
  * @since 5.5.0
@@ -1059,7 +1094,7 @@
 	if ( false === $next_update_time ) {
 		$message = __( 'Automatic update not scheduled. There may be a problem with WP-Cron.' );
 	} else {
-		$time_to_next_update = human_time_diff( intval( $next_update_time ) );
+		$time_to_next_update = human_time_diff( (int) $next_update_time );
 
 		// See if cron is overdue.
 		$overdue = ( time() - $next_update_time ) > 0;