Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions classes/class-starter-plugin-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ public function register_post_type () {
* @return void
*/
public function register_taxonomy () {
$this->taxonomies['thing-category'] = new Starter_Plugin_Taxonomy(); // Leave arguments empty, to use the default arguments.
$this->taxonomies['thing-category']->register();
foreach ( $taxonomies as $taxonomy ) :
$taxonomy = new Starter_Plugin_Taxonomy( esc_attr( $this->post_type ), $taxonomy, '', '', array() ); // Leave arguments empty, to use the default arguments.
$taxonomy->register();
endforeach;
} // End register_taxonomy()

/**
Expand Down Expand Up @@ -169,7 +171,7 @@ public function register_custom_columns ( $column_name, $id ) {
* @access public
* @param array $defaults
* @since 1.0.0
* @return void
* @return array $defaults
*/
public function register_custom_column_headings ( $defaults ) {
$new_columns = array( 'image' => __( 'Image', 'starter-plugin' ) );
Expand Down Expand Up @@ -413,4 +415,4 @@ private function flush_rewrite_rules () {
public function ensure_post_thumbnails_support () {
if ( ! current_theme_supports( 'post-thumbnails' ) ) { add_theme_support( 'post-thumbnails' ); }
} // End ensure_post_thumbnails_support()
} // End Class
} // End Class
4 changes: 3 additions & 1 deletion classes/class-starter-plugin-taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public function __construct ( $post_type = 'thing', $token = 'thing-category', $
if ( '' == $this->plural ) $this->plural = __( 'Categories', 'starter-plugin' );

$this->args = wp_parse_args( $args, $this->_get_default_args() );

add_action( 'init', array( $this, 'register' ) );
} // End __construct()

/**
Expand Down Expand Up @@ -117,4 +119,4 @@ public function register () {
register_taxonomy( esc_attr( $this->token ), esc_attr( $this->post_type ), (array)$this->args );
} // End register()
} // End Class
?>
?>
15 changes: 15 additions & 0 deletions starter-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ final class Starter_Plugin {
*/
public $post_types = array();
// Post Types - End

// Taxonomies - Start
/**
* The taxonomies we're registering.
* @var array
* @access public
* @since 1.0.0
*/
public $taxonomies = array();
// Taxonomies - End

/**
* Constructor function.
* @access public
Expand Down Expand Up @@ -136,6 +147,10 @@ public function __construct () {
// Register an example post type. To register other post types, duplicate this line.
$this->post_types['thing'] = new Starter_Plugin_Post_Type( 'thing', __( 'Thing', 'starter-plugin' ), __( 'Things', 'starter-plugin' ), array( 'menu_icon' => 'dashicons-carrot' ) );
// Post Types - End

//Register an example taxonomy. To register more taxonomies, duplicate this line.
$this->taxonomies['taxonomy'] = new Starter_Plugin_Taxonomy( 'thing', 'taxonomy_name', __( 'Taxonomy Name', 'starter-plugin' ), __( 'Taxonomy Names', 'starter-plugin' ) );

register_activation_hook( __FILE__, array( $this, 'install' ) );

add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
Expand Down