Version Description
- Initial release.
=
Download this release
Release Info
Developer | vinod dalvi |
Plugin | Ivory Search – WordPress Search Plugin |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- add-search-to-menu.php +92 -0
- admin/class-add-search-to-menu-admin.php +282 -0
- admin/js/add-search-to-menu-admin.js +19 -0
- includes/class-add-search-to-menu-activator.php +33 -0
- includes/class-add-search-to-menu-deactivator.php +33 -0
- includes/class-add-search-to-menu-i18n.php +52 -0
- includes/class-add-search-to-menu-loader.php +132 -0
- includes/class-add-search-to-menu.php +226 -0
- languages/default.po +143 -0
- public/class-add-search-to-menu-public.php +96 -0
- public/css/add-search-to-menu.css +70 -0
- public/js/add-search-to-menu.js +50 -0
- readme.txt +58 -0
- uninstall.php +16 -0
add-search-to-menu.php
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
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: 1.0
|
7 |
+
Author: Vinod Dalvi
|
8 |
+
Author URI: http://freewptp.com
|
9 |
+
License: GPL-2.0+
|
10 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
11 |
+
Domain Path: /languages
|
12 |
+
Text Domain: add-search-to-menu
|
13 |
+
|
14 |
+
Add Search To Menu plugin is free software: you can redistribute it and/or modify
|
15 |
+
it under the terms of the GNU General Public License as published by
|
16 |
+
the Free Software Foundation, either version 2 of the License, or
|
17 |
+
any later version.
|
18 |
+
|
19 |
+
Add Search To Menu plugin is distributed in the hope that it will be useful,
|
20 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
+
GNU General Public License for more details.
|
23 |
+
|
24 |
+
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 |
+
*/
|
32 |
+
|
33 |
+
/**
|
34 |
+
* The file responsible for starting the Add Search To Menu plugin
|
35 |
+
*
|
36 |
+
* The Add Search To Menu is a plugin that can be used
|
37 |
+
* to display search menu in the navigation bar. This particular file is responsible for
|
38 |
+
* including the necessary dependencies and starting the plugin.
|
39 |
+
*
|
40 |
+
* @package ASTM
|
41 |
+
*/
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* If this file is called directly, then abort execution.
|
46 |
+
*/
|
47 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
48 |
+
die;
|
49 |
+
}
|
50 |
+
|
51 |
+
|
52 |
+
/**
|
53 |
+
* The code that runs during plugin activation.
|
54 |
+
* This action is documented in includes/class-add-search-to-menu-activator.php
|
55 |
+
*/
|
56 |
+
function activate_add_search_to_menu() {
|
57 |
+
require_once plugin_dir_path( __FILE__ ) . 'includes/class-add-search-to-menu-activator.php';
|
58 |
+
Add_Search_To_Menu_Activator::activate();
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
/**
|
63 |
+
* The code that runs during plugin deactivation.
|
64 |
+
* This action is documented in includes/class-add-search-to-menu-deactivator.php
|
65 |
+
*/
|
66 |
+
function deactivate_add_search_to_menu() {
|
67 |
+
require_once plugin_dir_path( __FILE__ ) . 'includes/class-add-search-to-menu-deactivator.php';
|
68 |
+
Add_Search_To_Menu_Deactivator::deactivate();
|
69 |
+
}
|
70 |
+
|
71 |
+
register_activation_hook( __FILE__, 'activate_add_search_to_menu' );
|
72 |
+
register_deactivation_hook( __FILE__, 'deactivate_add_search_to_menu' );
|
73 |
+
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Include the core class responsible for loading all necessary components of the plugin.
|
77 |
+
*/
|
78 |
+
require_once plugin_dir_path( __FILE__ ) . 'includes/class-add-search-to-menu.php';
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Instantiates the Add Search To Menu class and then
|
82 |
+
* calls its run method officially starting up the plugin.
|
83 |
+
*/
|
84 |
+
function run_add_search_to_menu() {
|
85 |
+
$ewpd = new Add_Search_To_Menu();
|
86 |
+
$ewpd->run();
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Call the above function to begin execution of the plugin.
|
91 |
+
*/
|
92 |
+
run_add_search_to_menu();
|
admin/class-add-search-to-menu-admin.php
ADDED
@@ -0,0 +1,282 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The Add Search To Menu Admin defines all functionality for the dashboard
|
5 |
+
* of the plugin.
|
6 |
+
*
|
7 |
+
* This class defines the meta box used to display the post meta data and registers
|
8 |
+
* the style sheet responsible for styling the content of the meta box.
|
9 |
+
*
|
10 |
+
* @package ASTM
|
11 |
+
* @since 1.0.0
|
12 |
+
*/
|
13 |
+
class Add_Search_To_Menu_Admin {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Global plugin option.
|
17 |
+
*/
|
18 |
+
public $options;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* A reference to the version of the plugin that is passed to this class from the caller.
|
22 |
+
*
|
23 |
+
* @access private
|
24 |
+
* @var string $version The current version of the plugin.
|
25 |
+
*/
|
26 |
+
private $version;
|
27 |
+
|
28 |
+
|
29 |
+
/**
|
30 |
+
* are we network activated?
|
31 |
+
*/
|
32 |
+
private $networkactive;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Initializes this class and stores the current version of this plugin.
|
36 |
+
*
|
37 |
+
* @param string $version The current version of this plugin.
|
38 |
+
*/
|
39 |
+
public function __construct( $version ) {
|
40 |
+
$this->version = $version;
|
41 |
+
$this->options = get_option( 'add_search_to_menu' );
|
42 |
+
$this->networkactive = ( is_multisite() && array_key_exists( plugin_basename( __FILE__ ), (array) get_site_option( 'active_sitewide_plugins' ) ) );
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* PHP 4 Compatible Constructor
|
47 |
+
*
|
48 |
+
*/
|
49 |
+
function Add_Search_To_Menu_Admin() {
|
50 |
+
$this->__construct();
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Loads plugin javascript and stylesheet files in the admin area
|
55 |
+
*
|
56 |
+
*/
|
57 |
+
function add_search_to_menu_load_admin_assets(){
|
58 |
+
|
59 |
+
wp_register_script( 'add-search-to-menu-scripts', plugins_url( '/js/add-search-to-menu-admin.js', __FILE__ ), array( 'jquery' ), '1.0', true );
|
60 |
+
|
61 |
+
wp_localize_script( 'add-search-to-menu-scripts', 'add_search_to_menu', array(
|
62 |
+
'ajax_url' => admin_url( 'admin-ajax.php' )
|
63 |
+
) );
|
64 |
+
|
65 |
+
// Enqueued script with localized data.
|
66 |
+
wp_enqueue_script( 'add-search-to-menu-scripts' );
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Add a link to the settings page to the plugins list
|
71 |
+
*
|
72 |
+
* @param array $links array of links for the plugins, adapted when the current plugin is found.
|
73 |
+
* @param string $file the filename for the current plugin, which the filter loops through.
|
74 |
+
*
|
75 |
+
* @return array $links
|
76 |
+
*/
|
77 |
+
function add_search_to_menu_settings_link( $links, $file ) {
|
78 |
+
|
79 |
+
if ( false !== strpos( $file, 'add-search-to-menu' ) ) {
|
80 |
+
$mylinks = array(
|
81 |
+
'<a href="http://freewptp.com/forum/wordpress-plugins-forum/add-search-to-menu/">' . esc_html__( 'Get Support', 'add-search-to-menu' ) . '</a>',
|
82 |
+
'<a href="options-general.php?page=add_search_to_menu">' . esc_html__( 'Settings', 'add-search-to-menu' ) . '</a>'
|
83 |
+
);
|
84 |
+
$links = array_merge( $mylinks, $links );
|
85 |
+
}
|
86 |
+
return $links;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Displays plugin configuration notice in admin area
|
91 |
+
*
|
92 |
+
*/
|
93 |
+
function add_search_to_menu_setup_notice(){
|
94 |
+
|
95 |
+
if ( strpos( get_current_screen()->id, 'settings_page_add_search_to_menu' ) === 0 )
|
96 |
+
return;
|
97 |
+
|
98 |
+
$hascaps = $this->networkactive ? is_network_admin() && current_user_can( 'manage_network_plugins' ) : current_user_can( 'manage_options' );
|
99 |
+
|
100 |
+
if ( $hascaps ) {
|
101 |
+
$url = is_network_admin() ? network_site_url() : site_url( '/' );
|
102 |
+
echo '<div class="notice notice-info is-dismissible add-search-to-menu"><p>' . sprintf( __( 'To configure <em>Add Search To Menu plugin</em> please visit its <a href="%1$s">configuration page</a> and to get plugin support contact us on <a href="%2$s" target="_blank">plugin support forum</a> or <a href="%3$s" target="_blank">contact us page</a>.', 'add-search-to-menu'), $url . 'wp-admin/options-general.php?page=add_search_to_menu', 'http://freewptp.com/forum/wordpress-plugins-forum/add-search-to-menu/', 'http://freewptp.com/contact/' ) . '</p></div>';
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Handles plugin notice dismiss functionality using AJAX
|
108 |
+
*
|
109 |
+
*/
|
110 |
+
function add_search_to_menu_notice_dismiss() {
|
111 |
+
|
112 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
113 |
+
$options = $this->options;
|
114 |
+
$options['dismiss_admin_notices'] = 1;
|
115 |
+
update_option( 'add_search_to_menu', $options );
|
116 |
+
}
|
117 |
+
die();
|
118 |
+
}
|
119 |
+
|
120 |
+
/* Registers menu item */
|
121 |
+
function add_search_to_menu_admin_menu_setup(){
|
122 |
+
add_submenu_page( 'options-general.php', __( 'Add Search To Menu Settings', 'add-search-to-menu' ), __( 'Add Search To Menu', 'add-search-to-menu' ), 'manage_options', 'add_search_to_menu', array( $this, 'add_search_to_menu_admin_page_screen' ) );
|
123 |
+
}
|
124 |
+
|
125 |
+
/* Displays plugin admin page content */
|
126 |
+
function add_search_to_menu_admin_page_screen() { ?>
|
127 |
+
<div class="wrap">
|
128 |
+
<form id="add_search_to_menu_options" action="options.php" method="post">
|
129 |
+
<?php
|
130 |
+
settings_fields( 'add_search_to_menu' );
|
131 |
+
do_settings_sections( 'add_search_to_menu' );
|
132 |
+
submit_button( 'Save Options', 'primary', 'add_search_to_menu_options_submit' );
|
133 |
+
?>
|
134 |
+
<div id="after-submit">
|
135 |
+
<p>
|
136 |
+
<?php esc_html_e( 'Like Add Search To Menu?', 'add-search-to-menu' ); ?> <a href="https://wordpress.org/support/plugin/add-search-to-menu/reviews/?filter=5#new-post" target="_blank"><?php esc_html_e( 'Give us a rating', 'add-search-to-menu' ); ?></a>
|
137 |
+
</p>
|
138 |
+
<p>
|
139 |
+
<?php esc_html_e( 'Need Help or Have Suggestions?', 'add-search-to-menu' ); ?> <?php esc_html_e( 'contact us on', 'add-search-to-menu' ); ?> <a href="http://freewptp.com/forum/wordpress-plugins-forum/add-search-to-menu/" target="_blank"><?php esc_html_e( 'Plugin support forum', 'add-search-to-menu' ); ?></a> <?php esc_html_e( 'or', 'add-search-to-menu' ); ?> <a href="http://freewptp.com/contact/" target="_blank"><?php esc_html_e( 'Contact us page', 'add-search-to-menu' ); ?></a>
|
140 |
+
</p>
|
141 |
+
<p>
|
142 |
+
<?php esc_html_e( 'Access Plugin Documentation on', 'add-search-to-menu' ); ?> <a href="http://freewptp.com/plugins/add-search-to-menu/" target="_blank">http://freewptp.com/plugins/add-search-to-menu/</a>
|
143 |
+
</p>
|
144 |
+
</div>
|
145 |
+
</form>
|
146 |
+
</div>
|
147 |
+
<?php
|
148 |
+
}
|
149 |
+
|
150 |
+
/* Registers settings */
|
151 |
+
function add_search_to_menu_settings_init(){
|
152 |
+
|
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' );
|
162 |
+
|
163 |
+
}
|
164 |
+
|
165 |
+
/* Displays plugin description text */
|
166 |
+
function add_search_to_menu_section_desc(){
|
167 |
+
echo '<p>' . esc_html__( 'Configure the Add Search To Menu plugin settings here.', 'add-search-to-menu' ) . '</p>';
|
168 |
+
}
|
169 |
+
|
170 |
+
/* add search to menu choose locations field output */
|
171 |
+
function add_search_to_menu_locations() {
|
172 |
+
|
173 |
+
$options = $this->options;
|
174 |
+
$html = '';
|
175 |
+
$menus = get_registered_nav_menus();
|
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 |
+
|
183 |
+
update_option( 'add_search_to_menu', $options );
|
184 |
+
}
|
185 |
+
|
186 |
+
if ( isset( $options['add_search_to_menu_locations']['initial'] ) ){
|
187 |
+
unset( $options['add_search_to_menu_locations']['initial'] );
|
188 |
+
$location = array_keys( $menus );
|
189 |
+
$options['add_search_to_menu_locations'][ $location[0] ] = $location[0];
|
190 |
+
update_option( 'add_search_to_menu', $options );
|
191 |
+
}
|
192 |
+
|
193 |
+
foreach ( $menus as $location => $description ) {
|
194 |
+
|
195 |
+
$check_value = isset( $options['add_search_to_menu_locations'][$location] ) ? $options['add_search_to_menu_locations'][ $location ] : 0;
|
196 |
+
$html .= '<input type="checkbox" id="add_search_to_menu_locations' . esc_attr( $location ) . '" name="add_search_to_menu[add_search_to_menu_locations][' . esc_attr( $location ) . ']" value="' . esc_attr( $location ) . '" ' . checked( $location, $check_value, false ) . '/>';
|
197 |
+
$html .= '<label for="add_search_to_menu_locations' . esc_attr( $location ) . '"> ' . esc_html( $description ) . '</label><br />';
|
198 |
+
}
|
199 |
+
} else {
|
200 |
+
$html = __( 'No navigation menu registered on your site.', 'add-search-to-menu' );
|
201 |
+
}
|
202 |
+
echo $html;
|
203 |
+
|
204 |
+
}
|
205 |
+
|
206 |
+
/* add search to menu select style field output */
|
207 |
+
function add_search_to_menu_style() {
|
208 |
+
|
209 |
+
$options = $this->options;
|
210 |
+
$styles = array(
|
211 |
+
'default' => __( 'Default', 'add-search-to-menu' ),
|
212 |
+
'dropdown' => __( 'Dropdown', 'add-search-to-menu' ),
|
213 |
+
'sliding' => __( 'Sliding', 'add-search-to-menu' ),
|
214 |
+
'full-width-menu' => __( 'Full Width', 'add-search-to-menu' )
|
215 |
+
);
|
216 |
+
|
217 |
+
if ( empty( $options ) || ! isset( $options['add_search_to_menu_style'] ) ) {
|
218 |
+
$options['add_search_to_menu_style'] = 'default';
|
219 |
+
update_option( 'add_search_to_menu', $options );
|
220 |
+
}
|
221 |
+
|
222 |
+
$html = '';
|
223 |
+
$check_value = isset( $options['add_search_to_menu_style'] ) ? $options['add_search_to_menu_style'] : 'default';
|
224 |
+
|
225 |
+
foreach ( $styles as $key => $style ) {
|
226 |
+
|
227 |
+
$html .= '<input type="radio" id="add_search_to_menu_style' . esc_attr( $key ) . '" name="add_search_to_menu[add_search_to_menu_style]" value="' . esc_attr( $key ) . '" ' . checked( $key, $check_value, false ) . '/>';
|
228 |
+
$html .= '<label for="add_search_to_menu_style' . esc_attr( $key ) . '"> ' . esc_html( $style ) . '</label><br />';
|
229 |
+
}
|
230 |
+
echo $html;
|
231 |
+
}
|
232 |
+
|
233 |
+
/* add search to menu title field output */
|
234 |
+
function add_search_to_menu_title() {
|
235 |
+
|
236 |
+
$options = $this->options;
|
237 |
+
$options['add_search_to_menu_title'] = isset( $options['add_search_to_menu_title'] ) ? $options['add_search_to_menu_title'] : '';
|
238 |
+
$html = '<input type="text" id="add_search_to_menu_title" name="add_search_to_menu[add_search_to_menu_title]" value="' . esc_attr( $options['add_search_to_menu_title'] ) . '" size="50" />';
|
239 |
+
$html .= '<br /><label for="add_search_to_menu_title" style="font-size: 10px;">' . esc_html__( "If title field is not set then instead of title the search icon displays in navigation menu.", 'add-search-to-menu' ) . '</label>';
|
240 |
+
echo $html;
|
241 |
+
}
|
242 |
+
|
243 |
+
/* add search to menu classes field output */
|
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 |
+
|
252 |
+
/* add search to menu do not load plugin files field output */
|
253 |
+
function do_not_load_plugin_files() {
|
254 |
+
|
255 |
+
$options = $this->options;
|
256 |
+
$styles = array(
|
257 |
+
'plugin-css-file' => __( 'Plugin CSS File', 'add-search-to-menu' ),
|
258 |
+
'plugin-js-file' => __( 'Plugin JavaScript File', 'add-search-to-menu' )
|
259 |
+
|
260 |
+
);
|
261 |
+
|
262 |
+
|
263 |
+
$html = '';
|
264 |
+
foreach ( $styles as $key => $file ) {
|
265 |
+
|
266 |
+
$check_value = isset( $options['do_not_load_plugin_files'][ $key] ) ? $options['do_not_load_plugin_files'][ $key ] : 0;
|
267 |
+
$html .= '<input type="checkbox" id="do_not_load_plugin_files' . esc_attr( $key ) . '" name="add_search_to_menu[do_not_load_plugin_files][' . esc_attr( $key ) . ']" value="' . esc_attr( $key ) . '" ' . checked( $key, $check_value, false ) . '/>';
|
268 |
+
$html .= '<label for="do_not_load_plugin_files' . esc_attr( $key ) . '"> ' . esc_html( $file ) . '</label>';
|
269 |
+
|
270 |
+
if ( $key == 'plugin-css-file' ){
|
271 |
+
$html .= '<br /><label for="add_search_to_menu_title" style="font-size: 10px;">' . esc_html__( 'If checked, you have to add following plugin file code into your theme CSS file.', 'add-search-to-menu' ) . '</label>';
|
272 |
+
$html .= '<br /><a target="_blank" href="' . plugins_url( '/add-search-to-menu/public/js/add-search-to-menu.js' ) . '"/a>' . plugins_url( '/add-search-to-menu/public/js/add-search-to-menu.js' ) . '</a>';
|
273 |
+
$html .= '<br /><br />';
|
274 |
+
} else {
|
275 |
+
$html .= '<br /><label for="add_search_to_menu_title" style="font-size: 10px;">' . esc_html__( "If checked, you have to add following plugin file code into your theme JavaScript file.", 'add-search-to-menu' ) . '</label>';
|
276 |
+
$html .= '<br /><a target="_blank" href="' . plugins_url( '/add-search-to-menu/public/css/add-search-to-menu.css' ) . '"/a>' . plugins_url( '/add-search-to-menu/public/css/add-search-to-menu.css' ) . '</a>';
|
277 |
+
}
|
278 |
+
}
|
279 |
+
echo $html;
|
280 |
+
}
|
281 |
+
|
282 |
+
}
|
admin/js/add-search-to-menu-admin.js
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Dismisses plugin notices
|
3 |
+
*
|
4 |
+
*/
|
5 |
+
( function( $ ) {
|
6 |
+
"use strict";
|
7 |
+
$( document ).ready( function() {
|
8 |
+
$( '.notice.is-dismissible.add-search-to-menu .notice-dismiss').on( 'click', function() {
|
9 |
+
|
10 |
+
$.ajax( {
|
11 |
+
url: add_search_to_menu.ajax_url,
|
12 |
+
data: {
|
13 |
+
action: 'add_search_to_menu_notice_dismiss'
|
14 |
+
}
|
15 |
+
} );
|
16 |
+
|
17 |
+
} );
|
18 |
+
} );
|
19 |
+
} )( jQuery );
|
includes/class-add-search-to-menu-activator.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Fired during plugin activation.
|
5 |
+
*
|
6 |
+
* This class defines all code necessary to run during the plugin's activation.
|
7 |
+
*
|
8 |
+
* @link http://freewptp.com
|
9 |
+
* @since 1.0.0
|
10 |
+
* @package ASTM
|
11 |
+
* @subpackage ASTM/includes
|
12 |
+
* @author Free WPTP <freewptp@gmail.com>
|
13 |
+
*/
|
14 |
+
class Add_Search_To_Menu_Activator {
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Short Description.
|
18 |
+
*
|
19 |
+
* Long Description.
|
20 |
+
*
|
21 |
+
* @since 1.0.0
|
22 |
+
*/
|
23 |
+
public static function activate() {
|
24 |
+
|
25 |
+
$options = get_option( 'add_search_to_menu' );
|
26 |
+
|
27 |
+
if ( ! isset( $options['add_search_to_menu_locations'] ) ) {
|
28 |
+
$options['add_search_to_menu_locations']['initial'] = 'initial';
|
29 |
+
update_option( 'add_search_to_menu', $options );
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
}
|
includes/class-add-search-to-menu-deactivator.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Fired during plugin deactivation.
|
5 |
+
*
|
6 |
+
* This class defines all code necessary to run during the plugin's deactivation.
|
7 |
+
*
|
8 |
+
* @link http://freewptp.com
|
9 |
+
* @since 1.0.0
|
10 |
+
* @package ASTM
|
11 |
+
* @subpackage ASTM/includes
|
12 |
+
* @author Free WPTP <freewptp@gmail.com>
|
13 |
+
*/
|
14 |
+
class Add_Search_To_Menu_Deactivator {
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Short Description.
|
18 |
+
*
|
19 |
+
* Long Description.
|
20 |
+
*
|
21 |
+
* @since 1.0.0
|
22 |
+
*/
|
23 |
+
public static function deactivate() {
|
24 |
+
|
25 |
+
$options = get_option( 'add_search_to_menu' );
|
26 |
+
|
27 |
+
if ( isset( $options['dismiss_admin_notices'] ) ) {
|
28 |
+
unset( $options['dismiss_admin_notices'] );
|
29 |
+
update_option( 'add_search_to_menu', $options );
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
}
|
includes/class-add-search-to-menu-i18n.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Define the internationalization functionality.
|
5 |
+
*
|
6 |
+
* Loads and defines the internationalization files for this plugin
|
7 |
+
* so that it is ready for translation.
|
8 |
+
*
|
9 |
+
* @link http://freewptp.com
|
10 |
+
* @since 1.0.0
|
11 |
+
* @package ASTM
|
12 |
+
* @subpackage ASTM/includes
|
13 |
+
* @author Free WPTP <freewptp@gmail.com>
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Add_Search_To_Menu_i18n {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* The domain specified for this plugin.
|
20 |
+
*
|
21 |
+
* @since 1.0.0
|
22 |
+
* @access private
|
23 |
+
* @var string $domain The domain identifier for this plugin.
|
24 |
+
*/
|
25 |
+
private $domain;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Load the plugin text domain for translation.
|
29 |
+
*
|
30 |
+
* @since 1.0.0
|
31 |
+
*/
|
32 |
+
public function load_plugin_textdomain() {
|
33 |
+
|
34 |
+
load_plugin_textdomain(
|
35 |
+
$this->domain,
|
36 |
+
false,
|
37 |
+
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
|
38 |
+
);
|
39 |
+
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Set the domain equal to that of the specified domain.
|
44 |
+
*
|
45 |
+
* @since 1.0.0
|
46 |
+
* @param string $domain The domain that represents the locale of this plugin.
|
47 |
+
*/
|
48 |
+
public function set_domain( $domain ) {
|
49 |
+
$this->domain = $domain;
|
50 |
+
}
|
51 |
+
|
52 |
+
}
|
includes/class-add-search-to-menu-loader.php
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The Add Search To Menu Loader is a class that is responsible for
|
5 |
+
* coordinating all actions and filters used throughout the plugin
|
6 |
+
* by registering all actions and filters for the plugin.
|
7 |
+
*
|
8 |
+
* Maintain a list of all hooks that are registered throughout
|
9 |
+
* the plugin, and register them with the WordPress API. Call the
|
10 |
+
* run function to execute the list of actions and filters.
|
11 |
+
*
|
12 |
+
* @link http://freewptp.com
|
13 |
+
* @since 1.0.0
|
14 |
+
* @package ASTM
|
15 |
+
* @subpackage ASTM/includes
|
16 |
+
* @author Free WPTP <freewptp@gmail.com>
|
17 |
+
*/
|
18 |
+
class Add_Search_To_Menu_Loader {
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The array of actions registered with WordPress.
|
22 |
+
*
|
23 |
+
* @since 1.0.0
|
24 |
+
* @access protected
|
25 |
+
* @var array $actions The actions registered with WordPress to fire when the plugin loads.
|
26 |
+
*/
|
27 |
+
protected $actions;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* The array of filters registered with WordPress.
|
31 |
+
*
|
32 |
+
* @since 1.0.0
|
33 |
+
* @access protected
|
34 |
+
* @var array $filters The filters registered with WordPress to fire when the plugin loads.
|
35 |
+
*/
|
36 |
+
protected $filters;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Initialize the collections used to maintain the actions and filters.
|
40 |
+
*
|
41 |
+
* @since 1.0.0
|
42 |
+
*/
|
43 |
+
public function __construct() {
|
44 |
+
|
45 |
+
$this->actions = array();
|
46 |
+
$this->filters = array();
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* PHP 4 Compatible Constructor
|
52 |
+
*
|
53 |
+
*/
|
54 |
+
function Add_Search_To_Menu_Loader() {
|
55 |
+
$this->__construct();
|
56 |
+
}
|
57 |
+
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Add a new action to the collection to be registered with WordPress.
|
61 |
+
*
|
62 |
+
* @since 1.0.0
|
63 |
+
* @param string $hook The name of the WordPress action that is being registered.
|
64 |
+
* @param object $component A reference to the instance of the object on which the action is defined.
|
65 |
+
* @param string $callback The name of the function definition on the $component.
|
66 |
+
* @param int Optional $priority The priority at which the function should be fired.
|
67 |
+
* @param int Optional $accepted_args The number of arguments that should be passed to the $callback.
|
68 |
+
*/
|
69 |
+
public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
70 |
+
$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Add a new filter to the collection to be registered with WordPress.
|
75 |
+
*
|
76 |
+
* @since 1.0.0
|
77 |
+
* @param string $hook The name of the WordPress filter that is being registered.
|
78 |
+
* @param object $component A reference to the instance of the object on which the filter is defined.
|
79 |
+
* @param string $callback The name of the function definition on the $component.
|
80 |
+
* @param int Optional $priority The priority at which the function should be fired.
|
81 |
+
* @param int Optional $accepted_args The number of arguments that should be passed to the $callback.
|
82 |
+
*/
|
83 |
+
public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
84 |
+
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* A utility function that is used to register the actions and hooks into a single
|
89 |
+
* collection.
|
90 |
+
*
|
91 |
+
* @since 1.0.0
|
92 |
+
* @access private
|
93 |
+
* @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
|
94 |
+
* @param string $hook The name of the WordPress filter that is being registered.
|
95 |
+
* @param object $component A reference to the instance of the object on which the filter is defined.
|
96 |
+
* @param string $callback The name of the function definition on the $component.
|
97 |
+
* @param int Optional $priority The priority at which the function should be fired.
|
98 |
+
* @param int Optional $accepted_args The number of arguments that should be passed to the $callback.
|
99 |
+
* @return type The collection of actions and filters registered with WordPress.
|
100 |
+
*/
|
101 |
+
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
|
102 |
+
|
103 |
+
$hooks[] = array(
|
104 |
+
'hook' => $hook,
|
105 |
+
'component' => $component,
|
106 |
+
'callback' => $callback,
|
107 |
+
'priority' => $priority,
|
108 |
+
'accepted_args' => $accepted_args
|
109 |
+
);
|
110 |
+
|
111 |
+
return $hooks;
|
112 |
+
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Register the filters and actions with WordPress.
|
117 |
+
*
|
118 |
+
* @since 1.0.0
|
119 |
+
*/
|
120 |
+
public function run() {
|
121 |
+
|
122 |
+
foreach ( $this->filters as $hook ) {
|
123 |
+
add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
|
124 |
+
}
|
125 |
+
|
126 |
+
foreach ( $this->actions as $hook ) {
|
127 |
+
add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
|
128 |
+
}
|
129 |
+
|
130 |
+
}
|
131 |
+
|
132 |
+
}
|
includes/class-add-search-to-menu.php
ADDED
@@ -0,0 +1,226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The Add Search To Menu is the core plugin class responsible for including and
|
5 |
+
* instantiating all of the code that composes the plugin
|
6 |
+
*
|
7 |
+
* @package ASTM
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* The Add Search To Menu is the core plugin responsible for including and
|
12 |
+
* instantiating all of the code that composes the plugin.
|
13 |
+
*
|
14 |
+
* The Add Search To Menu includes an instance to the Add Search To Menu
|
15 |
+
* Loader which is responsible for coordinating the hooks that exist within the
|
16 |
+
* plugin.
|
17 |
+
*
|
18 |
+
* It also maintains a reference to the plugin name which can be used in
|
19 |
+
* internationalization, and a reference to the current version of the plugin
|
20 |
+
* so that we can easily update the version in a single place to provide
|
21 |
+
* cache busting functionality when including scripts and styles.
|
22 |
+
*
|
23 |
+
* @since 1.0.0
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Add_Search_To_Menu {
|
27 |
+
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Global plugin option.
|
31 |
+
*/
|
32 |
+
public $options;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* A reference to the loader class that coordinates the hooks and callbacks
|
36 |
+
* throughout the plugin.
|
37 |
+
*
|
38 |
+
* @access protected
|
39 |
+
* @var Add_Search_To_Menu_Loader $loader Manages hooks between the WordPress hooks and the callback functions.
|
40 |
+
*/
|
41 |
+
protected $loader;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Represents the name of hte plugin that can be used throughout the plugin
|
45 |
+
* for internationalization and other purposes.
|
46 |
+
*
|
47 |
+
* @access protected
|
48 |
+
* @var string $plugin_name The single, hyphenated string used to identify this plugin.
|
49 |
+
*/
|
50 |
+
protected $plugin_name;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Maintains the current version of the plugin so that we can use it throughout
|
54 |
+
* the plugin.
|
55 |
+
*
|
56 |
+
* @access protected
|
57 |
+
* @var string $version The current version of the plugin.
|
58 |
+
*/
|
59 |
+
protected $version;
|
60 |
+
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Instantiates the plugin by setting up the core properties and loading
|
64 |
+
* all necessary dependencies and defining the hooks.
|
65 |
+
*
|
66 |
+
* The constructor will define both the plugin name and the verison
|
67 |
+
* attributes, but will also use internal functions to import all the
|
68 |
+
* plugin dependencies, and will leverage the Add_Search_To_Menu for
|
69 |
+
* registering the hooks and the callback functions used throughout the
|
70 |
+
* plugin.
|
71 |
+
*/
|
72 |
+
public function __construct() {
|
73 |
+
|
74 |
+
$this->plugin_name = 'add-search-to-menu';
|
75 |
+
$this->version = '1.0.0';
|
76 |
+
$this->options = get_option( 'add_search_to_menu' );
|
77 |
+
|
78 |
+
$this->load_dependencies();
|
79 |
+
$this->set_locale();
|
80 |
+
|
81 |
+
if ( is_admin() ) {
|
82 |
+
$this->define_admin_hooks();
|
83 |
+
} else {
|
84 |
+
$this->define_public_hooks();
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
|
89 |
+
/**
|
90 |
+
* PHP 4 Compatible Constructor
|
91 |
+
*
|
92 |
+
*/
|
93 |
+
function Add_Search_To_Menu() {
|
94 |
+
$this->__construct();
|
95 |
+
}
|
96 |
+
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Imports the Add Search To Menu administration classes, and the Add Search To Menu Loader.
|
100 |
+
*
|
101 |
+
* The Add Search To Menu Manager administration class defines all unique functionality for
|
102 |
+
* introducing custom functionality into the WordPress dashboard.
|
103 |
+
*
|
104 |
+
* The Add Search To Menu Loader is the class that will coordinate the hooks and callbacks
|
105 |
+
* from WordPress and the plugin. This function instantiates and sets the reference to the
|
106 |
+
* $loader class property.
|
107 |
+
*
|
108 |
+
* @access private
|
109 |
+
*/
|
110 |
+
private function load_dependencies() {
|
111 |
+
|
112 |
+
/**
|
113 |
+
* The class responsible for orchestrating the actions and filters of the
|
114 |
+
* core plugin.
|
115 |
+
*/
|
116 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-add-search-to-menu-loader.php';
|
117 |
+
|
118 |
+
/**
|
119 |
+
* The class responsible for defining internationalization functionality
|
120 |
+
* of the plugin.
|
121 |
+
*/
|
122 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-add-search-to-menu-i18n.php';
|
123 |
+
|
124 |
+
/**
|
125 |
+
* The class responsible for defining all actions that occur in the admin area.
|
126 |
+
*/
|
127 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-add-search-to-menu-admin.php';
|
128 |
+
|
129 |
+
/**
|
130 |
+
* The class responsible for defining all actions that occur in the front end of site.
|
131 |
+
*/
|
132 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-add-search-to-menu-public.php';
|
133 |
+
|
134 |
+
$this->loader = new Add_Search_To_Menu_Loader();
|
135 |
+
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Define the locale for this plugin for internationalization.
|
140 |
+
*
|
141 |
+
* Uses the Plugin_Name_i18n class in order to set the domain and to register the hook
|
142 |
+
* with WordPress.
|
143 |
+
*
|
144 |
+
* @since 1.0.0
|
145 |
+
* @access private
|
146 |
+
*/
|
147 |
+
private function set_locale() {
|
148 |
+
$plugin_i18n = new Add_Search_To_Menu_i18n();
|
149 |
+
$plugin_i18n->set_domain( $this->get_plugin_name() );
|
150 |
+
$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Defines the hooks and callback functions that are used for setting up the plugin stylesheets
|
155 |
+
* and the plugin's admin options.
|
156 |
+
*
|
157 |
+
* This function relies on the Add Search To Menu Admin class and the Add Search To Menu
|
158 |
+
* Loader class property.
|
159 |
+
*
|
160 |
+
* @access private
|
161 |
+
*/
|
162 |
+
private function define_admin_hooks() {
|
163 |
+
|
164 |
+
$admin = new Add_Search_To_Menu_Admin( $this->get_version() );
|
165 |
+
$options = $this->options;
|
166 |
+
if ( ! isset( $options['dismiss_admin_notices'] ) || ! $options['dismiss_admin_notices'] ) {
|
167 |
+
$this->loader->add_action( 'all_admin_notices', $admin, 'add_search_to_menu_setup_notice' );
|
168 |
+
}
|
169 |
+
$this->loader->add_action( 'plugin_action_links', $admin, 'add_search_to_menu_settings_link', 10, 2 );
|
170 |
+
$this->loader->add_action( 'admin_menu', $admin, 'add_search_to_menu_admin_menu_setup' ); //menu setup
|
171 |
+
$this->loader->add_action( 'wp_ajax_nopriv_add_search_to_menu_notice_dismiss', $admin, 'add_search_to_menu_notice_dismiss' );
|
172 |
+
$this->loader->add_action( 'wp_ajax_add_search_to_menu_notice_dismiss', $admin, 'add_search_to_menu_notice_dismiss' );
|
173 |
+
$this->loader->add_action( 'admin_enqueue_scripts', $admin, 'add_search_to_menu_load_admin_assets' );
|
174 |
+
$this->loader->add_action( 'admin_init', $admin, 'add_search_to_menu_settings_init' );
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Defines the hooks and callback functions that are used for executing plugin functionality
|
179 |
+
* in the front end of site.
|
180 |
+
*
|
181 |
+
* This function relies on the Add Search To Menu Admin class and the Add Search To Menu
|
182 |
+
* Loader class property.
|
183 |
+
*
|
184 |
+
* @access private
|
185 |
+
*/
|
186 |
+
private function define_public_hooks() {
|
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 |
+
/**
|
194 |
+
* The name of the plugin used to uniquely identify it within the context of
|
195 |
+
* WordPress and to define internationalization functionality.
|
196 |
+
*
|
197 |
+
* @since 1.0.0
|
198 |
+
* @return string The name of the plugin.
|
199 |
+
*/
|
200 |
+
public function get_plugin_name() {
|
201 |
+
return $this->plugin_name;
|
202 |
+
}
|
203 |
+
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Sets this class into motion.
|
207 |
+
*
|
208 |
+
* Executes the plugin by calling the run method of the loader class which will
|
209 |
+
* register all of the hooks and callback functions used throughout the plugin
|
210 |
+
* with WordPress.
|
211 |
+
*/
|
212 |
+
public function run() {
|
213 |
+
$this->loader->run();
|
214 |
+
}
|
215 |
+
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Returns the current version of the plugin to the caller.
|
219 |
+
*
|
220 |
+
* @return string $this->version The current version of the plugin.
|
221 |
+
*/
|
222 |
+
public function get_version() {
|
223 |
+
return $this->version;
|
224 |
+
}
|
225 |
+
|
226 |
+
}
|
languages/default.po
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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"
|
16 |
+
|
17 |
+
#: ../admin/class-add-search-to-menu-admin.php:81
|
18 |
+
msgid "Get Support"
|
19 |
+
msgstr ""
|
20 |
+
|
21 |
+
#: ../admin/class-add-search-to-menu-admin.php:82
|
22 |
+
msgid "Settings"
|
23 |
+
msgstr ""
|
24 |
+
|
25 |
+
#: ../admin/class-add-search-to-menu-admin.php:102
|
26 |
+
#, php-format
|
27 |
+
msgid ""
|
28 |
+
"To configure <em>Add Search To Menu plugin</em> please visit its <a href="
|
29 |
+
"\"%1$s\">configuration page</a> and to get plugin support contact us on <a "
|
30 |
+
"href=\"%2$s\" target=\"_blank\">plugin support forum</a> or <a href=\"%3$s\" "
|
31 |
+
"target=\"_blank\">contact us page</a>."
|
32 |
+
msgstr ""
|
33 |
+
|
34 |
+
#: ../admin/class-add-search-to-menu-admin.php:122
|
35 |
+
#: ../admin/class-add-search-to-menu-admin.php:153
|
36 |
+
msgid "Add Search To Menu Settings"
|
37 |
+
msgstr ""
|
38 |
+
|
39 |
+
#: ../admin/class-add-search-to-menu-admin.php:122
|
40 |
+
msgid "Add Search To Menu"
|
41 |
+
msgstr ""
|
42 |
+
|
43 |
+
#: ../admin/class-add-search-to-menu-admin.php:136
|
44 |
+
msgid "Like Add Search To Menu?"
|
45 |
+
msgstr ""
|
46 |
+
|
47 |
+
#: ../admin/class-add-search-to-menu-admin.php:136
|
48 |
+
msgid "Give us a rating"
|
49 |
+
msgstr ""
|
50 |
+
|
51 |
+
#: ../admin/class-add-search-to-menu-admin.php:139
|
52 |
+
msgid "Need Help or Have Suggestions?"
|
53 |
+
msgstr ""
|
54 |
+
|
55 |
+
#: ../admin/class-add-search-to-menu-admin.php:139
|
56 |
+
msgid "contact us on"
|
57 |
+
msgstr ""
|
58 |
+
|
59 |
+
#: ../admin/class-add-search-to-menu-admin.php:139
|
60 |
+
msgid "Plugin support forum"
|
61 |
+
msgstr ""
|
62 |
+
|
63 |
+
#: ../admin/class-add-search-to-menu-admin.php:139
|
64 |
+
msgid "or"
|
65 |
+
msgstr ""
|
66 |
+
|
67 |
+
#: ../admin/class-add-search-to-menu-admin.php:139
|
68 |
+
msgid "Contact us page"
|
69 |
+
msgstr ""
|
70 |
+
|
71 |
+
#: ../admin/class-add-search-to-menu-admin.php:142
|
72 |
+
msgid "Access Plugin Documentation on"
|
73 |
+
msgstr ""
|
74 |
+
|
75 |
+
#: ../admin/class-add-search-to-menu-admin.php:155
|
76 |
+
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."
|
143 |
+
msgstr ""
|
public/class-add-search-to-menu-public.php
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The Add Search To Menu Public defines all functionality of plugin
|
5 |
+
* for the site front
|
6 |
+
*
|
7 |
+
* This class defines the meta box used to display the post meta data and registers
|
8 |
+
* the style sheet responsible for styling the content of the meta box.
|
9 |
+
*
|
10 |
+
* @package ASTM
|
11 |
+
* @since 1.0.0
|
12 |
+
*/
|
13 |
+
class Add_Search_To_Menu_Public {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Global plugin option.
|
17 |
+
*/
|
18 |
+
public $options;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* A reference to the version of the plugin that is passed to this class from the caller.
|
22 |
+
*
|
23 |
+
* @access private
|
24 |
+
* @var string $version The current version of the plugin.
|
25 |
+
*/
|
26 |
+
private $version;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Initializes this class and stores the current version of this plugin.
|
30 |
+
*
|
31 |
+
* @param string $version The current version of this plugin.
|
32 |
+
*/
|
33 |
+
public function __construct( $version ) {
|
34 |
+
$this->version = $version;
|
35 |
+
$this->options = get_option( 'add_search_to_menu' );
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* PHP 4 Compatible Constructor
|
40 |
+
*
|
41 |
+
*/
|
42 |
+
function Add_Search_To_Menu_Public() {
|
43 |
+
$this->__construct();
|
44 |
+
}
|
45 |
+
|
46 |
+
/* Enqueues search menu style and script files */
|
47 |
+
function add_search_to_menu_script_style(){
|
48 |
+
|
49 |
+
$options = $this->options;
|
50 |
+
|
51 |
+
if ( ! isset( $options['do_not_load_plugin_files']['plugin-css-file'] ) ){
|
52 |
+
wp_enqueue_style( 'add-search-to-menu-styles', plugins_url( '/css/add-search-to-menu.css', __FILE__ ) );
|
53 |
+
}
|
54 |
+
|
55 |
+
if ( ! isset( $options['do_not_load_plugin_files']['plugin-js-file'] ) && ( isset( $options['add_search_to_menu_style'] ) && $options['add_search_to_menu_style'] != 'default' ) ) {
|
56 |
+
wp_enqueue_script( 'add-search-to-menu-scripts', plugins_url( '/js/add-search-to-menu.js', __FILE__ ), array( 'jquery' ), '1.0', true );
|
57 |
+
}
|
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 |
+
|
65 |
+
if ( isset( $options['add_search_to_menu_locations'] ) ) {
|
66 |
+
|
67 |
+
if ( isset( $options['add_search_to_menu_locations']['initial'] ) ) {
|
68 |
+
unset( $options['add_search_to_menu_locations']['initial'] );
|
69 |
+
$options['add_search_to_menu_locations'][$args->theme_location] = $args->theme_location;
|
70 |
+
update_option( 'add_search_to_menu', $options );
|
71 |
+
}
|
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">
|
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 .= get_search_form( false ) . '</a></li>';
|
89 |
+
|
90 |
+
$items .= '</li>';
|
91 |
+
}
|
92 |
+
}
|
93 |
+
return $items;
|
94 |
+
}
|
95 |
+
|
96 |
+
}
|
public/css/add-search-to-menu.css
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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%;
|
22 |
+
position: absolute;
|
23 |
+
right: 0;
|
24 |
+
top: 100%;
|
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;
|
33 |
+
right: 0;
|
34 |
+
top: 10%;
|
35 |
+
width: 0;
|
36 |
+
z-index: 9;
|
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 |
+
}
|
public/js/add-search-to-menu.js
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
( function( $ ) {
|
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();
|
10 |
+
|
11 |
+
if ( $( this ).parent().parent().css( 'position' ) === 'static' ) {
|
12 |
+
$( this ).parent().parent().css( 'position', 'relative' );
|
13 |
+
}
|
14 |
+
|
15 |
+
if ( $( this ).parent().hasClass( 'dropdown' ) ) {
|
16 |
+
$( this ).parent().find( 'form' ).fadeToggle();
|
17 |
+
} else if ( $( this ).parent().hasClass( 'sliding' ) ) {
|
18 |
+
$( this ).parent().find( 'form' ).animate( { width:'300' } );
|
19 |
+
$( this ).parent().find( 'form input[type="search"], form input[type="text"]' ).focus();
|
20 |
+
$( this ).parent().addClass( 'open' );
|
21 |
+
} else if ( $( this ).parent().hasClass( 'full-width-menu' ) ) {
|
22 |
+
$( this ).parent().addClass('active-search');
|
23 |
+
$( this ).parent().find( 'form' ).animate( { width:'100%' } );
|
24 |
+
$( this ).parent().addClass( 'open' );
|
25 |
+
$( this ).parent().find( 'form input[type="search"], form input[type="text"]' ).focus();
|
26 |
+
}
|
27 |
+
} );
|
28 |
+
} );
|
29 |
+
|
30 |
+
$( 'li.search-menu form input[type="search"], li.search-menu form input[type="text"]' ).on( 'click', function( e ) {
|
31 |
+
e.stopPropagation(); // This is the preferred method.
|
32 |
+
return false;
|
33 |
+
} );
|
34 |
+
|
35 |
+
$( window ).click( function() {
|
36 |
+
if ( $( 'li.search-menu' ).hasClass( 'open' ) ) {
|
37 |
+
$( 'li.search-menu form' ).animate(
|
38 |
+
{ width:'0' },
|
39 |
+
400,
|
40 |
+
function() {
|
41 |
+
$( 'li.search-menu' ).removeClass( 'active-search' );
|
42 |
+
$( 'li.search-menu' ).removeClass( 'open' );
|
43 |
+
}
|
44 |
+
);
|
45 |
+
} else if ( $( 'li.search-menu' ).hasClass( 'dropdown' ) ){
|
46 |
+
$( 'li.search-menu form' ).fadeOut();
|
47 |
+
}
|
48 |
+
});
|
49 |
+
|
50 |
+
} )( jQuery );
|
readme.txt
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Add Search To Menu ===
|
2 |
+
Contributors: vinod dalvi, freewptp
|
3 |
+
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.7.3
|
7 |
+
Stable tag: 1.0
|
8 |
+
License: GPLv2 or later
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
|
11 |
+
The plugin displays search form in the navigation bar which can be configured from the admin area.
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
Add Search To Menu plugin allows you to add search form in your site navigation bar that makes users to search your site easily.
|
16 |
+
|
17 |
+
The plugin provides you various settings in the admin area which you can use to customize the search form.
|
18 |
+
|
19 |
+
The styling of search form highly depends on how the theme styles search form so if you face any styling issue with it then to style it correctly feel free to get free support from our support forum here [Plugin support forum](http://freewptp.com/forum/wordpress-plugins-forum/add-search-to-menu/)
|
20 |
+
|
21 |
+
<br /><br />
|
22 |
+
|
23 |
+
Like Add Search To Menu? [Give us a rating](https://wordpress.org/support/plugin/add-search-to-menu/reviews/?filter=5#new-post)
|
24 |
+
|
25 |
+
Need Help or Have Suggestions? contact us on [Plugin support forum](http://freewptp.com/forum/wordpress-plugins-forum/add-search-to-menu/) or [Contact us page](http://freewptp.com/contact/)
|
26 |
+
|
27 |
+
Access Plugin Documentation on [http://freewptp.com/plugins/add-search-to-menu/](http://freewptp.com/plugins/add-search-to-menu/)
|
28 |
+
|
29 |
+
== Installation ==
|
30 |
+
|
31 |
+
* Install the plugin from the 'Plugins' section in your dashboard (Go to `Plugins -> Add New -> Search` and search for Add Search To Menu).
|
32 |
+
* Alternatively, you can [download](http://downloads.wordpress.org/plugin/add-search-to-menu.zip "Download Add Search To Menu") the plugin from the repository. Unzip it and upload it to the plugins folder of your WordPress installation (`wp-content/plugins/` directory of your WordPress installation).
|
33 |
+
* Activate it through the 'Plugins' section.
|
34 |
+
* Use the `Settings -> Add Search To Menu` to configure the plugin
|
35 |
+
|
36 |
+
== Frequently Asked Questions ==
|
37 |
+
|
38 |
+
= Why does the search form not display on my site navigation? =
|
39 |
+
|
40 |
+
Please make sure you have configured the plugin settings from Settings -> Add Search To Menu
|
41 |
+
|
42 |
+
== Screenshots ==
|
43 |
+
|
44 |
+
1. Displays default search form in the navigation bar in the front end of site.
|
45 |
+
2. Displays dropdown search form in the navigation bar in the front end of site.
|
46 |
+
3. Displays sliding search form in the navigation bar in the front end of site.
|
47 |
+
4. Displays full width search form in the navigation bar in the front end of site.
|
48 |
+
5. Plugin settings in the admin area of the site.
|
49 |
+
|
50 |
+
== Changelog ==
|
51 |
+
|
52 |
+
= 1.0 =
|
53 |
+
* Initial release.
|
54 |
+
|
55 |
+
== Upgrade Notice ==
|
56 |
+
|
57 |
+
= 1.0 =
|
58 |
+
* Initial release.
|
uninstall.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Fired when the plugin is uninstalled.
|
5 |
+
*
|
6 |
+
*
|
7 |
+
* @link http://freewptp.com
|
8 |
+
* @since 1.0.0
|
9 |
+
*
|
10 |
+
* @package ASTM
|
11 |
+
*/
|
12 |
+
|
13 |
+
// If uninstall not called from WordPress, then exit.
|
14 |
+
if ( ! defined( 'ABSPATH' ) && ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
15 |
+
exit;
|
16 |
+
}
|