不知道这个标题大家能不能明白什么是什么意思,如果不明白的话,那么可以看看下面的图片即可了解:
那么这个弹出窗口添加一个TAB栏是什么意思呢?
不知道通过上面的截图,大家明白这个意思了没有,如果明白了,感兴趣的话可以继续往下面看看。
添加的这个TAB栏目可以用来做什么,就看个人的需求了。直接将下面的代码添加到主题目录下的function.php文件中即可,不会添加可以安装插件解决的问题:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
function mime_type_tab($tabs) { /* name of custom tab */ $new_tab = array('mimeframe' => __('Mime Types', 'mimetype')); return array_merge($tabs, $new_tab); } add_filter('media_upload_tabs', 'mime_type_tab'); function create_mime_type_page() { media_upload_header(); wp_enqueue_style( 'media' ); /* add custom code to display bellow this line */ /* display mime types */ $mimes = get_allowed_mime_types(); $types = array(); echo '<div class="type-outer">'; echo '<h3 class="media-title">Supported file types</h3>'; echo '<hr />'; foreach ($mimes as $ext => $mime) { $types[] = '<li>' . str_replace('|', ', ', $ext) . '</li>'; } echo '<ul class="mime-types">' . implode('', $types) . '</ul>'; echo '</div>'; /* end custom code */ } function insert_mime_type_iframe() { return wp_iframe( 'create_mime_type_page'); } add_action('media_upload_mimeframe', 'insert_mime_type_iframe'); add_action( 'admin_head', 'mime_frame_css' ); function mime_frame_css() { echo '<style type="text/css"> .type-outer{margin:20px;} .type-outer hr{ border:solid #ccc; border-width:0px 0px 1px 0px; margin:0px 0px 20px 0px; } .mime-types li{ font-size:10px; float:left; width:24%; padding:1px; } </style>'; } |
最终实现效果如下:
右边的内容可以自定义,也就是上面代码中create_mime_type_page()函数里面的内容了,大家可以修改为自己需要的东西用来展示或者别的功能都是可以的。