| @@ -1,5 +1,6 @@ | ||
| 1 | -<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly. | |
| 1 | +<?php if ( ! defined( 'ABSPATH' ) ) { | |
| 2 | + die; } // Cannot access directly. | |
| 2 | 3 | /** |
| 3 | 4 | * |
| 4 | 5 | * Field: icon |
| 5 | 6 | * |
| @@ -4,68 +5,68 @@ | ||
| 4 | 5 | * Field: icon |
| 5 | 6 | * |
| 6 | 7 | * @since 1.0.0 |
| 7 | 8 | * @version 1.0.0 |
| 8 | - * | |
| 9 | 9 | */ |
| 10 | 10 | if ( ! class_exists( 'DarkifyField_icon' ) ) { |
| 11 | - class DarkifyField_icon extends DarkifyFields { | |
| 11 | + class DarkifyField_icon extends DarkifyFields { | |
| 12 | 12 | |
| 13 | - public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) { | |
| 14 | - parent::__construct( $field, $value, $unique, $where, $parent ); | |
| 15 | - } | |
| 13 | + public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) { | |
| 14 | + parent::__construct( $field, $value, $unique, $where, $parent ); | |
| 15 | + } | |
| 16 | 16 | |
| 17 | - public function render() { | |
| 17 | + public function render() { | |
| 18 | 18 | |
| 19 | - $args = wp_parse_args( $this->field, array( | |
| 20 | - 'button_title' => esc_html__( 'Add Icon', 'darkify' ), | |
| 21 | - 'remove_title' => esc_html__( 'Remove Icon', 'darkify' ), | |
| 22 | - ) ); | |
| 19 | + $args = wp_parse_args( | |
| 20 | + $this->field, | |
| 21 | + array( | |
| 22 | + 'button_title' => esc_html__( 'Add Icon', 'darkify' ), | |
| 23 | + 'remove_title' => esc_html__( 'Remove Icon', 'darkify' ), | |
| 24 | + ) | |
| 25 | + ); | |
| 23 | 26 | |
| 24 | - echo wp_kses_post($this->field_before()); | |
| 27 | + echo wp_kses_post( $this->field_before() ); | |
| 25 | 28 | |
| 26 | - $nonce = wp_create_nonce( 'darkify_icon_nonce' ); | |
| 27 | - $hidden = ( empty( $this->value ) ) ? ' hidden' : ''; | |
| 29 | + $nonce = wp_create_nonce( 'darkify_icon_nonce' ); | |
| 30 | + $hidden = ( empty( $this->value ) ) ? ' hidden' : ''; | |
| 28 | 31 | |
| 29 | - echo '<div class="darkify-icon-select">'; | |
| 30 | - echo '<span class="darkify-icon-preview'. esc_attr( $hidden ) .'"><i class="'. esc_attr( $this->value ) .'"></i></span>'; | |
| 31 | - echo '<a href="#" class="button button-primary darkify-icon-add" data-nonce="'. esc_attr( $nonce ) .'">'. wp_kses_post($args['button_title']) .'</a>'; | |
| 32 | - echo '<a href="#" class="button darkify-warning-primary darkify-icon-remove'. esc_attr( $hidden ) .'">'. wp_kses_post($args['remove_title']) .'</a>'; | |
| 33 | - echo '<input type="hidden" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'" class="darkify-icon-value"'. wp_kses_post($this->field_attributes()) .' />'; | |
| 34 | - echo '</div>'; | |
| 32 | + echo '<div class="darkify-icon-select">'; | |
| 33 | + echo '<span class="darkify-icon-preview' . esc_attr( $hidden ) . '"><i class="' . esc_attr( $this->value ) . '"></i></span>'; | |
| 34 | + echo '<a href="#" class="button button-primary darkify-icon-add" data-nonce="' . esc_attr( $nonce ) . '">' . esc_html( $args['button_title'] ) . '</a>'; | |
| 35 | + echo '<a href="#" class="button darkify-warning-primary darkify-icon-remove' . esc_attr( $hidden ) . '">' . esc_html( $args['remove_title'] ) . '</a>'; | |
| 36 | + echo '<input type="hidden" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $this->value ) . '" class="darkify-icon-value"' . wp_kses_post( $this->field_attributes() ) . ' />'; | |
| 37 | + echo '</div>'; | |
| 35 | 38 | |
| 36 | - echo wp_kses_post($this->field_after()); | |
| 39 | + echo wp_kses_post( $this->field_after() ); | |
| 40 | + } | |
| 37 | 41 | |
| 38 | - } | |
| 42 | + public function enqueue() { | |
| 43 | + add_action( 'admin_footer', array( 'DarkifyField_icon', 'add_footer_modal_icon' ) ); | |
| 44 | + add_action( 'customize_controls_print_footer_scripts', array( 'DarkifyField_icon', 'add_footer_modal_icon' ) ); | |
| 45 | + } | |
| 39 | 46 | |
| 40 | - public function enqueue() { | |
| 41 | - add_action( 'admin_footer', array( 'DarkifyField_icon', 'add_footer_modal_icon' ) ); | |
| 42 | - add_action( 'customize_controls_print_footer_scripts', array( 'DarkifyField_icon', 'add_footer_modal_icon' ) ); | |
| 43 | - } | |
| 44 | - | |
| 45 | - public static function add_footer_modal_icon() { | |
| 46 | - ?> | |
| 47 | - <div id="darkify-modal-icon" class="darkify-modal darkify-modal-icon hidden"> | |
| 48 | - <div class="darkify-modal-table"> | |
| 49 | - <div class="darkify-modal-table-cell"> | |
| 50 | - <div class="darkify-modal-overlay"></div> | |
| 51 | - <div class="darkify-modal-inner"> | |
| 52 | - <div class="darkify-modal-title"> | |
| 53 | - <?php esc_html_e( 'Add Icon', 'darkify' ); ?> | |
| 54 | - <div class="darkify-modal-close darkify-icon-close"></div> | |
| 55 | - </div> | |
| 56 | - <div class="darkify-modal-header"> | |
| 57 | - <input type="text" placeholder="<?php esc_html_e( 'Search...', 'darkify' ); ?>" class="darkify-icon-search" /> | |
| 58 | - </div> | |
| 59 | - <div class="darkify-modal-content"> | |
| 60 | - <div class="darkify-modal-loading"><div class="darkify-loading"></div></div> | |
| 61 | - <div class="darkify-modal-load"></div> | |
| 62 | - </div> | |
| 63 | - </div> | |
| 64 | - </div> | |
| 65 | - </div> | |
| 66 | - </div> | |
| 67 | - <?php | |
| 68 | - } | |
| 69 | - | |
| 70 | - } | |
| 47 | + public static function add_footer_modal_icon() { | |
| 48 | + ?> | |
| 49 | + <div id="darkify-modal-icon" class="darkify-modal darkify-modal-icon hidden"> | |
| 50 | + <div class="darkify-modal-table"> | |
| 51 | + <div class="darkify-modal-table-cell"> | |
| 52 | + <div class="darkify-modal-overlay"></div> | |
| 53 | + <div class="darkify-modal-inner"> | |
| 54 | + <div class="darkify-modal-title"> | |
| 55 | + <?php esc_html_e( 'Add Icon', 'darkify' ); ?> | |
| 56 | + <div class="darkify-modal-close darkify-icon-close"></div> | |
| 57 | + </div> | |
| 58 | + <div class="darkify-modal-header"> | |
| 59 | + <input type="text" placeholder="<?php esc_html_e( 'Search...', 'darkify' ); ?>" class="darkify-icon-search" /> | |
| 60 | + </div> | |
| 61 | + <div class="darkify-modal-content"> | |
| 62 | + <div class="darkify-modal-loading"><div class="darkify-loading"></div></div> | |
| 63 | + <div class="darkify-modal-load"></div> | |
| 64 | + </div> | |
| 65 | + </div> | |
| 66 | + </div> | |
| 67 | + </div> | |
| 68 | + </div> | |
| 69 | + <?php | |
| 70 | + } | |
| 71 | + } | |
| 71 | 72 | } |