-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
37 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* class before calling 'register'. | ||
* | ||
* @package PattonWebz Post Type Registration Class | ||
* @version 0.2.1 | ||
* @version 0.2.2 | ||
* @since 0.1.0 | ||
* @author William Patton <[email protected]> | ||
* @copyright Copyright (c) 2018-2019, William Patton | ||
|
@@ -26,28 +26,51 @@ abstract class AbstractPostType { | |
/** | ||
* The identifier for this post type. | ||
* | ||
* @since 0.1.0 | ||
* @var string | ||
*/ | ||
public $name = 'post'; | ||
|
||
/** | ||
* The arguments used when registering this post type. | ||
* Icon to use for this post type. | ||
* | ||
* NOTE: This is PHP 7+ only. | ||
* @since 0.2.2 | ||
* @var string | ||
*/ | ||
public $icon = 'dashicons-admin-post'; | ||
|
||
/** | ||
* The arguments used when registering this post type. | ||
* | ||
* @since 0.1.0 | ||
* @var array | ||
*/ | ||
public $args = []; | ||
|
||
/** | ||
* The arguments used when registering this post type. | ||
* | ||
* NOTE: This is PHP 7+ only. | ||
* | ||
* @since 0.1.0 | ||
* @var array | ||
*/ | ||
public $labels = []; | ||
|
||
/** | ||
* Sets up the properties for use when registering. | ||
* | ||
* @method __construct | ||
* @since 0.2.2 | ||
* @param array $args The array of args to use when registering the CPT. | ||
* @param array $labels A custom labels array to use when registering the | ||
* post. NOTE: If you are passing a custom $args array | ||
* then this will not be included automatticaly so | ||
* include it in $args['labels'] directly. | ||
*/ | ||
public function __construct( array $args = [], array $labels = [] ) { | ||
$this->labels = ( ! empty( $labels ) ) ? $labels : $this->get_labels(); | ||
$this->args = ( ! empty( $args ) ) ? $args : $this->get_args(); | ||
} | ||
|
||
/** | ||
* Hook in and register the post type. | ||
* | ||
|
@@ -81,7 +104,7 @@ public function get_name() { | |
public function get_labels() { | ||
|
||
return ( ! empty( $this->labels ) ) ? $this->labels : [ | ||
'name' => ucfirst( $this->name ), | ||
'name' => ucwords( $this->name ), | ||
]; | ||
} | ||
|
||
|
@@ -101,6 +124,7 @@ public function get_args() { | |
'post_type' => $name, | ||
'label' => $name, | ||
'labels' => $labels, | ||
'menu_icon' => ( ! empty( $this->icon ) ) ? $this->icon : 'dashicons-admin-post', | ||
'public' => true, | ||
]; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters