Skip to content

Commit

Permalink
fix: custom post types fail to apply their specific configuration on …
Browse files Browse the repository at this point in the history
…registering
  • Loading branch information
LucaPipolo committed Apr 4, 2024
1 parent 0f57c89 commit 588ef4e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
23 changes: 15 additions & 8 deletions src/custom-post-types/class-custom-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,21 @@ class Custom_Post_Type {
*
* @var array
*/
protected array $args = array(
'supports' => array( 'title', 'editor', 'page-attributes' ),
'has_archive' => true,
'hierarchical' => true,
'public' => true,
'publicly_queryable' => true,
'show_in_rest' => false,
);
protected array $args = array();

/**
* Class constructor.
*/
public function __construct() {
$this->args = array(
'supports' => array( 'title', 'editor', 'page-attributes' ),
'has_archive' => true,
'hierarchical' => true,
'public' => true,
'publicly_queryable' => true,
'show_in_rest' => false,
);
}

/**
* Registers a Custom Post Type.
Expand Down
4 changes: 3 additions & 1 deletion src/custom-post-types/post-types/class-sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class Sample extends Custom_Post_Type {
* Class constructor.
*/
public function __construct() {
parent::__construct();

$args = array(
// phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
'menu_icon' => 'data:image/svg+xml;base64,' . base64_encode(
Expand All @@ -44,6 +46,6 @@ public function __construct() {
'show_in_rest' => true,
);

$this->args = wp_parse_args( $this->args, $args );
$this->args = wp_parse_args( $args, $this->args );
}
}
21 changes: 14 additions & 7 deletions src/custom-taxonomies/class-custom-taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,20 @@ class Custom_Taxonomy {
*
* @var array
*/
protected array $args = array(
'hierarchical' => true,
'show_ui' => true,
'show_in_rest' => true,
'show_admin_column' => true,
'query_var' => true,
);
protected array $args = array();

/**
* Class constructor.
*/
public function __construct() {
$this->args = array(
'hierarchical' => true,
'show_ui' => true,
'show_in_rest' => true,
'show_admin_column' => true,
'query_var' => true,
);
}

/**
* Registers a custom Taxonomy.
Expand Down

0 comments on commit 588ef4e

Please sign in to comment.