• Resolved dirkvw001

    (@dirkvw001)


    I am encountering several issues with the ACF Font Awesome field plugin on my WordPress site:

    1. Reverting to Duotone: When selecting icon types, the field settings unexpectedly revert to using the duotone option. Specifically, when I select two checkboxes, the selection reverts to two options at the bottom. When I select three checkboxes, it retains the last two selections but reverts one back to the bottom option.
    2. Unexpected JSON Return: The field is returning JSON data, although this is not configured as an option in the return format settings.

    I have ensured that both the ACF and Font Awesome field plugins are up-to-date. I have also tried deactivating other plugins and switching to a default theme to rule out conflicts. Despite these steps, the issues persist.

    I’ve was able to “bypass” these issues in the past by manually placing the generated code in my theme and changing the settings that way, but this does not work anymore.

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

    (@mattkeys)

    Thanks for reporting. I’ll take a look at item #1, this last update did include a code change in that area that must be related.

    As for the second item, can you confirm you are using the ACF “get_field” / “get_sub_field” functions to get your value? The symptoms you report sounds like you might be using the WordPress “get_post_meta” function which would bypass the field formatting and return the raw JSON from the database.

    Matt Keys

    Thread Starter dirkvw001

    (@dirkvw001)

    Hi Matt,

    Thanks for your quick response, i’ve used json_decode to handle the returned json gets me to where i need to be. I’m attempting to retrieve the field in a custom WordPress navigation walker class that extends the built-in Walker_Nav_Menu class. It’s not using the get_field or get_sub_field functions, and i don’t think it’s using get_post_meta either.

    I apologise if it’s not all that helpful, but here’s what the section of code looks like where i’m getting the icon data. It’s a fontawesome acf field shown in each menu item which has been added in a specific menu location:

    <?php

    class theme_nav_walker extends Walker_Nav_menu {
    private $current_item;

    function start_el(&$output, $item, $depth = 0, $args = null, $id = 0) {
    $this->current_item = $item;

    $args->link_before = '';
    if(!empty($item->menu_icon)) {

    $icon_field = json_decode($item->menu_icon, true);
    $icon_class = 'fa-'.$icon_field['style'].' fa-'.$icon_field['id'];

    $args->link_before = '<i class="'.$menu_class.'__icon '.$icon_class.'"></i>';

    }

    }
    }

    The fact i’m not using get_ functions probably explains the lack of formatting then, although it usually still returned the field in the format i specified in the settings.

    I can use json_decode to retrieve all the data i need from the returned json. It just seemed odd to me that the data it returned didn’t match the format i selected anymore.

    Plugin Author Matt Keys

    (@mattkeys)

    Hey @dirkvw001,

    Thanks again for the bug report, that issue with the icon sets should be fixed in v4.1.1 which I just released.

    As for the ACF fields in your menus. While the json_decode workaround you are using will also work, there is nothing to say it will continue working in future releases of this plugin. The safe route is to use the proper ACF functions for retrieving values from your fields. You can read the docs here: https://www.advancedcustomfields.com/resources/adding-fields-menu-items/

    I’d expect your code for getting the icon value to end up looking something like:

    $icon_class = get_field( 'menu_icon', $item );

    As for why this *used* to work for you but no longer does. In prior versions of this plugin, the class was stored in the database how you happened to need it. In current versions there is instead a JSON object as I needed to store more information in the database. Using the ACF functions will make any future changes to this not effect you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.