Support » Plugin: Crayon Syntax Highlighter » Invalid argument supplied for foreach() …/crayon_wp.class.php on line 435

Viewing 1 replies (of 1 total)
  • Would someone who knows evaluate my solution? Thanks in advance! The errors are no longer triggered and the highlighter seems to be working.

    I was getting the error in the title all over the site. I edited some the code around line 435, changing $crayon_posts for $posts, so that it now reads (change in bold):

    // Search for shortcode in posts
            foreach (<strong>$crayon_posts</strong> as $post) {
                $wp_id = $post->ID;
                $is_page = $post->post_type == 'page';
                if (!in_array($wp_id, $crayon_posts)) {
                    // If we get query for a page, then that page might have a template and load more posts containing Crayons
                    // By this state, we would be unable to enqueue anything (header already written).
                    if (CrayonGlobalSettings::val(CrayonSettings::SAFE_ENQUEUE) && $is_page) {
                        CrayonGlobalSettings::set(CrayonSettings::ENQUEUE_THEMES, false);
                        CrayonGlobalSettings::set(CrayonSettings::ENQUEUE_FONTS, false);
                    }
                    // Only include crayon posts
                    continue;
                }

    If this is a poor solution, please let me know. If it is a good one, perhaps consider addressing it in the next version of the plugin?

    Again, thanks for the feedback. I’d like to mark this “resolved.” I await your feedback!

Viewing 1 replies (of 1 total)
  • The topic ‘Invalid argument supplied for foreach() …/crayon_wp.class.php on line 435’ is closed to new replies.