WordPress.org

Ready to get started?Download WordPress

Forums

Grunion Contact Form
Grunion appears to be printing stuff when it should be returning it (2 posts)

  1. Dylan McCall
    Member
    Posted 2 years ago #

    Okay, first of all, here's how my WordPress site works:
    I'm one of those weird template system fanboys, and I have an obsession with splitting visual stuff from any kind of back-end logic. So, all the HTML for my website is in Smarty templates, and my WordPress theme basically grabs information from the back-end (as necessary) and passes it to the templates.

    This means all of the processing happens before any of the rendering: if anything gets printed, it appears at the very top of the document and results in an invalid page. Which breaks any web browser that feels such foolishness should not be tolerated. (Surprisingly enough, that is only Internet Explorer).

    Now, for a while I was using the_content() and output buffering to get post content. That prints it, but PHP catches the printed output and stores it in a variable instead. Kinda silly.

    I switched that to use get_the_content. When I did that, this happened...

    http://www.dylanmccall.com/contact/

    If you look at the source you'll see, at the very top of the file:

    <link rel='stylesheet' id='grunion.css-css' href='http://www.dylanmccall.com/wp-content/plugins/grunion-contact-form/css/grunion.css?ver=3.3.1' type='text/css' media='all' />

    Normally that appears right above the contact form.

    Two things here:
    This shouldn't be printed the way it is, because it screws up anyone who uses get_the_content.
    Can you use register_style and enqueue_style for this? I think it's a little cleaner.

    Thank you for the great plugin! It works really well :)

    http://wordpress.org/extend/plugins/grunion-contact-form/

  2. Dylan McCall
    Member
    Posted 2 years ago #

    Okay, I went ahead and fixed this on my end by changing grunion-contact-form.php, line 26, from wp_print_styles( 'grunion.css' ); to wp_enqueue_style( 'grunion.css' );

    So, the Contact page I linked to won't have the problem I described. Here's what its HTML looked like at the top, though, to be clear:

    <link rel='stylesheet' id='grunion.css-css'  href='http://www.dylanmccall.com/wp-content/plugins/grunion-contact-form/css/grunion.css?ver=3.3.1' type='text/css' media='all' />
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <title>Contact  |   Dylan McCall</title>

    With the change I made, the doctype tag is back at the top of the file and the grunion.css link is in wp_footer.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic