Home>Support>Custom Icon is not saved persistently

Custom Icon is not saved persistently

Howdy,

short note beforehand: developing new/additional plugins for the PageBuilder works like a charm and makes a lot a fun. So: thanks a lot for this really great API/Plugin System & PageBuilder itself!

Nevertheless I’m currently struggling to implement/add a custom icon font to the PageBuilder icon set as described here: https://siteorigin.com/docs/widgets-bundle/form-building/icons-and-fonts/
I’m able to choose a icon of my new set but after saving the entire post the icon is gone (selected value seems not to be saved).
Thus I do not see any icon the Frontend nor in the Backend. (Dumping the $instance in my .tpl file reveals that the property ‘icon’ is indeed empty). However this only happens if I choose a icon of my new set, all other icons still work as expected.

To load/add an additional icon set I registered one function to the

siteorigin_widgets_icon_families
filter hook. (Furthermore I added a custom filter to the icons itself, which should be needless for my purpose)

function openproject_icons_filter($icons) {
    return array_merge( $icons, array('align-center' => '','align-justify' => '','align-left' => '', ....... ));
}
add_filter('siteorigin_widgets_icons_openproject-icon', 'openproject_icons_filter');

function register_openproject_icon_font_family( $icon_families ) {
    $icon_families['openproject-icon'] = array(
        'name' => __( 'OpenProject Icon Font', 'openproject-theme' ),
        'style_uri' => get_stylesheet_directory_uri() . '/assets/fonts/openproject-icon-fonts.css',
        'icons' => apply_filters('siteorigin_widgets_icons_openproject-icon', array() )
    );
    return $icon_families;
}
add_filter('siteorigin_widgets_icon_families', 'register_openproject_icon_font_family');

As I’m able to choose a icon of the newly added set (c.f. screenshot below) I’ve no idea why the value is not saved (maybe it’s filtered/cleared?). Is any additional hook required to load the font during the ‘saving’ process? Maybe the font is unknown to the PageBuilder during the saving process, for what reason the value gets cleared?

I’m not able to find any difference between my implementation and your icon plugin (so-widgets-bundle/icons/icons.php). Thus I’ve no idea where my mistake would be. Hopefully you’ve a smart clue :).

Many thanks in advance,
Best regards,
Marco

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 8 years, 12 days ago Alex S
    Hi, I Work Here

    Hi Mmoscher,

    Unfortunately, there’s currently an issue (although it may be intended – unable to confirm at this time) with the font family names where it doesn’t allow for hyphens. The documentation is in the process of getting updated to reflect this issue.

    In other words, please change:

    $icon_families['openproject-icon'] = array(
    

    To just:

    $icon_families['openproject'] = array(
    

    That’ll resolve this issue and allow for the data to be saved. Sorry about this!

  2. 7 years, 11 months ago mmoscher

    Sorry for late Feedback.

    This indeed eliminates the failure – so thanks a lot for this small hint ;) :)

    (As you already adapted/reworked the relevant developer docs, I would appreciate if you also drop a little note, that one should not use any hyphens for the array keys / font family names (yet).)

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More