[theme-reviewers] Question about use of core WP functions in theme
Mario Peshev
mario at peshev.net
Thu Aug 11 15:04:15 UTC 2011
@Claude, good point.
By the way, since in my freelance job I have a 3rd party CMS I'm using with
the similar issue, we do use output buffering as a solution to this:
ob_start();
inner_annoying_always_echo_func();
$content = ob_get_contents();
ob_end_clean();
This is not the best practice, but aside of the buffering (speed plus) it
would affect the function in no way even after change of the implementation.
Any comments on this?
Mario Peshev
freelance software developer/trainer
http://www.linkedin.com/in/mpeshev
http://peshev.net/blog
On Thu, Aug 11, 2011 at 5:59 PM, Claude Needham <gxxaxx at gmail.com> wrote:
> A comment was made in a recent thread expressing the opinion that
> using core WP functions were *always* preferred to rolling your own.
> This is a slight restatement. Chip's actual statement is at the bottom
> of this email. Point is this reminded me that I am not comfortable
> with some of the design solutions I have been using recently.
>
> I'll give you an example. In a recent special page I had need for a
> string of the_content.
>
> Because the_content does not have an option for echo=false, I was
> forced to reproduce the innards of the function.
> $mycontent = get_the_content();
> $mycontent = apply_filters('the_content', $mycontent);
> $mycontent = str_replace(']]>', ']]>', $mycontent);
> .... do stuff with $mycontent
>
> This means that if a fix is applied to the_content function my theme
> will not automatically have the advantage of the update. There are
> quite a few functions with forced echo: the_content, the_excerpt,
> post_class, body_class, the_meta, and the_guid.
>
> I'm thinking there is a different design solution that I should be
> using. Or, could it be that adding echo=false is somewhere in queue
> for future release?
>
> Just wondering about the best practices here.
>
> Regards,
> Claude Needham
>
>
> Proper quote as promised.
> On Thu, Aug 11, 2011 at 5:57 AM, Chip Bennett <chip at chipbennett.net>
> wrote:
> > In general, though, IMHO, it is *always* preferable to use a core WP
> > function for content filtering and/or untrusted data
> > sanitization/validation.
> > Chip
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20110811/3e744c87/attachment-0001.htm>
More information about the theme-reviewers
mailing list