Advertisement
firoze

WP custom post & SMOF tab icons changing

Mar 20th, 2015
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. // wordpress post type icons changing by font icon / images|| smof tab icons changing
  2.  
  3. // wordpress default icons cdn
  4. function firoze() {
  5. wp_register_style('firoze_fonts', 'https://developer.wordpress.org/wp-includes/css/dashicons.min.css');
  6. wp_enqueue_style( 'firoze_fonts');
  7. }
  8.  
  9. add_action('wp_print_styles', 'firoze');
  10.  
  11. // for calling icon
  12. function add_append_jquery_in_admin_head(){
  13. ?>
  14. <script type="text/javascript">
  15. jQuery(document).ready(function(){
  16. <!-- images usages -->
  17. jQuery('li.changeicon a ').append('<img src="http://lorempixel.com/15/15/nature" alt="" />');
  18.  
  19. <!-- wordpress default icons usages -->
  20. jQuery('li.loremicon a ').append('<span class="dashicons dashicons-wordpress"></span>');
  21. });
  22. </script>
  23. <style type="text/css">
  24.  
  25. #of-nav ul li{position:relative;}
  26. .changeicon img, .loremicon img {
  27. height: 15px;left: 0;
  28. padding-left: 12px;padding-right: 5px;position: absolute;width: 15px;top:12px;}
  29.  
  30. .loremicon span{color: #52B231;
  31. display: inline-block;
  32. font-size: 18px;
  33. left: 10px;
  34. position: absolute;}
  35.  
  36.  
  37. </style>
  38. <?php
  39. }
  40. add_action('admin_head', 'add_append_jquery_in_admin_head');
  41.  
  42.  
  43.  
  44.  
  45. // register post type images changing
  46.  
  47. register_post_type( 'acme_product',
  48. array(
  49. 'labels' => array(
  50. 'name' => __( 'Products' ),
  51. 'singular_name' => __( 'Product' ),
  52. 'add_new'=>_('Add New product'),
  53.  
  54. ),
  55. 'public' => true,
  56. 'has_archive' => true,
  57. 'rewrite'=> array( 'slug' => 'product' ),
  58. 'supports'=> array( 'title', 'editor', 'custom-fields', 'author', 'comments', '' ),
  59. // 'menu_icon' => get_template_directory_uri() . '/image/icon-portfolio.png',
  60. 'menu_icon' => 'dashicons-portfolio',
  61.  
  62. )
  63. );
  64.  
  65.  
  66.  
  67.  
  68. // get wordpress all default all icons from here
  69.  
  70. https://developer.wordpress.org/resource/dashicons/#wordpress
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement