Filter
Since 1.0.0
uncanny-automator-pro
uapro_view_path
Filters the director path to the view file This can be used for view overrides by modifying the path to go to a directory in the theme or another plugin. Filters the view file path before loading, allowing theme or plugin overrides.
add_filter( 'uapro_view_path', $callback, 10, 2 );
Description
Filters the view file's directory path before it's loaded. Developers can use this hook to override default view files by returning a custom path, enabling theme or plugin-specific customizations. This hook fires during the initialization process when view files are being located.
Usage
add_filter( 'uapro_view_path', 'your_function_name', 10, 2 );
Parameters
-
$views_directory(string) - Path to the plugins view folder
-
$file_name(string) - The file name of the view file
Return Value
The filtered value.
Examples
// Example: Override a view file path to a custom directory within the theme.
add_filter( 'uapro_view_path', 'my_custom_uapro_view_path', 10, 2 );
/**
* Custom function to modify the view path for Uncanny Automator Pro.
*
* This function checks if a specific view file exists in a custom directory
* within the active theme. If it does, it returns the path to that custom file;
* otherwise, it falls back to the plugin's default view path.
*
* @param string $views_directory The default path to the plugin's view folder.
* @param string $file_name The name of the view file being requested.
* @return string The modified path to the view file.
*/
function my_custom_uapro_view_path( $views_directory, $file_name ) {
// Construct a potential custom path within the theme's folder.
// We're looking for a 'ua-pro-views' directory in the theme.
$theme_custom_path = trailingslashit( get_stylesheet_directory() ) . 'ua-pro-views/' . $file_name;
// Check if this custom file actually exists on the server.
if ( file_exists( $theme_custom_path ) ) {
// If it exists, return the path to our custom theme version.
return trailingslashit( get_stylesheet_directory() ) . 'ua-pro-views/';
}
// If the custom file doesn't exist, return the original plugin path.
return $views_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:213
public static function get_view( $file_name ) {
$views_directory = UAPro_ABSPATH . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR;
/**
* Filters the director path to the view file
*
* This can be used for view overrides by modifying the path to go to a directory in the theme or another plugin.
*
* @param string $views_directory Path to the plugins view folder
* @param string $file_name The file name of the view file
*
* @since 1.0.0
*/
$views_directory = apply_filters( 'uapro_view_path', $views_directory, $file_name );
return $views_directory . $file_name;
}