[theme-reviewers] Question about use of core WP functions in theme

Claude Needham gxxaxx at gmail.com
Thu Aug 11 15:15:30 UTC 2011


I guess I wanted to keep the apply_filters, and the str_replace that
is found in the_content in place.

I wanted to leave everything exactly how it would be if the_content
was called, then do a small bit of post grab pre echo processing.

Was basically trying to respect the core functions since I only
understand about 10% of what is going on in the core.

Claude

On Thu, Aug 11, 2011 at 8:08 AM, Chip Bennett <chip at chipbennett.net> wrote:
> Skimming your question briefly: is there any particular reason you can't use
> get_the_content()?
> Chip
>
> On Thu, Aug 11, 2011 at 9:59 AM, 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(']]>', ']]&gt;', $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
>
>
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>
>


More information about the theme-reviewers mailing list