• Hi,

    I’m getting this error in my error log:

    Trying to access array offset on value of type bool plugins/cooked/includes/class.cooked-shortcodes.php on line 378

    What can be the issue?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Braian Menkhoff

    (@bihush)

    I’m guessing that if there is no image in a recipes gallery it returns the php warning!

    Plugin Author XjSv

    (@xjsv)

    Hello @bihush, There is a check in the code to check if the gallery is empty and if so it does not attempt to load any files.

    I also just did a test right now to see if a recipe with no gallery images causes a error but I did not see anything.

    Could you link the recipe in question so I can take a look? Maybe there is a clue as to whats going on.

    Thread Starter Braian Menkhoff

    (@bihush)

    There is no specific recipe! That php warning is in my error-log

    I did this tweak in my local, it seems like solved the issue but do you think it’s a good approach? I have large amount of recipes I wanna make sure, before going online with this fix

    if ( isset($gallery_items) && !empty($gallery_items) ):
    foreach( $gallery_items as $item ):
    $image_src = wp_get_attachment_image_src( $item, [900, 900] );
    $image_title = get_the_title( $item );
    if ( is_array($image_src) && isset($image_src[0]) ) {
    $gallery_html .= '<a href="' . esc_url( $image_src[0] ) . '" data-alt="'.esc_attr( $image_title ).'" data-caption="'.esc_attr( $image_title ).'">
    <img alt="'.esc_attr( $image_title ).'" src="' . wp_get_attachment_image_url( $item, 'thumbnail' ) . '" />
    </a>';
    }
    endforeach;
    endif;
    Plugin Author XjSv

    (@xjsv)

    Interesting, because “!empty($gallery_items)” should have not allowed the loop if the array is empty. But I can see how it could possibly lead to this.

    Thank you for that, I will add this to the source code so that when the next update comes out you don’t loose any functionality.

    Thread Starter Braian Menkhoff

    (@bihush)

    Thank you 🙏

    Plugin Author XjSv

    (@xjsv)

    My pleasure.

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

The topic ‘Error in class.cooked-shortcodes.php’ is closed to new replies.