plugins - Override filter variable not working

admin2025-06-04  44

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..

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..

Share Improve this question asked Jan 8, 2019 at 9:29 Johnny97Johnny97 2147 silver badges18 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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/Awesome-Support/Awesome-Support/commit/4312c02a3e35bb369e943d807377610670e71f41

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749033164a315792.html

最新回复(0)