0

I'm currently trying to override a filter in a plugin. This filter has 1 variable which defines a root path to a folder where some templates are located.

This root path is normally in the assets folder of the plugin (Awesome Support). Because I want to override the templates I need to change the root path of the templates folder to my own folder so that my own templates are used and not the original ones.


After a lot of searching I found the right filter in the documentation: Filter

The filter gets applied in this file on line 722: File

So I've added this filter to my themes function.php file:

add_filter( 'wpas_email_template_root_path', 'set_wpas_email_template_root_path', 30, 1 );
function set_wpas_email_template_root_path( $template_root_path ) {

    error_log( 'email-functions.php' );

    return get_home_path() . 'wp-content/themes/' . get_option( 'stylesheet' ) . '/awesome-support/emails/';
}

To test it I've added some error logging in my function and at the place where I need to override the root path:

error_log( 'Before' );
// Allow other add-ons to set this path
apply_filters( 'wpas_email_template_root_path', $template_root_path );
error_log( 'functions-tools.php' . $template_root_path );

This is the debugging result:

[08-Jan-2019 08:56:19 UTC] Before
[08-Jan-2019 08:56:19 UTC] email-functions.php
[08-Jan-2019 08:56:19 UTC] functions-tools.php/var/www/vhosts/localhost/httpdocs/wp-content/plugins/awesome-support/assets/admin/email-templates/blue-block/

As you can see there is still the plugins template path set. I don't know what I'm doing wrong here..

0

The plugin author said that this is a bug. The fix will be included into the next release in some days. Therefore you can see the changes in the link below:

https://github.com/Awesome-Support/Awesome-Support/commit/4312c02a3e35bb369e943d807377610670e71f41

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review – Krzysiek Dróżdż Jan 8 at 10:13
  • @KrzysiekDróżdż I know, but in this case the release will be in the next days so the link is valid until the plugin dies. And when I becomes invalid earlier, the problem will be fixed months ago. – Mr. Jo Jan 8 at 12:49

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.