PluginProbe ʕ •ᴥ•ʔ
Menu Icons by Themeisle – Add Icons to Navigation Menus / trunk
Menu Icons by Themeisle – Add Icons to Navigation Menus vtrunk
trunk 0.1.0 0.1.1 0.1.2 0.1.3 0.1.4 0.1.5 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.11.2 0.11.3 0.11.4 0.11.5 0.12.0 0.12.1 0.12.10 0.12.11 0.12.12 0.12.2 0.12.3 0.12.4 0.12.5 0.12.6 0.12.7 0.12.8 0.12.9 0.13.0 0.13.1 0.13.10 0.13.11 0.13.12 0.13.13 0.13.14 0.13.15 0.13.16 0.13.17 0.13.18 0.13.19 0.13.2 0.13.20 0.13.21 0.13.22 0.13.23 0.13.3 0.13.4 0.13.5 0.13.6 0.13.7 0.13.8 0.13.9 0.2.0 0.2.1 0.2.2 0.2.3 0.3.0 0.3.1 0.3.2 0.4.0 0.5.0 0.5.1 0.6.0 0.7.0 0.8.0 0.8.1 0.9.0 0.9.2
menu-icons / includes / settings.php
menu-icons / includes Last commit date
library 6 months ago front.php 2 months ago media-template.php 4 years ago meta.php 2 months ago picker.php 3 years ago settings.php 2 months ago type-fonts.php 10 years ago type.php 10 years ago
settings.php
780 lines
1 <?php
2
3 /**
4 * Settings
5 *
6 * @package Menu_Icons
7 * @author Dzikri Aziz <kvcrvt@gmail.com>
8 */
9
10 /**
11 * Menu Icons Settings module
12 */
13 final class Menu_Icons_Settings {
14
15 const UPDATE_KEY = 'menu-icons-settings-update';
16
17 const RESET_KEY = 'menu-icons-settings-reset';
18
19 const TRANSIENT_KEY = 'menu_icons_message';
20
21 /**
22 * Default setting values
23 *
24 * @since 0.3.0
25 * @var array
26 * @access protected
27 */
28 protected static $defaults = array(
29 'global' => array(
30 'icon_types' => array( 'dashicons' ),
31 ),
32 );
33
34 /**
35 * Setting values
36 *
37 * @since 0.3.0
38 * @var array
39 * @access protected
40 */
41 protected static $settings = array();
42
43 /**
44 * Script dependencies
45 *
46 * @since 0.9.0
47 * @access protected
48 * @var array
49 */
50 protected static $script_deps = array( 'jquery' );
51
52 /**
53 * Settings init
54 *
55 * @since 0.3.0
56 */
57 public static function init() {
58 // Include Menu Icons for Block Editor
59 if ( class_exists( '\ThemeIsle\GutenbergMenuIcons' ) ) {
60 \ThemeIsle\GutenbergMenuIcons::instance();
61 add_action( 'enqueue_block_assets', array( __CLASS__, '_enqueue_font_awesome' ) );
62 }
63
64 /**
65 * Allow themes/plugins to override the default settings
66 *
67 * @since 0.9.0
68 *
69 * @param array $default_settings Default settings.
70 */
71 self::$defaults = apply_filters( 'menu_icons_settings_defaults', self::$defaults );
72
73 self::$settings = get_option( 'menu-icons', self::$defaults );
74
75 foreach ( self::$settings as $key => &$value ) {
76 if ( 'global' === $key ) {
77 // Remove unregistered icon types.
78 $value['icon_types'] = array_values(
79 array_intersect(
80 array_keys( Menu_Icons::get( 'types' ) ),
81 array_filter( (array) $value['icon_types'] )
82 )
83 );
84 } else {
85 // Backward-compatibility.
86 if ( isset( $value['width'] ) && ! isset( $value['svg_width'] ) ) {
87 $value['svg_width'] = $value['width'];
88 }
89
90 unset( $value['width'] );
91 }
92 }
93
94 unset( $value );
95
96 /**
97 * Allow themes/plugins to override the settings
98 *
99 * @since 0.9.0
100 *
101 * @param array $settings Menu Icons settings.
102 */
103 self::$settings = apply_filters( 'menu_icons_settings', self::$settings );
104
105 if ( self::is_menu_icons_disabled_for_menu() ) {
106 return;
107 }
108
109 if ( ! empty( self::$settings['global']['icon_types'] ) ) {
110 require_once Menu_Icons::get( 'dir' ) . 'includes/picker.php';
111 Menu_Icons_Picker::init();
112 self::$script_deps[] = 'icon-picker';
113 }
114
115 add_action( 'load-nav-menus.php', array( __CLASS__, '_load_nav_menus' ), 1 );
116 add_action( 'wp_ajax_menu_icons_update_settings', array( __CLASS__, '_ajax_menu_icons_update_settings' ) );
117 }
118
119 /**
120 * Check if menu icons is disabled for a menu
121 *
122 * @since 0.8.0
123 *
124 * @param int $menu_id Menu ID. Defaults to current menu being edited.
125 *
126 * @return bool
127 */
128 public static function is_menu_icons_disabled_for_menu( $menu_id = 0 ) {
129 if ( empty( $menu_id ) ) {
130 $menu_id = self::get_current_menu_id();
131 }
132
133 // When we're creating a new menu or the recently edited menu
134 // could not be found.
135 if ( empty( $menu_id ) ) {
136 return true;
137 }
138
139 $menu_settings = self::get_menu_settings( $menu_id );
140 $is_disabled = ! empty( $menu_settings['disabled'] );
141
142 return $is_disabled;
143 }
144
145 /**
146 * Get ID of menu being edited
147 *
148 * @since 0.7.0
149 * @since 0.8.0 Get the recently edited menu from user option.
150 *
151 * @return int
152 */
153 public static function get_current_menu_id() {
154 global $nav_menu_selected_id;
155
156 if ( ! empty( $nav_menu_selected_id ) ) {
157 return $nav_menu_selected_id;
158 }
159
160 if ( is_admin() && isset( $_REQUEST['menu'] ) ) {
161 $menu_id = absint( $_REQUEST['menu'] );
162 } else {
163 $menu_id = absint( get_user_option( 'nav_menu_recently_edited' ) );
164 }
165
166 return $menu_id;
167 }
168
169 /**
170 * Get menu settings
171 *
172 * @since 0.3.0
173 *
174 * @param int $menu_id
175 *
176 * @return array
177 */
178 public static function get_menu_settings( $menu_id ) {
179 $menu_settings = self::get( sprintf( 'menu_%d', $menu_id ) );
180 $menu_settings = apply_filters( 'menu_icons_menu_settings', $menu_settings, $menu_id );
181
182 if ( ! is_array( $menu_settings ) ) {
183 $menu_settings = array();
184 }
185
186 return $menu_settings;
187 }
188
189 /**
190 * Get setting value
191 *
192 * @since 0.3.0
193 * @return mixed
194 */
195 public static function get() {
196 $args = func_get_args();
197
198 return kucrut_get_array_value_deep( self::$settings, $args );
199 }
200
201 /**
202 * Prepare wp-admin/nav-menus.php page
203 *
204 * @since 0.3.0
205 * @wp_hook action load-nav-menus.php
206 */
207 public static function _load_nav_menus() {
208 add_action( 'admin_enqueue_scripts', array( __CLASS__, '_enqueue_assets' ), 99 );
209
210 /**
211 * Allow settings meta box to be disabled.
212 *
213 * @since 0.4.0
214 *
215 * @param bool $disabled Defaults to FALSE.
216 */
217 $settings_disabled = apply_filters( 'menu_icons_disable_settings', false );
218 if ( true === $settings_disabled ) {
219 return;
220 }
221
222 self::_maybe_update_settings();
223 self::_add_settings_meta_box();
224
225 add_action( 'admin_notices', array( __CLASS__, '_admin_notices' ) );
226 }
227
228 /**
229 * Update settings
230 *
231 * @since 0.3.0
232 */
233 public static function _maybe_update_settings() {
234 if ( ! empty( $_POST['menu-icons']['settings'] ) ) {
235 check_admin_referer( self::UPDATE_KEY, self::UPDATE_KEY );
236
237 $redirect_url = self::_update_settings( $_POST['menu-icons']['settings'] ); // Input var okay.
238 wp_redirect( $redirect_url );
239 } elseif ( ! empty( $_REQUEST[ self::RESET_KEY ] ) ) {
240 check_admin_referer( self::RESET_KEY, self::RESET_KEY );
241 wp_redirect( self::_reset_settings() );
242 }
243 }
244
245 /**
246 * Update settings
247 *
248 * @since 0.7.0
249 * @access protected
250 *
251 * @param array $values Settings values.
252 *
253 * @return string Redirect URL.
254 */
255 protected static function _update_settings( $values ) {
256 update_option(
257 'menu-icons',
258 wp_parse_args(
259 kucrut_validate( $values ),
260 self::$settings
261 )
262 );
263 set_transient( self::TRANSIENT_KEY, 'updated', 30 );
264
265 $redirect_url = remove_query_arg(
266 array( 'menu-icons-reset' ),
267 wp_get_referer()
268 );
269
270 return $redirect_url;
271 }
272
273 /**
274 * Reset settings
275 *
276 * @since 0.7.0
277 * @access protected
278 * @return string Redirect URL.
279 */
280 protected static function _reset_settings() {
281 delete_option( 'menu-icons' );
282 set_transient( self::TRANSIENT_KEY, 'reset', 30 );
283
284 $redirect_url = remove_query_arg(
285 array( self::RESET_KEY, 'menu-icons-updated' ),
286 wp_get_referer()
287 );
288
289 return $redirect_url;
290 }
291
292 /**
293 * Settings meta box
294 *
295 * @since 0.3.0
296 * @access private
297 */
298 private static function _add_settings_meta_box() {
299 add_meta_box(
300 'menu-icons-settings',
301 __( 'Menu Icons Settings', 'menu-icons' ),
302 array( __CLASS__, '_meta_box' ),
303 'nav-menus',
304 'side',
305 'low',
306 array()
307 );
308 }
309
310 /**
311 * Update settings via ajax
312 *
313 * @since 0.7.0
314 * @wp_hook action wp_ajax_menu_icons_update_settings
315 */
316 public static function _ajax_menu_icons_update_settings() {
317 check_ajax_referer( self::UPDATE_KEY, self::UPDATE_KEY );
318
319 if ( empty( $_POST['menu-icons']['settings'] ) ) {
320 wp_send_json_error();
321 }
322
323 $redirect_url = self::_update_settings( $_POST['menu-icons']['settings'] ); // Input var okay.
324 wp_send_json_success( array( 'redirectUrl' => $redirect_url ) );
325 }
326
327 /**
328 * Print admin notices
329 *
330 * @since 0.3.0
331 * @wp_hook action admin_notices
332 */
333 public static function _admin_notices() {
334 $messages = array(
335 'updated' => __( '<strong>Menu Icons Settings</strong> have been successfully updated.', 'menu-icons' ),
336 'reset' => __( '<strong>Menu Icons Settings</strong> have been successfully reset.', 'menu-icons' ),
337 );
338
339 $message_type = get_transient( self::TRANSIENT_KEY );
340
341 if ( ! empty( $message_type ) && ! empty( $messages[ $message_type ] ) ) {
342 printf(
343 '<div class="updated notice is-dismissible"><p>%s</p></div>',
344 wp_kses( $messages[ $message_type ], array( 'strong' => true ) )
345 );
346 }
347
348 delete_transient( self::TRANSIENT_KEY );
349 }
350
351 /**
352 * Settings meta box
353 *
354 * @since 0.3.0
355 */
356 public static function _meta_box() {
357 ?>
358 <div class="taxonomydiv">
359 <ul id="menu-icons-settings-tabs" class="taxonomy-tabs add-menu-item-tabs hide-if-no-js">
360 <?php foreach ( self::get_fields() as $section ) : ?>
361 <?php
362 printf(
363 '<li><a href="#" title="%s" class="mi-settings-nav-tab" data-type="menu-icons-settings-%s">%s</a></li>',
364 esc_attr( $section['description'] ),
365 esc_attr( $section['id'] ),
366 esc_html( $section['title'] )
367 );
368 ?>
369 <?php endforeach; ?>
370 </ul>
371 <?php foreach ( self::_get_fields() as $section_index => $section ) : ?>
372 <div id="menu-icons-settings-<?php echo esc_attr( $section['id'] ) ?>"
373 class="tabs-panel _<?php echo esc_attr( $section_index ) ?>">
374 <h4 class="hide-if-js"><?php echo esc_html( $section['title'] ) ?></h4>
375 <?php foreach ( $section['fields'] as $field ) : ?>
376 <div class="_field">
377 <?php
378 printf(
379 '<label for="%s" class="_main">%s</label>',
380 esc_attr( $field->id ),
381 esc_html( $field->label )
382 );
383 // Help text.
384 if ( $field->help_text ) :
385 printf( '<i>%s</i>', esc_html( $field->help_text ) );
386 endif;
387
388 $field->render();
389 ?>
390 </div>
391 <?php endforeach; ?>
392 </div>
393 <?php endforeach; ?>
394 </div>
395 <p class="submitbox button-controls">
396 <?php wp_nonce_field( self::UPDATE_KEY, self::UPDATE_KEY ) ?>
397 <span class="list-controls">
398 <?php
399 printf(
400 '<a href="%s" title="%s" class="select-all submitdelete">%s</a>',
401 esc_url(
402 wp_nonce_url(
403 admin_url( '/nav-menus.php' ),
404 self::RESET_KEY,
405 self::RESET_KEY
406 )
407 ),
408 esc_attr__( 'Discard all changes and reset to default state', 'menu-icons' ),
409 esc_html__( 'Reset', 'menu-icons' )
410 );
411 ?>
412 </span>
413
414 <span class="add-to-menu">
415 <span class="spinner"></span>
416 <?php
417 submit_button(
418 __( 'Save Settings', 'menu-icons' ),
419 'secondary',
420 'menu-icons-settings-save',
421 false
422 );
423 ?>
424 </span>
425 </p>
426 <?php
427 }
428
429 /**
430 * Get settings sections
431 *
432 * @since 0.3.0
433 * @uses apply_filters() Calls 'menu_icons_settings_sections'.
434 * @return array
435 */
436 public static function get_fields() {
437 $menu_id = self::get_current_menu_id();
438 $icon_types = wp_list_pluck( Menu_Icons::get( 'types' ), 'name' );
439
440 asort( $icon_types );
441
442 $sections = array(
443 'global' => array(
444 'id' => 'global',
445 'title' => __( 'Global', 'menu-icons' ),
446 'description' => __( 'Global settings', 'menu-icons' ),
447 'fields' => array(
448 array(
449 'id' => 'icon_types',
450 'type' => 'checkbox',
451 'label' => __( 'Icon Types', 'menu-icons' ),
452 'choices' => $icon_types,
453 'value' => self::get( 'global', 'icon_types' ),
454 ),
455 array(
456 'id' => 'fa5_extra_icons',
457 'type' => 'textarea',
458 'label' => __( 'FA Custom Icon Classes', 'menu-icons' ),
459 'value' => self::get( 'global', 'fa5_extra_icons' ),
460 'help_text' => '( comma separated icons )',
461 ),
462 ),
463 'args' => array(),
464 ),
465 );
466
467 if ( ! empty( $menu_id ) ) {
468 $menu_term = get_term( $menu_id, 'nav_menu' );
469 $menu_key = sprintf( 'menu_%d', $menu_id );
470 $menu_settings = self::get_menu_settings( $menu_id );
471
472 $sections['menu'] = array(
473 'id' => $menu_key,
474 'title' => __( 'Current Menu', 'menu-icons' ),
475 'description' => sprintf(
476 // translators: %s - the name of the menu.
477 __( '"%s" menu settings', 'menu-icons' ),
478 apply_filters( 'single_term_title', $menu_term->name )
479 ),
480 'fields' => self::get_settings_fields( $menu_settings ),
481 'args' => array( 'inline_description' => true ),
482 );
483 }
484
485 return apply_filters( 'menu_icons_settings_sections', $sections, $menu_id );
486 }
487
488 /**
489 * Get settings fields
490 *
491 * @since 0.4.0
492 *
493 * @param array $values Values to be applied to each field.
494 *
495 * @uses apply_filters() Calls 'menu_icons_settings_fields'.
496 * @return array
497 */
498 public static function get_settings_fields( array $values = array() ) {
499 $fields = array(
500 'hide_label' => array(
501 'id' => 'hide_label',
502 'type' => 'select',
503 'label' => __( 'Hide Label', 'menu-icons' ),
504 'default' => '',
505 'choices' => array(
506 array(
507 'value' => '',
508 'label' => __( 'No', 'menu-icons' ),
509 ),
510 array(
511 'value' => '1',
512 'label' => __( 'Yes', 'menu-icons' ),
513 ),
514 ),
515 ),
516 'position' => array(
517 'id' => 'position',
518 'type' => 'select',
519 'label' => __( 'Position', 'menu-icons' ),
520 'default' => 'before',
521 'choices' => array(
522 array(
523 'value' => 'before',
524 'label' => __( 'Before', 'menu-icons' ),
525 ),
526 array(
527 'value' => 'after',
528 'label' => __( 'After', 'menu-icons' ),
529 ),
530 ),
531 ),
532 'vertical_align' => array(
533 'id' => 'vertical_align',
534 'type' => 'select',
535 'label' => __( 'Vertical Align', 'menu-icons' ),
536 'default' => 'middle',
537 'choices' => array(
538 array(
539 'value' => 'top',
540 'label' => __( 'Top', 'menu-icons' ),
541 ),
542 array(
543 'value' => 'middle',
544 'label' => __( 'Middle', 'menu-icons' ),
545 ),
546 array(
547 'value' => 'baseline',
548 'label' => __( 'Baseline', 'menu-icons' ),
549 ),
550 array(
551 'value' => 'bottom',
552 'label' => __( 'Bottom', 'menu-icons' ),
553 ),
554 ),
555 ),
556 'font_size' => array(
557 'id' => 'font_size',
558 'type' => 'number',
559 'label' => __( 'Font Size', 'menu-icons' ),
560 'default' => '1.2',
561 'description' => 'em',
562 'attributes' => array(
563 'min' => '0.1',
564 'step' => '0.1',
565 ),
566 ),
567 'svg_width' => array(
568 'id' => 'svg_width',
569 'type' => 'number',
570 'label' => __( 'SVG Width', 'menu-icons' ),
571 'default' => '1',
572 'description' => 'em',
573 'attributes' => array(
574 'min' => '.5',
575 'step' => '.1',
576 ),
577 ),
578 'image_size' => array(
579 'id' => 'image_size',
580 'type' => 'select',
581 'label' => __( 'Image Size', 'menu-icons' ),
582 'default' => 'thumbnail',
583 'choices' => kucrut_get_image_sizes(),
584 ),
585 );
586
587 $fields = apply_filters( 'menu_icons_settings_fields', $fields );
588
589 foreach ( $fields as &$field ) {
590 if ( isset( $values[ $field['id'] ] ) ) {
591 $field['value'] = $values[ $field['id'] ];
592 }
593
594 if ( ! isset( $field['value'] ) && isset( $field['default'] ) ) {
595 $field['value'] = $field['default'];
596 }
597 }
598
599 unset( $field );
600
601 return $fields;
602 }
603
604 /**
605 * Get processed settings fields
606 *
607 * @since 0.3.0
608 * @access private
609 * @return array
610 */
611 private static function _get_fields() {
612 if ( ! class_exists( 'Kucrut_Form_Field' ) ) {
613 require_once Menu_Icons::get( 'dir' ) . 'includes/library/form-fields.php';
614 }
615
616 $keys = array( 'menu-icons', 'settings' );
617 $sections = self::get_fields();
618
619 foreach ( $sections as &$section ) {
620 $_keys = array_merge( $keys, array( $section['id'] ) );
621 $_args = array_merge( array( 'keys' => $_keys ), $section['args'] );
622
623 foreach ( $section['fields'] as &$field ) {
624 $field = Kucrut_Form_Field::create( $field, $_args );
625 }
626
627 unset( $field );
628 }
629
630 unset( $section );
631
632 return $sections;
633 }
634
635 /**
636 * Enqueue scripts & styles for Block Icons
637 *
638 * @since 0.3.0
639 * @wp_hook action enqueue_block_assets
640 */
641 public static function _enqueue_font_awesome() {
642 $url = Menu_Icons::get( 'url' );
643
644 wp_register_style(
645 'font-awesome-5',
646 "{$url}css/fontawesome/css/all.min.css"
647 );
648 }
649
650 /**
651 * Enqueue scripts & styles for Appearance > Menus page
652 *
653 * @since 0.3.0
654 * @wp_hook action admin_enqueue_scripts
655 */
656 public static function _enqueue_assets() {
657 $url = Menu_Icons::get( 'url' );
658 $suffix = kucrut_get_script_suffix();
659
660 if ( defined( 'MENU_ICONS_SCRIPT_DEBUG' ) && MENU_ICONS_SCRIPT_DEBUG ) {
661 $script_url = '//localhost:8081/';
662 } else {
663 $script_url = $url;
664 }
665
666 wp_enqueue_style(
667 'menu-icons',
668 "{$url}css/admin{$suffix}.css",
669 false,
670 Menu_Icons::VERSION
671 );
672
673 wp_enqueue_script(
674 'menu-icons',
675 "{$script_url}js/admin{$suffix}.js",
676 self::$script_deps,
677 Menu_Icons::VERSION,
678 true
679 );
680
681 $customizer_url = add_query_arg(
682 array(
683 'autofocus[section]' => 'custom_css',
684 'return' => admin_url( 'nav-menus.php' ),
685 ),
686 admin_url( 'customize.php' )
687 );
688
689 /**
690 * Allow plugins/themes to filter the settings' JS data
691 *
692 * @since 0.9.0
693 *
694 * @param array $js_data JS Data.
695 */
696 $menu_current_theme = '';
697 $theme = wp_get_theme();
698 if ( ! empty( $theme ) ) {
699 if ( is_child_theme() && $theme->parent() ) {
700 $menu_current_theme = $theme->parent()->get( 'Name' );
701 } else {
702 $menu_current_theme = $theme->get( 'Name' );
703 }
704 }
705 $upsell_notices = array();
706 $box_data = '<div id="menu-icons-sidebar">';
707
708 if ( ( $menu_current_theme != 'Neve' ) ) {
709 $upsell_notices['neve'] = array(
710 'content' => wp_sprintf( '<div class="menu-icon-notice-popup-img"><img src="%s"/></div><div class="menu-icon-notice-popup"><h4>%s</h4>%s', plugin_dir_url( __FILE__ ) . '../images/neve-theme.jpg', __( 'Check-out our latest lightweight FREE theme - Neve', 'menu-icons' ), __( 'Neve’s mobile-first approach, compatibility with AMP and popular page-builders makes website building accessible for everyone.', 'menu-icons' ) ),
711 'url' => add_query_arg(
712 array(
713 'theme' => 'neve',
714 ),
715 admin_url( 'theme-install.php' )
716 ),
717 'btn_text' => __( 'Preview Neve', 'menu-icons' ),
718 );
719 }
720
721 if ( ! in_array( 'otter-blocks/otter-blocks.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
722 $upsell_notices['otter-blocks'] = array(
723 'content' => wp_sprintf( '<div class="menu-icon-notice-popup-img"><img src="%s"/></div><div class="menu-icon-notice-popup"><h4>%s</h4>%s', plugin_dir_url( __FILE__ ) . '../images/otter-block.png', __( 'Build professional pages with Otter Blocks', 'menu-icons' ), __( 'Otter is a dynamic collection of page building blocks and templates, covering all the elements you need to build your WordPress site.', 'menu-icons' ) ),
724 'url' => add_query_arg(
725 array(
726 'tab' => 'plugin-information',
727 'plugin' => 'otter-blocks',
728 'TB_iframe' => true,
729 'width' => 772,
730 'height' => 551,
731 ),
732 admin_url( 'plugin-install.php' )
733 ),
734 'btn_text' => __( 'Preview Otter Blocks', 'menu-icons' ),
735 );
736 }
737
738 if ( ! empty( $upsell_notices ) ) {
739 $rand_key = array_rand( $upsell_notices );
740 $menu_upgrade_hestia_box_text = $upsell_notices[ $rand_key ]['content'];
741
742 $box_data .= '<div class="nv-upgrade-notice postbox new-card">';
743 $box_data .= wp_kses_post( wpautop( $menu_upgrade_hestia_box_text ) );
744 $box_data .= '<a class="button" href="' . $upsell_notices[ $rand_key ]['url'] . '" target="_blank">' . $upsell_notices[ $rand_key ]['btn_text'] . '</a>';
745 $box_data .= '</div></div>';
746 }
747 $js_data = apply_filters(
748 'menu_icons_settings_js_data',
749 array(
750 'text' => array(
751 'title' => __( 'Select Icon', 'menu-icons' ),
752 'select' => __( 'Select', 'menu-icons' ),
753 'remove' => __( 'Remove', 'menu-icons' ),
754 'change' => __( 'Change', 'menu-icons' ),
755 'all' => __( 'All', 'menu-icons' ),
756 'preview' => __( 'Preview', 'menu-icons' ),
757 'settingsInfo' => sprintf(
758 // translators: %2$s - a link to the Customizer with the label `the customizer`.
759 '<div> %1$s <p>' . esc_html__( 'Please note that the actual look of the icons on the front-end will also be affected by the style of your active theme. You can add your own CSS using %2$s.', 'menu-icons' ) . '</p></div>',
760 $box_data,
761 sprintf(
762 '<a href="%s">%s</a>',
763 esc_url( $customizer_url ),
764 esc_html__( 'the customizer', 'menu-icons' )
765 )
766 ),
767 ),
768 'settingsFields' => self::get_settings_fields(),
769 'activeTypes' => self::get( 'global', 'icon_types' ),
770 'ajaxUrls' => array(
771 'update' => add_query_arg( 'action', 'menu_icons_update_settings', admin_url( '/admin-ajax.php' ) ),
772 ),
773 'menuSettings' => self::get_menu_settings( self::get_current_menu_id() ),
774 )
775 );
776
777 wp_localize_script( 'menu-icons', 'menuIcons', $js_data );
778 }
779 }
780