Filter
Since 1.0.0
uncanny-automator-pro
uapro_includes_path_to
Filters the director path to the include file This can be used for include overrides by modifying the path to go to a directory in the theme or another plugin. Filters the include directory path to allow theme or plugin overrides for specific include files.
add_filter( 'uapro_includes_path_to', $callback, 10, 2 );
Description
Filters the path to include files. Developers can override the default include path to point to custom directories within their theme or other plugins, allowing for localized modifications of plugin functionality.
Usage
add_filter( 'uapro_includes_path_to', 'your_function_name', 10, 2 );
Parameters
-
$includes_directory(string) - Path to the plugins include folder
-
$file_name(string) - The file name of the include file
Return Value
The filtered value.
Examples
// Example: Override the default include path to load a custom template file from the theme.
// This is useful if you want to create a completely custom version of a file
// without modifying the plugin's core files directly.
add_filter( 'uapro_includes_path_to', 'my_custom_uapro_include_path', 10, 2 );
function my_custom_uapro_include_path( $includes_directory, $file_name ) {
// Check if the file being requested is a specific template we want to override.
if ( 'template-files/my-custom-template.php' === $file_name ) {
// Construct the path to the custom template file within the theme.
$custom_path = get_stylesheet_directory() . '/uncanny-automator-pro-overrides/' . $file_name;
// Ensure the custom file actually exists before returning its path.
if ( file_exists( $custom_path ) ) {
return $custom_path;
}
}
// If it's not the file we want to override, or the custom file doesn't exist,
// return the original path.
return $includes_directory;
}
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
uncanny-automator-pro/src/utilities.php:239
public static function get_include( $file_name ) {
$includes_directory = UAPro_ABSPATH . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR;
/**
* Filters the director path to the include file
*
* This can be used for include overrides by modifying the path to go to a directory in the theme or another plugin.
*
* @param string $includes_directory Path to the plugins include folder
* @param string $file_name The file name of the include file
*
* @since 1.0.0
*/
$includes_directory = apply_filters( 'uapro_includes_path_to', $includes_directory, $file_name );
return $includes_directory . $file_name;
}