wpseek.com
WordPress开发者和主题制作者的搜索引擎
update_gallery_tab › WordPress Function
Since2.5.0
已弃用n/a
› update_gallery_tab ( $tabs )
参数: |
|
返回: |
|
定义在: |
|
文档: |
Adds the gallery tab back to the tabs array if post has image attachments.
Related Functions: update_user_meta, update_term_meta, update_meta, update_usermeta, update_category_cache
源码
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; }