Update
This commit is contained in:
parent
8010b9ca34
commit
251eaf8ac5
@ -11,11 +11,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Opalestate_Field_Iconpicker {
|
class Opalestate_Field_Iconpicker {
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected static $icon_data = [];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current version number
|
* Current version number
|
||||||
*/
|
*/
|
||||||
@ -24,22 +19,35 @@ class Opalestate_Field_Iconpicker {
|
|||||||
/**
|
/**
|
||||||
* Initialize the plugin by hooking into CMB2
|
* Initialize the plugin by hooking into CMB2
|
||||||
*/
|
*/
|
||||||
public static function init() {
|
public function __construct() {
|
||||||
$icons = new Fontawesome();
|
add_filter( 'cmb2_render_opal_iconpicker', [ $this, 'render_iconpicker' ], 10, 5 );
|
||||||
static::$icon_data[] = $icons->get_icons();
|
add_filter( 'cmb2_sanitize_opal_iconpicker', [ $this, 'sanitize' ], 10, 4 );
|
||||||
|
}
|
||||||
|
|
||||||
add_filter( 'cmb2_render_opal_iconpicker', [ __CLASS__, 'render_iconpicker' ], 10, 5 );
|
public function get_icons() {
|
||||||
add_filter( 'cmb2_sanitize_opal_iconpicker', [ __CLASS__, 'sanitize' ], 10, 4 );
|
$fontawesome_key = 'opalestate_fontawesome_data';
|
||||||
|
|
||||||
|
$icon_data = [];
|
||||||
|
if ( false === ( $fontawesome_icons = get_transient( $fontawesome_key ) ) ) {
|
||||||
|
$fontawesome = new Opalestate_Iconpicker_Fontawesome();
|
||||||
|
$fontawesome_icons = $fontawesome->get_icons();
|
||||||
|
set_transient( $fontawesome_key, $fontawesome_icons, 24 * 7 * HOUR_IN_SECONDS );
|
||||||
|
$icon_data[] = $fontawesome_icons;
|
||||||
|
}
|
||||||
|
var_dump($icon_data);
|
||||||
|
return $icon_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render field.
|
* Render field.
|
||||||
*/
|
*/
|
||||||
public static function render_iconpicker( $field, $field_escaped_value, $field_object_id, $field_object_type, $field_type_object ) {
|
public function render_iconpicker( $field, $field_escaped_value, $field_object_id, $field_object_type, $field_type_object ) {
|
||||||
self::setup_admin_scripts();
|
$this->setup_admin_scripts();
|
||||||
|
|
||||||
$users = $field->value;
|
$users = $field->value;
|
||||||
|
|
||||||
|
var_dump($this->get_icons());
|
||||||
|
|
||||||
// $output = sprintf(
|
// $output = sprintf(
|
||||||
// '<select id="%1$s" class="%2$s" name="%3$s">',
|
// '<select id="%1$s" class="%2$s" name="%3$s">',
|
||||||
// sanitize_key( $this->form->form_id . $args['id'] ),
|
// sanitize_key( $this->form->form_id . $args['id'] ),
|
||||||
@ -60,14 +68,14 @@ class Opalestate_Field_Iconpicker {
|
|||||||
/**
|
/**
|
||||||
* Sanitize data.
|
* Sanitize data.
|
||||||
*/
|
*/
|
||||||
public static function sanitize( $override_value, $value, $object_id, $field_args ) {
|
public function sanitize( $override_value, $value, $object_id, $field_args ) {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enqueue scripts and styles.
|
* Enqueue scripts and styles.
|
||||||
*/
|
*/
|
||||||
public static function setup_admin_scripts() {
|
public function setup_admin_scripts() {
|
||||||
// Iconpicker.
|
// Iconpicker.
|
||||||
wp_register_style( 'fonticonpicker', plugins_url( 'assets/css/jquery.fonticonpicker.min.css', __FILE__ ), [], self::VERSION );
|
wp_register_style( 'fonticonpicker', plugins_url( 'assets/css/jquery.fonticonpicker.min.css', __FILE__ ), [], self::VERSION );
|
||||||
wp_register_style( 'fonticonpicker-grey-theme', plugins_url( 'assets/themes/grey-theme/jquery.fonticonpicker.grey.min.css', __FILE__ ), [], self::VERSION );
|
wp_register_style( 'fonticonpicker-grey-theme', plugins_url( 'assets/themes/grey-theme/jquery.fonticonpicker.grey.min.css', __FILE__ ), [], self::VERSION );
|
||||||
@ -77,4 +85,4 @@ class Opalestate_Field_Iconpicker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Opalestate_Field_Iconpicker::init();
|
new Opalestate_Field_Iconpicker();
|
||||||
|
1
inc/vendors/cmb2-plugins/init.php
vendored
1
inc/vendors/cmb2-plugins/init.php
vendored
@ -35,6 +35,7 @@ function opalestate_load_cmb2_files() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( file_exists( OPALESTATE_CMB2_DIR . 'custom-fields/iconpicker/iconpicker.php' ) ) {
|
if ( file_exists( OPALESTATE_CMB2_DIR . 'custom-fields/iconpicker/iconpicker.php' ) ) {
|
||||||
|
require_once OPALESTATE_CMB2_DIR . 'custom-fields/iconpicker/providers/fontawesome.php';
|
||||||
require_once OPALESTATE_CMB2_DIR . 'custom-fields/iconpicker/iconpicker.php';
|
require_once OPALESTATE_CMB2_DIR . 'custom-fields/iconpicker/iconpicker.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user