/** * AJAX callback for rendering icons popup. * * Outputs HTML * * @since 1.0.0 */ function appica_icons_callback() { if (empty($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'appica-ajax')) { die; } // Current icon, for repeated opening popup $current = sanitize_text_field($_POST['current']); $icons = appica_get_icons(); $html = ''; if (0 !== count($icons)) { $_el = array(); /** * @var string Template for single filterable icon */ $tpl = '<li data-filtertext="%1$s" %2$s><a href="#" class="pios-icon" data-icon="%1$s"><i class="%1$s"></i></a></li>'; $html .= '<form class="ui-filterable"><input type="text" id="pios-icons-filterable-input" class="widefat" data-type="search"></form>'; $html .= '<ul class="pios-filterable-icons clearfix" data-role="listview" data-filter="true" data-input="#pios-icons-filterable-input">'; foreach ((array) $icons as $icon) { $active = $icon === $current ? 'class="active"' : ''; $_el[] = sprintf($tpl, $icon, $active); } $html .= implode('', $_el); $html .= '</ul>'; } else { $html .= '<p>' . __('No icons found', 'appica') . '</p>'; } print $html; die; }
/** * Filter shortcodes param "iconpicker": add new icon pack "Flaticons" * * @since 1.0.0 * * @param array $icons Icons * * @return array New icons */ function appica_vc_iconpicker_flaticons($icons) { $_flaticons = appica_get_icons(); $flaticons = array(); foreach ((array) $_flaticons as $n) { $flaticons[] = array($n => $n); } unset($n, $_flaticons); return array_merge($icons, $flaticons); }