WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

update_gallery_tab() WP 2.5.0

Adds the gallery tab back to the tabs array if post has image attachments

Хуков нет.

Возвращает

Массив. $tabs with gallery if post has image attachment

Использование

update_gallery_tab( $tabs );
$tabs(массив) (обязательный)

Заметки

  • Global. wpdb. $wpdb WordPress database abstraction object.

Список изменений

С версии 2.5.0 Введена.

Код update_gallery_tab() WP 5.5.1

wp-admin/includes/media.php
<?php
function update_gallery_tab( $tabs ) {
	global $wpdb;

	if ( ! isset( $_REQUEST['post_id'] ) ) {
		unset( $tabs['gallery'] );
		return $tabs;
	}

	$post_id = intval( $_REQUEST['post_id'] );

	if ( $post_id ) {
		$attachments = intval( $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;
}