Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
content filters and page slugs
#1
I noticed a issue with content filters and certain setups.

I like the ability to use pages as components, say in a sidebar or footer or whatever.
This has the obvious advantage of having wysiwyg editor for these.
I've seen others post about this as well.

So I use dynpages with a component to grab the content of a slug.
Usually with get_i18n_content();

The problem is that some plugins use content filters that let you select a slug and perform actions on that slug with a content filter.

The problem is that these trigger on all content filters running on the same page request.
So all content gets replaced not just the content for the actual slug.

I am trying to figure out a way around this. The only thing i can come up with besides not doing things this way, I prefer plugins that use inline replacements instead, but slug selection has its merits as its less steps for users in some instances.

Perhaps it could be possible for content filter callback functions to be called with an argument specifying the contents actual slug. I can't think of any other way.

I mean maybe content filters shouldn't be used to replace or insert content at all, only for editing content.

Perhaps this is a misuse of content plugins to begin with.
Perhaps we can use something else such as dynamic pages.

Perhaps plugin authors could allow no slugs to be selected and then provide an inline replacement string as an alternate method.

ideas?
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#2
shawn_a Wrote:The problem is that some plugins use content filters that let you select a slug and perform actions on that slug with a content filter.

The problem is that these trigger on all content filters running on the same page request.
So all content gets replaced not just the content for the actual slug.

The content filter is available to filter the content of pages and replace parts or do some other processing.
If a plugin wants to replace the page content completely, it should rather do this in index-pretemplate:
  • this would allow this new content to include place holders for other plugins, as
  • it is irrelevant, if these other plugins runs before or after the "content replacing" plugin, and
  • the content is already available in theme-header (necessary e.g. for I18N Gallery).
  • Additionally content included with get_i18n_content or similar is not effected
In short: you could include e.g. I18N Galleries or GoogleMaps or components via DynPages in e.g. News Manager news and it would just work!

(this approach is used e.g. by I18N Special Pages)
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#3
Thanks!

It seems some plugins use filter hooks to output inline html, and that is whats causing these issues.

I wonder if it would be wise to modify core to output buffer and clear filter hooks from being uses as action hooks or at least throw an exception when they do.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#4
(2012-05-16, 06:28:13)mvlcek Wrote: The content filter is available to filter the content of pages and replace parts or do some other processing.
If a plugin wants to replace the page content completely, it should rather do this in index-pretemplate:
...

I've found that if you use index-pretemplate instead of the content filter to replace a page's content, the $content variable must be prepared (encoded, slashed) so that GS can process it properly -- if not, a page having &lt; in the body will be broken or not rendered as expected, as it is decoded to <

Would this be the correct way to fix this?
Code:
$content = addslashes(htmlspecialchars($content, ENT_NOQUOTES, 'UTF-8'));

BTW @shawn_a - GS Blog seems to have this problem.
Reply
#5
I assume this is because get_page_content()
does a $content = strip_decode($content);
which is stripslashes(htmlspecialchars_decode($text, ENT_QUOTES));

good catch, I think that should do it, we should add a strip_encode function to core.
It depends on where your new content is coming from of course as to whether it is required.

If you are grabbing page contents then that is where you should be using strip_decode
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply




Users browsing this thread: 1 Guest(s)