update_gallery_tab

Definition:
function update_gallery_tab($tabs) {}

Parameters

  • unknown_type $tabs

Source code

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;

	}



	$tabs['gallery'] = sprintf(__('Gallery (%s)'), "<span id='attachments-count'>$attachments</span>");



	return $tabs;

}

3171

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: