Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
pattonwebz committed Feb 26, 2019
2 parents 63a69ad + 6a9c73c commit 57eaa00
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
36 changes: 30 additions & 6 deletions AbstractPostType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
*
Expand Down Expand Up @@ -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 ),
];
}

Expand All @@ -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,
];
}
Expand Down
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ _No documentation available about unreleased changes as of yet._
## [0.2.1] - 2019-02-10

- Changed where the uppercase first letter when backfilling is done for 'label'

## [0.2.2] - 2019-02-26

### Added

- Added a class constructor method to handle setup of properties at instantiation for overriding defaults.
- Add menu_icon option to class.

0 comments on commit 57eaa00

Please sign in to comment.