Plugin Directory

Changeset 553013


Ignore:
Timestamp:
06/04/2012 03:54:16 PM (14 years ago)
Author:
cvernon
Message:

v.1.5 including new custom icons

Location:
sld-custom-content-and-taxonomies
Files:
6 added
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • sld-custom-content-and-taxonomies/tags/1.5/class.register-post-type.php

    r476513 r553013  
    88    private $post_type_object;
    99    private $defaults;
     10    private $custom_icon;
     11    private $custom_icons;
    1012   
    1113    public function __construct( $post_type = null, $args = array(), $custom_plural = false ) {
     
    1921        // sort out those $args
    2022        $this->set_defaults();
     23        if ( !empty($args['custom_icon']) ) {
     24            $this->custom_icon = $args['custom_icon'];
     25            unset($args['custom_icon']);
     26        }
    2127        $this->args = wp_parse_args($args, $this->defaults);
    2228       
     
    5662            'not_found_in_trash' => 'No ' . $plural . ' found in Trash'
    5763        );
     64
     65        $this->custom_icons = array(
     66            'audio',
     67            'pound',
     68            'clipboard',
     69            'bookmark',
     70            'jamjar',
     71            'locationpin',
     72            'calendar',
     73            'mobile',
     74            'mortarboard',
     75            'star',
     76            'box',
     77            'users',
     78            'pencil',
     79            'book',
     80            'folder',
     81            'rectangles',
     82            // 'bookmarkbook', // need 32px image from Laura
     83            );
    5884    }
    5985   
     
    6187        add_action( 'init', array($this, 'register_post_type') );
    6288        add_action( 'template_redirect', array($this, 'context_fixer') );
     89        if ( !empty($this->custom_icon) && in_array( $this->custom_icon, $this->custom_icons ) )
     90            add_action( 'admin_head', array($this, 'admin_head') );
    6391    }
    6492
     
    105133    }
    106134
     135    public function admin_head() {
     136        $icon = $this->custom_icon;
     137        $admin_icons = $this->custom_icons;
     138        $type = $this->post_type;
     139        $url = plugins_url( 'images', __FILE__ );
     140        $index = array_search( $icon, $admin_icons );
     141        ?>
     142        <style type="text/css" media="screen">
     143        #adminmenu #menu-posts-<?php echo $type ?> div.wp-menu-image { background:transparent url('<?php echo $url ?>/icons16.png') no-repeat <?php echo ( $index * -32 ); ?>px -32px !important; }
     144        #adminmenu #menu-posts-<?php echo $type ?>:hover div.wp-menu-image, #adminmenu #menu-posts-<?php echo $type ?>.wp-has-current-submenu div.wp-menu-image { background-position:<?php echo ( $index * -32 ); ?>px 0px!important; }
     145        .type-<?php echo $type ?> #icon-edit { background:transparent url('<?php echo $url ?>/icons32.png') <?php echo ( $index * -60 ); ?>px -5px no-repeat; }
     146        </style>
     147        <?php
     148    }
     149
    107150} // end SLD_Register_Post_Type class
  • sld-custom-content-and-taxonomies/tags/1.5/readme.txt

    r476513 r553013  
    44Requires at least: 3.0
    55Tested up to: 3.4 (alpha)
    6 Stable tag: 1.4.1
     6Stable tag: 1.5
    77
    88== Description ==
     
    1919
    2020Originally based on the work of Matt Wiebe @ <http://somadesign.ca/projects/smarter-custom-post-types/>
     21
     22Awesome custom admin icons designed by Laura Kalbag <http://laurakalbag.com/wordpress-admin-icons/>
    2123
    2224You can follow development of this plugin on GitHub @ <https://github.com/jkudish/sld-custom-content-and-taxonomies>
     
    3941
    4042== Changelog ==
     43
     44= 1.5 =
     45
     46Add the ability to choose an icon for your custom content type in the WP admin section. sld_register_post_type() now accepts a new parameter 'custom_icon' to the optional $args array, which will provide an awesome custom icon to the admin section
    4147
    4248= 1.4.1 =
  • sld-custom-content-and-taxonomies/trunk/class.register-post-type.php

    r476513 r553013  
    88    private $post_type_object;
    99    private $defaults;
     10    private $custom_icon;
     11    private $custom_icons;
    1012   
    1113    public function __construct( $post_type = null, $args = array(), $custom_plural = false ) {
     
    1921        // sort out those $args
    2022        $this->set_defaults();
     23        if ( !empty($args['custom_icon']) ) {
     24            $this->custom_icon = $args['custom_icon'];
     25            unset($args['custom_icon']);
     26        }
    2127        $this->args = wp_parse_args($args, $this->defaults);
    2228       
     
    5662            'not_found_in_trash' => 'No ' . $plural . ' found in Trash'
    5763        );
     64
     65        $this->custom_icons = array(
     66            'audio',
     67            'pound',
     68            'clipboard',
     69            'bookmark',
     70            'jamjar',
     71            'locationpin',
     72            'calendar',
     73            'mobile',
     74            'mortarboard',
     75            'star',
     76            'box',
     77            'users',
     78            'pencil',
     79            'book',
     80            'folder',
     81            'rectangles',
     82            // 'bookmarkbook', // need 32px image from Laura
     83            );
    5884    }
    5985   
     
    6187        add_action( 'init', array($this, 'register_post_type') );
    6288        add_action( 'template_redirect', array($this, 'context_fixer') );
     89        if ( !empty($this->custom_icon) && in_array( $this->custom_icon, $this->custom_icons ) )
     90            add_action( 'admin_head', array($this, 'admin_head') );
    6391    }
    6492
     
    105133    }
    106134
     135    public function admin_head() {
     136        $icon = $this->custom_icon;
     137        $admin_icons = $this->custom_icons;
     138        $type = $this->post_type;
     139        $url = plugins_url( 'images', __FILE__ );
     140        $index = array_search( $icon, $admin_icons );
     141        ?>
     142        <style type="text/css" media="screen">
     143        #adminmenu #menu-posts-<?php echo $type ?> div.wp-menu-image { background:transparent url('<?php echo $url ?>/icons16.png') no-repeat <?php echo ( $index * -32 ); ?>px -32px !important; }
     144        #adminmenu #menu-posts-<?php echo $type ?>:hover div.wp-menu-image, #adminmenu #menu-posts-<?php echo $type ?>.wp-has-current-submenu div.wp-menu-image { background-position:<?php echo ( $index * -32 ); ?>px 0px!important; }
     145        .type-<?php echo $type ?> #icon-edit { background:transparent url('<?php echo $url ?>/icons32.png') <?php echo ( $index * -60 ); ?>px -5px no-repeat; }
     146        </style>
     147        <?php
     148    }
     149
    107150} // end SLD_Register_Post_Type class
  • sld-custom-content-and-taxonomies/trunk/readme.txt

    r476513 r553013  
    44Requires at least: 3.0
    55Tested up to: 3.4 (alpha)
    6 Stable tag: 1.4.1
     6Stable tag: 1.5
    77
    88== Description ==
     
    1919
    2020Originally based on the work of Matt Wiebe @ <http://somadesign.ca/projects/smarter-custom-post-types/>
     21
     22Awesome custom admin icons designed by Laura Kalbag <http://laurakalbag.com/wordpress-admin-icons/>
    2123
    2224You can follow development of this plugin on GitHub @ <https://github.com/jkudish/sld-custom-content-and-taxonomies>
     
    3941
    4042== Changelog ==
     43
     44= 1.5 =
     45
     46Add the ability to choose an icon for your custom content type in the WP admin section. sld_register_post_type() now accepts a new parameter 'custom_icon' to the optional $args array, which will provide an awesome custom icon to the admin section
    4147
    4248= 1.4.1 =
Note: See TracChangeset for help on using the changeset viewer.