WordPress.org

Forums

Crayon Syntax Highlighter
Invalid argument supplied for foreach() .../crayon_wp.class.php on line 435 (2 posts)

  1. doclalor
    Member
    Posted 1 year ago #

    Conflict With the content-only plugin?:

    Warning: Invalid argument supplied for foreach() in /home/doclalor/philosophy.thereitis.org/ptii-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php on line 435

    http://wordpress.org/plugins/crayon-syntax-highlighter/

  2. doclalor
    Member
    Posted 1 year ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Crayon Syntax Highlighter
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic