Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: wp_upload_tabs

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
35      // 0 => tab display name, 1 => required cap, 2 => function that produces tab content, 3 => total number objects OR array(total, objects per page), 4 => add_query_args
36      $wp_upload_tabs['upload'] = array(__('Upload'), 'upload_files', 'wp_upload_tab_upload', 0);
37      if ( $all_atts && $post_atts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = '$post_id'") )
38           $wp_upload_tabs['browse'] = array(__('Browse'), 'upload_files', "wp_upload_tab_browse", $action ? 0 : $post_atts);
39      if ( $post_atts < $all_atts )
40           $wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse', $action ? 0 : $all_atts);
41 } else
42      $wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse', $action ? 0 : $all_atts);
43
44      $wp_upload_tabs = array_merge($wp_upload_tabs, apply_filters( 'wp_upload_tabs', array() ));
45
46 if ( !is_callable($wp_upload_tabs[$tab][2]) ) {
47      $to_tab = isset($wp_upload_tabs['upload']) ? 'upload' : 'browse-all';
48      wp_redirect( add_query_arg( 'tab', $to_tab ) );
49      exit;
50 }
51
52 foreach ( $wp_upload_tabs as $t => $tab_array ) {
53      if ( !current_user_can( $tab_array[1] ) ) {