You've already forked wp-fedistream
68 lines
1.1 KiB
PHP
68 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
/**
|
||
|
|
* Abstract base class for custom taxonomies.
|
||
|
|
*
|
||
|
|
* @package WP_FediStream
|
||
|
|
*/
|
||
|
|
|
||
|
|
namespace WP_FediStream\Taxonomies;
|
||
|
|
|
||
|
|
// Prevent direct file access.
|
||
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
||
|
|
exit;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Abstract taxonomy class.
|
||
|
|
*
|
||
|
|
* Provides common functionality for all custom taxonomies.
|
||
|
|
*/
|
||
|
|
abstract class AbstractTaxonomy {
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Taxonomy key.
|
||
|
|
*
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
protected string $taxonomy;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Post types this taxonomy applies to.
|
||
|
|
*
|
||
|
|
* @var array
|
||
|
|
*/
|
||
|
|
protected array $post_types = array();
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Constructor.
|
||
|
|
*/
|
||
|
|
public function __construct() {
|
||
|
|
add_action( 'init', array( $this, 'register' ) );
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Register the taxonomy.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
abstract public function register(): void;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the taxonomy key.
|
||
|
|
*
|
||
|
|
* @return string
|
||
|
|
*/
|
||
|
|
public function get_taxonomy(): string {
|
||
|
|
return $this->taxonomy;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the post types this taxonomy is registered for.
|
||
|
|
*
|
||
|
|
* @return array
|
||
|
|
*/
|
||
|
|
public function get_post_types(): array {
|
||
|
|
return $this->post_types;
|
||
|
|
}
|
||
|
|
}
|