Changeset 553013
- Timestamp:
- 06/04/2012 03:54:16 PM (14 years ago)
- Location:
- sld-custom-content-and-taxonomies
- Files:
-
- 6 added
- 4 edited
- 1 copied
-
tags/1.5 (copied) (copied from sld-custom-content-and-taxonomies/trunk)
-
tags/1.5/class.register-post-type.php (modified) (5 diffs)
-
tags/1.5/images (added)
-
tags/1.5/images/icons16.png (added)
-
tags/1.5/images/icons32.png (added)
-
tags/1.5/readme.txt (modified) (3 diffs)
-
trunk/class.register-post-type.php (modified) (5 diffs)
-
trunk/images (added)
-
trunk/images/icons16.png (added)
-
trunk/images/icons32.png (added)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sld-custom-content-and-taxonomies/tags/1.5/class.register-post-type.php
r476513 r553013 8 8 private $post_type_object; 9 9 private $defaults; 10 private $custom_icon; 11 private $custom_icons; 10 12 11 13 public function __construct( $post_type = null, $args = array(), $custom_plural = false ) { … … 19 21 // sort out those $args 20 22 $this->set_defaults(); 23 if ( !empty($args['custom_icon']) ) { 24 $this->custom_icon = $args['custom_icon']; 25 unset($args['custom_icon']); 26 } 21 27 $this->args = wp_parse_args($args, $this->defaults); 22 28 … … 56 62 'not_found_in_trash' => 'No ' . $plural . ' found in Trash' 57 63 ); 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 ); 58 84 } 59 85 … … 61 87 add_action( 'init', array($this, 'register_post_type') ); 62 88 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') ); 63 91 } 64 92 … … 105 133 } 106 134 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 107 150 } // end SLD_Register_Post_Type class -
sld-custom-content-and-taxonomies/tags/1.5/readme.txt
r476513 r553013 4 4 Requires at least: 3.0 5 5 Tested up to: 3.4 (alpha) 6 Stable tag: 1. 4.16 Stable tag: 1.5 7 7 8 8 == Description == … … 19 19 20 20 Originally based on the work of Matt Wiebe @ <http://somadesign.ca/projects/smarter-custom-post-types/> 21 22 Awesome custom admin icons designed by Laura Kalbag <http://laurakalbag.com/wordpress-admin-icons/> 21 23 22 24 You can follow development of this plugin on GitHub @ <https://github.com/jkudish/sld-custom-content-and-taxonomies> … … 39 41 40 42 == Changelog == 43 44 = 1.5 = 45 46 Add 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 41 47 42 48 = 1.4.1 = -
sld-custom-content-and-taxonomies/trunk/class.register-post-type.php
r476513 r553013 8 8 private $post_type_object; 9 9 private $defaults; 10 private $custom_icon; 11 private $custom_icons; 10 12 11 13 public function __construct( $post_type = null, $args = array(), $custom_plural = false ) { … … 19 21 // sort out those $args 20 22 $this->set_defaults(); 23 if ( !empty($args['custom_icon']) ) { 24 $this->custom_icon = $args['custom_icon']; 25 unset($args['custom_icon']); 26 } 21 27 $this->args = wp_parse_args($args, $this->defaults); 22 28 … … 56 62 'not_found_in_trash' => 'No ' . $plural . ' found in Trash' 57 63 ); 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 ); 58 84 } 59 85 … … 61 87 add_action( 'init', array($this, 'register_post_type') ); 62 88 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') ); 63 91 } 64 92 … … 105 133 } 106 134 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 107 150 } // end SLD_Register_Post_Type class -
sld-custom-content-and-taxonomies/trunk/readme.txt
r476513 r553013 4 4 Requires at least: 3.0 5 5 Tested up to: 3.4 (alpha) 6 Stable tag: 1. 4.16 Stable tag: 1.5 7 7 8 8 == Description == … … 19 19 20 20 Originally based on the work of Matt Wiebe @ <http://somadesign.ca/projects/smarter-custom-post-types/> 21 22 Awesome custom admin icons designed by Laura Kalbag <http://laurakalbag.com/wordpress-admin-icons/> 21 23 22 24 You can follow development of this plugin on GitHub @ <https://github.com/jkudish/sld-custom-content-and-taxonomies> … … 39 41 40 42 == Changelog == 43 44 = 1.5 = 45 46 Add 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 41 47 42 48 = 1.4.1 =
Note: See TracChangeset
for help on using the changeset viewer.