WordPressのプラグインで、get_template_part的なものを使いたい

<?php// wp-content/plugins/wp-onocom-plugin.php class wp_onocom_plugin { static $instance = null; function __construct(){ self::$instance = $this; } public static function get_instance() { if( self::$instance != null ) { return self::$instance; } else { return new self(); } } public function get_plugin_template_part($slug, $name = null) { $templates = array(); $name = (string) $name; if ( '' !== $name ) $templates[] = "{$slug}-{$name}.php"; $templates[] = "{$slug}.php"; $located = ''; foreach ( (array) $templates as $template_name ) { if ( !$template_name ) { continue; } if ( file_exists($this->get_plugin_path() . '/' . $template_name) ) { $located = $this->get_plugin_path() . '/' . $template_name; break; } } if($located) { require_once( $located ); } } public function get_plugin_url() { return plugins_url("",__FILE__); } public function get_plugin_path() { return dirname(__FILE__); }}

WordPress TinyMCEのスタイルメニューの項目追加

<?phpif ( !function_exists( 'initialize_tinymce_styles' ) ):add_filter('tiny_mce_before_init', 'initialize_tinymce_styles', 10000);function initialize_tinymce_styles($init_array) { $style_formats = array( array( 'title' => '否定', 'inline' => 'span', 'classes' => 'text-negative' ), array( 'title' => '肯定', 'inline' => 'span', 'classes' => 'text-positive' ), array( 'title' => '例示・用語', 'inline' => 'span', 'classes' => 'text-example' ), array( 'title' => '強調', 'inline' => 'strong', 'classes' => 'text-emphasis' ), array( 'title' => '区切り線', 'block' => 'hr', 'classes' => 'hr-divider' ), ); $init_array['style_formats'] = json_encode($style_formats); return $init_array;}endif;

WordPressのfunctions.phpでまとめてタクソノミー登録

<?phpadd_action('init', 'onocom_custom_taxonomies');function onocom_custom_taxonomies() { $post_type = 'item'; $taxonomies = array( "taxslug-a" => "タクソノミーA", "taxslug-b" => "タクソノミーB", "taxslug-c" => "タクソノミーC", "taxslug-d" => "タクソノミーD", "taxslug-e" => "タクソノミーE", "taxslug-f" => "タクソノミーF", ); foreach ($taxonomies as $key => $label) : $labels = array( 'hierarchical' => true, 'label' => $label, 'query_var' => true ); register_taxonomy( $key, $post_type, $labels ); endforeach;}?>