• Resolved vasko_t

    (@vasko_t)


    Hello.

    I just updated the plugin from v. 1.1.3 to v. 1.2.0. I already had a couple of custom post types and I got the following notices:

    Notice: Undefined index: description in /.../wp-content/plugins/custom-post-type-ui/custom-post-type-ui.php on line 340
    Notice: Undefined index: show_in_rest in /.../wp-content/plugins/custom-post-type-ui/custom-post-type-ui.php on line 346
    Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /.../wp-content/plugins/custom-post-type-ui/custom-post-type-ui.php:346) in /.../wp-content/plugins/ag-custom-admin/plugin.php on line 91

    I believe this happens because of the introduction of the taxonomy properties description, show_in_rest and rest_base. For the rest_base there is a proper check above the arguments declaration, but not for the description and the show_in_rest properties. The notices will dissapear once these checks are in place.

    I installed it on another WordPress installation and since it doesn’t have any custom post types yet, these notices didn’t appear.

    Regards

    https://www.ads-software.com/plugins/custom-post-type-ui/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter vasko_t

    (@vasko_t)

    Also 4 more notices of the same type on Edit post types screen:

    Notice: Undefined index: show_in_nav_menus in /.../wp-content/plugins/custom-post-type-ui/inc/post-types.php on line 473
    Notice: Undefined index: show_in_nav_menus in /.../wp-content/plugins/custom-post-type-ui/inc/post-types.php on line 474
    Notice: Undefined index: show_in_rest in /.../wp-content/plugins/custom-post-type-ui/inc/post-types.php on line 493
    Notice: Undefined index: show_in_rest in /.../wp-content/plugins/custom-post-type-ui/inc/post-types.php on line 494

    This is for an existing custom post type created before the plugin was updated.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Could have sworn I did my usual checks to prevent these from showing up, but apparently not as well as I intended.

    For what it’s worth, notices aren’t going to break the site, and I’m planning to keep an eye on all reported ones and look into a 1.2.1 release. I know I have translation updates pending as well, which will go into that too.

    If they get really bothersome in the meantime, setting them to something, and then re-setting them back to default values should clear them up, if I recall right.

    Thread Starter vasko_t

    (@vasko_t)

    This is how I fixed it:

    custom-post-type-ui.php lines 332 – 354:

    $rest_base = $description = $show_in_rest = null;
    if ( ! empty( $taxonomy['rest_base'] ) ) {
    	$rest_base = $taxonomy['rest_base'];
    }
    if ( ! empty( $taxonomy['description'] ) ) {
    	$description = $taxonomy['description'];
    }
    if ( ! empty( $taxonomy['show_in_rest'] ) ) {
    	$show_in_rest = $taxonomy['show_in_rest'];
    }
    
    $args = array(
    	'labels'            => $labels,
    	'label'             => $taxonomy['label'],
    	'description'       => $description,
    	'hierarchical'      => get_disp_boolean( $taxonomy['hierarchical'] ),
    	'show_ui'           => get_disp_boolean( $taxonomy['show_ui'] ),
    	'query_var'         => $taxonomy['query_var'],
    	'rewrite'           => $rewrite,
    	'show_admin_column' => $show_admin_column,
    	'show_in_rest'      => get_disp_boolean( $show_in_rest ),
    	'rest_base'         => $rest_base,
    );

    inc/post-types.php line 473:
    $selected = ( isset( $current ) AND isset( $current['show_in_nav_menus'] ) ) ? disp_boolean( $current['show_in_nav_menus'] ) : '';

    inc/post-types.php line 493:
    $selected = ( isset( $current ) AND isset( $current['show_in_rest'] ) ) ? disp_boolean( $current['show_in_rest'] ) : '';

    Cheers ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘PHP Notices after updating from 1.1.3 to 1.2.0’ is closed to new replies.