Ivory Search – WordPress Search Plugin - Version 3.0

Version Description

  • Added plugin options Search Post Types, Google CSE, Mobile Display and Custom CSS
  • Styled it for default WordPress themes

=

Download this release

Release Info

Developer vinod dalvi
Plugin Icon 128x128 Ivory Search – WordPress Search Plugin
Version 3.0
Comparing to
See all releases

Code changes from version 2.0 to 3.0

add-search-to-menu.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Add Search To Menu
4
  Plugin URI: http://freewptp.com/plugins/add-search-to-menu/
5
  Description: The plugin displays search form in the navigation bar which can be configured from the admin area.
6
- Version: 2.0
7
  Author: Vinod Dalvi
8
  Author URI: http://freewptp.com
9
  License: GPL-2.0+
@@ -25,12 +25,6 @@ You should have received a copy of the GNU General Public License
25
  along with Add Search To Menu plugin. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
26
  */
27
 
28
- /**
29
- * Changelog :
30
- * 1.0 - Intial release.
31
- * 2.0 - Resolved scrolling issue in fixed menu and made magnifying glass icon resizable.
32
- */
33
-
34
  /**
35
  * The file responsible for starting the Add Search To Menu plugin
36
  *
3
  Plugin Name: Add Search To Menu
4
  Plugin URI: http://freewptp.com/plugins/add-search-to-menu/
5
  Description: The plugin displays search form in the navigation bar which can be configured from the admin area.
6
+ Version: 3.0
7
  Author: Vinod Dalvi
8
  Author URI: http://freewptp.com
9
  License: GPL-2.0+
25
  along with Add Search To Menu plugin. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
26
  */
27
 
 
 
 
 
 
 
