PluginProbe ʕ •ᴥ•ʔ
Menu Icons by Themeisle – Add Icons to Navigation Menus / 0.13.22
Menu Icons by Themeisle – Add Icons to Navigation Menus v0.13.22
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 4 months ago media-template.php 4 years ago meta.php 3 years ago picker.php 3 years ago settings.php 1 year ago type-fonts.php 10 years ago type.php 10 years ago
settings.php
796 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' => 'super',
540 'label' => __( 'Super', 'menu-icons' ),
541 ),
542 array(
543 'value' => 'top',
544 'label' => __( 'Top', 'menu-icons' ),
545 ),
546 array(
547 'value' => 'text-top',
548 'label' => __( 'Text Top', 'menu-icons' ),
549 ),
550 array(
551 'value' => 'middle',
552 'label' => __( 'Middle', 'menu-icons' ),
553 ),
554 array(
555 'value' => 'baseline',
556 'label' => __( 'Baseline', 'menu-icons' ),
557 ),
558 array(
559 'value' => 'text-bottom',
560 'label' => __( 'Text Bottom', 'menu-icons' ),
561 ),
562 array(
563 'value' => 'bottom',
564 'label' => __( 'Bottom', 'menu-icons' ),
565 ),
566 array(
567 'value' => 'sub',
568 'label' => __( 'Sub', 'menu-icons' ),
569 ),
570 ),
571 ),
572 'font_size' => array(
573 'id' => 'font_size',
574 'type' => 'number',
575 'label' => __( 'Font Size', 'menu-icons' ),
576 'default' => '1.2',
577 'description' => 'em',
578 'attributes' => array(
579 'min' => '0.1',
580 'step' => '0.1',
581 ),
582 ),
583 'svg_width' => array(
584 'id' => 'svg_width',
585 'type' => 'number',
586 'label' => __( 'SVG Width', 'menu-icons' ),
587 'default' => '1',
588 'description' => 'em',
589 'attributes' => array(
590 'min' => '.5',
591 'step' => '.1',
592 ),
593 ),
594 'image_size' => array(
595 'id' => 'image_size',
596 'type' => 'select',
597 'label' => __( 'Image Size', 'menu-icons' ),
598 'default' => 'thumbnail',
599 'choices' => kucrut_get_image_sizes(),
600 ),
601 );
602
603 $fields = apply_filters( 'menu_icons_settings_fields', $fields );
604
605 foreach ( $fields as &$field ) {
606 if ( isset( $values[ $field['id'] ] ) ) {
607 $field['value'] = $values[ $field['id'] ];
608 }
609
610 if ( ! isset( $field['value'] ) && isset( $field['default'] ) ) {
611 $field['value'] = $field['default'];
612 }
613 }
614
615 unset( $field );
616
617 return $fields;
618 }
619
620 /**
621 * Get processed settings fields
622 *
623 * @since 0.3.0
624 * @access private
625 * @return array
626 */
627 private static function _get_fields() {
628 if ( ! class_exists( 'Kucrut_Form_Field' ) ) {
629 require_once Menu_Icons::get( 'dir' ) . 'includes/library/form-fields.php';
630 }
631
632 $keys = array( 'menu-icons', 'settings' );
633 $sections = self::get_fields();
634
635 foreach ( $sections as &$section ) {
636 $_keys = array_merge( $keys, array( $section['id'] ) );
637 $_args = array_merge( array( 'keys' => $_keys ), $section['args'] );
638
639 foreach ( $section['fields'] as &$field ) {
640 $field = Kucrut_Form_Field::create( $field, $_args );
641 }
642
643 unset( $field );
644 }
645
646 unset( $section );
647
648 return $sections;
649 }
650
651 /**
652 * Enqueue scripts & styles for Block Icons
653 *
654 * @since 0.3.0
655 * @wp_hook action enqueue_block_assets
656 */
657 public static function _enqueue_font_awesome() {
658 $url = Menu_Icons::get( 'url' );
659
660 wp_register_style(
661 'font-awesome-5',
662 "{$url}css/fontawesome/css/all.min.css"
663 );
664 }
665
666 /**
667 * Enqueue scripts & styles for Appearance > Menus page
668 *
669 * @since 0.3.0
670 * @wp_hook action admin_enqueue_scripts
671 */
672 public static function _enqueue_assets() {
673 $url = Menu_Icons::get( 'url' );
674 $suffix = kucrut_get_script_suffix();
675
676 if ( defined( 'MENU_ICONS_SCRIPT_DEBUG' ) && MENU_ICONS_SCRIPT_DEBUG ) {
677 $script_url = '//localhost:8081/';
678 } else {
679 $script_url = $url;
680 }
681
682 wp_enqueue_style(
683 'menu-icons',
684 "{$url}css/admin{$suffix}.css",
685 false,
686 Menu_Icons::VERSION
687 );
688
689 wp_enqueue_script(
690 'menu-icons',
691 "{$script_url}js/admin{$suffix}.js",
692 self::$script_deps,
693 Menu_Icons::VERSION,
694 true
695 );
696
697 $customizer_url = add_query_arg(
698 array(
699 'autofocus[section]' => 'custom_css',
700 'return' => admin_url( 'nav-menus.php' ),
701 ),
702 admin_url( 'customize.php' )
703 );
704
705 /**
706 * Allow plugins/themes to filter the settings' JS data
707 *
708 * @since 0.9.0
709 *
710 * @param array $js_data JS Data.
711 */
712 $menu_current_theme = '';
713 $theme = wp_get_theme();
714 if ( ! empty( $theme ) ) {
715 if ( is_child_theme() && $theme->parent() ) {
716 $menu_current_theme = $theme->parent()->get( 'Name' );
717 } else {
718 $menu_current_theme = $theme->get( 'Name' );
719 }
720 }
721 $upsell_notices = array();
722 $box_data = '<div id="menu-icons-sidebar">';
723
724 if ( ( $menu_current_theme != 'Neve' ) ) {
725 $upsell_notices['neve'] = array(
726 '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' ) ),
727 'url' => add_query_arg(
728 array(
729 'theme' => 'neve',
730 ),
731 admin_url( 'theme-install.php' )
732 ),
733 'btn_text' => __( 'Preview Neve', 'menu-icons' ),
734 );
735 }
736
737 if ( ! in_array( 'otter-blocks/otter-blocks.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
738 $upsell_notices['otter-blocks'] = array(
739 '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' ) ),
740 'url' => add_query_arg(
741 array(
742 'tab' => 'plugin-information',
743 'plugin' => 'otter-blocks',
744 'TB_iframe' => true,
745 'width' => 772,
746 'height' => 551,
747 ),
748 admin_url( 'plugin-install.php' )
749 ),
750 'btn_text' => __( 'Preview Otter Blocks', 'menu-icons' ),
751 );
752 }
753
754 if ( ! empty( $upsell_notices ) ) {
755 $rand_key = array_rand( $upsell_notices );
756 $menu_upgrade_hestia_box_text = $upsell_notices[ $rand_key ]['content'];
757
758 $box_data .= '<div class="nv-upgrade-notice postbox new-card">';
759 $box_data .= wp_kses_post( wpautop( $menu_upgrade_hestia_box_text ) );
760 $box_data .= '<a class="button" href="' . $upsell_notices[ $rand_key ]['url'] . '" target="_blank">' . $upsell_notices[ $rand_key ]['btn_text'] . '</a>';
761 $box_data .= '</div></div>';
762 }
763 $js_data = apply_filters(
764 'menu_icons_settings_js_data',
765 array(
766 'text' => array(
767 'title' => __( 'Select Icon', 'menu-icons' ),
768 'select' => __( 'Select', 'menu-icons' ),
769 'remove' => __( 'Remove', 'menu-icons' ),
770 'change' => __( 'Change', 'menu-icons' ),
771 'all' => __( 'All', 'menu-icons' ),
772 'preview' => __( 'Preview', 'menu-icons' ),
773 'settingsInfo' => sprintf(
774 // translators: %2$s - a link to the Customizer with the label `the customizer`.
775 '<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>',
776 $box_data,
777 sprintf(
778 '<a href="%s">%s</a>',
779 esc_url( $customizer_url ),
780 esc_html__( 'the customizer', 'menu-icons' )
781 )
782 ),
783 ),
784 'settingsFields' => self::get_settings_fields(),
785 'activeTypes' => self::get( 'global', 'icon_types' ),
786 'ajaxUrls' => array(
787 'update' => add_query_arg( 'action', 'menu_icons_update_settings', admin_url( '/admin-ajax.php' ) ),
788 ),
789 'menuSettings' => self::get_menu_settings( self::get_current_menu_id() ),
790 )
791 );
792
793 wp_localize_script( 'menu-icons', 'menuIcons', $js_data );
794 }
795 }
796