• Resolved stuartsharpe

    (@stuartsharpe)


    Warning: foreach() argument must be of type array|object, false given in /plugins/custom-post-type-ui/inc/utility.php on line 1015

    Of course it’s not exactly on line 1015 but in that function.

    function cptui_post_thumbnail_theme_support() {
    $post_types = cptui_get_post_type_data();

    // Check if $post_types is an array before proceeding
    if ( ! is_array( $post_types ) ) {
    return; // Exit early if it's not an array
    }

    $supported = [];
    foreach ( $post_types as $post_type ) {
    if ( empty( $post_type['supports'] ) ) {
    continue;
    }
    if (
    is_array( $post_type['supports'] ) &&
    in_array( 'thumbnail', $post_type['supports'] )
    ) {
    $supported[] = $post_type['name'];
    }
    }
    if ( ! empty( $supported ) ) {
    add_theme_support( 'post-thumbnails', $supported );
    }
    }

    ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Hmm

    Not DIS-agreeing with your amendment to the function but i’m looking at this below

    function cptui_get_post_type_data() {
    return apply_filters( 'cptui_get_post_type_data', get_option( 'cptui_post_types', [] ), get_current_blog_id() );
    }

    and am curious what may be causing the get_option to return false. If the option doesn’t exist, it should be returning empty array.

    Out of curiosity are you in a multisite and/or have you looked at that option in the database table to see what may be stored there? Also in case it’s a factor, have you also purchased our CPTUI-Extended plugin?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    @stuartsharpe did this ever get resolved?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Array warning for cptui_post_thumbnail_theme_support php 8.3.14’ is closed to new replies.