28
  /**
29
  * The file responsible for starting the Add Search To Menu plugin
30
  *
admin/class-add-search-to-menu-admin.php CHANGED
@@ -153,9 +153,13 @@ class Add_Search_To_Menu_Admin {
153
  add_settings_section( 'add_search_to_menu_section', __( 'Add Search To Menu Settings', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_section_desc'), 'add_search_to_menu' );
154
 
155
  add_settings_field( 'add_search_to_menu_locations', __( 'Add Search to Menu : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_locations' ), 'add_search_to_menu', 'add_search_to_menu_section' );
156
- add_settings_field( 'add_search_to_menu_style', __( 'Select Style : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_style' ), 'add_search_to_menu', 'add_search_to_menu_section' );
 
157
  add_settings_field( 'add_search_to_menu_title', __( 'Search Menu Title : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_title' ), 'add_search_to_menu', 'add_search_to_menu_section' );
158
  add_settings_field( 'add_search_to_menu_classes', __( 'Search Menu Classes : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_classes' ), 'add_search_to_menu', 'add_search_to_menu_section' );
 
 
 
159
  add_settings_field( 'do_not_load_plugin_files', __( 'Do not load plugin files : ', 'add-search-to-menu' ), array( $this, 'do_not_load_plugin_files' ), 'add_search_to_menu', 'add_search_to_menu_section' );
160
 
161
  register_setting( 'add_search_to_menu', 'add_search_to_menu' );
@@ -176,7 +180,7 @@ class Add_Search_To_Menu_Admin {
176
 
177
  if ( ! empty( $menus ) ){
178
 
179
- if ( empty( $options ) ){
180
  $location = array_keys( $menus );
181
  $options['add_search_to_menu_locations'][ $location[0] ] = $location[0];
182
 
@@ -203,7 +207,50 @@ class Add_Search_To_Menu_Admin {
203
 
204
  }
205
 
206
- /* add search to menu select style field output */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  function add_search_to_menu_style() {
208
 
209
  $options = $this->options;
@@ -244,8 +291,39 @@ class Add_Search_To_Menu_Admin {
244
  function add_search_to_menu_classes() {
245
 
246
  $options = $this->options;
247
- $options['add_search_to_menu_classes'] = isset( $options['add_search_to_menu_classes'] ) ? $options['add_search_to_menu_classes'] : 'search-menu';
248
  $html = '<input type="text" id="add_search_to_menu_classes" name="add_search_to_menu[add_search_to_menu_classes]" value="' . esc_attr( $options['add_search_to_menu_classes'] ) . '" size="50" />';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  echo $html;
250
  }
251
 
153
  add_settings_section( 'add_search_to_menu_section', __( 'Add Search To Menu Settings', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_section_desc'), 'add_search_to_menu' );
154
 
155
  add_settings_field( 'add_search_to_menu_locations', __( 'Add Search to Menu : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_locations' ), 'add_search_to_menu', 'add_search_to_menu_section' );
156
+ add_settings_field( 'add_search_to_menu_posts', __( 'Search Post Types : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_posts' ), 'add_search_to_menu', 'add_search_to_menu_section' );
157
+ add_settings_field( 'add_search_to_menu_style', __( 'Search Form Style : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_style' ), 'add_search_to_menu', 'add_search_to_menu_section' );
158
  add_settings_field( 'add_search_to_menu_title', __( 'Search Menu Title : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_title' ), 'add_search_to_menu', 'add_search_to_menu_section' );
159
  add_settings_field( 'add_search_to_menu_classes', __( 'Search Menu Classes : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_classes' ), 'add_search_to_menu', 'add_search_to_menu_section' );
160
+ add_settings_field( 'add_search_to_menu_gcse', __( 'Google CSE : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_gcse' ), 'add_search_to_menu', 'add_search_to_menu_section' );
161
+ add_settings_field( 'add_search_to_menu_display_in_header', __( 'Mobile Display : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_display_in_header' ), 'add_search_to_menu', 'add_search_to_menu_section' );
162
+ add_settings_field( 'add_search_to_menu_css', __( 'Custom CSS : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_css' ), 'add_search_to_menu', 'add_search_to_menu_section' );
163
  add_settings_field( 'do_not_load_plugin_files', __( 'Do not load plugin files : ', 'add-search-to-menu' ), array( $this, 'do_not_load_plugin_files' ), 'add_search_to_menu', 'add_search_to_menu_section' );
164
 
165
  register_setting( 'add_search_to_menu', 'add_search_to_menu' );
180
 
181
  if ( ! empty( $menus ) ){
182
 
183
+ if ( empty( $options ) || ! isset( $options['add_search_to_menu_locations'] ) ){
184
  $location = array_keys( $menus );
185
  $options['add_search_to_menu_locations'][ $location[0] ] = $location[0];
186
 
207
 
208
  }
209
 
210
+ /* add search to menu choose post types field output */
211
+ function add_search_to_menu_posts() {
212
+
213
+ $options = $this->options;
214
+ $html = '';
215
+ $args = array( 'exclude_from_search' => false );
216
+
217
+ $posts = get_post_types( $args );
218
+
219
+ if ( ! empty( $posts ) ){
220
+
221
+ if ( empty( $options ) || ! isset( $options['add_search_to_menu_posts'] ) ){
222
+ $post_keys = array_keys( $posts );
223
+
224
+ foreach ( $post_keys as $post_key ) {
225
+ $options['add_search_to_menu_posts'][ $post_key ] = $post_key;
226
+ }
227
+
228
+ update_option( 'add_search_to_menu', $options );
229
+ }
230
+
231
+ if ( isset( $options['add_search_to_menu_posts']['initial'] ) ){
232
+ unset( $options['add_search_to_menu_posts']['initial'] );
233
+ $post_keys = array_keys( $posts );
234
+ foreach ( $post_keys as $post_key ) {
235
+ $options['add_search_to_menu_posts'][ $post_key ] = $post_key;
236
+ }
237
+ update_option( 'add_search_to_menu', $options );
238
+ }
239
+
240
+ foreach ( $posts as $key => $post ) {
241
+
242
+ $check_value = isset( $options['add_search_to_menu_posts'][$key] ) ? $options['add_search_to_menu_posts'][ $key ] : 0;
243
+ $html .= '<input type="checkbox" id="add_search_to_menu_posts' . esc_attr( $key ) . '" name="add_search_to_menu[add_search_to_menu_posts][' . esc_attr( $key ) . ']" value="' . esc_attr( $key ) . '" ' . checked( $key, $check_value, false ) . '/>';
244
+ $html .= '<label for="add_search_to_menu_posts' . esc_attr( $key ) . '"> ' . esc_html( $post ) . '</label><br />';
245
+ }
246
+ } else {
247
+ $html = __( 'No post types registered on your site.', 'add-search-to-menu' );
248
+ }
249
+ echo $html;
250
+
251
+ }
252
+
253
+ /* add search to menu search form style field output */
254
  function add_search_to_menu_style() {
255
 
256
  $options = $this->options;
291
  function add_search_to_menu_classes() {
292
 
293
  $options = $this->options;
294
+ $options['add_search_to_menu_classes'] = isset( $options['add_search_to_menu_classes'] ) ? $options['add_search_to_menu_classes'] : 'astm-search-menu';
295
  $html = '<input type="text" id="add_search_to_menu_classes" name="add_search_to_menu[add_search_to_menu_classes]" value="' . esc_attr( $options['add_search_to_menu_classes'] ) . '" size="50" />';
296
+ $html .= '<br /><label for="add_search_to_menu_classes" style="font-size: 10px;">' . esc_html__( "Add classes seperated by space.", 'add-search-to-menu' ) . '</label>';
297
+ echo $html;
298
+ }
299
+
300
+ /* add search to menu google cse field output */
301
+ function add_search_to_menu_gcse() {
302
+
303
+ $options = $this->options;
304
+ $options['add_search_to_menu_gcse'] = isset( $options['add_search_to_menu_gcse'] ) ? $options['add_search_to_menu_gcse'] : '';
305
+ $html = '<input type="text" id="add_search_to_menu_gcse" name="add_search_to_menu[add_search_to_menu_gcse]" value="' . esc_attr( $options['add_search_to_menu_gcse'] ) . '" size="50" />';
306
+ $html .= '<br /><label for="add_search_to_menu_gcse" style="font-size: 10px;">' . esc_html__( "Add only Google CSE search form code in the above text box that will replace default search form.", 'add-search-to-menu' ) . '</label>';
307
+ echo $html;
308
+ }
309
+
310
+ /* add search to menu display in header field output */
311
+ function add_search_to_menu_display_in_header() {
312
+
313
+ $options = $this->options;
314
+ $check_value = isset( $options['add_search_to_menu_display_in_header'] ) ? $options['add_search_to_menu_display_in_header'] : 0;
315
+ $html = '<input type="checkbox" id="add_search_to_menu_display_in_header" name="add_search_to_menu[add_search_to_menu_display_in_header]" value="add_search_to_menu_display_in_header" ' . checked( 'add_search_to_menu_display_in_header', $check_value, false ) . ' />';
316
+ $html .= '<label for="add_search_to_menu_display_in_header"> ' . esc_html__( 'Display Search Form in Header on Mobile Devices', 'add-search-to-menu' ) . '</label>';
317
+ echo $html;
318
+ }
319
+
320
+ /* add search to menu custom css field output */
321
+ function add_search_to_menu_css() {
322
+
323
+ $options = $this->options;
324
+ $options['add_search_to_menu_css'] = isset( $options['add_search_to_menu_css'] ) ? $options['add_search_to_menu_css'] : '';
325
+ $html = '<textarea rows="4" cols="53" id="add_search_to_menu_css" name="add_search_to_menu[add_search_to_menu_css]" >' . esc_attr( $options['add_search_to_menu_css'] ) . '</textarea>';
326
+ $html .= '<br /><label for="add_search_to_menu_css" style="font-size: 10px;">' . esc_html__( "Add custom css code if any to style search form.", 'add-search-to-menu' ) . '</label>';
327
  echo $html;
328
  }
329
 
includes/class-add-search-to-menu-activator.php CHANGED
@@ -28,6 +28,11 @@ class Add_Search_To_Menu_Activator {
28
  $options['add_search_to_menu_locations']['initial'] = 'initial';
29
  update_option( 'add_search_to_menu', $options );
30
  }
 
 
 
 
 
31
  }
32
 
33
  }
28
  $options['add_search_to_menu_locations']['initial'] = 'initial';
29
  update_option( 'add_search_to_menu', $options );
30
  }
31
+
32
+ if ( ! isset( $options['add_search_to_menu_posts'] ) ) {
33
+ $options['add_search_to_menu_posts']['initial'] = 'initial';
34
+ update_option( 'add_search_to_menu', $options );
35
+ }
36
  }
37
 
38
  }
includes/class-add-search-to-menu.php CHANGED
@@ -187,7 +187,21 @@ class Add_Search_To_Menu {
187
 
188
  $public = new Add_Search_To_Menu_Public( $this->get_version() );
189
  $this->loader->add_action( 'wp_enqueue_scripts', $public, 'add_search_to_menu_script_style' );
190
- $this->loader->add_filter( 'wp_nav_menu_items', $public, 'add_search_to_menu_items', 99, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  }
192
 
193
  /**
187
 
188
  $public = new Add_Search_To_Menu_Public( $this->get_version() );
189
  $this->loader->add_action( 'wp_enqueue_scripts', $public, 'add_search_to_menu_script_style' );
190
+ $options = $this->options;
191
+ $display_in_header = isset( $options['add_search_to_menu_display_in_header'] ) ? $options['add_search_to_menu_display_in_header'] : 0;
192
+ $display_in_mobile_menu = $display_in_header && wp_is_mobile() ? true : false;
193
+
194
+ if ( $display_in_mobile_menu ) {
195
+ $this->loader->add_filter( 'wp_head', $public, 'add_search_to_menu_in_header', 99 );
196
+ } else {
197
+ $this->loader->add_filter( 'wp_nav_menu_items', $public, 'add_search_to_menu_items', 99, 2 );
198
+ }
199
+
200
+ if ( ! isset( $options['add_search_to_menu_gcse'] ) || $options['add_search_to_menu_gcse'] == '' ) {
201
+ $this->loader-> add_action( 'pre_get_posts', $public, 'add_search_to_menu_search_filter' );
202
+ }
203
+
204
+ $this->loader-> add_action( 'wp_footer', $public, 'add_search_to_menu_css' );
205
  }
206
 
207
  /**
languages/default.po CHANGED
@@ -1,15 +1,15 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Add Search To Menu\n"
4
- "POT-Creation-Date: 2017-04-07 20:22+0530\n"
5
- "PO-Revision-Date: 2017-04-07 20:22+0530\n"
6
  "Last-Translator: \n"
7
  "Language-Team: Free WP TP <freewptp@gmail.com>\n"
8
  "Language: en_US\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.5.4\n"
13
  "X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e;esc_html_e;esc_html__\n"
14
  "X-Poedit-Basepath: .\n"
15
  "X-Poedit-SearchPath-0: ..\n"
@@ -77,66 +77,104 @@ msgid "Add Search to Menu : "
77
  msgstr ""
78
 
79
  #: ../admin/class-add-search-to-menu-admin.php:156
80
- msgid "Select Style : "
81
  msgstr ""
82
 
83
  #: ../admin/class-add-search-to-menu-admin.php:157
84
- msgid "Search Menu Title : "
85
  msgstr ""
86
 
87
  #: ../admin/class-add-search-to-menu-admin.php:158
88
- msgid "Search Menu Classes : "
89
  msgstr ""
90
 
91
  #: ../admin/class-add-search-to-menu-admin.php:159
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  msgid "Do not load plugin files : "
93
  msgstr ""
94
 
95
- #: ../admin/class-add-search-to-menu-admin.php:167
96
  msgid "Configure the Add Search To Menu plugin settings here."
97
  msgstr ""
98
 
99
- #: ../admin/class-add-search-to-menu-admin.php:200
100
  msgid "No navigation menu registered on your site."
101
  msgstr ""
102
 
103
- #: ../admin/class-add-search-to-menu-admin.php:211
 
 
 
 
104
  msgid "Default"
105
  msgstr ""
106
 
107
- #: ../admin/class-add-search-to-menu-admin.php:212
108
  msgid "Dropdown"
109
  msgstr ""
110
 
111
- #: ../admin/class-add-search-to-menu-admin.php:213
112
  msgid "Sliding"
113
  msgstr ""
114
 
115
- #: ../admin/class-add-search-to-menu-admin.php:214
116
  msgid "Full Width"
117
  msgstr ""
118
 
119
- #: ../admin/class-add-search-to-menu-admin.php:239
120
  msgid ""
121
  "If title field is not set then instead of title the search icon displays in "
122
  "navigation menu."
123
  msgstr ""
124
 
125
- #: ../admin/class-add-search-to-menu-admin.php:257
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  msgid "Plugin CSS File"
127
  msgstr ""
128
 
129
- #: ../admin/class-add-search-to-menu-admin.php:258
130
  msgid "Plugin JavaScript File"
131
  msgstr ""
132
 
133
- #: ../admin/class-add-search-to-menu-admin.php:271
134
  msgid ""
135
  "If checked, you have to add following plugin file code into your theme CSS "
136
  "file."
137
  msgstr ""
138
 
139
- #: ../admin/class-add-search-to-menu-admin.php:275
140
  msgid ""
141
  "If checked, you have to add following plugin file code into your theme "
142
  "JavaScript file."
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Add Search To Menu\n"
4
+ "POT-Creation-Date: 2017-08-03 18:17+0530\n"
5
+ "PO-Revision-Date: 2017-08-03 18:17+0530\n"
6
  "Last-Translator: \n"
7
  "Language-Team: Free WP TP <freewptp@gmail.com>\n"
8
  "Language: en_US\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.7.1\n"
13
  "X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e;esc_html_e;esc_html__\n"
14
  "X-Poedit-Basepath: .\n"
15
  "X-Poedit-SearchPath-0: ..\n"
77
  msgstr ""
78
 
79
  #: ../admin/class-add-search-to-menu-admin.php:156
80
+ msgid "Search Post Types : "
81
  msgstr ""
82
 
83
  #: ../admin/class-add-search-to-menu-admin.php:157
84
+ msgid "Search Form Style : "
85
  msgstr ""
86
 
87
  #: ../admin/class-add-search-to-menu-admin.php:158
88
+ msgid "Search Menu Title : "
89
  msgstr ""
90
 
91
  #: ../admin/class-add-search-to-menu-admin.php:159
92
+ msgid "Search Menu Classes : "
93
+ msgstr ""
94
+
95
+ #: ../admin/class-add-search-to-menu-admin.php:160
96
+ msgid "Google CSE : "
97
+ msgstr ""
98
+
99
+ #: ../admin/class-add-search-to-menu-admin.php:161
100
+ msgid "Mobile Display : "
101
+ msgstr ""
102
+
103
+ #: ../admin/class-add-search-to-menu-admin.php:162
104
+ msgid "Custom CSS : "
105
+ msgstr ""
106
+
107
+ #: ../admin/class-add-search-to-menu-admin.php:163
108
  msgid "Do not load plugin files : "
109
  msgstr ""
110
 
111
+ #: ../admin/class-add-search-to-menu-admin.php:171
112
  msgid "Configure the Add Search To Menu plugin settings here."
113
  msgstr ""
114
 
115
+ #: ../admin/class-add-search-to-menu-admin.php:204
116
  msgid "No navigation menu registered on your site."
117
  msgstr ""
118
 
119
+ #: ../admin/class-add-search-to-menu-admin.php:247
120
+ msgid "No post types registered on your site."
121
+ msgstr ""
122
+
123
+ #: ../admin/class-add-search-to-menu-admin.php:258
124
  msgid "Default"
125
  msgstr ""
126
 
127
+ #: ../admin/class-add-search-to-menu-admin.php:259
128
  msgid "Dropdown"
129
  msgstr ""
130
 
131
+ #: ../admin/class-add-search-to-menu-admin.php:260
132
  msgid "Sliding"
133
  msgstr ""
134
 
135
+ #: ../admin/class-add-search-to-menu-admin.php:261
136
  msgid "Full Width"
137
  msgstr ""
138
 
139
+ #: ../admin/class-add-search-to-menu-admin.php:286
140
  msgid ""
141
  "If title field is not set then instead of title the search icon displays in "
142
  "navigation menu."
143
  msgstr ""
144
 
145
+ #: ../admin/class-add-search-to-menu-admin.php:296
146
+ msgid "Add classes seperated by space."
147
+ msgstr ""
148
+
149
+ #: ../admin/class-add-search-to-menu-admin.php:306
150
+ msgid ""
151
+ "Add only Google CSE search form code in the above text box that will replace "
152
+ "default search form."
153
+ msgstr ""
154
+
155
+ #: ../admin/class-add-search-to-menu-admin.php:316
156
+ msgid "Display Search Form in Header on Mobile Devices"
157
+ msgstr ""
158
+
159
+ #: ../admin/class-add-search-to-menu-admin.php:326
160
+ msgid "Add custom css code if any to style search form."
161
+ msgstr ""
162
+
163
+ #: ../admin/class-add-search-to-menu-admin.php:335
164
  msgid "Plugin CSS File"
165
  msgstr ""
166
 
167
+ #: ../admin/class-add-search-to-menu-admin.php:336
168
  msgid "Plugin JavaScript File"
169
  msgstr ""
170
 
171
+ #: ../admin/class-add-search-to-menu-admin.php:349
172
  msgid ""
173
  "If checked, you have to add following plugin file code into your theme CSS "
174
  "file."
175
  msgstr ""
176
 
177
+ #: ../admin/class-add-search-to-menu-admin.php:353
178
  msgid ""
179
  "If checked, you have to add following plugin file code into your theme "
180
  "JavaScript file."
public/class-add-search-to-menu-public.php CHANGED
@@ -58,7 +58,7 @@ class Add_Search_To_Menu_Public {
58
  }
59
 
60
  /* Adds search in the navigation bar in the front end of site */
61
- function add_search_to_menu_items( $items, $args ){
62
 
63
  $options = $this->options;
64
 
@@ -72,25 +72,106 @@ class Add_Search_To_Menu_Public {
72
 
73
  if ( isset( $options['add_search_to_menu_locations'][$args->theme_location] ) ) {
74
 
75
- $search_class = isset( $options['add_search_to_menu_classes'] ) ? $options['add_search_to_menu_classes'].' search-menu ' : 'search-menu ';
76
- $search_class .= isset( $options['add_search_to_menu_style'] ) ? $options['add_search_to_menu_style'] : 'default';
77
- $title = isset( $options['add_search_to_menu_title'] ) ? $options['add_search_to_menu_title'] : '';
78
- $items .= '<li class="' . esc_attr( $search_class ) . '"><a title="' . esc_attr( $title ) . '" href="#">';
79
-
80
- if ( $options['add_search_to_menu_style'] != 'default' ){
81
- if ( $title == '' ) {
82
- $items .= '<svg width="20" height="20" class="search-icon" role="img" viewBox="2 9 20 5">
83
- <path class="search-icon-path" d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path></svg>';
84
- } else {
85
- $items .= $title;
 
 
 
 
 
 
 
 
86
  }
 
87
  }
88
- $items .= '</a>' . get_search_form( false ) . '</li>';
89
 
90
- $items .= '</li>';
91
  }
92
  }
93
  return $items;
94
  }
95
 
96
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  }
59
 
60
  /* Adds search in the navigation bar in the front end of site */
61
+ function add_search_to_menu_items( $items, $args ) {
62
 
63
  $options = $this->options;
64
 
72
 
73
  if ( isset( $options['add_search_to_menu_locations'][$args->theme_location] ) ) {
74
 
75
+ if ( isset( $options['add_search_to_menu_gcse'] ) && $options['add_search_to_menu_gcse'] != '' ) {
76
+ $items .= '<li class="gsc-cse-search-menu">' . $options['add_search_to_menu_gcse'] . '</li>';
77
+ } else {
78
+ $search_class = isset( $options['add_search_to_menu_classes'] ) ? $options['add_search_to_menu_classes'].' astm-search-menu ' : 'astm-search-menu ';
79
+ $search_class .= isset( $options['add_search_to_menu_style'] ) ? $options['add_search_to_menu_style'] : 'default';
80
+ $title = isset( $options['add_search_to_menu_title'] ) ? $options['add_search_to_menu_title'] : '';
81
+ $items .= '<li class="' . esc_attr( $search_class ) . '">';
82
+
83
+ if ( $options['add_search_to_menu_style'] != 'default' ){
84
+
85
+ $items .= '<a title="' . esc_attr( $title ) . '" href="#">';
86
+
87
+ if ( $title == '' ) {
88
+ $items .= '<svg width="20" height="20" class="search-icon" role="img" viewBox="2 9 20 5">
89
+ <path class="search-icon-path" d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path></svg>';
90
+ } else {
91
+ $items .= $title;
92
+ }
93
+ $items .= '</a>';
94
  }
95
+ $items .= get_search_form( false ) . '</li>';
96
  }
 
97
 
 
98
  }
99
  }
100
  return $items;
101
  }
