: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
defined( 'ABSPATH' ) || exit;
if( ! class_exists( 'Themify_Icon_Font',false ) ) :
* Definition for icon font classes
class Themify_Icon_Font {
protected static $usedIcons = array();
protected function __construct(){
self::$types[$this->get_id()]=$this;
public static function init(){
$dir = trailingslashit( dirname( __FILE__ ) );
include $dir.'includes/class-icon-themify.php';
include $dir .'includes/class-icon-fontawesome.php';
include $dir .'includes/class-icon-fontello.php';
include $dir .'includes/class-icon-lineawesome.php';
add_action( 'wp_ajax_tf_get_icon', array( __CLASS__, 'tf_ajax_get_icon' ) );
add_action('wp_ajax_tf_icon_get_by_type',array(__CLASS__,'get_ajax_by_type'));
add_action('wp_ajax_nopriv_tf_load_icons',array(__CLASS__,'load_icons'));
add_action('wp_ajax_tf_load_icons',array(__CLASS__,'load_icons'));
* Return the ID of the icon font
* Return the name of the icon font
* Returns a list of icon fonts registered
public static function get_types() {
* Gets an icon name and checks if it's a valid icon in the font
* @param $name name of the icon
function is_valid_icon( $name ) {
* Returns the formatted CSS classname for the icon
function get_classname( $icon ,$lazy=null,$data_only=false) {
function get_categories(){
* Load script and style required for the icon picker interface
* Must be called manually wherever you need the icon picker.
public static function enqueue() {
$types=self::get_types();
foreach($types as $type){
$titles[$type->get_id()]=$type->get_label();
wp_enqueue_script( 'tf-icon-picker', THEMIFY_URI . '/themify-icon-picker/assets/script.js', array( 'themify-main-script' ), THEMIFY_VERSION, true );
wp_localize_script( 'tf-icon-picker', 'tfIconPicker', array(
'title'=> __( 'Choose icon', 'themify' ),
'search'=>__( 'Search', 'themify' )
do_action( 'themify_icon_picker_enqueue' );
public function get_icons_by_category($cat=''){
public static function get_used_icons() {
* Hooked to "tf_get_icon" Ajax call, returns the icon CSS classname for $_POST['tf_icon']
public static function tf_ajax_get_icon() {
if ( isset( $_GET['tf_icon'] ) ) {
echo themify_get_icon( $_GET['tf_icon'] );
public static function load_icons(){
if(!empty($_POST['icons'])){
$icons=json_decode(str_replace('\\','',$_POST['icons']));
$r=themify_get_icon(trim($ic),false,false,true);
public static function get_ajax_by_type(){
if(!empty($_POST['type'])){
$cat = !empty($_POST['cat'])?$_POST['cat']:'';
$types = self::get_types();
if(isset($types[$type])){
header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
echo json_encode(array('icons'=>$types[$type]->get_icons_by_category($cat),'cats'=>$types[$type]->get_categories()));
protected static function svg_attributes($attrs){
if(isset($attrs['aria-label'])){
$attrs['aria-hidden']='true';
return themify_get_element_attributes($attrs);
protected static function get_svg($id,array $attrs=array()){
if(isset($attrs['class'])){
$cl.=' '.$attrs['class'];
return '<svg '.self::svg_attributes($attrs).'><use href="#tf-' . $id . '"></use></svg>';
if( ! function_exists( 'themify_get_icon' ) ){
* Retrieve an icon name and returns the proper CSS classname to display that icon
function themify_get_icon( $name,$type=false,$lazy=false,$data_only=false,$attrs=array()) {
$types = Themify_Icon_Font::get_types();
if($type!==false && isset($types[$type])){
return $types[$type]->get_classname( $name,$lazy,$data_only,$attrs );
foreach( $types as $font ) {
if( $font->is_valid_icon( $name ) ) {
return $font->get_classname( $name,$lazy,$data_only,$attrs );
add_action( 'init', array( 'Themify_Icon_Font', 'init' ) );