Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Adding acf_icon_path and acf_icon_url filters, updating README #11

Merged
merged 2 commits into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions fields/acf-icon-picker-v5.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down