Skip to content

Commit

Permalink
Demo post type and taxonomy that can be cloned
Browse files Browse the repository at this point in the history
  • Loading branch information
darylldoyle committed Mar 14, 2024
1 parent a253d52 commit 0b8990d
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
71 changes: 71 additions & 0 deletions mu-plugins/10up-plugin/includes/classes/PostTypes/Demo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
/**
* Demo Post Type
*
* @package TenUpPlugin
*/

namespace TenUpPlugin\PostTypes;

/**
* Demo post type.
*/
class Demo extends AbstractPostType {

/**
* Get the post type name.
*
* @return string
*/
public function get_name() {
return 'tenup-demo';
}

/**
* Get the singular post type label.
*
* @return string
*/
public function get_singular_label() {
return esc_html__( 'Demo', 'tenup-plugin' );
}

/**
* Get the plural post type label.
*
* @return string
*/
public function get_plural_label() {
return esc_html__( 'Demos', 'tenup-plugin' );
}

/**
* Can the class be registered?
*
* @return bool
*/
public function can_register() {
return false;
}

/**
* Returns the default supported taxonomies. The subclass should declare the
* Taxonomies that it supports here if required.
*
* @return array
*/
public function get_supported_taxonomies() {
return [
'tenup-tax-demo',
];
}

/**
* Run any code after the post type has been registered.
*
* @return void
*/
public function after_register() {
// Register any hooks/filters you need.
}
}
50 changes: 50 additions & 0 deletions mu-plugins/10up-plugin/includes/classes/Taxonomies/Demo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* Demo Taxonomy
*
* @package TenUpPlugin
*/

namespace TenUpPlugin\Taxonomies;

/**
* Demo Taxonomy.
*/
class Demo extends AbstractTaxonomy {

/**
* Get the taxonomy name.
*
* @return string
*/
public function get_name() {
return 'tenup-tax-demo';
}

/**
* Get the singular taxonomy label.
*
* @return string
*/
public function get_singular_label() {
return esc_html__( 'Demo Term', 'tenup-plugin' );
}

/**
* Get the plural taxonomy label.
*
* @return string
*/
public function get_plural_label() {
return esc_html__( 'Demo Terms', 'tenup-plugin' );
}

/**
* Checks whether the Module should run within the current context.
*
* @return bool
*/
public function can_register() {
return false;
}
}

0 comments on commit 0b8990d

Please sign in to comment.