Is it possible to add apply_filters to internal functions like get_author() and etc.? This way we can do small modifications without copying the template files to child theme.
For example (Newspaper/includes/wp_booster/td_module_single_base.php:L65):
//$show_stars_on_review - not used
function get_author() {
$buffy = '';
if (td_util::get_option('tds_p_show_author_name') != 'hide') {
$buffy .= '<div class="td-post-author-name"><div class="td-author-by">' . __td('By', TD_THEME_NAME) . '</div> ';
$buffy .= '<a>post->post_author) . '">' . get_the_author_meta('display_name', $this->post->post_author) . '</a>' ;
if (td_util::get_option('tds_p_show_author_name') != 'hide' and td_util::get_option('tds_p_show_date') != 'hide') {
$buffy .= '<div class="td-author-line"> - </div> ';
}
$buffy .= '</div>';
}
return apply_filters( 'td_filters_get_author', $buffy );
}
-
This topic was modified 9 years by
emreerkan. Reason: code formatting
Hello Bogdan,
I know that I can modify original theme files but I don’t want to. 🙂 What I’m asking is you doing this, not me. So the theme gets more functionality and I don’t have to track some modifications which each theme update. It’s not something special to me, it may be useful for all Newspaper users.
Hi,
The whole purpose of having a child theme is to not lose your main theme customization by updating. If these modifications are not working anymore after a theme update, the code used needs to be checked and adapted.
If you would kindly provide more details about what your suggestion, and the improvements it may add to the theme we will take it into consideration.
Thank you for understanding!
I’ll try to give more details. 🙂 English is not my native language so bear with me here.
I’m a theme/plugin developer myself. I do lots of WordPress jobs for my customers. I understand child theme concept very well. No problems there, I assure you.
What I’m suggesting is, “you”, as tagDiv, could you please add filters to your internal functions? I’ll try to explain with an example.
There are 14 different (13 + default) single post styles in Newspaper theme. All of them have this line for author box;
<?php echo $td_mod_single->get_author_box();?>
This is great, so if I want to change author box, I can copy td_module_single_base.php from /includes/wp_booster/ to my child theme with the same folder structure and do necessary modifications. And voila, all of the author boxes are updated. But (there is a huge but here) now I have to inspect every changelog that if td_module_single_base.php file changed or not during version bumps. And I had to copy a whole file despite I want to change only one function.
Here comes my solution; Filters
If tagDiv could apply filters just before returning that cuddly $buffy, developers can add a hook to that filter and without copying whole td_module_single_base.php file, they can change the output of get_author_box() function.
I hope this time I explained my self much better. 🙂 Thanks for your responses.
Hi,
Please note that if this request becomes more popular, we will consider adding this suggestion on the list. I could not tell you exactly if something like this will be implemented, but we take into account every recommendation from our users and review it. Each update is meant to improve the theme functionality, design and add more useful features.
Thank you for understanding!