WordPress.org

Ready to get started?Download WordPress

Forums

Comments Re: WordPress functions outputing directly (4 posts)

  1. robvdl
    Member
    Posted 9 years ago #

    I am using WordPress 1.5 through my own content management system and to do so, I need WordPress functions to NOT directly echo() onto the PHP stream, but rather return a value, so I can place it into a variable for my content management system.

    The problem is that most functions do not allow this at all, they echo directly onto the stream which is very annoying. To use such a function, I have to copy that function from the original source, give it a different name and modify that function to return a value, rather than echo it directly to the stream.

    The problem also, is that there is inconsitency in these functions. Some functions can take a boolean $echo parameter, true or false, some do not have that parameter. Worse of all, some functions have the paramater but it doesn't even work - it echos directly to the stream regardless.

    for example function the get_links() function in links.php will echo to the stream regardless if the last parameter is set to true or false. and I have seen other functions like this too.

    I had this same issue with WordPress 1.2 it would be nice to see it addressed in the future.

  2. bruceyeah
    Member
    Posted 9 years ago #

    Well said... I agree totally.
    I was thinking it would be far better and more flexible to not have any functions output directly, but always return strings or objects.

    eg. easy outputting for beginners...

    <?= $wp->post_title() ?>

    or custom outputting for power developers...

    <? $title = $wp->post_title(); ?>
    <?= $wp->myStringFormatFunction($title); ?>

    The list outputting gumph that's hardcoded all over the place (ie. 'before' and 'after' parameters for all the list outputs) could be completely centralised into a single flexible list outputting function. eg.

    <? $linkList = $wp->get_links_list(); ?>
    <?= $wp->listFormat($linkList, "<li>", "</li>"); ?>

    Let's face it, WordPress' main market in the future will be customised CMS installations, not beginner bloggers (who are more than happy to use something like TypePad and Blogger). It's important that WP is more flexible to adapt.

  3. robvdl
    Member
    Posted 9 years ago #

    That way would be perfect. I couldn't agree better :-)

  4. abrazell
    Member
    Posted 9 years ago #

    It's been a legitimate gripe for a long time, at least with me. For all of the standards compliance an coding guidelines for developers, this is the one thing that is a glaring problem.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.