PluginProbe ʕ •ᴥ•ʔ
Menu Icons by Themeisle – Add Icons to Navigation Menus / 0.13.6
Menu Icons by Themeisle – Add Icons to Navigation Menus v0.13.6
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 3 years ago front.php 3 years ago media-template.php 4 years ago meta.php 3 years ago picker.php 3 years ago settings.php 3 years ago type-fonts.php 10 years ago type.php 10 years ago
settings.php
807 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 <?php
371 printf(
372 '<li><a href="#" class="mi-settings-nav-tab" data-type="menu-icons-settings-extensions">%s</a></li>',
373 esc_html__( 'Extensions', 'menu-icons' )
374 );
375 ?>
376 </ul>
377 <?php foreach ( self::_get_fields() as $section_index => $section ) : ?>
378 <div id="menu-icons-settings-<?php echo esc_attr( $section['id'] ) ?>"
379 class="tabs-panel _<?php echo esc_attr( $section_index ) ?>">
380 <h4 class="hide-if-js"><?php echo esc_html( $section['title'] ) ?></h4>
381 <?php foreach ( $section['fields'] as $field ) : ?>
382 <div class="_field">
383 <?php
384 printf(
385 '<label for="%s" class="_main">%s</label>',
386 esc_attr( $field->id ),
387 esc_html( $field->label )
388 );
389 // Help text.
390 if ( $field->help_text ) :
391 printf( '<i>%s</i>', esc_html( $field->help_text ) );
392 endif;
393
394 $field->render();
395 ?>
396 </div>
397 <?php endforeach; ?>
398 </div>
399 <?php endforeach; ?>
400 <div id="menu-icons-settings-extensions" class="tabs-panel _extensions">
401 <h4 class="hide-if-js"><?php echo esc_html__( 'Extensions', 'menu-icons' ) ?></h4>
402 <ul>
403 <li><a target="_blank" href="http://wordpress.org/plugins/menu-icons-icomoon/">IcoMoon</a></li>
404 </ul>
405 </div>
406 </div>
407 <p class="submitbox button-controls">
408 <?php wp_nonce_field( self::UPDATE_KEY, self::UPDATE_KEY ) ?>
409 <span class="list-controls">
410 <?php
411 printf(
412 '<a href="%s" title="%s" class="select-all submitdelete">%s</a>',
413 esc_url(
414 wp_nonce_url(
415 admin_url( '/nav-menus.php' ),
416 self::RESET_KEY,
417 self::RESET_KEY
418 )
419 ),
420 esc_attr__( 'Discard all changes and reset to default state', 'menu-icons' ),
421 esc_html__( 'Reset', 'menu-icons' )
422 );
423 ?>
424 </span>
425
426 <span class="add-to-menu">
427 <span class="spinner"></span>
428 <?php
429 submit_button(
430 __( 'Save Settings', 'menu-icons' ),
431 'secondary',
432 'menu-icons-settings-save',
433 false
434 );
435 ?>
436 </span>
437 </p>
438 <?php
439 }
440
441 /**
442 * Get settings sections
443 *
444 * @since 0.3.0
445 * @uses apply_filters() Calls 'menu_icons_settings_sections'.
446 * @return array
447 */
448 public static function get_fields() {
449 $menu_id = self::get_current_menu_id();
450 $icon_types = wp_list_pluck( Menu_Icons::get( 'types' ), 'name' );
451
452 asort( $icon_types );
453
454 $sections = array(
455 'global' => array(
456 'id' => 'global',
457 'title' => __( 'Global', 'menu-icons' ),
458 'description' => __( 'Global settings', 'menu-icons' ),
459 'fields' => array(
460 array(
461 'id' => 'icon_types',
462 'type' => 'checkbox',
463 'label' => __( 'Icon Types', 'menu-icons' ),
464 'choices' => $icon_types,
465 'value' => self::get( 'global', 'icon_types' ),
466 ),
467 array(
468 'id' => 'fa5_extra_icons',
469 'type' => 'textarea',
470 'label' => __( 'FA Custom Icon Classes', 'menu-icons' ),
471 'value' => self::get( 'global', 'fa5_extra_icons' ),
472 'help_text' => '( comma separated icons )',
473 ),
474 ),
475 'args' => array(),
476 ),
477 );
478
479 if ( ! empty( $menu_id ) ) {
480 $menu_term = get_term( $menu_id, 'nav_menu' );
481 $menu_key = sprintf( 'menu_%d', $menu_id );
482 $menu_settings = self::get_menu_settings( $menu_id );
483
484 $sections['menu'] = array(
485 'id' => $menu_key,
486 'title' => __( 'Current Menu', 'menu-icons' ),
487 'description' => sprintf(
488 __( '"%s" menu settings', 'menu-icons' ),
489 apply_filters( 'single_term_title', $menu_term->name )
490 ),
491 'fields' => self::get_settings_fields( $menu_settings ),
492 'args' => array( 'inline_description' => true ),
493 );
494 }
495
496 return apply_filters( 'menu_icons_settings_sections', $sections, $menu_id );
497 }
498
499 /**
500 * Get settings fields
501 *
502 * @since 0.4.0
503 *
504 * @param array $values Values to be applied to each field.
505 *
506 * @uses apply_filters() Calls 'menu_icons_settings_fields'.
507 * @return array
508 */
509 public static function get_settings_fields( array $values = array() ) {
510 $fields = array(
511 'hide_label' => array(
512 'id' => 'hide_label',
513 'type' => 'select',
514 'label' => __( 'Hide Label', 'menu-icons' ),
515 'default' => '',
516 'choices' => array(
517 array(
518 'value' => '',
519 'label' => __( 'No', 'menu-icons' ),
520 ),
521 array(
522 'value' => '1',
523 'label' => __( 'Yes', 'menu-icons' ),
524 ),
525 ),
526 ),
527 'position' => array(
528 'id' => 'position',
529 'type' => 'select',
530 'label' => __( 'Position', 'menu-icons' ),
531 'default' => 'before',
532 'choices' => array(
533 array(
534 'value' => 'before',
535 'label' => __( 'Before', 'menu-icons' ),
536 ),
537 array(
538 'value' => 'after',
539 'label' => __( 'After', 'menu-icons' ),
540 ),
541 ),
542 ),
543 'vertical_align' => array(
544 'id' => 'vertical_align',
545 'type' => 'select',
546 'label' => __( 'Vertical Align', 'menu-icons' ),
547 'default' => 'middle',
548 'choices' => array(
549 array(
550 'value' => 'super',
551 'label' => __( 'Super', 'menu-icons' ),
552 ),
553 array(
554 'value' => 'top',
555 'label' => __( 'Top', 'menu-icons' ),
556 ),
557 array(
558 'value' => 'text-top',
559 'label' => __( 'Text Top', 'menu-icons' ),
560 ),
561 array(
562 'value' => 'middle',
563 'label' => __( 'Middle', 'menu-icons' ),
564 ),
565 array(
566 'value' => 'baseline',
567 'label' => __( 'Baseline', 'menu-icons' ),
568 ),
569 array(
570 'value' => 'text-bottom',
571 'label' => __( 'Text Bottom', 'menu-icons' ),
572 ),
573 array(
574 'value' => 'bottom',
575 'label' => __( 'Bottom', 'menu-icons' ),
576 ),
577 array(
578 'value' => 'sub',
579 'label' => __( 'Sub', 'menu-icons' ),
580 ),
581 ),
582 ),
583 'font_size' => array(
584 'id' => 'font_size',
585 'type' => 'number',
586 'label' => __( 'Font Size', 'menu-icons' ),
587 'default' => '1.2',
588 'description' => 'em',
589 'attributes' => array(
590 'min' => '0.1',
591 'step' => '0.1',
592 ),
593 ),
594 'svg_width' => array(
595 'id' => 'svg_width',
596 'type' => 'number',
597 'label' => __( 'SVG Width', 'menu-icons' ),
598 'default' => '1',
599 'description' => 'em',
600 'attributes' => array(
601 'min' => '.5',
602 'step' => '.1',
603 ),
604 ),
605 'image_size' => array(
606 'id' => 'image_size',
607 'type' => 'select',
608 'label' => __( 'Image Size', 'menu-icons' ),
609 'default' => 'thumbnail',
610 'choices' => kucrut_get_image_sizes(),
611 ),
612 );
613
614 $fields = apply_filters( 'menu_icons_settings_fields', $fields );
615
616 foreach ( $fields as &$field ) {
617 if ( isset( $values[ $field['id'] ] ) ) {
618 $field['value'] = $values[ $field['id'] ];
619 }
620
621 if ( ! isset( $field['value'] ) && isset( $field['default'] ) ) {
622 $field['value'] = $field['default'];
623 }
624 }
625
626 unset( $field );
627
628 return $fields;
629 }
630
631 /**
632 * Get processed settings fields
633 *
634 * @since 0.3.0
635 * @access private
636 * @return array
637 */
638 private static function _get_fields() {
639 if ( ! class_exists( 'Kucrut_Form_Field' ) ) {
640 require_once Menu_Icons::get( 'dir' ) . 'includes/library/form-fields.php';
641 }
642
643 $keys = array( 'menu-icons', 'settings' );
644 $sections = self::get_fields();
645
646 foreach ( $sections as &$section ) {
647 $_keys = array_merge( $keys, array( $section['id'] ) );
648 $_args = array_merge( array( 'keys' => $_keys ), $section['args'] );
649
650 foreach ( $section['fields'] as &$field ) {
651 $field = Kucrut_Form_Field::create( $field, $_args );
652 }
653
654 unset( $field );
655 }
656
657 unset( $section );
658
659 return $sections;
660 }
661
662 /**
663 * Enqueue scripts & styles for Block Icons
664 *
665 * @since 0.3.0
666 * @wp_hook action enqueue_block_assets
667 */
668 public static function _enqueue_font_awesome() {
669 $url = Menu_Icons::get( 'url' );
670
671 wp_register_style(
672 'font-awesome-5',
673 "{$url}css/fontawesome/css/all.min.css"
674 );
675 }
676
677 /**
678 * Enqueue scripts & styles for Appearance > Menus page
679 *
680 * @since 0.3.0
681 * @wp_hook action admin_enqueue_scripts
682 */
683 public static function _enqueue_assets() {
684 $url = Menu_Icons::get( 'url' );
685 $suffix = kucrut_get_script_suffix();
686
687 if ( defined( 'MENU_ICONS_SCRIPT_DEBUG' ) && MENU_ICONS_SCRIPT_DEBUG ) {
688 $script_url = '//localhost:8081/';
689 } else {
690 $script_url = $url;
691 }
692
693 wp_enqueue_style(
694 'menu-icons',
695 "{$url}css/admin{$suffix}.css",
696 false,
697 Menu_Icons::VERSION
698 );
699
700 wp_enqueue_script(
701 'menu-icons',
702 "{$script_url}js/admin{$suffix}.js",
703 self::$script_deps,
704 Menu_Icons::VERSION,
705 true
706 );
707
708 $customizer_url = add_query_arg(
709 array(
710 'autofocus[section]' => 'custom_css',
711 'return' => admin_url( 'nav-menus.php' ),
712 ),
713 admin_url( 'customize.php' )
714 );
715
716 /**
717 * Allow plugins/themes to filter the settings' JS data
718 *
719 * @since 0.9.0
720 *
721 * @param array $js_data JS Data.
722 */
723 $menu_current_theme = '';
724 $theme = wp_get_theme();
725 if ( ! empty( $theme ) ) {
726 if ( is_child_theme() && $theme->parent() ) {
727 $menu_current_theme = $theme->parent()->get( 'Name' );
728 } else {
729 $menu_current_theme = $theme->get( 'Name' );
730 }
731 }
732 $upsell_notices = array();
733 $box_data = '<div id="menu-icons-sidebar">';
734
735 if ( ( $menu_current_theme != 'Neve' ) ) {
736 $upsell_notices['neve'] = array(
737 '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' ) ),
738 'url' => add_query_arg(
739 array(
740 'theme' => 'neve',
741 ),
742 admin_url( 'theme-install.php' )
743 ),
744 'btn_text' => __( 'Preview Neve', 'menu-icons' ),
745 );
746 }
747
748 if ( ! in_array( 'otter-blocks/otter-blocks.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
749 $upsell_notices['otter-blocks'] = array(
750 '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' ) ),
751 'url' => add_query_arg(
752 array(
753 'tab' => 'plugin-information',
754 'plugin' => 'otter-blocks',
755 'TB_iframe' => true,
756 'width' => 772,
757 'height' => 551,
758 ),
759 admin_url( 'plugin-install.php' )
760 ),
761 'btn_text' => __( 'Preview Otter Blocks', 'menu-icons' ),
762 );
763 }
764
765 if ( ! empty( $upsell_notices ) ) {
766 $rand_key = array_rand( $upsell_notices );
767 $menu_upgrade_hestia_box_text = $upsell_notices[ $rand_key ]['content'];
768
769 $box_data .= '<div class="nv-upgrade-notice postbox new-card">';
770 $box_data .= wp_kses_post( wpautop( $menu_upgrade_hestia_box_text ) );
771 $box_data .= '<a class="button" href="' . $upsell_notices[ $rand_key ]['url'] . '" target="_blank">' . $upsell_notices[ $rand_key ]['btn_text'] . '</a>';
772 $box_data .= '</div></div>';
773 }
774 $js_data = apply_filters(
775 'menu_icons_settings_js_data',
776 array(
777 'text' => array(
778 'title' => __( 'Select Icon', 'menu-icons' ),
779 'select' => __( 'Select', 'menu-icons' ),
780 'remove' => __( 'Remove', 'menu-icons' ),
781 'change' => __( 'Change', 'menu-icons' ),
782 'all' => __( 'All', 'menu-icons' ),
783 'preview' => __( 'Preview', 'menu-icons' ),
784 'settingsInfo' => sprintf(
785 '<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 or a plugin such as %3$s if you need to override it.', 'menu-icons' ) . '</p></div>',
786 $box_data,
787 sprintf(
788 '<a href="%s">%s</a>',
789 esc_url( $customizer_url ),
790 esc_html__( 'the customizer', 'menu-icons' )
791 ),
792 '<a target="_blank" href="https://wordpress.org/plugins/advanced-css-editor/">Advanced CSS Editor</a>'
793 ),
794 ),
795 'settingsFields' => self::get_settings_fields(),
796 'activeTypes' => self::get( 'global', 'icon_types' ),
797 'ajaxUrls' => array(
798 'update' => add_query_arg( 'action', 'menu_icons_update_settings', admin_url( '/admin-ajax.php' ) ),
799 ),
800 'menuSettings' => self::get_menu_settings( self::get_current_menu_id() ),
801 )
802 );
803
804 wp_localize_script( 'menu-icons', 'menuIcons', $js_data );
805 }
806 }
807