102
 
103
+ /* Adds search in the mobile header in the front end of site */
104
+ function add_search_to_menu_in_header() {
105
+ $options = $this->options;
106
+ $items = '';
107
+
108
+ if ( isset( $options['add_search_to_menu_locations']['initial'] ) ) {
109
+ unset( $options['add_search_to_menu_locations']['initial'] );
110
+ $options['add_search_to_menu_locations'][$args->theme_location] = $args->theme_location;
111
+ update_option( 'add_search_to_menu', $options );
112
+ }
113
+
114
+ if ( isset( $options['add_search_to_menu_gcse'] ) && $options['add_search_to_menu_gcse'] != '' ) {
115
+ $items .= '<li class="gsc-cse-search-menu">' . $options['add_search_to_menu_gcse'] . '</li>';
116
+ } else {
117
+ $search_class = isset( $options['add_search_to_menu_classes'] ) ? $options['add_search_to_menu_classes'].' astm-search-menu ' : 'astm-search-menu ';
118
+ $search_class .= isset( $options['add_search_to_menu_style'] ) ? $options['add_search_to_menu_style'] : 'default';
119
+ $title = isset( $options['add_search_to_menu_title'] ) ? $options['add_search_to_menu_title'] : '';
120
+ $items .= '<div class="astm-search-menu-wrapper"><div>';
121
+ $items .= '<span class="' . esc_attr( $search_class ) . '">';
122
+
123
+ if ( $options['add_search_to_menu_style'] != 'default' ){
124
+
125
+ $items .= '<a title="' . esc_attr( $title ) . '" href="#">';
126
+
127
+ if ( $title == '' ) {
128
+ $items .= '<svg width="20" height="20" class="search-icon" role="img" viewBox="2 9 20 5">
129
+ <path class="search-icon-path" d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path></svg>';
130
+ } else {
131
+ $items .= $title;
132
+ }
133
+
134
+ $items .= '</a>';
135
+ }
136
+ $items .= get_search_form( false ) . '</span></div></div>';
137
+ }
138
+
139
+ echo $items;
140
+ }
141
+
142
+ /* Filters search result */
143
+ function add_search_to_menu_search_filter( $query ) {
144
+
145
+ $options = $this->options;
146
+
147
+ if ( isset( $options['add_search_to_menu_posts']['initial'] ) ) {
148
+ $args = array( 'exclude_from_search' => false );
149
+ $posts = get_post_types( $args );
150
+ $post_keys = array_keys( $posts );
151
+
152
+ foreach ( $post_keys as $post_key ) {
153
+ $options['add_search_to_menu_posts'][ $post_key ] = $post_key;
154
+ }
155
+
156
+ unset( $options['add_search_to_menu_posts']['initial'] );
157
+ update_option( 'add_search_to_menu', $options );
158
+ }
159
+
160
+ if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) {
161
+ $query->set( 'post_type', $options['add_search_to_menu_posts'] );
162
+ }
163
+ }
164
+
165
+ /* Adds custom CSS code in the site front end */
166
+ function add_search_to_menu_css() {
167
+ $options = $this->options;
168
+
169
+ if ( isset( $options['add_search_to_menu_css'] ) && $options['add_search_to_menu_css'] != '' ) {
170
+ echo '<style type="text/css" media="screen">';
171
+ echo '/* Add search to menu custom CSS code */';
172
+ esc_html_e( $options['add_search_to_menu_css'] );
173
+ echo '</style>';
174
+ }
175
+ }
176
+ }
177
+
public/css/add-search-to-menu.css CHANGED
@@ -1,21 +1,33 @@
1
- li.search-menu {
2
  position: relative;
3
  }
