PluginProbe ʕ •ᴥ•ʔ
Menu Icons by Themeisle – Add Icons to Navigation Menus / 0.11.2
Menu Icons by Themeisle – Add Icons to Navigation Menus v0.11.2
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 8 years ago front.php 8 years ago media-template.php 8 years ago meta.php 8 years ago picker.php 8 years ago settings.php 8 years ago type-fonts.php 8 years ago type.php 8 years ago
settings.php
799 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 /**
59 * Allow themes/plugins to override the default settings
60 *
61 * @since 0.9.0
62 *
63 * @param array $default_settings Default settings.
64 */
65 self::$defaults = apply_filters( 'menu_icons_settings_defaults', self::$defaults );
66
67 self::$settings = get_option( 'menu-icons', self::$defaults );
68
69 foreach ( self::$settings as $key => &$value ) {
70 if ( 'global' === $key ) {
71 // Remove unregistered icon types.
72 $value['icon_types'] = array_values(
73 array_intersect(
74 array_keys( Menu_Icons::get( 'types' ) ),
75 array_filter( (array) $value['icon_types'] )
76 )
77 );
78 } else {
79 // Backward-compatibility.
80 if ( isset( $value['width'] ) && ! isset( $value['svg_width'] ) ) {
81 $value['svg_width'] = $value['width'];
82 }
83
84 unset( $value['width'] );
85 }
86 }
87
88 unset( $value );
89
90 /**
91 * Allow themes/plugins to override the settings
92 *
93 * @since 0.9.0
94 *
95 * @param array $settings Menu Icons settings.
96 */
97 self::$settings = apply_filters( 'menu_icons_settings', self::$settings );
98
99 if ( self::is_menu_icons_disabled_for_menu() ) {
100 return;
101 }
102
103 if ( ! empty( self::$settings['global']['icon_types'] ) ) {
104 require_once Menu_Icons::get( 'dir' ) . 'includes/picker.php';
105 Menu_Icons_Picker::init();
106 self::$script_deps[] = 'icon-picker';
107 }
108
109 add_action( 'load-nav-menus.php', array( __CLASS__, '_load_nav_menus' ), 1 );
110 add_action( 'wp_ajax_menu_icons_update_settings', array( __CLASS__, '_ajax_menu_icons_update_settings' ) );
111 }
112
113 /**
114 * Check if menu icons is disabled for a menu
115 *
116 * @since 0.8.0
117 *
118 * @param int $menu_id Menu ID. Defaults to current menu being edited.
119 *
120 * @return bool
121 */
122 public static function is_menu_icons_disabled_for_menu( $menu_id = 0 ) {
123 if ( empty( $menu_id ) ) {
124 $menu_id = self::get_current_menu_id();
125 }
126
127 // When we're creating a new menu or the recently edited menu
128 // could not be found.
129 if ( empty( $menu_id ) ) {
130 return true;
131 }
132
133 $menu_settings = self::get_menu_settings( $menu_id );
134 $is_disabled = ! empty( $menu_settings['disabled'] );
135
136 return $is_disabled;
137 }
138
139 /**
140 * Get ID of menu being edited
141 *
142 * @since 0.7.0
143 * @since 0.8.0 Get the recently edited menu from user option.
144 *
145 * @return int
146 */
147 public static function get_current_menu_id() {
148 global $nav_menu_selected_id;
149
150 if ( ! empty( $nav_menu_selected_id ) ) {
151 return $nav_menu_selected_id;
152 }
153
154 if ( is_admin() && isset( $_REQUEST['menu'] ) ) {
155 $menu_id = absint( $_REQUEST['menu'] );
156 } else {
157 $menu_id = absint( get_user_option( 'nav_menu_recently_edited' ) );
158 }
159
160 return $menu_id;
161 }
162
163 /**
164 * Get menu settings
165 *
166 * @since 0.3.0
167 *
168 * @param int $menu_id
169 *
170 * @return array
171 */
172 public static function get_menu_settings( $menu_id ) {
173 $menu_settings = self::get( sprintf( 'menu_%d', $menu_id ) );
174 $menu_settings = apply_filters( 'menu_icons_menu_settings', $menu_settings, $menu_id );
175
176 if ( ! is_array( $menu_settings ) ) {
177 $menu_settings = array();
178 }
179
180 return $menu_settings;
181 }
182
183 /**
184 * Get setting value
185 *
186 * @since 0.3.0
187 * @return mixed
188 */
189 public static function get() {
190 $args = func_get_args();
191
192 return kucrut_get_array_value_deep( self::$settings, $args );
193 }
194
195 /**
196 * Prepare wp-admin/nav-menus.php page
197 *
198 * @since 0.3.0
199 * @wp_hook action load-nav-menus.php
200 */
201 public static function _load_nav_menus() {
202 add_action( 'admin_enqueue_scripts', array( __CLASS__, '_enqueue_assets' ), 99 );
203
204 /**
205 * Allow settings meta box to be disabled.
206 *
207 * @since 0.4.0
208 *
209 * @param bool $disabled Defaults to FALSE.
210 */
211 $settings_disabled = apply_filters( 'menu_icons_disable_settings', false );
212 if ( true === $settings_disabled ) {
213 return;
214 }
215
216 self::_maybe_update_settings();
217 self::_add_settings_meta_box();
218
219 add_action( 'admin_notices', array( __CLASS__, '_admin_notices' ) );
220 }
221
222 /**
223 * Update settings
224 *
225 * @since 0.3.0
226 */
227 public static function _maybe_update_settings() {
228 if ( ! empty( $_POST['menu-icons']['settings'] ) ) {
229 check_admin_referer( self::UPDATE_KEY, self::UPDATE_KEY );
230
231 $redirect_url = self::_update_settings( $_POST['menu-icons']['settings'] ); // Input var okay.
232 wp_redirect( $redirect_url );
233 } elseif ( ! empty( $_REQUEST[ self::RESET_KEY ] ) ) {
234 check_admin_referer( self::RESET_KEY, self::RESET_KEY );
235 wp_redirect( self::_reset_settings() );
236 }
237 }
238
239 /**
240 * Update settings
241 *
242 * @since 0.7.0
243 * @access protected
244 *
245 * @param array $values Settings values.
246 *
247 * @return string Redirect URL.
248 */
249 protected static function _update_settings( $values ) {
250 update_option(
251 'menu-icons',
252 wp_parse_args(
253 kucrut_validate( $values ),
254 self::$settings
255 )
256 );
257 set_transient( self::TRANSIENT_KEY, 'updated', 30 );
258
259 $redirect_url = remove_query_arg(
260 array( 'menu-icons-reset' ),
261 wp_get_referer()
262 );
263
264 return $redirect_url;
265 }
266
267 /**
268 * Reset settings
269 *
270 * @since 0.7.0
271 * @access protected
272 * @return string Redirect URL.
273 */
274 protected static function _reset_settings() {
275 delete_option( 'menu-icons' );
276 set_transient( self::TRANSIENT_KEY, 'reset', 30 );
277
278 $redirect_url = remove_query_arg(
279 array( self::RESET_KEY, 'menu-icons-updated' ),
280 wp_get_referer()
281 );
282
283 return $redirect_url;
284 }
285
286 /**
287 * Settings meta box
288 *
289 * @since 0.3.0
290 * @access private
291 */
292 private static function _add_settings_meta_box() {
293 add_meta_box(
294 'menu-icons-settings',
295 __( 'Menu Icons Settings', 'menu-icons' ),
296 array( __CLASS__, '_meta_box' ),
297 'nav-menus',
298 'side',
299 'low',
300 array()
301 );
302 }
303
304 /**
305 * Update settings via ajax
306 *
307 * @since 0.7.0
308 * @wp_hook action wp_ajax_menu_icons_update_settings
309 */
310 public static function _ajax_menu_icons_update_settings() {
311 check_ajax_referer( self::UPDATE_KEY, self::UPDATE_KEY );
312
313 if ( empty( $_POST['menu-icons']['settings'] ) ) {
314 wp_send_json_error();
315 }
316
317 $redirect_url = self::_update_settings( $_POST['menu-icons']['settings'] ); // Input var okay.
318 wp_send_json_success( array( 'redirectUrl' => $redirect_url ) );
319 }
320
321 /**
322 * Print admin notices
323 *
324 * @since 0.3.0
325 * @wp_hook action admin_notices
326 */
327 public static function _admin_notices() {
328 $messages = array(
329 'updated' => __( '<strong>Menu Icons Settings</strong> have been successfully updated.', 'menu-icons' ),
330 'reset' => __( '<strong>Menu Icons Settings</strong> have been successfully reset.', 'menu-icons' ),
331 );
332
333 $message_type = get_transient( self::TRANSIENT_KEY );
334
335 if ( ! empty( $message_type ) && ! empty( $messages[ $message_type ] ) ) {
336 printf(
337 '<div class="updated notice is-dismissible"><p>%s</p></div>',
338 wp_kses( $messages[ $message_type ], array( 'strong' => true ) )
339 );
340 }
341
342 delete_transient( self::TRANSIENT_KEY );
343 }
344
345 /**
346 * Settings meta box
347 *
348 * @since 0.3.0
349 */
350 public static function _meta_box() {
351 ?>
352 <div class="taxonomydiv">
353 <ul id="menu-icons-settings-tabs" class="taxonomy-tabs add-menu-item-tabs hide-if-no-js">
354 <?php foreach ( self::get_fields() as $section ) : ?>
355 <?php
356 printf(
357 '<li><a href="#" title="%s" class="mi-settings-nav-tab" data-type="menu-icons-settings-%s">%s</a></li>',
358 esc_attr( $section['description'] ),
359 esc_attr( $section['id'] ),
360 esc_html( $section['title'] )
361 );
362 ?>
363 <?php endforeach; ?>
364 <?php
365 printf(
366 '<li><a href="#" class="mi-settings-nav-tab" data-type="menu-icons-settings-extensions">%s</a></li>',
367 esc_html__( 'Extensions', 'menu-icons' )
368 );
369 ?>
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 ?>
384 <?php $field->render() ?>
385 </div>
386 <?php endforeach; ?>
387 </div>
388 <?php endforeach; ?>
389 <div id="menu-icons-settings-extensions" class="tabs-panel _extensions">
390 <h4 class="hide-if-js"><?php echo esc_html__( 'Extensions', 'menu-icons' ) ?></h4>
391 <ul>
392 <li><a target="_blank" href="http://wordpress.org/plugins/menu-icons-icomoon/">IcoMoon</a></li>
393 </ul>
394 </div>
395 </div>
396 <p class="submitbox button-controls">
397 <?php wp_nonce_field( self::UPDATE_KEY, self::UPDATE_KEY ) ?>
398 <span class="list-controls">
399 <?php
400 printf(
401 '<a href="%s" title="%s" class="select-all submitdelete">%s</a>',
402 esc_url(
403 wp_nonce_url(
404 admin_url( '/nav-menus.php' ),
405 self::RESET_KEY,
406 self::RESET_KEY
407 )
408 ),
409 esc_attr__( 'Discard all changes and reset to default state', 'menu-icons' ),
410 esc_html__( 'Reset', 'menu-icons' )
411 );
412 ?>
413 </span>
414
415 <span class="add-to-menu">
416 <span class="spinner"></span>
417 <?php
418 submit_button(
419 __( 'Save Settings', 'menu-icons' ),
420 'secondary',
421 'menu-icons-settings-save',
422 false
423 );
424 ?>
425 </span>
426 </p>
427 <?php
428 }
429
430 /**
431 * Get settings sections
432 *
433 * @since 0.3.0
434 * @uses apply_filters() Calls 'menu_icons_settings_sections'.
435 * @return array
436 */
437 public static function get_fields() {
438 $menu_id = self::get_current_menu_id();
439 $icon_types = wp_list_pluck( Menu_Icons::get( 'types' ), 'name' );
440
441 asort( $icon_types );
442
443 $sections = array(
444 'global' => array(
445 'id' => 'global',
446 'title' => __( 'Global', 'menu-icons' ),
447 'description' => __( 'Global settings', 'menu-icons' ),
448 'fields' => array(
449 array(
450 'id' => 'icon_types',
451 'type' => 'checkbox',
452 'label' => __( 'Icon Types', 'menu-icons' ),
453 'choices' => $icon_types,
454 'value' => self::get( 'global', 'icon_types' ),
455 ),
456 ),
457 'args' => array(),
458 ),
459 );
460
461 if ( ! empty( $menu_id ) ) {
462 $menu_term = get_term( $menu_id, 'nav_menu' );
463 $menu_key = sprintf( 'menu_%d', $menu_id );
464 $menu_settings = self::get_menu_settings( $menu_id );
465
466 $sections['menu'] = array(
467 'id' => $menu_key,
468 'title' => __( 'Current Menu', 'menu-icons' ),
469 'description' => sprintf(
470 __( '"%s" menu settings', 'menu-icons' ),
471 apply_filters( 'single_term_title', $menu_term->name )
472 ),
473 'fields' => self::get_settings_fields( $menu_settings ),
474 'args' => array( 'inline_description' => true ),
475 );
476 }
477
478 return apply_filters( 'menu_icons_settings_sections', $sections, $menu_id );
479 }
480
481 /**
482 * Get settings fields
483 *
484 * @since 0.4.0
485 *
486 * @param array $values Values to be applied to each field.
487 *
488 * @uses apply_filters() Calls 'menu_icons_settings_fields'.
489 * @return array
490 */
491 public static function get_settings_fields( array $values = array() ) {
492 $fields = array(
493 'hide_label' => array(
494 'id' => 'hide_label',
495 'type' => 'select',
496 'label' => __( 'Hide Label', 'menu-icons' ),
497 'default' => '',
498 'choices' => array(
499 array(
500 'value' => '',
501 'label' => __( 'No', 'menu-icons' ),
502 ),
503 array(
504 'value' => '1',
505 'label' => __( 'Yes', 'menu-icons' ),
506 ),
507 ),
508 ),
509 'position' => array(
510 'id' => 'position',
511 'type' => 'select',
512 'label' => __( 'Position', 'menu-icons' ),
513 'default' => 'before',
514 'choices' => array(
515 array(
516 'value' => 'before',
517 'label' => __( 'Before', 'menu-icons' ),
518 ),
519 array(
520 'value' => 'after',
521 'label' => __( 'After', 'menu-icons' ),
522 ),
523 ),
524 ),
525 'vertical_align' => array(
526 'id' => 'vertical_align',
527 'type' => 'select',
528 'label' => __( 'Vertical Align', 'menu-icons' ),
529 'default' => 'middle',
530 'choices' => array(
531 array(
532 'value' => 'super',
533 'label' => __( 'Super', 'menu-icons' ),
534 ),
535 array(
536 'value' => 'top',
537 'label' => __( 'Top', 'menu-icons' ),
538 ),
539 array(
540 'value' => 'text-top',
541 'label' => __( 'Text Top', 'menu-icons' ),
542 ),
543 array(
544 'value' => 'middle',
545 'label' => __( 'Middle', 'menu-icons' ),
546 ),
547 array(
548 'value' => 'baseline',
549 'label' => __( 'Baseline', 'menu-icons' ),
550 ),
551 array(
552 'value' => 'text-bottom',
553 'label' => __( 'Text Bottom', 'menu-icons' ),
554 ),
555 array(
556 'value' => 'bottom',
557 'label' => __( 'Bottom', 'menu-icons' ),
558 ),
559 array(
560 'value' => 'sub',
561 'label' => __( 'Sub', 'menu-icons' ),
562 ),
563 ),
564 ),
565 'font_size' => array(
566 'id' => 'font_size',
567 'type' => 'number',
568 'label' => __( 'Font Size', 'menu-icons' ),
569 'default' => '1.2',
570 'description' => 'em',
571 'attributes' => array(
572 'min' => '0.1',
573 'step' => '0.1',
574 ),
575 ),
576 'svg_width' => array(
577 'id' => 'svg_width',
578 'type' => 'number',
579 'label' => __( 'SVG Width', 'menu-icons' ),
580 'default' => '1',
581 'description' => 'em',
582 'attributes' => array(
583 'min' => '.5',
584 'step' => '.1',
585 ),
586 ),
587 'image_size' => array(
588 'id' => 'image_size',
589 'type' => 'select',
590 'label' => __( 'Image Size', 'menu-icons' ),
591 'default' => 'thumbnail',
592 'choices' => kucrut_get_image_sizes(),
593 ),
594 );
595
596 $fields = apply_filters( 'menu_icons_settings_fields', $fields );
597
598 foreach ( $fields as &$field ) {
599 if ( isset( $values[ $field['id'] ] ) ) {
600 $field['value'] = $values[ $field['id'] ];
601 }
602
603 if ( ! isset( $field['value'] ) && isset( $field['default'] ) ) {
604 $field['value'] = $field['default'];
605 }
606 }
607
608 unset( $field );
609
610 return $fields;
611 }
612
613 /**
614 * Get processed settings fields
615 *
616 * @since 0.3.0
617 * @access private
618 * @return array
619 */
620 private static function _get_fields() {
621 if ( ! class_exists( 'Kucrut_Form_Field' ) ) {
622 require_once Menu_Icons::get( 'dir' ) . 'includes/library/form-fields.php';
623 }
624
625 $keys = array( 'menu-icons', 'settings' );
626 $sections = self::get_fields();
627
628 foreach ( $sections as &$section ) {
629 $_keys = array_merge( $keys, array( $section['id'] ) );
630 $_args = array_merge( array( 'keys' => $_keys ), $section['args'] );
631
632 foreach ( $section['fields'] as &$field ) {
633 $field = Kucrut_Form_Field::create( $field, $_args );
634 }
635
636 unset( $field );
637 }
638
639 unset( $section );
640
641 return $sections;
642 }
643
644 /**
645 * Enqueue scripts & styles for Appearance > Menus page
646 *
647 * @since 0.3.0
648 * @wp_hook action admin_enqueue_scripts
649 */
650 public static function _enqueue_assets() {
651 $url = Menu_Icons::get( 'url' );
652 $suffix = kucrut_get_script_suffix();
653
654 if ( defined( 'MENU_ICONS_SCRIPT_DEBUG' ) && MENU_ICONS_SCRIPT_DEBUG ) {
655 $script_url = '//localhost:8081/';
656 } else {
657 $script_url = $url;
658 }
659
660 wp_enqueue_style(
661 'menu-icons',
662 "{$url}css/admin{$suffix}.css",
663 false,
664 Menu_Icons::VERSION
665 );
666
667 wp_enqueue_script(
668 'menu-icons',
669 "{$script_url}js/admin{$suffix}.js",
670 self::$script_deps,
671 Menu_Icons::VERSION,
672 true
673 );
674
675 $customizer_url = add_query_arg(
676 array(
677 'autofocus[section]' => 'custom_css',
678 'return' => admin_url( 'nav-menus.php' ),
679 ),
680 admin_url( 'customize.php' )
681 );
682
683 /**
684 * Allow plugins/themes to filter the settings' JS data
685 *
686 * @since 0.9.0
687 *
688 * @param array $js_data JS Data.
689 */
690 $menu_current_theme = '';
691 $theme = wp_get_theme();
692 if ( ! empty( $theme ) ) {
693 if ( is_child_theme() ) {
694 $menu_current_theme = $theme->parent()->get( 'Name' );
695 } else {
696 $menu_current_theme = $theme->get( 'Name' );
697 }
698 }
699 $box_data = '<div id="menu-icons-sidebar">';
700 if ( ( $menu_current_theme != 'Hestia' ) && ( $menu_current_theme != 'Hestia Pro' ) ) {
701
702 $menu_upgrade_hestia_box_text = 'Check-out our latest FREE multi-purpose theme: <strong>Hestia</strong>';
703
704 if ( $menu_current_theme == 'Zerif Lite' ) {
705 $menu_upgrade_hestia_box_text = 'Check-out our latest FREE multi-purpose theme: <strong>Hestia</strong>, your Zerif Lite content will be imported automatically! ';
706 }
707
708 $menu_upgrade_hestia_url = add_query_arg(
709 array(
710 'theme' => 'hestia',
711 ), admin_url( 'theme-install.php' )
712 );
713 $box_data .= '<div class="menu-icons-upgrade-hestia postbox new-card">';
714 $box_data .= '<p>' . wp_kses_post( $menu_upgrade_hestia_box_text ) . '</p>';
715 $box_data .= '<a class="button" href="' . $menu_upgrade_hestia_url . '" target="_blank">Preview Hestia</a>';
716 $box_data .= '</div>';
717 }
718
719 if ( ! empty( $_POST['menu_icons_mail'] ) ) {
720 require( plugin_dir_path( __DIR__ ) . 'mailin.php' );
721 $user_info = get_userdata( 1 );
722 $mailin = new Mailin( 'https://api.sendinblue.com/v2.0', 'cHW5sxZnzE7mhaYb' );
723 $data = array(
724 'email' => $_POST['menu_icons_mail'],
725 'attributes' => array(
726 'NAME' => $user_info->first_name,
727 'SURNAME' => $user_info->last_name,
728 ),
729 'blacklisted' => 0,
730 'listid' => array( 145 ),
731 'blacklisted_sms' => 0,
732 );
733 $status = $mailin->create_update_user( $data );
734 if ( $status['code'] == 'success' ) {
735 update_option( 'menu_icons_subscribe', true );
736 }
737 }
738 $email_output = '<div class="menu-icons-subscribe postbox new-card">';
739 $email_output .= '<h3 class="title">' . esc_html__( 'Get Our Free Email Course', 'menu-icons' ) . '</h3>';
740 $email_output .= '<div id="formdata"><p>' . esc_html__( 'Ready to learn how to reduce your website loading times by half? Come and join the 1st lesson here!', 'menu-icons' ) . ' </p><form class="menu-icons-submit-mail" method="post"><input name="menu_icons_mail" type="email" value="' . get_option( 'admin_email' ) . '" /><input id="ebutton" class="button" type="submit" value="Submit"></form></div>';
741 $email_output .= '<p id="success">' . esc_html__( 'Thank you for subscribing! You have been added to the mailing list and will receive the next email information in the coming weeks. If you ever wish to unsubscribe, simply use the "Unsubscribe" link included in each newsletter.', 'menu-icons' ) . '</p>';
742 $email_output .= '<p id="failiure">' . esc_html__( 'Unable to Subscribe.', 'menu-icons' ) . '</p>';
743 $email_output .= '</div>';
744 $email_output .= '</div>';
745 $email_output .= '<script>';
746 $email_output .= '$( \'#failiure\' ).hide();';
747 $email_output .= '$( \'#success\' ).hide();';
748 $email_output .= '$( \'form.menu-icons-submit-mail\' ).submit(function(event) {';
749 $email_output .= 'event.preventDefault();';
750 $email_output .= '$.ajax({';
751 $email_output .= 'type: \'POST\',';
752 $email_output .= 'data: $( \'form.menu-icons-submit-mail\' ).serialize(),';
753 $email_output .= 'success: function(result) {';
754 $email_output .= '$( \'#formdata\' ).hide();';
755 $email_output .= '$( \'#success\' ).show();';
756 $email_output .= '},';
757 $email_output .= 'error: function(result) { $( \'#failiure\' ).show(); }';
758 $email_output .= '}); });';
759 $email_output .= '</script>';
760 $shown = (bool) get_option( 'menu_icons_subscribe', false );
761
762 if ( $shown === true ) {
763 $email_output = '';
764 }
765 $box_data .= $email_output;
766 $js_data = apply_filters(
767 'menu_icons_settings_js_data',
768 array(
769 'text' => array(
770 'title' => __( 'Select Icon', 'menu-icons' ),
771 'select' => __( 'Select', 'menu-icons' ),
772 'remove' => __( 'Remove', 'menu-icons' ),
773 'change' => __( 'Change', 'menu-icons' ),
774 'all' => __( 'All', 'menu-icons' ),
775 'preview' => __( 'Preview', 'menu-icons' ),
776 'settingsInfo' => sprintf(
777 '<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>',
778 $box_data,
779 sprintf(
780 '<a href="%s">%s</a>',
781 esc_url( $customizer_url ),
782 esc_html__( 'the customizer', 'menu-icons' )
783 ),
784 '<a target="_blank" href="https://wordpress.org/plugins/advanced-css-editor/">Advanced CSS Editor</a>'
785 ),
786 ),
787 'settingsFields' => self::get_settings_fields(),
788 'activeTypes' => self::get( 'global', 'icon_types' ),
789 'ajaxUrls' => array(
790 'update' => add_query_arg( 'action', 'menu_icons_update_settings', admin_url( '/admin-ajax.php' ) ),
791 ),
792 'menuSettings' => self::get_menu_settings( self::get_current_menu_id() ),
793 )
794 );
795
796 wp_localize_script( 'menu-icons', 'menuIcons', $js_data );
797 }
798 }
799