public
Created

Register some bogus post types with icons.

  • Download Gist
plugin.php
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
<?php
/**
* Plugin Name: Register Some Post Types
*/
add_action( 'init', 'my_register_post_types' );
function my_register_post_types() {
register_post_type( 'cpt-1', array(
'label' => 'Image',
'public' => true,
'show_in_menu' => true,
'menu_icon' => 'http://0.gravatar.com/avatar/8585b20b69e8ff4b0ba737accfdbb31b?s=50',
) );
 
register_post_type( 'cpt-2', array(
'label' => 'Sprite',
'public' => true,
'show_in_menu' => true,
'menu_icon' => array(
'image_url' => admin_url( 'images/menu.png?ver=' . time() ),
'background_position' => '-359px -33px',
'background_position_hover' => '-359px, -1px',
),
) );
 
register_post_type( 'cpt-3', array(
'label' => 'Sprite 2x',
'public' => true,
'show_in_menu' => true,
'menu_icon' => array(
'regular' => array(
'image_url' => admin_url( 'images/menu.png?ver=' . time() ),
'background_position' => '-359px, -33px',
'background_position_hover' => '-359px -1px',
),
'2x' => array(
'image_url' => admin_url( 'images/menu-2x.png?ver=' . time() ),
'background_size' => '390 64',
),
),
) );
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.