Skip to content

Commit

Permalink
fix: use post type label in meta box settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed Jan 9, 2025
1 parent e4c9da9 commit f9ed205
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions inc/admin/metabox/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,20 @@ public function save( $post_id ) {
* Register meta box to control layout on pages and posts.
*/
public function add() {
$post_type = 'Neve';
$post_type_label = 'Neve';
$post_type_from_db = get_post_type();
if ( $post_type_from_db ) {
$post_type = ucfirst( $post_type_from_db );
$post_type_object = get_post_type_object( $post_type_from_db );

if ( $post_type_object && isset( $post_type_object->labels ) && isset( $post_type_object->labels->name ) ) {

Check failure on line 123 in inc/admin/metabox/manager.php

View workflow job for this annotation

GitHub Actions / PHPStan

Property WP_Post_Type::$labels (stdClass) in isset() is not nullable.
$post_type_label = $post_type_object->labels->name;
}

add_meta_box(
'neve-page-settings',
sprintf(
/* translators: %s - post type */
__( '%s Settings', 'neve' ),
$post_type
$post_type_label
),
array( $this, 'render_metabox' ),
array( 'post', 'page', 'product' ),
Expand All @@ -144,7 +146,7 @@ public function add() {
sprintf(
/* translators: %s - post type */
__( '%s Settings', 'neve' ),
$post_type
$post_type_label
),
array( $this, 'render_metabox_notice' ),
Supported_Post_Types::get( 'block_editor' ),
Expand Down

0 comments on commit f9ed205

Please sign in to comment.