Make WordPress Core


Ignore:
Timestamp:
12/08/2008 07:38:05 AM (16 years ago)
Author:
azaozz
Message:

Do not show Gallery tab in the uploader if no files have been uploaded.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/media.php

    r10118 r10124  
    3535function update_gallery_tab($tabs) {
    3636    global $wpdb;
     37
    3738    if ( !isset($_REQUEST['post_id']) ) {
    3839        unset($tabs['gallery']);
    3940        return $tabs;
    4041    }
     42
    4143    if ( intval($_REQUEST['post_id']) )
    4244        $attachments = intval($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $_REQUEST['post_id'])));
     45
     46    if ( empty($attachments) ) {
     47        unset($tabs['gallery']);
     48        return $tabs;
     49    }
    4350
    4451    $tabs['gallery'] = sprintf(__('Gallery (%s)'), "<span id='attachments-count'>$attachments</span>");
Note: See TracChangeset for help on using the changeset viewer.