wp/wp-admin/includes/update.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
   238 
   238 
   239 	if ( ! isset( $cur->current ) ) {
   239 	if ( ! isset( $cur->current ) ) {
   240 		$cur->current = '';
   240 		$cur->current = '';
   241 	}
   241 	}
   242 
   242 
   243 	if ( ! isset( $cur->url ) ) {
       
   244 		$cur->url = '';
       
   245 	}
       
   246 
       
   247 	if ( ! isset( $cur->response ) ) {
   243 	if ( ! isset( $cur->response ) ) {
   248 		$cur->response = '';
   244 		$cur->response = '';
   249 	}
   245 	}
   250 
   246 
       
   247 	// Include an unmodified $wp_version.
       
   248 	require ABSPATH . WPINC . '/version.php';
       
   249 
       
   250 	$is_development_version = preg_match( '/alpha|beta|RC/', $wp_version );
       
   251 
       
   252 	if ( $is_development_version ) {
       
   253 		return sprintf(
       
   254 			/* translators: 1: WordPress version number, 2: URL to WordPress Updates screen. */
       
   255 			__( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ),
       
   256 			get_bloginfo( 'version', 'display' ),
       
   257 			network_admin_url( 'update-core.php' )
       
   258 		);
       
   259 	}
       
   260 
   251 	switch ( $cur->response ) {
   261 	switch ( $cur->response ) {
   252 		case 'development':
       
   253 			return sprintf(
       
   254 				/* translators: 1: WordPress version number, 2: URL to WordPress Updates screen. */
       
   255 				__( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ),
       
   256 				get_bloginfo( 'version', 'display' ),
       
   257 				network_admin_url( 'update-core.php' )
       
   258 			);
       
   259 
       
   260 		case 'upgrade':
   262 		case 'upgrade':
   261 			return sprintf(
   263 			return sprintf(
   262 				'<strong><a href="%s">%s</a></strong>',
   264 				'<strong><a href="%s">%s</a></strong>',
   263 				network_admin_url( 'update-core.php' ),
   265 				network_admin_url( 'update-core.php' ),
   264 				/* translators: %s: WordPress version. */
   266 				/* translators: %s: WordPress version. */
   431 		'em'      => array(),
   433 		'em'      => array(),
   432 		'strong'  => array(),
   434 		'strong'  => array(),
   433 	);
   435 	);
   434 
   436 
   435 	$plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
   437 	$plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
   436 	$details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $response->slug . '&section=changelog&TB_iframe=true&width=600&height=800' );
   438 	$plugin_slug = isset( $response->slug ) ? $response->slug : $response->id;
       
   439 
       
   440 	if ( isset( $response->slug ) ) {
       
   441 		$details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_slug . '&section=changelog' );
       
   442 	} elseif ( isset( $response->url ) ) {
       
   443 		$details_url = $response->url;
       
   444 	} else {
       
   445 		$details_url = $plugin_data['PluginURI'];
       
   446 	}
       
   447 
       
   448 	$details_url = add_query_arg(
       
   449 		array(
       
   450 			'TB_iframe' => 'true',
       
   451 			'width'     => 600,
       
   452 			'height'    => 800,
       
   453 		),
       
   454 		$details_url
       
   455 	);
   437 
   456 
   438 	/** @var WP_Plugins_List_Table $wp_list_table */
   457 	/** @var WP_Plugins_List_Table $wp_list_table */
   439 	$wp_list_table = _get_list_table(
   458 	$wp_list_table = _get_list_table(
   440 		'WP_Plugins_List_Table',
   459 		'WP_Plugins_List_Table',
   441 		array(
   460 		array(
   457 		printf(
   476 		printf(
   458 			'<tr class="plugin-update-tr%s" id="%s" data-slug="%s" data-plugin="%s">' .
   477 			'<tr class="plugin-update-tr%s" id="%s" data-slug="%s" data-plugin="%s">' .
   459 			'<td colspan="%s" class="plugin-update colspanchange">' .
   478 			'<td colspan="%s" class="plugin-update colspanchange">' .
   460 			'<div class="update-message notice inline %s notice-alt"><p>',
   479 			'<div class="update-message notice inline %s notice-alt"><p>',
   461 			$active_class,
   480 			$active_class,
   462 			esc_attr( $response->slug . '-update' ),
   481 			esc_attr( $plugin_slug . '-update' ),
   463 			esc_attr( $response->slug ),
   482 			esc_attr( $plugin_slug ),
   464 			esc_attr( $file ),
   483 			esc_attr( $file ),
   465 			esc_attr( $wp_list_table->get_column_count() ),
   484 			esc_attr( $wp_list_table->get_column_count() ),
   466 			$notice_type
   485 			$notice_type
   467 		);
   486 		);
   468 
   487 
  1044 
  1063 
  1045 	return false;
  1064 	return false;
  1046 }
  1065 }
  1047 
  1066 
  1048 /**
  1067 /**
       
  1068  * Checks whether auto-updates are forced for an item.
       
  1069  *
       
  1070  * @since 5.6.0
       
  1071  *
       
  1072  * @param string    $type   The type of update being checked: 'theme' or 'plugin'.
       
  1073  * @param bool|null $update Whether to update. The value of null is internally used
       
  1074  *                          to detect whether nothing has hooked into this filter.
       
  1075  * @param object    $item   The update offer.
       
  1076  * @return bool True if auto-updates are forced for `$item`, false otherwise.
       
  1077  */
       
  1078 function wp_is_auto_update_forced_for_item( $type, $update, $item ) {
       
  1079 	/** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
       
  1080 	return apply_filters( "auto_update_{$type}", $update, $item );
       
  1081 }
       
  1082 
       
  1083 /**
  1049  * Determines the appropriate auto-update message to be displayed.
  1084  * Determines the appropriate auto-update message to be displayed.
  1050  *
  1085  *
  1051  * @since 5.5.0
  1086  * @since 5.5.0
  1052  *
  1087  *
  1053  * @return string The update message to be shown.
  1088  * @return string The update message to be shown.
  1057 
  1092 
  1058 	// Check if the event exists.
  1093 	// Check if the event exists.
  1059 	if ( false === $next_update_time ) {
  1094 	if ( false === $next_update_time ) {
  1060 		$message = __( 'Automatic update not scheduled. There may be a problem with WP-Cron.' );
  1095 		$message = __( 'Automatic update not scheduled. There may be a problem with WP-Cron.' );
  1061 	} else {
  1096 	} else {
  1062 		$time_to_next_update = human_time_diff( intval( $next_update_time ) );
  1097 		$time_to_next_update = human_time_diff( (int) $next_update_time );
  1063 
  1098 
  1064 		// See if cron is overdue.
  1099 		// See if cron is overdue.
  1065 		$overdue = ( time() - $next_update_time ) > 0;
  1100 		$overdue = ( time() - $next_update_time ) > 0;
  1066 
  1101 
  1067 		if ( $overdue ) {
  1102 		if ( $overdue ) {