wppaste
WordPress

update_gallery_tab( array $tabs ): array

Since
2.5.0
Source
wp-admin/includes/media.php:44
Adds the gallery tab back to the tabs array if post has image attachments.

Parameters

$tabsarray

Return

array
$tabs with gallery if post has image attachment

Uses · 1

  • __()Retrieves the translation of $text.

Source

function update_gallery_tab( $tabs ) {	global $wpdb; 	if ( ! isset( $_REQUEST['post_id'] ) ) {		unset( $tabs['gallery'] );		return $tabs;	} 	$post_id = (int) $_REQUEST['post_id']; 	if ( $post_id ) {		$attachments = (int) $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent = %d", $post_id ) );	} 	if ( empty( $attachments ) ) {		unset( $tabs['gallery'] );		return $tabs;	} 	/* translators: %s: Number of attachments. */	$tabs['gallery'] = sprintf( __( 'Gallery (%s)' ), "<span id='attachments-count'>$attachments</span>" ); 	return $tabs;}

History

Introduced in 2.5.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-admin/includes/media.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.