• Resolved jasonlively

    (@jasonlively)


    Hi Matt, great plugin! I wanted to see if there was documentation for using the filters? I’m trying to limit the icons available to select to just a handful, and I was looking at how to use the ACFFA_get_icons filter mentioned in the plugin description. Could you point me towards a resource for that?

    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Matt Keys

    (@mattkeys)

    Hey Jason,

    Unfortunately I don’t have any docs prepared for you, but I will share some tips here that hopefully will get you pointed in the right direction.

    the ACFFA_get_icons filter should return a multidimensional array. Here is a log of the entire array for the FontAwesome 4.7 icon set: https://gist.github.com/mattkeys/ef79a67649882ef100d83e343e395225.

    Basically there are 3 main keys for this array:

    1. list: This is a simple array of all icons which is used in the backend area of the site when generating the select list dropdowns for users to pick their icons. The format for an item in this array is: {classname} => {unicode} {iconname}
    2. details: This array contains expanded information about each icon. The key for each item is still the classname, but then the value is another array with keys for element, class, hex, and unicode.
    3. prefix: This is the class prefix used by the version of FontAwesome you are using. In 4.x this is ‘fa-‘

    An example is probably a much simpler way to absorb this all. Lets say that you wanted to only include 3 social media icons (Facebook, Twitter, and Instagram). You could add the following function to your functions.php:

    function get_social_icons( $icons ) {
    	$icons = array(
    		'list' => array(
    			null			=> '',
    			'fa-facebook'	=> ' facebook',
    			'fa-twitter'	=> ' twitter',
    			'fa-instagram'	=> ' instagram'
    		),
    		'details'	=> array(
    			'fa-facebook' => array(
    					'element'	=> '<i class="fa fa-facebook" aria-hidden="true"></i>',
    					'class'		=> 'fa-facebook',
    					'hex'		=> '\f09a',
    					'unicode'	=> '',
    			),
    			'fa-twitter' => array(
    					'element'	=> '<i class="fa fa-twitter" aria-hidden="true"></i>',
    					'class'		=> 'fa-twitter',
    					'hex'		=> '\f099',
    					'unicode'	=> '',
    			),
    			'fa-instagram' => array(
    					'element'	=> '<i class="fa fa-instagram" aria-hidden="true"></i>',
    					'class'		=> 'fa-instagram',
    					'hex'		=> '\f16d',
    					'unicode'	=> '',
    			),
    		),
    		'prefix'	=> 'fa-'
    
    	);
    
    	return $icons;
    }
    add_filter( 'ACFFA_get_icons', 'get_social_icons', 10, 1 );

    Note: In the process of writing and testing this code for you, I found a bug where the ACFFA_get_icons filter wasn’t used in one place internally, so that values were not respected in the backend. I just pushed version 2.1.2 which fixes this bug, so make sure that you update your code before trying out the code sample above.

    I hope this helps, let me know if you have questions.

    Thanks,

    Matt Keys

    Plugin Author Matt Keys

    (@mattkeys)

    It looks like the unicode values are not going to copy/paste well from here because the browser is trying to render them. I recommend getting the unicode values by searching the GitHub Gist I posted of the icon set from 4.7.

    Thread Starter jasonlively

    (@jasonlively)

    This looks great and straightforward. Thanks for the fantastic support! I’ll be rolling this out Monday and will follow up if I run into any issues.

    Thread Starter jasonlively

    (@jasonlively)

    Thank you Matt, this worked great! Thanks for taking the time to write this out and also for testing the example and debugging it. It works exactly like I was expecting.

    Plugin Author Matt Keys

    (@mattkeys)

    Awesome, glad it worked out for you.

    Matt

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Filter Documentation’ is closed to new replies.