-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Page and Post to use a similar approach to CPTs
- Loading branch information
1 parent
d388f53
commit 1fd2092
Showing
3 changed files
with
119 additions
and
18 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
mu-plugins/10up-plugin/includes/classes/PostTypes/AbstractCorePostType.php
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
/** | ||
* AbstractCorePostType | ||
* | ||
* @package TenUpPlugin | ||
*/ | ||
|
||
namespace TenUpPlugin\PostTypes; | ||
|
||
/** | ||
* Abstract class for core post types. | ||
* | ||
* This class is intended to be extended by post types that are part of core WordPress functionality. | ||
* This allows for a more common interface for core post types and custom post types. | ||
* It's unlikely that this class will need to be used directly. | ||
*/ | ||
abstract class AbstractCorePostType extends AbstractPostType { | ||
|
||
/** | ||
* Get the singular post type label. | ||
* | ||
* No-op for core post types since they are already registered by WordPress. | ||
* | ||
* @return string | ||
*/ | ||
public function get_singular_label() { | ||
return ''; | ||
} | ||
|
||
/** | ||
* Get the plural post type label. | ||
* | ||
* No-op for core post types since they are already registered by WordPress. | ||
* | ||
* @return string | ||
*/ | ||
public function get_plural_label() { | ||
return ''; | ||
} | ||
|
||
/** | ||
* Get the menu icon for the post type. | ||
* | ||
* No-op for core post types since they are already registered by WordPress. | ||
* | ||
* @return string | ||
*/ | ||
public function get_menu_icon() { | ||
return ''; | ||
} | ||
|
||
/** | ||
* Checks whether the Module should run within the current context. | ||
* | ||
* True for core post types since they are already registered by WordPress. | ||
* | ||
* @return bool | ||
*/ | ||
public function can_register() { | ||
return true; | ||
} | ||
|
||
/** | ||
* Registers a post type and associates its taxonomies. | ||
* | ||
* @uses $this->get_name() to get the post's type name. | ||
* @return Bool Whether this theme has supports for this post type. | ||
*/ | ||
public function register() { | ||
$this->register_taxonomies(); | ||
$this->after_register(); | ||
|
||
return 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
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