• Resolved negru13

    (@negru13)


    Hello,
    I get this in my website errorlog and I don’t know how to fix it.
    PHP Warning: Invalid argument supplied for foreach() in /public_html/wp-content/plugins/custom-post-type-ui/custom-post-type-ui.php on line 352

    on line 352 in that file is:

    foreach ( $post_type['labels'] as $key => $label ) {
    
    		if ( ! empty( $label ) ) {
    			if ( 'parent' === $key ) {
    				$labels['parent_item_colon'] = $label;
    			} else {
    				$labels[ $key ] = $label;
    			}
    		} elseif ( empty( $label ) && in_array( $key, $preserved ) ) {
    			$singular_or_plural = ( in_array( $key, array_keys( $preserved_labels['post_types']['plural'] ) ) ) ? 'plural' : 'singular';
    			$label_plurality = ( 'plural' === $singular_or_plural ) ? $post_type['label'] : $post_type['singular_label'];
    			$labels[ $key ] = sprintf( $preserved_labels['post_types'][ $singular_or_plural ][ $key ], $label_plurality );
    		}
    	}
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Try re-saving the sesttings for the post type(s) in question to see if that triggers getting at least an empty array saved into the settings. Or fill in some labels and that should help as well.

    Thread Starter negru13

    (@negru13)

    No change..I’ve re-saved all the 3 post types, all three of them have the labels set. Same error..

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Can you go to your tools menu inside the CPTUI menu and visit the “post types” tab. Curious what is in your settings at the moment that’s causing the error, especially if you have values saved.

    Copy/Paste the content in the right hand side textarea, here into a reply.

    Thread Starter negru13

    (@negru13)

    Sure, here:

    First

    name: project
    label: Projects
    singular_label: Project
    description: ""
    public: true
    publicly_queryable: true
    show_ui: true
    show_in_nav_menus: true
    show_in_rest: false
    rest_base: ""
    rest_controller_class: ""
    has_archive: false
    has_archive_string: ""
    exclude_from_search: false
    capability_type: post
    hierarchical: false
    rewrite: true
    rewrite_slug: ""
    rewrite_withfront: true
    query_var: true
    query_var_slug: ""
    menu_position: ""
    show_in_menu: true
    show_in_menu_string: ""
    menu_icon: ""
    custom_supports: ""

    Second

    name: homepage_featured
    label: Homepage featured
    singular_label: homeage featured
    description: posts that appear in homepage 
    public: true
    publicly_queryable: true
    show_ui: true
    show_in_nav_menus: true
    show_in_rest: false
    rest_base: ""
    rest_controller_class: ""
    has_archive: false
    has_archive_string: ""
    exclude_from_search: false
    capability_type: post
    hierarchical: false
    rewrite: true
    rewrite_slug: ""
    rewrite_withfront: true
    query_var: true
    query_var_slug: ""
    menu_position: ""
    show_in_menu: true
    show_in_menu_string: ""
    menu_icon: ""
    custom_supports: "" 

    Third

    name: team_member
    label: Team
    singular_label: Member
    description: ""
    public: true
    publicly_queryable: true
    show_ui: true
    show_in_nav_menus: true
    show_in_rest: false
    rest_base: ""
    rest_controller_class: ""
    has_archive: false
    has_archive_string: ""
    exclude_from_search: false
    capability_type: post
    hierarchical: false
    rewrite: true
    rewrite_slug: ""
    rewrite_withfront: true
    query_var: true
    query_var_slug: ""
    menu_position: ""
    show_in_menu: true
    show_in_menu_string: ""
    menu_icon: ""
    custom_supports: "" 

    This is the info below “Settings”

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not quite what I was requesting, though close.

    I wanted the info on the right hand side of this screen,

    https://cloudup.com/cXlv7WnjNll which is what you should see when you click

    which is what you should see when you click the “Tools” from this part:

    https://cloudup.com/cpfgxDGqTRn

    It’ll be a representation of your saved settings for the post types, and also allow me to import the same settings into my own installs, etc.

    Thread Starter negru13

    (@negru13)

    Ok, I see here is the data:

    {"project":{"name":"project","label":"Projects","singular_label":"Project","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","show_in_rest":"false","rest_base":"","rest_controller_class":"","has_archive":"false","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"false","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"","supports":["title","editor","thumbnail","excerpt","custom-fields","comments","revisions","author","page-attributes","post-formats"],"taxonomies":["category"],"labels":{"new_item":"Project","menu_name":"","all_items":"","add_new":"","add_new_item":"","edit_item":"","view_item":"","view_items":"","search_items":"","not_found":"","not_found_in_trash":"","parent_item_colon":"","featured_image":"","set_featured_image":"","remove_featured_image":"","use_featured_image":"","archives":"","insert_into_item":"","uploaded_to_this_item":"","filter_items_list":"","items_list_navigation":"","items_list":"","attributes":"","name_admin_bar":""},"custom_supports":""},"homepage_featured":{"name":"homepage_featured","label":"Homepage featured","singular_label":"homeage featured","description":"posts that appear in homepage ","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","show_in_rest":"false","rest_base":"","rest_controller_class":"","has_archive":"false","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"false","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"","supports":[],"taxonomies":[],"labels":{"new_item":"homepage_featured","archives":"homepage_featured","name_admin_bar":"homepage_featured","menu_name":"","all_items":"","add_new":"","add_new_item":"","edit_item":"","view_item":"","view_items":"","search_items":"","not_found":"","not_found_in_trash":"","parent_item_colon":"","featured_image":"","set_featured_image":"","remove_featured_image":"","use_featured_image":"","insert_into_item":"","uploaded_to_this_item":"","filter_items_list":"","items_list_navigation":"","items_list":"","attributes":""},"custom_supports":""},"team_member":{"name":"team_member","label":"Team","singular_label":"Member","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","show_in_rest":"false","rest_base":"","rest_controller_class":"","has_archive":"false","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"false","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"","supports":["title","editor","thumbnail","custom-fields","page-attributes"],"taxonomies":[],"labels":{"new_item":"team_member","menu_name":"","all_items":"","add_new":"","add_new_item":"","edit_item":"","view_item":"","view_items":"","search_items":"","not_found":"","not_found_in_trash":"","parent_item_colon":"","featured_image":"","set_featured_image":"","remove_featured_image":"","use_featured_image":"","archives":"","insert_into_item":"","uploaded_to_this_item":"","filter_items_list":"","items_list_navigation":"","items_list":"","attributes":"","name_admin_bar":""},"custom_supports":""}}

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not managing to recreate any warnings/errors with that output. Just on a whim, perhaps try importing that blob of code I had you provide, and see if that helps out at all. Just paste it into the left side and click the “import” button right below it.

    Only other idea I have at the moment is possibly somehow duplicate options in the database, but it feels like a stretch.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘PHP Warning: Invalid argument supplied for foreach()’ is closed to new replies.