4
 
5
- li.search-menu a {
6
  outline: 0;
7
  }
8
 
9
- li.search-menu a::before,
10
- li.search-menu a::after {
11
  display: none !important;
12
  }
13
 
14
- li.search-menu.default form {
 
 
 
 
 
 
 
 
 
 
 
15
  max-width: 300px;
 
16
  }
17
 
18
- li.search-menu.dropdown form {
19
  display: none;
20
  min-width: 300px;
21
  max-width: 100%;
@@ -25,8 +37,8 @@ li.search-menu.dropdown form {
25
  z-index: 9;
26
  }
27
 
28
- li.search-menu.full-width-menu form,
29
- li.search-menu.sliding form {
30
  min-width: 0 !important;
31
  overflow: hidden;
32
  position: absolute;
@@ -37,34 +49,65 @@ li.search-menu.sliding form {
37
 
38
  }
39
 
40
- li.search-menu.full-width-menu.active-search {
41
- bottom: 20%;
42
  position: absolute;
43
  right: 0;
44
  width: 100%;
45
  }
46
 
47
- li.search-menu.full-width-menu.active-search a > svg {
48
  display: none;
49
  }
50
 
51
- li.search-menu form .screen-reader-text {
52
  display: none;
53
  }
54
 
55
- li.search-menu form label {
56
  margin: 0;
57
  padding: 0;
58
  }
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  @media screen and ( max-width: 910px ) {
61
- li.search-menu form {
62
  left: 0;
63
  min-width: 50%;
64
  right: auto;
65
  }
66
 
67
- li.search-menu.full-width-menu.active-search {
68
  position: relative;
69
  }
70
  }
1
+ .astm-search-menu {
2
  position: relative;
3
  }
4
 
5
+ .astm-search-menu a {
6
  outline: 0;
7
  }
8
 
9
+ .astm-search-menu a::before,
10
+ .astm-search-menu a::after {
11
  display: none !important;
12
  }
13
 
14
+ .astm-search-menu a svg {
15
+ background: #fff !important;
16
+ }
17
+
18
+ .astm-search-menu:hover > a,
19
+ .astm-search-menu a:hover,
20
+ .astm-search-menu a:focus {
21
+ background: transparent !important;
22
+ outline: none;
23
+ }
24
+
25
+ .astm-search-menu.default form {
26
  max-width: 300px;
27
+ position: static;
28
  }
29
 
30
+ .astm-search-menu.dropdown form {
31
  display: none;
32
  min-width: 300px;
33
  max-width: 100%;
37
  z-index: 9;
38
  }
39
 
40
+ .astm-search-menu.full-width-menu form,
41
+ .astm-search-menu.sliding form {
42
  min-width: 0 !important;
43
  overflow: hidden;
44
  position: absolute;
49
 
50
  }
51
 
52
+ .astm-search-menu.full-width-menu.active-search {
53
+ top: 0;
54
  position: absolute;
55
  right: 0;
56
  width: 100%;
57
  }
58
 
59
+ .astm-search-menu.full-width-menu.active-search a {
60
  display: none;
61
  }
62
 
63
+ .astm-search-menu form .screen-reader-text {
64
  display: none;
65
  }
66
 
67
+ .astm-search-menu form label {
68
  margin: 0;
69
  padding: 0;
70
  }
71
 
72
+ .astm-search-menu-wrapper {
73
+ position: absolute;
74
+ right: 5px;
75
+ top: 5px;
76
+ width: 100%;
77
+ z-index: 9999;
78
+ }
79
+
80
+ .admin-bar .astm-search-menu-wrapper {
81
+ top: 51px;
82
+ }
83
+
84
+ .astm-search-menu-wrapper .astm-search-menu {
85
+ float: right;
86
+ }
87
+
88
+ .astm-search-menu-wrapper .astm-search-menu form {
89
+ right: 0;
90
+ left: auto;
91
+ }
92
+
93
+ .gsc-cse-search-menu {
94
+ max-width: 300px;
95
+ float: right
96
+ }
97
+
98
+ .gsc-cse-search-menu .cse .gsc-control-cse,
99
+ .gsc-cse-search-menu .gsc-control-cse {
100
+ padding: 0;
101
+ }
102
+
103
  @media screen and ( max-width: 910px ) {
104
+ .astm-search-menu form {
105
  left: 0;
106
  min-width: 50%;
107
  right: auto;
108
  }
109
 
110
+ .astm-search-menu.full-width-menu.active-search {
111
  position: relative;
112
  }
113
  }
public/js/add-search-to-menu.js CHANGED
@@ -3,7 +3,7 @@
3
  "use strict";
4
  $(document).ready(function(){
5
 
6
- $( 'li.search-menu a' ).on( 'click', function( e ) {
7
 
8
  // Cancel the default action
9
  e.stopPropagation();
@@ -25,26 +25,29 @@
25
  $( this ).parent().addClass( 'open' );
26
  $( this ).parent().find( 'form input[type="search"], form input[type="text"]' ).focus();
27
  }
 
 
 
28
  } );
29
  } );
30
 
31
- $( 'li.search-menu form input[type="search"], li.search-menu form input[type="text"]' ).on( 'click', function( e ) {
32
  e.stopPropagation();
33
  return false;
34
  } );
35
 
36
  $( window ).click( function() {
37
- if ( $( 'li.search-menu' ).hasClass( 'open' ) ) {
38
- $( 'li.search-menu form' ).animate(
39
  { width:'0' },
40
  400,
41
  function() {
42
- $( 'li.search-menu' ).removeClass( 'active-search' );
43
- $( 'li.search-menu' ).removeClass( 'open' );
44
  }
45
  );
46
- } else if ( $( 'li.search-menu' ).hasClass( 'dropdown' ) ){
47
- $( 'li.search-menu form' ).fadeOut();
48
  }
49
  });
50
 
3
  "use strict";
4
  $(document).ready(function(){
5
 
6
+ $( '.astm-search-menu a' ).on( 'click', function( e ) {
7
 
8
  // Cancel the default action
9
  e.stopPropagation();
25
  $( this ).parent().addClass( 'open' );
26
  $( this ).parent().find( 'form input[type="search"], form input[type="text"]' ).focus();
27
  }
28
+
29
+ $( '.astm-search-menu form input[type="search"], .astm-search-menu form input[type="text"]' ).focus();
30
+
31
  } );
32
  } );
