Version Description
- Enhanced Mobile Display option to work with caching.
=
Download this release
Release Info
Developer | vinod dalvi |
Plugin | Ivory Search – WordPress Search Plugin |
Version | 3.3 |
Comparing to | |
See all releases |
Code changes from version 3.2 to 3.3
- add-search-to-menu.php +86 -30
- admin/class-astm-admin.php +46 -80
- admin/partials/admin-page.php +30 -0
- includes/class-astm-activator.php +7 -8
- includes/class-astm-deactivator.php +4 -5
- includes/class-astm-i18n.php +19 -2
- includes/class-astm-loader.php +0 -130
- includes/class-astm.php +43 -52
- public/class-astm-public.php +52 -55
- public/css/add-search-to-menu.css +5 -0
- readme.txt +7 -4
add-search-to-menu.php
CHANGED
@@ -3,31 +3,31 @@
|
|
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.
|
7 |
* Author: Vinod Dalvi
|
8 |
* Author URI: http://freewptp.com
|
9 |
* License: GPL2+
|
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 |
-
*
|
15 |
* Add Search To Menu is free software: you can redistribute it and/or modify
|
16 |
* it under the terms of the GNU General Public License as published by
|
17 |
* the Free Software Foundation, either version 2 of the License, or
|
18 |
* any later version.
|
19 |
-
*
|
20 |
* Add Search To Menu is distributed in the hope that it will be useful,
|
21 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
23 |
* GNU General Public License for more details.
|
24 |
-
*
|
25 |
* You should have received a copy of the GNU General Public License
|
26 |
* along with Add Search To Menu. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
|
27 |
*/
|
28 |
-
|
29 |
|
30 |
-
|
|
|
31 |
* Includes necessary dependencies and starts the plugin.
|
32 |
*
|
33 |
* @package ASTM
|
@@ -37,32 +37,88 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
37 |
exit; // Exits if accessed directly.
|
38 |
}
|
39 |
|
40 |
-
|
41 |
-
* Defines constants.
|
42 |
-
*/
|
43 |
-
define( 'ASTM_VERSION', '3.2' );
|
44 |
-
define( 'ASTM_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
45 |
-
define( 'ASTM_PLUGIN_FILE', __FILE__ );
|
46 |
|
47 |
-
/**
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
require_once ASTM_PLUGIN_DIR . 'admin/class-astm-admin.php';
|
54 |
-
require_once ASTM_PLUGIN_DIR . 'public/class-astm-public.php';
|
55 |
-
require_once ASTM_PLUGIN_DIR . 'includes/class-astm-loader.php';
|
56 |
-
require_once ASTM_PLUGIN_DIR . 'includes/class-astm.php';
|
57 |
|
58 |
-
/**
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
/**
|
65 |
* Starts plugin execution.
|
66 |
*/
|
67 |
-
$astm =
|
68 |
-
$astm
|
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.3
|
7 |
* Author: Vinod Dalvi
|
8 |
* Author URI: http://freewptp.com
|
9 |
* License: GPL2+
|
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 |
+
*
|
15 |
* Add Search To Menu is free software: you can redistribute it and/or modify
|
16 |
* it under the terms of the GNU General Public License as published by
|
17 |
* the Free Software Foundation, either version 2 of the License, or
|
18 |
* any later version.
|
19 |
+
*
|
20 |
* Add Search To Menu is distributed in the hope that it will be useful,
|
21 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
23 |
* GNU General Public License for more details.
|
24 |
+
*
|
25 |
* You should have received a copy of the GNU General Public License
|
26 |
* along with Add Search To Menu. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
|
27 |
*/
|
|
|
28 |
|
29 |
+
|
30 |
+
/**
|
31 |
* Includes necessary dependencies and starts the plugin.
|
32 |
*
|
33 |
* @package ASTM
|
37 |
exit; // Exits if accessed directly.
|
38 |
}
|
39 |
|
40 |
+
if ( ! class_exists( 'Add_Search_To_Menu' ) ) {
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
/**
|
43 |
+
* Main Add Search To Menu Class.
|
44 |
+
*
|
45 |
+
* @class Add_Search_To_Menu
|
46 |
+
*/
|
47 |
+
final class Add_Search_To_Menu {
|
|
|
|
|
|
|
|
|
48 |
|
49 |
+
/**
|
50 |
+
* Stores plugin options.
|
51 |
+
*/
|
52 |
+
public $opt;
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Core singleton class
|
56 |
+
* @var self
|
57 |
+
*/
|
58 |
+
private static $_instance;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Add Search To Menu Constructor.
|
62 |
+
*/
|
63 |
+
public function __construct() {
|
64 |
+
$this->opt = get_option( 'add_search_to_menu' );
|
65 |
+
$this->define_constants();
|
66 |
+
$this->includes();
|
67 |
+
$this->init_hooks();
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Gets the instance of this class.
|
72 |
+
*
|
73 |
+
* @return self
|
74 |
+
*/
|
75 |
+
public static function getInstance() {
|
76 |
+
if ( ! ( self::$_instance instanceof self ) ) {
|
77 |
+
self::$_instance = new self();
|
78 |
+
}
|
79 |
+
|
80 |
+
return self::$_instance;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Defines Add Search To Menu Constants.
|
85 |
+
*/
|
86 |
+
private function define_constants() {
|
87 |
+
define( 'ASTM_VERSION', '3.2' );
|
88 |
+
define( 'ASTM_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
89 |
+
define( 'ASTM_PLUGIN_FILE', __FILE__ );
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Includes required core files used in admin and on the frontend.
|
94 |
+
*/
|
95 |
+
public function includes() {
|
96 |
+
require_once ASTM_PLUGIN_DIR . 'includes/class-astm-activator.php';
|
97 |
+
require_once ASTM_PLUGIN_DIR . 'includes/class-astm-deactivator.php';
|
98 |
+
require_once ASTM_PLUGIN_DIR . 'includes/class-astm-i18n.php';
|
99 |
+
|
100 |
+
if ( is_admin() ) {
|
101 |
+
require_once ASTM_PLUGIN_DIR . 'admin/class-astm-admin.php';
|
102 |
+
} else {
|
103 |
+
require_once ASTM_PLUGIN_DIR . 'public/class-astm-public.php';
|
104 |
+
}
|
105 |
+
|
106 |
+
require_once ASTM_PLUGIN_DIR . 'includes/class-astm.php';
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Hooks into actions and filters.
|
111 |
+
*/
|
112 |
+
private function init_hooks() {
|
113 |
+
// Executes necessary actions on plugin activation and deactivation.
|
114 |
+
register_activation_hook( ASTM_PLUGIN_FILE, array( 'ASTM_Activator', 'activate' ) );
|
115 |
+
register_deactivation_hook( ASTM_PLUGIN_FILE, array( 'ASTM_Deactivator', 'deactivate' ) );
|
116 |
+
}
|
117 |
+
}
|
118 |
+
}
|
119 |
|
120 |
/**
|
121 |
* Starts plugin execution.
|
122 |
*/
|
123 |
+
$astm = Add_Search_To_Menu::getInstance();
|
124 |
+
new ASTM_Loader( $astm );
|
admin/class-astm-admin.php
CHANGED
@@ -7,46 +7,56 @@
|
|
7 |
*/
|
8 |
|
9 |
if ( ! class_exists( 'ASTM_Admin' ) ) {
|
10 |
-
|
11 |
class ASTM_Admin {
|
12 |
|
13 |
/**
|
14 |
* Stores plugin options.
|
15 |
*/
|
16 |
-
public $
|
17 |
|
18 |
/**
|
19 |
* Stores network activation status.
|
20 |
*/
|
21 |
private $networkactive;
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
/**
|
24 |
* Initializes this class.
|
25 |
*
|
26 |
*/
|
27 |
public function __construct() {
|
28 |
-
$
|
|
|
29 |
$this->networkactive = ( is_multisite() && array_key_exists( plugin_basename( ASTM_PLUGIN_FILE ), (array) get_site_option( 'active_sitewide_plugins' ) ) );
|
30 |
}
|
31 |
|
32 |
/**
|
33 |
-
*
|
|
|
|
|
34 |
*/
|
35 |
-
function
|
36 |
-
|
|
|
|
|
|
|
|
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
* Loads plugin javascript and stylesheet files in the admin area.
|
41 |
*/
|
42 |
function admin_script_style(){
|
43 |
-
|
44 |
wp_register_script( 'add-search-to-menu-scripts', plugins_url( '/admin/js/add-search-to-menu-admin.js', ASTM_PLUGIN_FILE ), array( 'jquery' ), ASTM_VERSION, true );
|
45 |
-
|
46 |
wp_localize_script( 'add-search-to-menu-scripts', 'add_search_to_menu', array(
|
47 |
'ajax_url' => admin_url( 'admin-ajax.php' )
|
48 |
) );
|
49 |
-
|
50 |
wp_enqueue_script( 'add-search-to-menu-scripts' );
|
51 |
}
|
52 |
|
@@ -59,7 +69,6 @@ if ( ! class_exists( 'ASTM_Admin' ) ) {
|
|
59 |
* @return array $links
|
60 |
*/
|
61 |
function plugin_settings_link( $links, $file ) {
|
62 |
-
|
63 |
if ( false !== strpos( $file, 'add-search-to-menu' ) ) {
|
64 |
$mylinks = array(
|
65 |
'<a href="http://freewptp.com/forum/wordpress-plugins-forum/add-search-to-menu/">' . esc_html__( 'Get Support', 'add-search-to-menu' ) . '</a>',
|
@@ -74,7 +83,6 @@ if ( ! class_exists( 'ASTM_Admin' ) ) {
|
|
74 |
* Displays plugin configuration notice in admin area.
|
75 |
*/
|
76 |
function setup_notice(){
|
77 |
-
|
78 |
if ( 0 === strpos( get_current_screen()->id, 'settings_page_add_search_to_menu' ) ) {
|
79 |
return;
|
80 |
}
|
@@ -91,11 +99,9 @@ if ( ! class_exists( 'ASTM_Admin' ) ) {
|
|
91 |
* Handles plugin notice dismiss functionality using AJAX.
|
92 |
*/
|
93 |
function dismiss_notice() {
|
94 |
-
|
95 |
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
96 |
-
$
|
97 |
-
|
98 |
-
update_option( 'add_search_to_menu', $options );
|
99 |
}
|
100 |
die();
|
101 |
}
|
@@ -108,38 +114,16 @@ if ( ! class_exists( 'ASTM_Admin' ) ) {
|
|
108 |
}
|
109 |
|
110 |
/**
|
111 |
-
*
|
112 |
*/
|
113 |
function admin_page_screen() {
|
114 |
-
|
115 |
-
<div class="wrap">
|
116 |
-
<form id="add_search_to_menu_options" action="options.php" method="post">
|
117 |
-
<?php
|
118 |
-
settings_fields( 'add_search_to_menu' );
|
119 |
-
do_settings_sections( 'add_search_to_menu' );
|
120 |
-
submit_button( 'Save Options', 'primary', 'add_search_to_menu_options_submit' );
|
121 |
-
?>
|
122 |
-
<div id="after-submit">
|
123 |
-
<p>
|
124 |
-
<?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>
|
125 |
-
</p>
|
126 |
-
<p>
|
127 |
-
<?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>
|
128 |
-
</p>
|
129 |
-
<p>
|
130 |
-
<?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>
|
131 |
-
</p>
|
132 |
-
</div>
|
133 |
-
</form>
|
134 |
-
</div>
|
135 |
-
<?php
|
136 |
}
|
137 |
|
138 |
/**
|
139 |
* Registers plugin settings.
|
140 |
*/
|
141 |
function settings_init(){
|
142 |
-
|
143 |
add_settings_section( 'add_search_to_menu_section', __( 'Add Search To Menu Settings', 'add-search-to-menu' ), array( $this, 'settings_section_desc'), 'add_search_to_menu' );
|
144 |
|
145 |
add_settings_field( 'add_search_to_menu_locations', __( 'Add Search to Menu : ', 'add-search-to-menu' ), array( $this, 'menu_locations' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
@@ -154,7 +138,6 @@ if ( ! class_exists( 'ASTM_Admin' ) ) {
|
|
154 |
add_settings_field( 'do_not_load_plugin_files', __( 'Do not load plugin files : ', 'add-search-to-menu' ), array( $this, 'plugin_files' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
155 |
|
156 |
register_setting( 'add_search_to_menu', 'add_search_to_menu' );
|
157 |
-
|
158 |
}
|
159 |
|
160 |
/**
|
@@ -168,8 +151,6 @@ if ( ! class_exists( 'ASTM_Admin' ) ) {
|
|
168 |
* Displays choose menu locations field.
|
169 |
*/
|
170 |
function menu_locations() {
|
171 |
-
|
172 |
-
$options = $this->options;
|
173 |
$html = '';
|
174 |
$menus = get_registered_nav_menus();
|
175 |
|
@@ -177,7 +158,7 @@ if ( ! class_exists( 'ASTM_Admin' ) ) {
|
|
177 |
|
178 |
foreach ( $menus as $location => $description ) {
|
179 |
|
180 |
-
$check_value = isset( $
|
181 |
$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 ) . '/>';
|
182 |
$html .= '<label for="add_search_to_menu_locations' . esc_attr( $location ) . '"> ' . esc_html( $description ) . '</label><br />';
|
183 |
}
|
@@ -191,8 +172,6 @@ if ( ! class_exists( 'ASTM_Admin' ) ) {
|
|
191 |
* Displays choose post types field.
|
192 |
*/
|
193 |
function post_posts() {
|
194 |
-
|
195 |
-
$options = $this->options;
|
196 |
$html = '';
|
197 |
$args = array( 'exclude_from_search' => false );
|
198 |
|
@@ -202,7 +181,7 @@ if ( ! class_exists( 'ASTM_Admin' ) ) {
|
|
202 |
|
203 |
foreach ( $posts as $key => $post ) {
|
204 |
|
205 |
-
$check_value = isset( $
|
206 |
$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 ) . '/>';
|
207 |
$html .= '<label for="add_search_to_menu_posts' . esc_attr( $key ) . '"> ' . esc_html( $post ) . '</label><br />';
|
208 |
}
|
@@ -217,8 +196,6 @@ if ( ! class_exists( 'ASTM_Admin' ) ) {
|
|
217 |
* Displays form style field.
|
218 |
*/
|
219 |
function form_style() {
|
220 |
-
|
221 |
-
$options = $this->options;
|
222 |
$styles = array(
|
223 |
'default' => __( 'Default', 'add-search-to-menu' ),
|
224 |
'dropdown' => __( 'Dropdown', 'add-search-to-menu' ),
|
@@ -226,13 +203,13 @@ if ( ! class_exists( 'ASTM_Admin' ) ) {
|
|
226 |
'full-width-menu' => __( 'Full Width', 'add-search-to-menu' )
|
227 |
);
|
228 |
|
229 |
-
if ( empty( $
|
230 |
-
$
|
231 |
-
update_option( 'add_search_to_menu', $
|
232 |
}
|
233 |
|
234 |
$html = '';
|
235 |
-
$check_value = isset( $
|
236 |
|
237 |
foreach ( $styles as $key => $style ) {
|
238 |
|
@@ -246,10 +223,8 @@ if ( ! class_exists( 'ASTM_Admin' ) ) {
|
|
246 |
* Displays search menu title field.
|
247 |
*/
|
248 |
function menu_title() {
|
249 |
-
|
250 |
-
$
|
251 |
-
$options['add_search_to_menu_title'] = isset( $options['add_search_to_menu_title'] ) ? $options['add_search_to_menu_title'] : '';
|
252 |
-
$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" />';
|
253 |
$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>';
|
254 |
echo $html;
|
255 |
}
|
@@ -258,10 +233,8 @@ if ( ! class_exists( 'ASTM_Admin' ) ) {
|
|
258 |
* Displays search menu classes field.
|
259 |
*/
|
260 |
function menu_classes() {
|
261 |
-
|
262 |
-
$
|
263 |
-
$options['add_search_to_menu_classes'] = isset( $options['add_search_to_menu_classes'] ) ? $options['add_search_to_menu_classes'] : 'astm-search-menu';
|
264 |
-
$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" />';
|
265 |
$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>';
|
266 |
echo $html;
|
267 |
}
|
@@ -270,10 +243,8 @@ if ( ! class_exists( 'ASTM_Admin' ) ) {
|
|
270 |
* Displays google cse field.
|
271 |
*/
|
272 |
function google_cse() {
|
273 |
-
|
274 |
-
$
|
275 |
-
$options['add_search_to_menu_gcse'] = isset( $options['add_search_to_menu_gcse'] ) ? $options['add_search_to_menu_gcse'] : '';
|
276 |
-
$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" />';
|
277 |
$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>';
|
278 |
echo $html;
|
279 |
}
|
@@ -282,12 +253,14 @@ if ( ! class_exists( 'ASTM_Admin' ) ) {
|
|
282 |
* Displays display in header field.
|
283 |
*/
|
284 |
function display_in_header() {
|
285 |
-
|
286 |
-
$options = $this->options;
|
287 |
-
$check_value = isset( $options['add_search_to_menu_display_in_header'] ) ? $options['add_search_to_menu_display_in_header'] : 0;
|
288 |
$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 ) . ' />';
|
289 |
$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>';
|
290 |
-
$html .= '<br /><label for="add_search_to_menu_display_in_header" style="font-size: 10px;">' . esc_html__( "It doesn not work with caching as this functionality uses WordPress wp_is_mobile function.", 'add-search-to-menu' ) . '</label>';
|
|
|
|
|
|
|
|
|
291 |
echo $html;
|
292 |
}
|
293 |
|
@@ -295,9 +268,7 @@ if ( ! class_exists( 'ASTM_Admin' ) ) {
|
|
295 |
* Displays search form close icon field.
|
296 |
*/
|
297 |
function close_icon() {
|
298 |
-
|
299 |
-
$options = $this->options;
|
300 |
-
$check_value = isset( $options['add_search_to_menu_close_icon'] ) ? $options['add_search_to_menu_close_icon'] : 0;
|
301 |
$html = '<input type="checkbox" id="add_search_to_menu_close_icon" name="add_search_to_menu[add_search_to_menu_close_icon]" value="add_search_to_menu_close_icon" ' . checked( 'add_search_to_menu_close_icon', $check_value, false ) . ' />';
|
302 |
$html .= '<label for="add_search_to_menu_close_icon"> ' . esc_html__( 'Display Search Form Close Icon', 'add-search-to-menu' ) . '</label>';
|
303 |
echo $html;
|
@@ -307,10 +278,8 @@ if ( ! class_exists( 'ASTM_Admin' ) ) {
|
|
307 |
* Displays custom css field.
|
308 |
*/
|
309 |
function custom_css() {
|
310 |
-
|
311 |
-
$
|
312 |
-
$options['add_search_to_menu_css'] = isset( $options['add_search_to_menu_css'] ) ? $options['add_search_to_menu_css'] : '';
|
313 |
-
$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>';
|
314 |
$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>';
|
315 |
echo $html;
|
316 |
}
|
@@ -319,19 +288,16 @@ if ( ! class_exists( 'ASTM_Admin' ) ) {
|
|
319 |
* Displays do not load plugin files field.
|
320 |
*/
|
321 |
function plugin_files() {
|
322 |
-
|
323 |
-
$options = $this->options;
|
324 |
$styles = array(
|
325 |
'plugin-css-file' => __( 'Plugin CSS File', 'add-search-to-menu' ),
|
326 |
-
'plugin-js-file'
|
327 |
|
328 |
);
|
329 |
|
330 |
-
|
331 |
$html = '';
|
332 |
foreach ( $styles as $key => $file ) {
|
333 |
|
334 |
-
$check_value = isset( $
|
335 |
$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 ) . '/>';
|
336 |
$html .= '<label for="do_not_load_plugin_files' . esc_attr( $key ) . '"> ' . esc_html( $file ) . '</label>';
|
337 |
|
7 |
*/
|
8 |
|
9 |
if ( ! class_exists( 'ASTM_Admin' ) ) {
|
10 |
+
|
11 |
class ASTM_Admin {
|
12 |
|
13 |
/**
|
14 |
* Stores plugin options.
|
15 |
*/
|
16 |
+
public $opt;
|
17 |
|
18 |
/**
|
19 |
* Stores network activation status.
|
20 |
*/
|
21 |
private $networkactive;
|
22 |
|
23 |
+
/**
|
24 |
+
* Core singleton class
|
25 |
+
* @var self
|
26 |
+
*/
|
27 |
+
private static $_instance;
|
28 |
+
|
29 |
/**
|
30 |
* Initializes this class.
|
31 |
*
|
32 |
*/
|
33 |
public function __construct() {
|
34 |
+
$astm = Add_Search_To_Menu::getInstance();
|
35 |
+
$this->opt = ( null !== $astm ) ? $astm->opt : get_option( 'add_search_to_menu' );
|
36 |
$this->networkactive = ( is_multisite() && array_key_exists( plugin_basename( ASTM_PLUGIN_FILE ), (array) get_site_option( 'active_sitewide_plugins' ) ) );
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
+
* Gets the instance of this class.
|
41 |
+
*
|
42 |
+
* @return self
|
43 |
*/
|
44 |
+
public static function getInstance() {
|
45 |
+
if ( ! ( self::$_instance instanceof self ) ) {
|
46 |
+
self::$_instance = new self();
|
47 |
+
}
|
48 |
+
|
49 |
+
return self::$_instance;
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
* Loads plugin javascript and stylesheet files in the admin area.
|
54 |
*/
|
55 |
function admin_script_style(){
|
|
|
56 |
wp_register_script( 'add-search-to-menu-scripts', plugins_url( '/admin/js/add-search-to-menu-admin.js', ASTM_PLUGIN_FILE ), array( 'jquery' ), ASTM_VERSION, true );
|
|
|
57 |
wp_localize_script( 'add-search-to-menu-scripts', 'add_search_to_menu', array(
|
58 |
'ajax_url' => admin_url( 'admin-ajax.php' )
|
59 |
) );
|
|
|
60 |
wp_enqueue_script( 'add-search-to-menu-scripts' );
|
61 |
}
|
62 |
|
69 |
* @return array $links
|
70 |
*/
|
71 |
function plugin_settings_link( $links, $file ) {
|
|
|
72 |
if ( false !== strpos( $file, 'add-search-to-menu' ) ) {
|
73 |
$mylinks = array(
|
74 |
'<a href="http://freewptp.com/forum/wordpress-plugins-forum/add-search-to-menu/">' . esc_html__( 'Get Support', 'add-search-to-menu' ) . '</a>',
|
83 |
* Displays plugin configuration notice in admin area.
|
84 |
*/
|
85 |
function setup_notice(){
|
|
|
86 |
if ( 0 === strpos( get_current_screen()->id, 'settings_page_add_search_to_menu' ) ) {
|
87 |
return;
|
88 |
}
|
99 |
* Handles plugin notice dismiss functionality using AJAX.
|
100 |
*/
|
101 |
function dismiss_notice() {
|
|
|
102 |
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
103 |
+
$this->opt['dismiss_admin_notices'] = 1;
|
104 |
+
update_option( 'add_search_to_menu', $this->opt );
|
|
|
105 |
}
|
106 |
die();
|
107 |
}
|
114 |
}
|
115 |
|
116 |
/**
|
117 |
+
* Renders the settings page for this plugin.
|
118 |
*/
|
119 |
function admin_page_screen() {
|
120 |
+
include_once( 'partials/admin-page.php' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
}
|
122 |
|
123 |
/**
|
124 |
* Registers plugin settings.
|
125 |
*/
|
126 |
function settings_init(){
|
|
|
127 |
add_settings_section( 'add_search_to_menu_section', __( 'Add Search To Menu Settings', 'add-search-to-menu' ), array( $this, 'settings_section_desc'), 'add_search_to_menu' );
|
128 |
|
129 |
add_settings_field( 'add_search_to_menu_locations', __( 'Add Search to Menu : ', 'add-search-to-menu' ), array( $this, 'menu_locations' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
138 |
add_settings_field( 'do_not_load_plugin_files', __( 'Do not load plugin files : ', 'add-search-to-menu' ), array( $this, 'plugin_files' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
139 |
|
140 |
register_setting( 'add_search_to_menu', 'add_search_to_menu' );
|
|
|
141 |
}
|
142 |
|
143 |
/**
|
151 |
* Displays choose menu locations field.
|
152 |
*/
|
153 |
function menu_locations() {
|
|
|
|
|
154 |
$html = '';
|
155 |
$menus = get_registered_nav_menus();
|
156 |
|
158 |
|
159 |
foreach ( $menus as $location => $description ) {
|
160 |
|
161 |
+
$check_value = isset( $this->opt['add_search_to_menu_locations'][ $location ] ) ? $this->opt['add_search_to_menu_locations'][ $location ] : 0;
|
162 |
$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 ) . '/>';
|
163 |
$html .= '<label for="add_search_to_menu_locations' . esc_attr( $location ) . '"> ' . esc_html( $description ) . '</label><br />';
|
164 |
}
|
172 |
* Displays choose post types field.
|
173 |
*/
|
174 |
function post_posts() {
|
|
|
|
|
175 |
$html = '';
|
176 |
$args = array( 'exclude_from_search' => false );
|
177 |
|
181 |
|
182 |
foreach ( $posts as $key => $post ) {
|
183 |
|
184 |
+
$check_value = isset( $this->opt['add_search_to_menu_posts'][$key] ) ? $this->opt['add_search_to_menu_posts'][ $key ] : 0;
|
185 |
$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 ) . '/>';
|
186 |
$html .= '<label for="add_search_to_menu_posts' . esc_attr( $key ) . '"> ' . esc_html( $post ) . '</label><br />';
|
187 |
}
|
196 |
* Displays form style field.
|
197 |
*/
|
198 |
function form_style() {
|
|
|
|
|
199 |
$styles = array(
|
200 |
'default' => __( 'Default', 'add-search-to-menu' ),
|
201 |
'dropdown' => __( 'Dropdown', 'add-search-to-menu' ),
|
203 |
'full-width-menu' => __( 'Full Width', 'add-search-to-menu' )
|
204 |
);
|
205 |
|
206 |
+
if ( empty( $this->opt ) || ! isset( $this->opt['add_search_to_menu_style'] ) ) {
|
207 |
+
$this->opt['add_search_to_menu_style'] = 'default';
|
208 |
+
update_option( 'add_search_to_menu', $this->opt );
|
209 |
}
|
210 |
|
211 |
$html = '';
|
212 |
+
$check_value = isset( $this->opt['add_search_to_menu_style'] ) ? $this->opt['add_search_to_menu_style'] : 'default';
|
213 |
|
214 |
foreach ( $styles as $key => $style ) {
|
215 |
|
223 |
* Displays search menu title field.
|
224 |
*/
|
225 |
function menu_title() {
|
226 |
+
$this->opt['add_search_to_menu_title'] = isset( $this->opt['add_search_to_menu_title'] ) ? $this->opt['add_search_to_menu_title'] : '';
|
227 |
+
$html = '<input type="text" id="add_search_to_menu_title" name="add_search_to_menu[add_search_to_menu_title]" value="' . esc_attr( $this->opt['add_search_to_menu_title'] ) . '" size="50" />';
|
|
|
|
|
228 |
$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>';
|
229 |
echo $html;
|
230 |
}
|
233 |
* Displays search menu classes field.
|
234 |
*/
|
235 |
function menu_classes() {
|
236 |
+
$this->opt['add_search_to_menu_classes'] = isset( $this->opt['add_search_to_menu_classes'] ) ? $this->opt['add_search_to_menu_classes'] : 'astm-search-menu';
|
237 |
+
$html = '<input type="text" id="add_search_to_menu_classes" name="add_search_to_menu[add_search_to_menu_classes]" value="' . esc_attr( $this->opt['add_search_to_menu_classes'] ) . '" size="50" />';
|
|
|
|
|
238 |
$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>';
|
239 |
echo $html;
|
240 |
}
|
243 |
* Displays google cse field.
|
244 |
*/
|
245 |
function google_cse() {
|
246 |
+
$this->opt['add_search_to_menu_gcse'] = isset( $this->opt['add_search_to_menu_gcse'] ) ? $this->opt['add_search_to_menu_gcse'] : '';
|
247 |
+
$html = '<input type="text" id="add_search_to_menu_gcse" name="add_search_to_menu[add_search_to_menu_gcse]" value="' . esc_attr( $this->opt['add_search_to_menu_gcse'] ) . '" size="50" />';
|
|
|
|
|
248 |
$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>';
|
249 |
echo $html;
|
250 |
}
|
253 |
* Displays display in header field.
|
254 |
*/
|
255 |
function display_in_header() {
|
256 |
+
$check_value = isset( $this->opt['add_search_to_menu_display_in_header'] ) ? $this->opt['add_search_to_menu_display_in_header'] : 0;
|
|
|
|
|
257 |
$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 ) . ' />';
|
258 |
$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>';
|
259 |
+
$html .= '<br /><label for="add_search_to_menu_display_in_header" style="font-size: 10px;margin: 5px 0 10px;display: inline-block;">' . esc_html__( "It doesn not work with caching as this functionality uses WordPress wp_is_mobile function.", 'add-search-to-menu' ) . '</label>';
|
260 |
+
$check_value = isset( $this->opt['astm_site_uses_cache'] ) ? $this->opt['astm_site_uses_cache'] : 0;
|
261 |
+
$html .= '<br /><input type="checkbox" id="astm_site_uses_cache" name="add_search_to_menu[astm_site_uses_cache]" value="astm_site_uses_cache" ' . checked( 'astm_site_uses_cache', $check_value, false ) . ' />';
|
262 |
+
$html .= '<label for="astm_site_uses_cache"> ' . esc_html__( 'This site uses Cache', 'add-search-to-menu' ) . '</label>';
|
263 |
+
$html .= '<br /><label for="astm_site_uses_cache" style="font-size: 10px;">' . esc_html__( "Use this option to hide search form using CSS code and display it in site header on mobile devices.", 'add-search-to-menu' ) . '</label>';
|
264 |
echo $html;
|
265 |
}
|
266 |
|
268 |
* Displays search form close icon field.
|
269 |
*/
|
270 |
function close_icon() {
|
271 |
+
$check_value = isset( $this->opt['add_search_to_menu_close_icon'] ) ? $this->opt['add_search_to_menu_close_icon'] : 0;
|
|
|
|
|
272 |
$html = '<input type="checkbox" id="add_search_to_menu_close_icon" name="add_search_to_menu[add_search_to_menu_close_icon]" value="add_search_to_menu_close_icon" ' . checked( 'add_search_to_menu_close_icon', $check_value, false ) . ' />';
|
273 |
$html .= '<label for="add_search_to_menu_close_icon"> ' . esc_html__( 'Display Search Form Close Icon', 'add-search-to-menu' ) . '</label>';
|
274 |
echo $html;
|
278 |
* Displays custom css field.
|
279 |
*/
|
280 |
function custom_css() {
|
281 |
+
$this->opt['add_search_to_menu_css'] = isset( $this->opt['add_search_to_menu_css'] ) ? $this->opt['add_search_to_menu_css'] : '';
|
282 |
+
$html = '<textarea rows="4" cols="53" id="add_search_to_menu_css" name="add_search_to_menu[add_search_to_menu_css]" >' . esc_attr( $this->opt['add_search_to_menu_css'] ) . '</textarea>';
|
|
|
|
|
283 |
$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>';
|
284 |
echo $html;
|
285 |
}
|
288 |
* Displays do not load plugin files field.
|
289 |
*/
|
290 |
function plugin_files() {
|
|
|
|
|
291 |
$styles = array(
|
292 |
'plugin-css-file' => __( 'Plugin CSS File', 'add-search-to-menu' ),
|
293 |
+
'plugin-js-file' => __( 'Plugin JavaScript File', 'add-search-to-menu' )
|
294 |
|
295 |
);
|
296 |
|
|
|
297 |
$html = '';
|
298 |
foreach ( $styles as $key => $file ) {
|
299 |
|
300 |
+
$check_value = isset( $this->opt['do_not_load_plugin_files'][ $key] ) ? $this->opt['do_not_load_plugin_files'][ $key ] : 0;
|
301 |
$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 ) . '/>';
|
302 |
$html .= '<label for="do_not_load_plugin_files' . esc_attr( $key ) . '"> ' . esc_html( $file ) . '</label>';
|
303 |
|
admin/partials/admin-page.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Represents the view for the administration dashboard.
|
4 |
+
*
|
5 |
+
* This includes the header, options, and other information that should provide
|
6 |
+
* The User Interface to the end user.
|
7 |
+
*
|
8 |
+
* @package ASTM
|
9 |
+
*/
|
10 |
+
?>
|
11 |
+
<div class="wrap">
|
12 |
+
<form id="add_search_to_menu_options" action="options.php" method="post">
|
13 |
+
<?php
|
14 |
+
settings_fields( 'add_search_to_menu' );
|
15 |
+
do_settings_sections( 'add_search_to_menu' );
|
16 |
+
submit_button( 'Save Options', 'primary', 'add_search_to_menu_options_submit' );
|
17 |
+
?>
|
18 |
+
<div id="after-submit">
|
19 |
+
<p>
|
20 |
+
<?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>
|
21 |
+
</p>
|
22 |
+
<p>
|
23 |
+
<?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>
|
24 |
+
</p>
|
25 |
+
<p>
|
26 |
+
<?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>
|
27 |
+
</p>
|
28 |
+
</div>
|
29 |
+
</form>
|
30 |
+
</div>
|
includes/class-astm-activator.php
CHANGED
@@ -20,26 +20,25 @@ if ( ! class_exists( 'ASTM_Activator' ) ) {
|
|
20 |
* @since 1.0.0
|
21 |
*/
|
22 |
public static function activate() {
|
|
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
if ( ! isset( $options['add_search_to_menu_locations'] ) ) {
|
27 |
$menus = get_registered_nav_menus();
|
28 |
if ( ! empty( $menus ) ) {
|
29 |
$menu_keys = array_keys($menus);
|
30 |
-
$
|
31 |
-
update_option( 'add_search_to_menu', $
|
32 |
}
|
33 |
}
|
34 |
|
35 |
-
if ( ! isset( $
|
36 |
$args = array( 'exclude_from_search' => false );
|
37 |
$posts = get_post_types( $args );
|
38 |
$post_keys = array_keys( $posts );
|
39 |
foreach ( $post_keys as $post_key ) {
|
40 |
-
$
|
41 |
}
|
42 |
-
update_option( 'add_search_to_menu', $
|
43 |
}
|
44 |
}
|
45 |
}
|
20 |
* @since 1.0.0
|
21 |
*/
|
22 |
public static function activate() {
|
23 |
+
$opt = get_option( 'add_search_to_menu' );
|
24 |
|
25 |
+
if ( ! isset( $opt['add_search_to_menu_locations'] ) ) {
|
|
|
|
|
26 |
$menus = get_registered_nav_menus();
|
27 |
if ( ! empty( $menus ) ) {
|
28 |
$menu_keys = array_keys($menus);
|
29 |
+
$opt['add_search_to_menu_locations'][ $menu_keys[0] ] = $menu_keys[0];
|
30 |
+
update_option( 'add_search_to_menu', $opt );
|
31 |
}
|
32 |
}
|
33 |
|
34 |
+
if ( ! isset( $opt['add_search_to_menu_posts'] ) ) {
|
35 |
$args = array( 'exclude_from_search' => false );
|
36 |
$posts = get_post_types( $args );
|
37 |
$post_keys = array_keys( $posts );
|
38 |
foreach ( $post_keys as $post_key ) {
|
39 |
+
$opt['add_search_to_menu_posts'][ $post_key ] = $post_key;
|
40 |
}
|
41 |
+
update_option( 'add_search_to_menu', $opt );
|
42 |
}
|
43 |
}
|
44 |
}
|
includes/class-astm-deactivator.php
CHANGED
@@ -20,12 +20,11 @@ if ( ! class_exists( 'ASTM_Deactivator' ) ) {
|
|
20 |
* @since 1.0.0
|
21 |
*/
|
22 |
public static function deactivate() {
|
|
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
unset( $options['dismiss_admin_notices'] );
|
28 |
-
update_option( 'add_search_to_menu', $options );
|
29 |
}
|
30 |
}
|
31 |
}
|
20 |
* @since 1.0.0
|
21 |
*/
|
22 |
public static function deactivate() {
|
23 |
+
$opt = get_option( 'add_search_to_menu' );
|
24 |
|
25 |
+
if ( isset( $opt['dismiss_admin_notices'] ) ) {
|
26 |
+
unset( $opt['dismiss_admin_notices'] );
|
27 |
+
update_option( 'add_search_to_menu', $opt );
|
|
|
|
|
28 |
}
|
29 |
}
|
30 |
}
|
includes/class-astm-i18n.php
CHANGED
@@ -15,15 +15,32 @@ if ( ! class_exists( 'ASTM_i18n' ) ) {
|
|
15 |
|
16 |
class ASTM_i18n {
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
/**
|
19 |
* Loads the plugin text domain for translation.
|
20 |
*
|
21 |
* @since 1.0.0
|
22 |
*/
|
23 |
public function load_plugin_textdomain() {
|
24 |
-
|
25 |
load_plugin_textdomain( 'add-search-to-menu', false, dirname( dirname( plugin_basename( ASTM_PLUGIN_FILE ) ) ) . '/languages/' );
|
26 |
-
|
27 |
}
|
28 |
}
|
29 |
}
|
15 |
|
16 |
class ASTM_i18n {
|
17 |
|
18 |
+
/**
|
19 |
+
* Core singleton class
|
20 |
+
* @var self
|
21 |
+
*/
|
22 |
+
private static $_instance;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Gets the instance of this class.
|
26 |
+
*
|
27 |
+
* @return self
|
28 |
+
*/
|
29 |
+
public static function getInstance() {
|
30 |
+
if ( ! ( self::$_instance instanceof self ) ) {
|
31 |
+
self::$_instance = new self();
|
32 |
+
}
|
33 |
+
|
34 |
+
return self::$_instance;
|
35 |
+
}
|
36 |
+
|
37 |
/**
|
38 |
* Loads the plugin text domain for translation.
|
39 |
*
|
40 |
* @since 1.0.0
|
41 |
*/
|
42 |
public function load_plugin_textdomain() {
|
|
|
43 |
load_plugin_textdomain( 'add-search-to-menu', false, dirname( dirname( plugin_basename( ASTM_PLUGIN_FILE ) ) ) . '/languages/' );
|
|
|
44 |
}
|
45 |
}
|
46 |
}
|
includes/class-astm-loader.php
DELETED
@@ -1,130 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* The class is responsible for coordinating all actions and filters
|
4 |
-
* used throughout the plugin by registering all actions and filters
|
5 |
-
* for the plugin.
|
6 |
-
*
|
7 |
-
* Maintains a list of all hooks that are registered throughout
|
8 |
-
* the plugin, and register them with the WordPress API. Call the
|
9 |
-
* run function to execute the list of actions and filters.
|
10 |
-
*
|
11 |
-
* @since 1.0.0
|
12 |
-
* @package ASTM
|
13 |
-
* @subpackage ASTM/includes
|
14 |
-
* @author Free WPTP <freewptp@gmail.com>
|
15 |
-
*/
|
16 |
-
|
17 |
-
if ( ! class_exists( 'ASTM_Loader' ) ) {
|
18 |
-
|
19 |
-
class ASTM_Loader {
|
20 |
-
|
21 |
-
/**
|
22 |
-
* The array of actions registered with WordPress.
|
23 |
-
*
|
24 |
-
* @since 1.0.0
|
25 |
-
* @access protected
|
26 |
-
* @var array $actions The actions registered with WordPress to fire when the plugin loads.
|
27 |
-
*/
|
28 |
-
protected $actions;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* The array of filters registered with WordPress.
|
32 |
-
*
|
33 |
-
* @since 1.0.0
|
34 |
-
* @access protected
|
35 |
-
* @var array $filters The filters registered with WordPress to fire when the plugin loads.
|
36 |
-
*/
|
37 |
-
protected $filters;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Initializes the collections used to maintain the actions and filters.
|
41 |
-
*
|
42 |
-
* @since 1.0.0
|
43 |
-
*/
|
44 |
-
public function __construct() {
|
45 |
-
|
46 |
-
$this->actions = array();
|
47 |
-
$this->filters = array();
|
48 |
-
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* PHP 4 Compatible Constructor.
|
53 |
-
*/
|
54 |
-
function ASTM_Loader() {
|
55 |
-
$this->__construct();
|
56 |
-
}
|
57 |
-
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Adds 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 |
-
* Adds 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 |
-
* Registers the actions and hooks into a single collection.
|
89 |
-
*
|
90 |
-
* @since 1.0.0
|
91 |
-
* @access private
|
92 |
-
* @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
|
93 |
-
* @param string $hook The name of the WordPress filter that is being registered.
|
94 |
-
* @param object $component A reference to the instance of the object on which the filter is defined.
|
95 |
-
* @param string $callback The name of the function definition on the $component.
|
96 |
-
* @param int Optional $priority The priority at which the function should be fired.
|
97 |
-
* @param int Optional $accepted_args The number of arguments that should be passed to the $callback.
|
98 |
-
* @return type The collection of actions and filters registered with WordPress.
|
99 |
-
*/
|
100 |
-
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
|
101 |
-
|
102 |
-
$hooks[] = array(
|
103 |
-
'hook' => $hook,
|
104 |
-
'component' => $component,
|
105 |
-
'callback' => $callback,
|
106 |
-
'priority' => $priority,
|
107 |
-
'accepted_args' => $accepted_args
|
108 |
-
);
|
109 |
-
|
110 |
-
return $hooks;
|
111 |
-
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* Registers the filters and actions with WordPress.
|
116 |
-
*
|
117 |
-
* @since 1.0.0
|
118 |
-
*/
|
119 |
-
public function init() {
|
120 |
-
|
121 |
-
foreach ( $this->filters as $hook ) {
|
122 |
-
add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
|
123 |
-
}
|
124 |
-
|
125 |
-
foreach ( $this->actions as $hook ) {
|
126 |
-
add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
|
127 |
-
}
|
128 |
-
}
|
129 |
-
}
|
130 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/class-astm.php
CHANGED
@@ -11,24 +11,20 @@
|
|
11 |
* @package ASTM
|
12 |
*/
|
13 |
|
14 |
-
if ( ! class_exists( '
|
15 |
-
|
16 |
-
class Add_Search_To_Menu {
|
17 |
|
|
|
18 |
|
19 |
/**
|
20 |
-
*
|
21 |
*/
|
22 |
-
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
-
* @access protected
|
29 |
-
* @var Add_Search_To_Menu_Loader $loader Manages hooks between the WordPress hooks and the callback functions.
|
30 |
*/
|
31 |
-
|
32 |
|
33 |
/**
|
34 |
* Instantiates the plugin by setting up the core properties and loading
|
@@ -38,11 +34,8 @@ if ( ! class_exists( 'Add_Search_To_Menu' ) ) {
|
|
38 |
* plugin dependencies, and will leverage the Add_Search_To_Menu for
|
39 |
* registering the hooks and the callback functions used throughout the plugin.
|
40 |
*/
|
41 |
-
public function __construct() {
|
42 |
-
|
43 |
-
$this->options = get_option( 'add_search_to_menu' );
|
44 |
-
$this->loader = new ASTM_Loader();
|
45 |
-
|
46 |
$this->set_locale();
|
47 |
|
48 |
if ( is_admin() ) {
|
@@ -53,14 +46,20 @@ if ( ! class_exists( 'Add_Search_To_Menu' ) ) {
|
|
53 |
}
|
54 |
|
55 |
/**
|
56 |
-
*
|
|
|
|
|
57 |
*/
|
58 |
-
function
|
59 |
-
|
|
|
|
|
|
|
|
|
60 |
}
|
61 |
|
62 |
/**
|
63 |
-
*
|
64 |
*
|
65 |
* Uses the ASTM_i18n class in order to set the domain and to register the hook
|
66 |
* with WordPress.
|
@@ -69,7 +68,8 @@ if ( ! class_exists( 'Add_Search_To_Menu' ) ) {
|
|
69 |
* @access private
|
70 |
*/
|
71 |
private function set_locale() {
|
72 |
-
$
|
|
|
73 |
}
|
74 |
|
75 |
/**
|
@@ -78,19 +78,18 @@ if ( ! class_exists( 'Add_Search_To_Menu' ) ) {
|
|
78 |
* @access private
|
79 |
*/
|
80 |
private function admin_hooks() {
|
81 |
-
$
|
82 |
-
$admin = new ASTM_Admin( ASTM_VERSION );
|
83 |
|
84 |
-
if ( ! isset( $
|
85 |
-
|
86 |
}
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
}
|
95 |
|
96 |
/**
|
@@ -100,34 +99,26 @@ if ( ! class_exists( 'Add_Search_To_Menu' ) ) {
|
|
100 |
* @access private
|
101 |
*/
|
102 |
private function public_hooks() {
|
103 |
-
$
|
104 |
-
|
105 |
-
|
106 |
-
$display_in_header = isset( $
|
|
|
107 |
$display_in_mobile_menu = $display_in_header && wp_is_mobile() ? true : false;
|
108 |
|
109 |
-
if ( $display_in_mobile_menu ) {
|
110 |
-
|
111 |
-
} else {
|
112 |
-
$this->loader->add_filter( 'wp_nav_menu_items', $public, 'search_menu_item', 99, 2 );
|
113 |
}
|
114 |
|
115 |
-
if (
|
116 |
-
|
117 |
}
|
118 |
|
119 |
-
$this->
|
120 |
-
|
|
|
121 |
|
122 |
-
|
123 |
-
* Sets this class into motion.
|
124 |
-
*
|
125 |
-
* Executes the plugin by calling the init method of the loader class which will
|
126 |
-
* register all of the hooks and callback functions used throughout the plugin
|
127 |
-
* with WordPress.
|
128 |
-
*/
|
129 |
-
public function init() {
|
130 |
-
$this->loader->init();
|
131 |
}
|
132 |
}
|
133 |
}
|
11 |
* @package ASTM
|
12 |
*/
|
13 |
|
14 |
+
if ( ! class_exists( 'ASTM_Loader' ) ) {
|
|
|
|
|
15 |
|
16 |
+
class ASTM_Loader {
|
17 |
|
18 |
/**
|
19 |
+
* Stores plugin options.
|
20 |
*/
|
21 |
+
public $opt;
|
22 |
|
23 |
/**
|
24 |
+
* Core singleton class
|
25 |
+
* @var self
|
|
|
|
|
|
|
26 |
*/
|
27 |
+
private static $_instance;
|
28 |
|
29 |
/**
|
30 |
* Instantiates the plugin by setting up the core properties and loading
|
34 |
* plugin dependencies, and will leverage the Add_Search_To_Menu for
|
35 |
* registering the hooks and the callback functions used throughout the plugin.
|
36 |
*/
|
37 |
+
public function __construct( $astm = null ) {
|
38 |
+
$this->opt = ( null !== $astm ) ? $astm->opt : get_option( 'add_search_to_menu' );
|
|
|
|
|
|
|
39 |
$this->set_locale();
|
40 |
|
41 |
if ( is_admin() ) {
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
+
* Gets the instance of this class.
|
50 |
+
*
|
51 |
+
* @return self
|
52 |
*/
|
53 |
+
public static function getInstance() {
|
54 |
+
if ( ! ( self::$_instance instanceof self ) ) {
|
55 |
+
self::$_instance = new self();
|
56 |
+
}
|
57 |
+
|
58 |
+
return self::$_instance;
|
59 |
}
|
60 |
|
61 |
/**
|
62 |
+
* Defines the locale for this plugin for internationalization.
|
63 |
*
|
64 |
* Uses the ASTM_i18n class in order to set the domain and to register the hook
|
65 |
* with WordPress.
|
68 |
* @access private
|
69 |
*/
|
70 |
private function set_locale() {
|
71 |
+
$astm_i18n = ASTM_i18n::getInstance();
|
72 |
+
add_action( 'plugins_loaded', array( $astm_i18n, 'load_plugin_textdomain' ) );
|
73 |
}
|
74 |
|
75 |
/**
|
78 |
* @access private
|
79 |
*/
|
80 |
private function admin_hooks() {
|
81 |
+
$admin = ASTM_Admin::getInstance();
|
|
|
82 |
|
83 |
+
if ( ! isset( $this->opt['dismiss_admin_notices'] ) || ! $this->opt['dismiss_admin_notices'] ) {
|
84 |
+
add_action( 'all_admin_notices', array( $admin, 'setup_notice' ) );
|
85 |
}
|
86 |
|
87 |
+
add_action( 'plugin_action_links', array( $admin, 'plugin_settings_link' ), 10, 2 );
|
88 |
+
add_action( 'admin_menu', array( $admin, 'admin_menu_setup' ) );
|
89 |
+
add_action( 'wp_ajax_nopriv_dismiss_notice', array( $admin, 'dismiss_notice' ) );
|
90 |
+
add_action( 'wp_ajax_dismiss_notice', array( $admin, 'dismiss_notice' ) );
|
91 |
+
add_action( 'admin_enqueue_scripts', array( $admin, 'admin_script_style' ) );
|
92 |
+
add_action( 'admin_init', array( $admin, 'settings_init' ) );
|
93 |
}
|
94 |
|
95 |
/**
|
99 |
* @access private
|
100 |
*/
|
101 |
private function public_hooks() {
|
102 |
+
$public = ASTM_Public::getInstance();
|
103 |
+
add_action( 'wp_enqueue_scripts', array( $public, 'enqueue_script_style' ) );
|
104 |
+
|
105 |
+
$display_in_header = isset( $this->opt['add_search_to_menu_display_in_header'] ) ? $this->opt['add_search_to_menu_display_in_header'] : 0;
|
106 |
+
$site_cache = isset( $this->opt['astm_site_uses_cache'] ) ? $this->opt['astm_site_uses_cache'] : 0;
|
107 |
$display_in_mobile_menu = $display_in_header && wp_is_mobile() ? true : false;
|
108 |
|
109 |
+
if ( $display_in_mobile_menu || $site_cache ) {
|
110 |
+
add_filter( 'wp_head', array( $public, 'search_in_header' ), 99 );
|
|
|
|
|
111 |
}
|
112 |
|
113 |
+
if ( ! $display_in_mobile_menu || $site_cache ) {
|
114 |
+
add_filter( 'wp_nav_menu_items', array( $public, 'search_menu_item' ), 99, 2 );
|
115 |
}
|
116 |
|
117 |
+
if ( isset( $this->opt['add_search_to_menu_posts'] ) && ( ! isset( $this->opt['add_search_to_menu_gcse'] ) || '' == $this->opt['add_search_to_menu_gcse'] ) ) {
|
118 |
+
add_action( 'pre_get_posts', array( $public, 'search_filter' ) );
|
119 |
+
}
|
120 |
|
121 |
+
add_action( 'wp_footer', array( $public, 'custom_css' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
}
|
123 |
}
|
124 |
}
|
public/class-astm-public.php
CHANGED
@@ -11,36 +11,46 @@ if ( ! class_exists( 'ASTM_Public' ) ) {
|
|
11 |
class ASTM_Public {
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
*/
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
/**
|
19 |
* Initializes this class and stores the plugin options.
|
20 |
*/
|
21 |
public function __construct() {
|
22 |
-
$
|
|
|
23 |
}
|
24 |
|
25 |
/**
|
26 |
-
*
|
|
|
|
|
27 |
*/
|
28 |
-
function
|
29 |
-
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
|
32 |
/**
|
33 |
* Enqueues search menu style and script files.
|
34 |
*/
|
35 |
function enqueue_script_style(){
|
36 |
-
|
37 |
-
$options = $this->options;
|
38 |
-
|
39 |
-
if ( ! isset( $options['do_not_load_plugin_files']['plugin-css-file'] ) ){
|
40 |
wp_enqueue_style( 'add-search-to-menu-styles', plugins_url( '/public/css/add-search-to-menu.css', ASTM_PLUGIN_FILE ), array(), ASTM_VERSION );
|
41 |
}
|
42 |
|
43 |
-
if ( ! isset( $
|
44 |
wp_enqueue_script( 'add-search-to-menu-scripts', plugins_url( '/public/js/add-search-to-menu.js', ASTM_PLUGIN_FILE ), array( 'jquery' ), ASTM_VERSION, true );
|
45 |
}
|
46 |
}
|
@@ -49,42 +59,35 @@ if ( ! class_exists( 'ASTM_Public' ) ) {
|
|
49 |
* Displays search form in the navigation bar in the front end of site.
|
50 |
*/
|
51 |
function search_menu_item( $items, $args ) {
|
|
|
52 |
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
-
|
56 |
|
57 |
-
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
$title = isset( $options['add_search_to_menu_title'] ) ? $options['add_search_to_menu_title'] : '';
|
65 |
-
$items .= '<li class="' . esc_attr( $search_class ) . '">';
|
66 |
-
|
67 |
-
if ( $options['add_search_to_menu_style'] != 'default' ){
|
68 |
-
|
69 |
-
$items .= '<a title="' . esc_attr( $title ) . '" href="#">';
|
70 |
-
|
71 |
-
if ( '' == $title ) {
|
72 |
-
$items .= '<svg width="20" height="20" class="search-icon" role="img" viewBox="2 9 20 5">
|
73 |
-
<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>';
|
74 |
-
} else {
|
75 |
-
$items .= $title;
|
76 |
-
}
|
77 |
-
$items .= '</a>';
|
78 |
-
}
|
79 |
-
$items .= get_search_form( false );
|
80 |
-
|
81 |
-
if ( isset( $options['add_search_to_menu_close_icon'] ) && $options['add_search_to_menu_close_icon'] ) {
|
82 |
-
$items .= '<div class="search-close"></div>';
|
83 |
}
|
|
|
|
|
|
|
84 |
|
85 |
-
|
|
|
86 |
}
|
87 |
|
|
|
88 |
}
|
89 |
}
|
90 |
return $items;
|
@@ -94,19 +97,18 @@ if ( ! class_exists( 'ASTM_Public' ) ) {
|
|
94 |
* Displays search form in mobile header in the front end of site.
|
95 |
*/
|
96 |
function search_in_header() {
|
97 |
-
$options = $this->options;
|
98 |
$items = '';
|
99 |
|
100 |
-
if ( isset( $
|
101 |
-
$items .= '<li class="gsc-cse-search-menu">' . $
|
102 |
} else {
|
103 |
-
$search_class = isset( $
|
104 |
-
$search_class .= isset( $
|
105 |
-
$title = isset( $
|
106 |
$items .= '<div class="astm-search-menu-wrapper"><div>';
|
107 |
$items .= '<span class="' . esc_attr( $search_class ) . '">';
|
108 |
|
109 |
-
if ( $
|
110 |
|
111 |
$items .= '<a title="' . esc_attr( $title ) . '" href="#">';
|
112 |
|
@@ -121,7 +123,7 @@ if ( ! class_exists( 'ASTM_Public' ) ) {
|
|
121 |
}
|
122 |
$items .= get_search_form( false );
|
123 |
|
124 |
-
if ( isset( $
|
125 |
$items .= '<div class="search-close"></div>';
|
126 |
}
|
127 |
|
@@ -135,11 +137,8 @@ if ( ! class_exists( 'ASTM_Public' ) ) {
|
|
135 |
* Filters search results.
|
136 |
*/
|
137 |
function search_filter( $query ) {
|
138 |
-
|
139 |
-
$options = $this->options;
|
140 |
-
|
141 |
if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) {
|
142 |
-
$query->set( 'post_type', $
|
143 |
}
|
144 |
}
|
145 |
|
@@ -147,12 +146,10 @@ if ( ! class_exists( 'ASTM_Public' ) ) {
|
|
147 |
* Adds custom CSS code in the site front end.
|
148 |
*/
|
149 |
function custom_css() {
|
150 |
-
$
|
151 |
-
|
152 |
-
if ( isset( $options['add_search_to_menu_css'] ) && $options['add_search_to_menu_css'] != '' ) {
|
153 |
echo '<style type="text/css" media="screen">';
|
154 |
echo '/* Add search to menu custom CSS code */';
|
155 |
-
echo wp_specialchars_decode( esc_html( $
|
156 |
echo '</style>';
|
157 |
}
|
158 |
}
|
11 |
class ASTM_Public {
|
12 |
|
13 |
/**
|
14 |
+
* Stores plugin options.
|
15 |
*/
|
16 |
+
public $opt;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Core singleton class
|
20 |
+
* @var self
|
21 |
+
*/
|
22 |
+
private static $_instance;
|
23 |
|
24 |
/**
|
25 |
* Initializes this class and stores the plugin options.
|
26 |
*/
|
27 |
public function __construct() {
|
28 |
+
$astm = Add_Search_To_Menu::getInstance();
|
29 |
+
$this->opt = ( null !== $astm ) ? $astm->opt : get_option( 'add_search_to_menu' );
|
30 |
}
|
31 |
|
32 |
/**
|
33 |
+
* Gets the instance of this class.
|
34 |
+
*
|
35 |
+
* @return self
|
36 |
*/
|
37 |
+
public static function getInstance() {
|
38 |
+
if ( ! ( self::$_instance instanceof self ) ) {
|
39 |
+
self::$_instance = new self();
|
40 |
+
}
|
41 |
+
|
42 |
+
return self::$_instance;
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
* Enqueues search menu style and script files.
|
47 |
*/
|
48 |
function enqueue_script_style(){
|
49 |
+
if ( ! isset( $this->opt['do_not_load_plugin_files']['plugin-css-file'] ) ){
|
|
|
|
|
|
|
50 |
wp_enqueue_style( 'add-search-to-menu-styles', plugins_url( '/public/css/add-search-to-menu.css', ASTM_PLUGIN_FILE ), array(), ASTM_VERSION );
|
51 |
}
|
52 |
|
53 |
+
if ( ! isset( $this->opt['do_not_load_plugin_files']['plugin-js-file'] ) && ( isset( $this->opt['add_search_to_menu_style'] ) && $this->opt['add_search_to_menu_style'] != 'default' ) ) {
|
54 |
wp_enqueue_script( 'add-search-to-menu-scripts', plugins_url( '/public/js/add-search-to-menu.js', ASTM_PLUGIN_FILE ), array( 'jquery' ), ASTM_VERSION, true );
|
55 |
}
|
56 |
}
|
59 |
* Displays search form in the navigation bar in the front end of site.
|
60 |
*/
|
61 |
function search_menu_item( $items, $args ) {
|
62 |
+
if ( isset( $this->opt['add_search_to_menu_locations'] ) && isset( $this->opt['add_search_to_menu_locations'][ $args->theme_location ] ) ) {
|
63 |
|
64 |
+
if ( isset( $this->opt['add_search_to_menu_gcse'] ) && $this->opt['add_search_to_menu_gcse'] != '' ) {
|
65 |
+
$items .= '<li class="gsc-cse-search-menu">' . $this->opt['add_search_to_menu_gcse'] . '</li>';
|
66 |
+
} else {
|
67 |
+
$search_class = isset( $this->opt['add_search_to_menu_classes'] ) ? $this->opt['add_search_to_menu_classes'].' astm-search-menu ' : 'astm-search-menu ';
|
68 |
+
$search_class .= isset( $this->opt['add_search_to_menu_style'] ) ? $this->opt['add_search_to_menu_style'] : 'default';
|
69 |
+
$title = isset( $this->opt['add_search_to_menu_title'] ) ? $this->opt['add_search_to_menu_title'] : '';
|
70 |
+
$items .= '<li class="' . esc_attr( $search_class ) . '">';
|
71 |
|
72 |
+
if ( $this->opt['add_search_to_menu_style'] != 'default' ){
|
73 |
|
74 |
+
$items .= '<a title="' . esc_attr( $title ) . '" href="#">';
|
75 |
|
76 |
+
if ( '' == $title ) {
|
77 |
+
$items .= '<svg width="20" height="20" class="search-icon" role="img" viewBox="2 9 20 5">
|
78 |
+
<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>';
|
79 |
+
} else {
|
80 |
+
$items .= $title;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
}
|
82 |
+
$items .= '</a>';
|
83 |
+
}
|
84 |
+
$items .= get_search_form( false );
|
85 |
|
86 |
+
if ( isset( $this->opt['add_search_to_menu_close_icon'] ) && $this->opt['add_search_to_menu_close_icon'] ) {
|
87 |
+
$items .= '<div class="search-close"></div>';
|
88 |
}
|
89 |
|
90 |
+
$items .= '</li>';
|
91 |
}
|
92 |
}
|
93 |
return $items;
|
97 |
* Displays search form in mobile header in the front end of site.
|
98 |
*/
|
99 |
function search_in_header() {
|
|
|
100 |
$items = '';
|
101 |
|
102 |
+
if ( isset( $this->opt['add_search_to_menu_gcse'] ) && $this->opt['add_search_to_menu_gcse'] != '' ) {
|
103 |
+
$items .= '<li class="gsc-cse-search-menu">' . $this->opt['add_search_to_menu_gcse'] . '</li>';
|
104 |
} else {
|
105 |
+
$search_class = isset( $this->opt['add_search_to_menu_classes'] ) ? $this->opt['add_search_to_menu_classes'].' astm-search-menu ' : 'astm-search-menu ';
|
106 |
+
$search_class .= isset( $this->opt['add_search_to_menu_style'] ) ? $this->opt['add_search_to_menu_style'] : 'default';
|
107 |
+
$title = isset( $this->opt['add_search_to_menu_title'] ) ? $this->opt['add_search_to_menu_title'] : '';
|
108 |
$items .= '<div class="astm-search-menu-wrapper"><div>';
|
109 |
$items .= '<span class="' . esc_attr( $search_class ) . '">';
|
110 |
|
111 |
+
if ( $this->opt['add_search_to_menu_style'] != 'default' ){
|
112 |
|
113 |
$items .= '<a title="' . esc_attr( $title ) . '" href="#">';
|
114 |
|
123 |
}
|
124 |
$items .= get_search_form( false );
|
125 |
|
126 |
+
if ( isset( $this->opt['add_search_to_menu_close_icon'] ) && $this->opt['add_search_to_menu_close_icon'] ) {
|
127 |
$items .= '<div class="search-close"></div>';
|
128 |
}
|
129 |
|
137 |
* Filters search results.
|
138 |
*/
|
139 |
function search_filter( $query ) {
|
|
|
|
|
|
|
140 |
if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) {
|
141 |
+
$query->set( 'post_type', $this->opt['add_search_to_menu_posts'] );
|
142 |
}
|
143 |
}
|
144 |
|
146 |
* Adds custom CSS code in the site front end.
|
147 |
*/
|
148 |
function custom_css() {
|
149 |
+
if ( isset( $this->opt['add_search_to_menu_css'] ) && $this->opt['add_search_to_menu_css'] != '' ) {
|
|
|
|
|
150 |
echo '<style type="text/css" media="screen">';
|
151 |
echo '/* Add search to menu custom CSS code */';
|
152 |
+
echo wp_specialchars_decode( esc_html( $this->opt['add_search_to_menu_css'] ), ENT_QUOTES );
|
153 |
echo '</style>';
|
154 |
}
|
155 |
}
|
public/css/add-search-to-menu.css
CHANGED
@@ -66,6 +66,7 @@
|
|
66 |
}
|
67 |
|
68 |
.astm-search-menu-wrapper {
|
|
|
69 |
position: absolute;
|
70 |
right: 5px;
|
71 |
top: 5px;
|
@@ -149,4 +150,8 @@
|
|
149 |
.astm-search-menu.full-width-menu.active-search {
|
150 |
position: relative;
|
151 |
}
|
|
|
|
|
|
|
|
|
152 |
}
|
66 |
}
|
67 |
|
68 |
.astm-search-menu-wrapper {
|
69 |
+
display: none;
|
70 |
position: absolute;
|
71 |
right: 5px;
|
72 |
top: 5px;
|
150 |
.astm-search-menu.full-width-menu.active-search {
|
151 |
position: relative;
|
152 |
}
|
153 |
+
|
154 |
+
.astm-search-menu-wrapper {
|
155 |
+
display: block;
|
156 |
+
}
|
157 |
}
|
readme.txt
CHANGED
@@ -4,17 +4,17 @@ 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: 3.
|
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
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
Add Search To Menu plugin allows you to add search form in your site navigation bar that
|
16 |
|
17 |
-
|
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 |
|
@@ -67,6 +67,9 @@ Please make sure you have configured the plugin settings from Settings -> Add Se
|
|
67 |
* Fixed incorrect JavaScript and CSS files URLs displayed in the plugin settings.
|
68 |
* Fixed issue of using quotation in plugin custom CSS option.
|
69 |
|
|
|
|
|
|
|
70 |
== Upgrade Notice ==
|
71 |
|
72 |
= 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.3
|
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 menu which you can configure 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 enables users to search your site easily.
|
16 |
|
17 |
+
You can use various plugin settings in the admin area to customize the search form and search results.
|
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 |
|
67 |
* Fixed incorrect JavaScript and CSS files URLs displayed in the plugin settings.
|
68 |
* Fixed issue of using quotation in plugin custom CSS option.
|
69 |
|
70 |
+
= 3.3 =
|
71 |
+
* Enhanced Mobile Display option to work with caching.
|
72 |
+
|
73 |
== Upgrade Notice ==
|
74 |
|
75 |
= 1.0 =
|