Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 13 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
9 README.md
@@ -65,6 +65,11 @@ Advanced Users See: post_type.php
Making post types with ACPT is fast and easy. The post_type class takes up to 4 arguments (only the first two are required). First the singular name and then the plural name of your post type (makes these lowercase). The next is for capabilities. If you don’t know how capabilities work set this to false and everything should work expected (the default, false, is the same as posts capabilities). Set capabilities to true to create custom capabilities using the post types name (see roles for advanced usage). Last, you have the settings argument. This is used if you want to change the default settings or override them. Use the settings argument the same as you would for creating post types using Wordpress building registration method.
+Icons:
+=
+
+You can also add icons using the 'icon' method as in the example. Icons include: notebook, refresh, thumbs-up, box, bug, cake, calendar. Use these names as the parameters for the icon method.
+
```php
include('acpt/init.php');
@@ -78,6 +83,8 @@ function makethem() {
$books = new post_type('book','books', false, $args );
+ $books->icon('notebook');
+
}
```
@@ -240,6 +247,8 @@ function makeThem() {
$books = new post_type('book','books', false, $args );
$courses = new post_type('course','courses', false, $args );
+ $books->icon('notebook');
+
new tax('color', 'colors', 'book', true);
new tax('author', 'authors', array($books, $courses), true );
View
BIN  core/img/menu.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
82 core/post_type.php
@@ -22,14 +22,76 @@ class post_type extends acpt {
public $singular = null;
public $plural = null;
+ public $icon = null;
+ public $icon_pos = array(
+ 'notebook' => array('a' => '2px -3px', 'i' => '2px -35px'),
+ 'refresh' => array('a' => '-30px -3px', 'i' => '-30px -35px'),
+ 'thumbs-up' => array('a' => '-60px -3px', 'i' => '-60px -35px'),
+ 'box' => array('a' => '-86px -3px', 'i' => '-86px -35px'),
+ 'bug' => array('a' => '-135px -3px', 'i' => '-135px -35px'),
+ 'cake' => array('a' => '-159px -3px', 'i' => '-159px -35px'),
+ 'calendar' => array('a' => '-182px -3px', 'i' => '-182px -35px'),
+ 'card-biz' => array('a' => '-230px -3px', 'i' => '-230px -35px'),
+ 'task' => array('a' => '-254px -3px', 'i' => '-254px -35px'),
+ 'clock' => array('a' => '-279px -3px', 'i' => '-279px -35px'),
+ 'color' => array('a' => '-303px -3px', 'i' => '-303px -35px'),
+ 'compass' => array('a' => '-326px -3px', 'i' => '-326px -35px'),
+ 'dine' => array('a' => '-350px -3px', 'i' => '-350px -35px'),
+ 'ipad' => array('a' => '-371px -3px', 'i' => '-371px -35px'),
+ 'ticket' => array('a' => '-392px -3px', 'i' => '-392px -35px'),
+ 'shirt' => array('a' => '-420px -3px', 'i' => '-420px -35px'),
+ 'pulse' => array('a' => '-442px -3px', 'i' => '-442px -35px'),
+ 'card-play' => array('a' => '-464px -3px', 'i' => '-464px -35px'),
+ 'dine-plate' => array('a' => '-485px -3px', 'i' => '-485px -35px'),
+ 'pill' => array('a' => '-510px -3px', 'i' => '-510px -35px'),
+ 'plane' => array('a' => '-531px -3px', 'i' => '-531px -35px'),
+ 'paint' => array('a' => '-557px -3px', 'i' => '-557px -35px'),
+ 'mic' => array('a' => '-580px -3px', 'i' => '-580px -35px'),
+ 'location' => array('a' => '-605px -3px', 'i' => '-605px -35px'),
+ 'leaf' => array('a' => '-622px -3px', 'i' => '-622px -35px'),
+ 'music' => array('a' => '-643px -3px', 'i' => '-643px -35px'),
+ 'wine' => array('a' => '-665px -3px', 'i' => '-665px -35px'),
+ 'dashboard' => array('a' => '-688px -3px', 'i' => '-688px -35px'),
+ 'person' => array('a' => '-711px -3px', 'i' => '-711px -35px'),
+ 'weather' => array('a' => '-735px -3px', 'i' => '-735px -35px')
+ );
- function __construct( $singular = null, $plural = null, $cap = false, $settings = array() ) {
+ function __construct( $singular = null, $plural = null, $cap = false, $settings = array(), $icon = null ) {
if($singular !== null ) $this->make($singular, $plural, $cap, $settings);
}
-
+
+ function icon($name) {
+ if(!array_key_exists($name, $this->icon_pos)) exit('Adding Icon: You need to enter a valid icon name. You used ' . $name);
+
+ $this->icon = $name;
+
+ add_action( 'admin_head', array($this, 'set_icon_css') );
+
+ }
+
+ function set_icon_css() { ?>
+
+ <style type="text/css">
+ #adminmenu #menu-posts-<?php echo $this->singular; ?> .wp-menu-image {
+ background-image: url('<?php echo ACPT_LOCATION; ?>/<?php echo ACPT_FOLDER_NAME; ?>/core/img/menu.png');
+ }
+
+ #adminmenu #menu-posts-<?php echo $this->singular; ?> .wp-menu-image {
+ background-position: <?php echo $this->icon_pos[$this->icon]['i']; ?>;
+ }
+
+ #adminmenu #menu-posts-<?php echo $this->singular; ?>:hover div.wp-menu-image,
+ #adminmenu #menu-posts-<?php echo $this->singular; ?>.wp-has-current-submenu div.wp-menu-image,
+ #adminmenu #menu-posts-<?php echo $this->singular; ?>.current div.wp-menu-image {
+ background-position: <?php echo $this->icon_pos[$this->icon]['a']; ?>;
+ }
+ </style>
+
+ <?php }
+
/**
* Make Post Type. Do not use before init.
- *
+ *
* @param string $singular singular name is required
* @param string $plural plural name is required
* @param boolean $cap turn on custom capabilities
@@ -46,7 +108,7 @@ function make($singular = null, $plural = null, $cap = false, $settings = array(
// setup object for later use
$this->plural = $plural;
$this->singular = $singular;
-
+
// make uppercase
$upperSingular = ucwords($singular);
$upperPlural = ucwords($plural);
@@ -61,11 +123,11 @@ function make($singular = null, $plural = null, $cap = false, $settings = array(
'view_item' => 'View '.$upperSingular,
'search_items' => 'Search '.$upperPlural,
'not_found' => 'No '.$plural.' found',
- 'not_found_in_trash' => 'No '.$plural.' found in Trash',
+ 'not_found_in_trash' => 'No '.$plural.' found in Trash',
'parent_item_colon' => '',
'menu_name' => $upperPlural,
);
-
+
$capabilities = array(
'publish_posts' => 'publish_'.$plural,
'edit_post' => 'edit_'.$singular,
@@ -77,7 +139,7 @@ function make($singular = null, $plural = null, $cap = false, $settings = array(
'read_post' => 'read_'.$singular,
'read_private_posts' => 'read_private_'.$plural,
);
-
+
if($cap === true) :
$cap = array(
'capability_type' => $singular,
@@ -86,7 +148,7 @@ function make($singular = null, $plural = null, $cap = false, $settings = array(
else :
$cap = array();
endif;
-
+
$args = array(
'labels' => $labels,
'description' => $plural,
@@ -94,9 +156,9 @@ function make($singular = null, $plural = null, $cap = false, $settings = array(
'public' => true,
'has_archive' => true,
);
-
+
$args = array_merge($args, $cap, $settings);
-
+
// Register post type
register_post_type($singular, $args);
}
View
2  plugins/basic-slider/index.php
@@ -13,6 +13,8 @@ function acpt_slider() {
$slide = new post_type('slide','slides', false, $args );
+$slide->icon('refresh');
+
new tax('group','groups', $slide, true);
}
View
2  plugins/sample/index.php
@@ -10,6 +10,8 @@ function makeThem() {
$sample = new post_type('sample','samples', false, $args );
+$sample->icon('person');
+
new tax('color', 'colors', $sample, true, false);
}
View
1  sample-config.php
@@ -2,6 +2,7 @@
// location of acpt class
define('ACPT_LOCATION', get_stylesheet_directory_uri());
define('ACPT_FILE_PATH', get_stylesheet_directory());
+define('ACPT_FOLDER_NAME', 'acpt');
// turn on styles
define('ACPT_STYLES', true);

No commit comments for this range

Something went wrong with that request. Please try again.