33
 
34
+ $( '.astm-search-menu form input[type="search"], .astm-search-menu form input[type="text"]' ).on( 'click', function( e ) {
35
  e.stopPropagation();
36
  return false;
37
  } );
38
 
39
  $( window ).click( function() {
40
+ if ( $( '.astm-search-menu' ).hasClass( 'open' ) ) {
41
+ $( '.astm-search-menu form' ).animate(
42
  { width:'0' },
43
  400,
44
  function() {
45
+ $( '.astm-search-menu' ).removeClass( 'active-search' );
46
+ $( '.astm-search-menu' ).removeClass( 'open' );
47
  }
48
  );
49
+ } else if ( $( '.astm-search-menu' ).hasClass( 'dropdown' ) ){
50
+ $( '.astm-search-menu form' ).fadeOut();
51
  }
52
  });
53
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://freewptp.com/contact/
4
  Tags: menu, search menu, plugin, search box to navigation bar, search to navigation menu, navigation bar search menu, search form to navigation bar
5
  Requires at least: 3.0
6
  Tested up to: 4.8
7
- Stable tag: 2.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -55,6 +55,10 @@ Please make sure you have configured the plugin settings from Settings -> Add Se
55
  = 2.0 =
56
  * Resolved scrolling issue in fixed menu and made magnifying glass icon resizable.
57
 
 
 
 
 
58
  == Upgrade Notice ==
59
 
60
  = 1.0 =
4
  Tags: menu, search menu, plugin, search box to navigation bar, search to navigation menu, navigation bar search menu, search form to navigation bar
5
  Requires at least: 3.0
6
  Tested up to: 4.8
7
+ Stable tag: 3.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
55
  = 2.0 =
56
  * Resolved scrolling issue in fixed menu and made magnifying glass icon resizable.
57
 
58
+ = 3.0 =
59
+ * Added plugin options Search Post Types, Google CSE, Mobile Display and Custom CSS
60
+ * Styled it for default WordPress themes
61
+
62
  == Upgrade Notice ==
63
 
64
  = 1.0 =