Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Page content hook suggestions
#1
This is code that I work with to be able to implement PAGE SHORTCODES. When I start adding SHORTCODES I realize that code:

Code:
add_filter('content', 'FUNCTION_TO_CALL');

Work only with page $content variable. So it wasn't possible to add shortcodes in template.

Modifications index.php:
Code:
ob_start();
# include the template and template file set within theme.php and each page
if ( (!file_exists(GSTHEMESPATH .$TEMPLATE."/".$template_file)) || ($template_file == '') ) { $template_file = "template.php"; }

include(GSTHEMESPATH .$TEMPLATE."/".$template_file);
$data = ob_get_contents();
ob_clean();
exec_filter('page-content', $data);

And I call function :
Code:
add_filter('page-content', 'FUNCTION_TO_CALL');

I think this is cleanest solution, and could be implemented in core. In this way implementing caching system would be easy. And base functionality is not changed.
Reply
#2
Why would you want to use short codes in templates when you can call php functions directly.
No sure I understand.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#3
I didn't think about it. Why not ???

Forget Shortcodes. You can use caching system, code indentation fix and few more things with this.
Reply




Users browsing this thread: 1 Guest(s)