Skip to content

Commit

Permalink
Fix default values when registering post type (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
candy02058912 authored Sep 2, 2024
1 parent 505bba1 commit 6c7c8c3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions includes/runtime/class-content-model.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ public function __construct( WP_Post $content_model_post ) {
private function register_post_type() {
$singular_name = $this->title;

$plural_name = get_post_meta( $this->post_id, 'plural_label', true );
$plural_name ??= $singular_name . 's';
$plural_name = get_post_meta( $this->post_id, 'plural_label', true );
if ( empty( $plural_name ) ) {
$plural_name = $singular_name . 's';
}

$labels = array(
'name' => $plural_name,
Expand All @@ -137,7 +139,10 @@ private function register_post_type() {
'not_found_in_trash' => sprintf( __( 'No %s found in trash' ), $plural_name ),
);

$icon = get_post_meta( $this->post_id, 'icon', true ) ?? 'admin-site';
$icon = get_post_meta( $this->post_id, 'icon', true );
if ( empty( $icon ) ) {
$icon = 'admin-site';
}
$icon = str_replace( 'dashicons-', '', $icon );

register_post_type(
Expand Down

0 comments on commit 6c7c8c3

Please sign in to comment.