diff --git a/README.md b/README.md index fbc897a..79a88b1 100755 --- a/README.md +++ b/README.md @@ -25,13 +25,30 @@ This ACF field type is compatible with: ## Filters -Use this filter if you want to override the default icon folder. +Use the below filters to override the default icon folder, path, and / or URL: - add_filter( 'acf_icon_path_suffix', 'acf_icon_path_suffix' ); +```php +// modify the path to the icons directory +add_filter( 'acf_icon_path_suffix', 'acf_icon_path_suffix' ); - function acf_icon_path_suffix( $path_suffix ) { - return 'assets/img/icons/'; - } +function acf_icon_path_suffix( $path_suffix ) { + return 'assets/img/icons/'; +} + +// modify the path to the above prefix +add_filter( 'acf_icon_path', 'acf_icon_path' ); + +function acf_icon_path( $path_suffix ) { + return plugin_dir_path( __FILE__ ); +} + +// modify the URL to the icons directory to display on the page +add_filter( 'acf_icon_url', 'acf_icon_url' ); + +function acf_icon_url( $path_suffix ) { + return plugin_dir_url( __FILE__ ); +} +``` ## Changelog diff --git a/fields/acf-icon-picker-v5.php b/fields/acf-icon-picker-v5.php index 7101912..7d53a2f 100755 --- a/fields/acf-icon-picker-v5.php +++ b/fields/acf-icon-picker-v5.php @@ -26,9 +26,9 @@ function __construct( $settings ) { $this->path_suffix = apply_filters( 'acf_icon_path_suffix', 'assets/img/acf/' ); - $this->path = $this->settings['path'] . $this->path_suffix; + $this->path = apply_filters( 'acf_icon_path', $this->settings['path'] ) . $this->path_suffix; - $this->url = $this->settings['url'] . $this->path_suffix; + $this->url = apply_filters( 'acf_icon_url', $this->settings['url'] ) . $this->path_suffix; $priority_dir_lookup = get_stylesheet_directory() . '/' . $this->path_suffix;