PluginProbe
QuadMenu – Mega Menu / 3.3.8
QuadMenu – Mega Menu v3.3.8
3.3.8 3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 88 releases
quadmenu / lib / frontend / walker / class-quadmenu-item-search.php

class-quadmenu-item-search.php in QuadMenu – Mega Menu 3.3.8, at lib/frontend/walker/class-quadmenu-item-search.php

84 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace QuadLayers\QuadMenu\Frontend\Walker;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 die( '-1' );
6 }
7 use QuadLayers\QuadMenu\Frontend\Walker\QuadMenu_Item;
8
9 /**
10 * QuadMenuItemSearch Class
11 */
12 class QuadMenu_Item_Search extends QuadMenu_Item {
13
14 protected $type = 'search';
15 public $instance = 0;
16 protected $has_placeholder = false;
17
18 function init() {
19 $this->item->url = '';
20 $this->item->title = '';
21 $this->has_children = false;
22 $this->has_placeholder = (bool) $this->item->placeholder;
23
24 $this->item->placeholder = $this->has_placeholder ? $this->item->placeholder : esc_html__( 'Search', 'quadmenu' );
25 }
26
27 function get_start_el() {
28
29 $item_output = '';
30
31 $this->add_item_classes();
32
33 $this->add_item_classes_prefix();
34
35 $this->add_item_classes_quadmenu();
36
37 $id = $this->get_item_id();
38
39 $class = $this->get_item_classes();
40
41 $item_output .= '<li' . $id . $class . '>';
42
43 $this->add_link_atts();
44
45 $this->add_link_atts_toggle();
46
47 $item_output .= $this->form();
48
49 return $item_output;
50 }
51
52 function get_search_toggle() {
53 $item_output = $this->get_link();
54 $item_output .= $this->get_dropdown_wrap_start();
55 $item_output .= $this->get_search_embed();
56 $item_output .= $this->get_dropdown_wrap_end();
57 return $item_output;
58 }
59
60 function form() {
61
62 $this->instance = rand();
63
64 ob_start();
65 ?>
66 <form role="search" method="get" id="searchform_<?php echo esc_attr( $this->instance ); ?>" action="<?php echo esc_url( quadmenu_get_translated_home_url( '/' ) ); ?>">
67 <span class="quadmenu-item-content">
68 <?php echo $this->get_icon(); ?>
69 <input type="text" id="s_<?php echo esc_attr( $this->instance ); ?>" name="s" value="<?php echo esc_attr( get_search_query() ); ?>" placeholder="<?php echo esc_html( $this->item->placeholder ); ?>" />
70 <?php
71 foreach ( (array) $this->item->search as $search ) :
72 if ( $search != '' ) :
73 ?>
74 <input type="hidden" name="post_type" value="<?php echo esc_attr( $search ); ?>">
75 <?php
76 endif;
77 endforeach;
78 ?>
79 </form>
80 <?php
81 return ob_get_clean();
82 }
83 }
84