Commit 4b1c5b8e authored by Erick Hitter's avatar Erick Hitter
Browse files

Basic data structures

parent 4b336031
<?php
namespace ETH\WinePress;
class Data_Structures {
use Singleton;
public const POST_TYPE = '_eth_winepress_wine';
public const TAXONOMY_VINTAGE = '_eth_winepress_vintage';
public const TAXONOMY_STYLE = '_eth_winepress_style';
public const TAXONOMY_WINEMAKER = '_eth_winepress_winemaker';
public const TAXONOMY_SOURCE = '_eth_winepress_source';
protected function _setup(): void {
add_action( 'init', [ $this, 'post_type' ] );
add_action( 'init', [ $this, 'taxonomies' ], 11 );
}
public function post_type(): void {
register_post_type(
static::POST_TYPE,
[
'label' => 'Wine',
'public' => true,
'supports' => [
'title',
],
]
);
}
public function taxonomies(): void {
$taxes = [
static::TAXONOMY_VINTAGE,
static::TAXONOMY_STYLE,
static::TAXONOMY_WINEMAKER,
static::TAXONOMY_SOURCE,
];
foreach ( $taxes as $tax ) {
register_taxonomy(
$tax,
static::POST_TYPE,
[
'label' => $tax,
'public' => true,
]
);
}
}
}
<?php
namespace ETH\WinePress;
trait Singleton {
protected static $__instance;
protected function __construct() {}
public static function instance() {
if ( null === static::$__instance ) {
static::$__instance = new static();
static::$__instance->_setup();
}
return static::$__instance;
}
protected function _setup(): void {}
}
<?php
/**
* Plugin Name: WinePress
* Plugin URI: https://ethitter.com/plugins/
* Description:
* Author: Erick Hitter
* Author URI: https://ethitter.com/
* Text Domain: winepress
* Domain Path: /languages
* Version: 0.1.0
*
* @package WinePress
*/
namespace ETH\WinePress;
const PLUGIN_PATH = __DIR__;
require_once PLUGIN_PATH . '/autoload.php';
// TODO: REMOVE WHEN AUTOLOAD WORKS!
require_once PLUGIN_PATH . '/inc/trait-singleton.php';
require_once PLUGIN_PATH . '/inc/class-data-structures.php';
Data_Structures::instance();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment