Version Description
- Fixed incorrect JavaScript and CSS files URLs displayed in the plugin settings.
- Fixed issue of using quotation in plugin custom CSS option.
=
Download this release
Release Info
Developer | vinod dalvi |
Plugin | Ivory Search – WordPress Search Plugin |
Version | 3.2 |
Comparing to | |
See all releases |
Code changes from version 3.1 to 3.2
- add-search-to-menu.php +48 -67
- admin/class-add-search-to-menu-admin.php +0 -372
- admin/class-astm-admin.php +350 -0
- admin/index.php +4 -0
- admin/js/add-search-to-menu-admin.js +5 -6
- includes/class-add-search-to-menu-activator.php +0 -38
- includes/class-add-search-to-menu-deactivator.php +0 -33
- includes/class-add-search-to-menu-i18n.php +0 -52
- includes/class-add-search-to-menu-loader.php +0 -132
- includes/class-add-search-to-menu.php +0 -240
- includes/class-astm-activator.php +46 -0
- includes/class-astm-deactivator.php +32 -0
- includes/class-astm-i18n.php +29 -0
- includes/class-astm-loader.php +130 -0
- includes/class-astm.php +133 -0
- includes/index.php +4 -0
- index.php +4 -0
- languages/default.po +43 -44
- public/class-add-search-to-menu-public.php +0 -189
- public/class-astm-public.php +160 -0
- public/css/add-search-to-menu.css +3 -3
- public/index.php +4 -0
- public/js/add-search-to-menu.js +10 -12
- readme.txt +9 -5
- uninstall.php +3 -8
add-search-to-menu.php
CHANGED
@@ -1,87 +1,68 @@
|
|
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: 3.1
|
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 |
-
*
|
30 |
-
*
|
31 |
-
* The
|
32 |
-
*
|
33 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
*
|
35 |
* @package ASTM
|
36 |
*/
|
37 |
|
38 |
-
|
39 |
-
/**
|
40 |
-
* If this file is called directly, then abort execution.
|
41 |
-
*/
|
42 |
if ( ! defined( 'ABSPATH' ) ) {
|
43 |
-
|
44 |
}
|
45 |
|
46 |
-
|
47 |
-
/**
|
48 |
-
* The code that runs during plugin activation.
|
49 |
-
* This action is documented in includes/class-add-search-to-menu-activator.php
|
50 |
-
*/
|
51 |
-
function activate_add_search_to_menu() {
|
52 |
-
require_once plugin_dir_path( __FILE__ ) . 'includes/class-add-search-to-menu-activator.php';
|
53 |
-
Add_Search_To_Menu_Activator::activate();
|
54 |
-
}
|
55 |
-
|
56 |
-
|
57 |
/**
|
58 |
-
*
|
59 |
-
* This action is documented in includes/class-add-search-to-menu-deactivator.php
|
60 |
*/
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
}
|
65 |
-
|
66 |
-
register_activation_hook( __FILE__, 'activate_add_search_to_menu' );
|
67 |
-
register_deactivation_hook( __FILE__, 'deactivate_add_search_to_menu' );
|
68 |
-
|
69 |
|
70 |
/**
|
71 |
-
*
|
72 |
*/
|
73 |
-
require_once
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
/**
|
76 |
-
*
|
77 |
-
* calls its run method officially starting up the plugin.
|
78 |
*/
|
79 |
-
|
80 |
-
|
81 |
-
$ewpd->run();
|
82 |
-
}
|
83 |
|
84 |
/**
|
85 |
-
*
|
86 |
*/
|
87 |
-
|
|
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: 3.2
|
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
|
34 |
*/
|
35 |
|
|
|
|
|
|
|
|
|
36 |
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 |
+
* Includes the core files responsible for loading all necessary plugin components.
|
49 |
*/
|
50 |
+
require_once ASTM_PLUGIN_DIR . 'includes/class-astm-activator.php';
|
51 |
+
require_once ASTM_PLUGIN_DIR . 'includes/class-astm-deactivator.php';
|
52 |
+
require_once ASTM_PLUGIN_DIR . 'includes/class-astm-i18n.php';
|
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 |
+
* Executes necessary actions on plugin activation and deactivation.
|
|
|
60 |
*/
|
61 |
+
register_activation_hook( __FILE__, array( 'ASTM_Activator', 'activate' ) );
|
62 |
+
register_deactivation_hook( __FILE__, array( 'ASTM_Deactivator', 'deactivate' ) );
|
|
|
|
|
63 |
|
64 |
/**
|
65 |
+
* Starts plugin execution.
|
66 |
*/
|
67 |
+
$astm = new Add_Search_To_Menu();
|
68 |
+
$astm->init();
|
admin/class-add-search-to-menu-admin.php
DELETED
@@ -1,372 +0,0 @@
|
|
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_posts', __( 'Search Post Types : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_posts' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
157 |
-
add_settings_field( 'add_search_to_menu_style', __( 'Search Form Style : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_style' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
158 |
-
add_settings_field( 'add_search_to_menu_title', __( 'Search Menu Title : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_title' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
159 |
-
add_settings_field( 'add_search_to_menu_classes', __( 'Search Menu Classes : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_classes' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
160 |
-
add_settings_field( 'add_search_to_menu_gcse', __( 'Google CSE : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_gcse' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
161 |
-
add_settings_field( 'add_search_to_menu_display_in_header', __( 'Mobile Display : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_display_in_header' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
162 |
-
add_settings_field( 'add_search_to_menu_close_icon', __( 'Close Icon: ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_close_icon' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
163 |
-
add_settings_field( 'add_search_to_menu_css', __( 'Custom CSS : ', 'add-search-to-menu' ), array( $this, 'add_search_to_menu_css' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
164 |
-
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' );
|
165 |
-
|
166 |
-
register_setting( 'add_search_to_menu', 'add_search_to_menu' );
|
167 |
-
|
168 |
-
}
|
169 |
-
|
170 |
-
/* Displays plugin description text */
|
171 |
-
function add_search_to_menu_section_desc(){
|
172 |
-
echo '<p>' . esc_html__( 'Configure the Add Search To Menu plugin settings here.', 'add-search-to-menu' ) . '</p>';
|
173 |
-
}
|
174 |
-
|
175 |
-
/* add search to menu choose locations field output */
|
176 |
-
function add_search_to_menu_locations() {
|
177 |
-
|
178 |
-
$options = $this->options;
|
179 |
-
$html = '';
|
180 |
-
$menus = get_registered_nav_menus();
|
181 |
-
|
182 |
-
if ( ! empty( $menus ) ){
|
183 |
-
|
184 |
-
if ( empty( $options ) || ! isset( $options['add_search_to_menu_locations'] ) ){
|
185 |
-
$location = array_keys( $menus );
|
186 |
-
$options['add_search_to_menu_locations'][ $location[0] ] = $location[0];
|
187 |
-
|
188 |
-
update_option( 'add_search_to_menu', $options );
|
189 |
-
}
|
190 |
-
|
191 |
-
if ( isset( $options['add_search_to_menu_locations']['initial'] ) ){
|
192 |
-
unset( $options['add_search_to_menu_locations']['initial'] );
|
193 |
-
$location = array_keys( $menus );
|
194 |
-
$options['add_search_to_menu_locations'][ $location[0] ] = $location[0];
|
195 |
-
update_option( 'add_search_to_menu', $options );
|
196 |
-
}
|
197 |
-
|
198 |
-
foreach ( $menus as $location => $description ) {
|
199 |
-
|
200 |
-
$check_value = isset( $options['add_search_to_menu_locations'][$location] ) ? $options['add_search_to_menu_locations'][ $location ] : 0;
|
201 |
-
$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 ) . '/>';
|
202 |
-
$html .= '<label for="add_search_to_menu_locations' . esc_attr( $location ) . '"> ' . esc_html( $description ) . '</label><br />';
|
203 |
-
}
|
204 |
-
} else {
|
205 |
-
$html = __( 'No navigation menu registered on your site.', 'add-search-to-menu' );
|
206 |
-
}
|
207 |
-
echo $html;
|
208 |
-
|
209 |
-
}
|
210 |
-
|
211 |
-
/* add search to menu choose post types field output */
|
212 |
-
function add_search_to_menu_posts() {
|
213 |
-
|
214 |
-
$options = $this->options;
|
215 |
-
$html = '';
|
216 |
-
$args = array( 'exclude_from_search' => false );
|
217 |
-
|
218 |
-
$posts = get_post_types( $args );
|
219 |
-
|
220 |
-
if ( ! empty( $posts ) ){
|
221 |
-
|
222 |
-
if ( empty( $options ) || ! isset( $options['add_search_to_menu_posts'] ) ){
|
223 |
-
$post_keys = array_keys( $posts );
|
224 |
-
|
225 |
-
foreach ( $post_keys as $post_key ) {
|
226 |
-
$options['add_search_to_menu_posts'][ $post_key ] = $post_key;
|
227 |
-
}
|
228 |
-
|
229 |
-
update_option( 'add_search_to_menu', $options );
|
230 |
-
}
|
231 |
-
|
232 |
-
if ( isset( $options['add_search_to_menu_posts']['initial'] ) ){
|
233 |
-
unset( $options['add_search_to_menu_posts']['initial'] );
|
234 |
-
$post_keys = array_keys( $posts );
|
235 |
-
foreach ( $post_keys as $post_key ) {
|
236 |
-
$options['add_search_to_menu_posts'][ $post_key ] = $post_key;
|
237 |
-
}
|
238 |
-
update_option( 'add_search_to_menu', $options );
|
239 |
-
}
|
240 |
-
|
241 |
-
foreach ( $posts as $key => $post ) {
|
242 |
-
|
243 |
-
$check_value = isset( $options['add_search_to_menu_posts'][$key] ) ? $options['add_search_to_menu_posts'][ $key ] : 0;
|
244 |
-
$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 ) . '/>';
|
245 |
-
$html .= '<label for="add_search_to_menu_posts' . esc_attr( $key ) . '"> ' . esc_html( $post ) . '</label><br />';
|
246 |
-
}
|
247 |
-
} else {
|
248 |
-
$html = __( 'No post types registered on your site.', 'add-search-to-menu' );
|
249 |
-
}
|
250 |
-
echo $html;
|
251 |
-
|
252 |
-
}
|
253 |
-
|
254 |
-
/* add search to menu search form style field output */
|
255 |
-
function add_search_to_menu_style() {
|
256 |
-
|
257 |
-
$options = $this->options;
|
258 |
-
$styles = array(
|
259 |
-
'default' => __( 'Default', 'add-search-to-menu' ),
|
260 |
-
'dropdown' => __( 'Dropdown', 'add-search-to-menu' ),
|
261 |
-
'sliding' => __( 'Sliding', 'add-search-to-menu' ),
|
262 |
-
'full-width-menu' => __( 'Full Width', 'add-search-to-menu' )
|
263 |
-
);
|
264 |
-
|
265 |
-
if ( empty( $options ) || ! isset( $options['add_search_to_menu_style'] ) ) {
|
266 |
-
$options['add_search_to_menu_style'] = 'default';
|
267 |
-
update_option( 'add_search_to_menu', $options );
|
268 |
-
}
|
269 |
-
|
270 |
-
$html = '';
|
271 |
-
$check_value = isset( $options['add_search_to_menu_style'] ) ? $options['add_search_to_menu_style'] : 'default';
|
272 |
-
|
273 |
-
foreach ( $styles as $key => $style ) {
|
274 |
-
|
275 |
-
$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 ) . '/>';
|
276 |
-
$html .= '<label for="add_search_to_menu_style' . esc_attr( $key ) . '"> ' . esc_html( $style ) . '</label><br />';
|
277 |
-
}
|
278 |
-
echo $html;
|
279 |
-
}
|
280 |
-
|
281 |
-
/* add search to menu title field output */
|
282 |
-
function add_search_to_menu_title() {
|
283 |
-
|
284 |
-
$options = $this->options;
|
285 |
-
$options['add_search_to_menu_title'] = isset( $options['add_search_to_menu_title'] ) ? $options['add_search_to_menu_title'] : '';
|
286 |
-
$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" />';
|
287 |
-
$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>';
|
288 |
-
echo $html;
|
289 |
-
}
|
290 |
-
|
291 |
-
/* add search to menu classes field output */
|
292 |
-
function add_search_to_menu_classes() {
|
293 |
-
|
294 |
-
$options = $this->options;
|
295 |
-
$options['add_search_to_menu_classes'] = isset( $options['add_search_to_menu_classes'] ) ? $options['add_search_to_menu_classes'] : 'astm-search-menu';
|
296 |
-
$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" />';
|
297 |
-
$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>';
|
298 |
-
echo $html;
|
299 |
-
}
|
300 |
-
|
301 |
-
/* add search to menu google cse field output */
|
302 |
-
function add_search_to_menu_gcse() {
|
303 |
-
|
304 |
-
$options = $this->options;
|
305 |
-
$options['add_search_to_menu_gcse'] = isset( $options['add_search_to_menu_gcse'] ) ? $options['add_search_to_menu_gcse'] : '';
|
306 |
-
$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" />';
|
307 |
-
$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>';
|
308 |
-
echo $html;
|
309 |
-
}
|
310 |
-
|
311 |
-
/* add search to menu display in header field output */
|
312 |
-
function add_search_to_menu_display_in_header() {
|
313 |
-
|
314 |
-
$options = $this->options;
|
315 |
-
$check_value = isset( $options['add_search_to_menu_display_in_header'] ) ? $options['add_search_to_menu_display_in_header'] : 0;
|
316 |
-
$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 ) . ' />';
|
317 |
-
$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>';
|
318 |
-
$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>';
|
319 |
-
echo $html;
|
320 |
-
}
|
321 |
-
|
322 |
-
/* add search to menu search from close icon field output */
|
323 |
-
function add_search_to_menu_close_icon() {
|
324 |
-
|
325 |
-
$options = $this->options;
|
326 |
-
$check_value = isset( $options['add_search_to_menu_close_icon'] ) ? $options['add_search_to_menu_close_icon'] : 0;
|
327 |
-
$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 ) . ' />';
|
328 |
-
$html .= '<label for="add_search_to_menu_close_icon"> ' . esc_html__( 'Display Search Form Close Icon', 'add-search-to-menu' ) . '</label>';
|
329 |
-
echo $html;
|
330 |
-
}
|
331 |
-
|
332 |
-
/* add search to menu custom css field output */
|
333 |
-
function add_search_to_menu_css() {
|
334 |
-
|
335 |
-
$options = $this->options;
|
336 |
-
$options['add_search_to_menu_css'] = isset( $options['add_search_to_menu_css'] ) ? $options['add_search_to_menu_css'] : '';
|
337 |
-
$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>';
|
338 |
-
$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>';
|
339 |
-
echo $html;
|
340 |
-
}
|
341 |
-
|
342 |
-
/* add search to menu do not load plugin files field output */
|
343 |
-
function do_not_load_plugin_files() {
|
344 |
-
|
345 |
-
$options = $this->options;
|
346 |
-
$styles = array(
|
347 |
-
'plugin-css-file' => __( 'Plugin CSS File', 'add-search-to-menu' ),
|
348 |
-
'plugin-js-file' => __( 'Plugin JavaScript File', 'add-search-to-menu' )
|
349 |
-
|
350 |
-
);
|
351 |
-
|
352 |
-
|
353 |
-
$html = '';
|
354 |
-
foreach ( $styles as $key => $file ) {
|
355 |
-
|
356 |
-
$check_value = isset( $options['do_not_load_plugin_files'][ $key] ) ? $options['do_not_load_plugin_files'][ $key ] : 0;
|
357 |
-
$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 ) . '/>';
|
358 |
-
$html .= '<label for="do_not_load_plugin_files' . esc_attr( $key ) . '"> ' . esc_html( $file ) . '</label>';
|
359 |
-
|
360 |
-
if ( $key == 'plugin-css-file' ){
|
361 |
-
$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>';
|
362 |
-
$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>';
|
363 |
-
$html .= '<br /><br />';
|
364 |
-
} else {
|
365 |
-
$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>';
|
366 |
-
$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>';
|
367 |
-
}
|
368 |
-
}
|
369 |
-
echo $html;
|
370 |
-
}
|
371 |
-
|
372 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/class-astm-admin.php
ADDED
@@ -0,0 +1,350 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The class defines all functionality for the dashboard of the plugin.
|
4 |
+
*
|
5 |
+
* @package ASTM
|
6 |
+
* @since 1.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'ASTM_Admin' ) ) {
|
10 |
+
|
11 |
+
class ASTM_Admin {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Stores plugin options.
|
15 |
+
*/
|
16 |
+
public $options;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Stores network activation status.
|
20 |
+
*/
|
21 |
+
private $networkactive;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Initializes this class.
|
25 |
+
*
|
26 |
+
*/
|
27 |
+
public function __construct() {
|
28 |
+
$this->options = get_option( 'add_search_to_menu' );
|
29 |
+
$this->networkactive = ( is_multisite() && array_key_exists( plugin_basename( ASTM_PLUGIN_FILE ), (array) get_site_option( 'active_sitewide_plugins' ) ) );
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* PHP 4 Compatible Constructor.
|
34 |
+
*/
|
35 |
+
function ASTM_Admin() {
|
36 |
+
$this->__construct();
|
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 |
+
|
53 |
+
/**
|
54 |
+
* Adds a link to the settings page in the plugins list.
|
55 |
+
*
|
56 |
+
* @param array $links array of links for the plugins, adapted when the current plugin is found.
|
57 |
+
* @param string $file the filename for the current plugin, which the filter loops through.
|
58 |
+
*
|
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>',
|
66 |
+
'<a href="options-general.php?page=add_search_to_menu">' . esc_html__( 'Settings', 'add-search-to-menu' ) . '</a>'
|
67 |
+
);
|
68 |
+
$links = array_merge( $mylinks, $links );
|
69 |
+
}
|
70 |
+
return $links;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
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 |
+
}
|
81 |
+
|
82 |
+
$hascaps = $this->networkactive ? is_network_admin() && current_user_can( 'manage_network_plugins' ) : current_user_can( 'manage_options' );
|
83 |
+
|
84 |
+
if ( $hascaps ) {
|
85 |
+
$url = is_network_admin() ? network_site_url() : site_url( '/' );
|
86 |
+
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>';
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Handles plugin notice dismiss functionality using AJAX.
|
92 |
+
*/
|
93 |
+
function dismiss_notice() {
|
94 |
+
|
95 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
96 |
+
$options = $this->options;
|
97 |
+
$options['dismiss_admin_notices'] = 1;
|
98 |
+
update_option( 'add_search_to_menu', $options );
|
99 |
+
}
|
100 |
+
die();
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Registers plugin admin menu item.
|
105 |
+
*/
|
106 |
+
function admin_menu_setup(){
|
107 |
+
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, 'admin_page_screen' ) );
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Displays plugin admin page content.
|
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' );
|
146 |
+
add_settings_field( 'add_search_to_menu_posts', __( 'Search Post Types : ', 'add-search-to-menu' ), array( $this, 'post_posts' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
147 |
+
add_settings_field( 'add_search_to_menu_style', __( 'Search Form Style : ', 'add-search-to-menu' ), array( $this, 'form_style' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
148 |
+
add_settings_field( 'add_search_to_menu_title', __( 'Search Menu Title : ', 'add-search-to-menu' ), array( $this, 'menu_title' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
149 |
+
add_settings_field( 'add_search_to_menu_classes', __( 'Search Menu Classes : ', 'add-search-to-menu' ), array( $this, 'menu_classes' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
150 |
+
add_settings_field( 'add_search_to_menu_gcse', __( 'Google CSE : ', 'add-search-to-menu' ), array( $this, 'google_cse' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
151 |
+
add_settings_field( 'add_search_to_menu_display_in_header', __( 'Mobile Display : ', 'add-search-to-menu' ), array( $this, 'display_in_header' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
152 |
+
add_settings_field( 'add_search_to_menu_close_icon', __( 'Close Icon: ', 'add-search-to-menu' ), array( $this, 'close_icon' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
153 |
+
add_settings_field( 'add_search_to_menu_css', __( 'Custom CSS : ', 'add-search-to-menu' ), array( $this, 'custom_css' ), 'add_search_to_menu', 'add_search_to_menu_section' );
|
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 |
+
/**
|
161 |
+
* Displays plugin description text.
|
162 |
+
*/
|
163 |
+
function settings_section_desc(){
|
164 |
+
echo '<p>' . esc_html__( 'Configure the Add Search To Menu plugin settings here.', 'add-search-to-menu' ) . '</p>';
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
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 |
+
|
176 |
+
if ( ! empty( $menus ) ){
|
177 |
+
|
178 |
+
foreach ( $menus as $location => $description ) {
|
179 |
+
|
180 |
+
$check_value = isset( $options['add_search_to_menu_locations'][ $location ] ) ? $options['add_search_to_menu_locations'][ $location ] : 0;
|
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 |
+
}
|
184 |
+
} else {
|
185 |
+
$html = __( 'No navigation menu registered on your site.', 'add-search-to-menu' );
|
186 |
+
}
|
187 |
+
echo $html;
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
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 |
+
|
199 |
+
$posts = get_post_types( $args );
|
200 |
+
|
201 |
+
if ( ! empty( $posts ) ){
|
202 |
+
|
203 |
+
foreach ( $posts as $key => $post ) {
|
204 |
+
|
205 |
+
$check_value = isset( $options['add_search_to_menu_posts'][$key] ) ? $options['add_search_to_menu_posts'][ $key ] : 0;
|
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 |
+
}
|
209 |
+
} else {
|
210 |
+
$html = __( 'No post types registered on your site.', 'add-search-to-menu' );
|
211 |
+
}
|
212 |
+
echo $html;
|
213 |
+
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
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' ),
|
225 |
+
'sliding' => __( 'Sliding', 'add-search-to-menu' ),
|
226 |
+
'full-width-menu' => __( 'Full Width', 'add-search-to-menu' )
|
227 |
+
);
|
228 |
+
|
229 |
+
if ( empty( $options ) || ! isset( $options['add_search_to_menu_style'] ) ) {
|
230 |
+
$options['add_search_to_menu_style'] = 'default';
|
231 |
+
update_option( 'add_search_to_menu', $options );
|
232 |
+
}
|
233 |
+
|
234 |
+
$html = '';
|
235 |
+
$check_value = isset( $options['add_search_to_menu_style'] ) ? $options['add_search_to_menu_style'] : 'default';
|
236 |
+
|
237 |
+
foreach ( $styles as $key => $style ) {
|
238 |
+
|
239 |
+
$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 ) . '/>';
|
240 |
+
$html .= '<label for="add_search_to_menu_style' . esc_attr( $key ) . '"> ' . esc_html( $style ) . '</label><br />';
|
241 |
+
}
|
242 |
+
echo $html;
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Displays search menu title field.
|
247 |
+
*/
|
248 |
+
function menu_title() {
|
249 |
+
|
250 |
+
$options = $this->options;
|
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 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Displays search menu classes field.
|
259 |
+
*/
|
260 |
+
function menu_classes() {
|
261 |
+
|
262 |
+
$options = $this->options;
|
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 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Displays google cse field.
|
271 |
+
*/
|
272 |
+
function google_cse() {
|
273 |
+
|
274 |
+
$options = $this->options;
|
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 |
+
}
|
280 |
+
|
281 |
+
/**
|
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 |
+
|
294 |
+
/**
|
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;
|
304 |
+
}
|
305 |
+
|
306 |
+
/**
|
307 |
+
* Displays custom css field.
|
308 |
+
*/
|
309 |
+
function custom_css() {
|
310 |
+
|
311 |
+
$options = $this->options;
|
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 |
+
}
|
317 |
+
|
318 |
+
/**
|
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' => __( 'Plugin JavaScript File', 'add-search-to-menu' )
|
327 |
+
|
328 |
+
);
|
329 |
+
|
330 |
+
|
331 |
+
$html = '';
|
332 |
+
foreach ( $styles as $key => $file ) {
|
333 |
+
|
334 |
+
$check_value = isset( $options['do_not_load_plugin_files'][ $key] ) ? $options['do_not_load_plugin_files'][ $key ] : 0;
|
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 |
+
|
338 |
+
if ( 'plugin-css-file' == $key ) {
|
339 |
+
$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>';
|
340 |
+
$html .= '<br /><a target="_blank" href="' . plugins_url( '/public/css/add-search-to-menu.css', ASTM_PLUGIN_FILE ) . '"/a>' . plugins_url( '/public/css/add-search-to-menu.css', ASTM_PLUGIN_FILE ) . '</a>';
|
341 |
+
$html .= '<br /><br />';
|
342 |
+
} else {
|
343 |
+
$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>';
|
344 |
+
$html .= '<br /><a target="_blank" href="' . plugins_url( '/public/js/add-search-to-menu.js', ASTM_PLUGIN_FILE ) . '"/a>' . plugins_url( '/public/js/add-search-to-menu.js', ASTM_PLUGIN_FILE ) . '</a>';
|
345 |
+
}
|
346 |
+
}
|
347 |
+
echo $html;
|
348 |
+
}
|
349 |
+
}
|
350 |
+
}
|
admin/index.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Nothing to see here.
|
4 |
+
*/
|
admin/js/add-search-to-menu-admin.js
CHANGED
@@ -1,19 +1,18 @@
|
|
1 |
/**
|
2 |
-
* Dismisses plugin notices
|
3 |
-
*
|
4 |
*/
|
5 |
( function( $ ) {
|
6 |
-
|
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: '
|
14 |
}
|
15 |
} );
|
16 |
|
17 |
} );
|
18 |
} );
|
19 |
-
} )( jQuery );
|
1 |
/**
|
2 |
+
* Dismisses plugin notices.
|
|
|
3 |
*/
|
4 |
( function( $ ) {
|
5 |
+
'use strict';
|
6 |
$( document ).ready( function() {
|
7 |
+
$( '.notice.is-dismissible.add-search-to-menu .notice-dismiss' ).on( 'click', function() {
|
8 |
|
9 |
$.ajax( {
|
10 |
url: add_search_to_menu.ajax_url,
|
11 |
data: {
|
12 |
+
action: 'dismiss_notice'
|
13 |
}
|
14 |
} );
|
15 |
|
16 |
} );
|
17 |
} );
|
18 |
+
} )( jQuery );
|
includes/class-add-search-to-menu-activator.php
DELETED
@@ -1,38 +0,0 @@
|
|
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 |
-
if ( ! isset( $options['add_search_to_menu_posts'] ) ) {
|
33 |
-
$options['add_search_to_menu_posts']['initial'] = 'initial';
|
34 |
-
update_option( 'add_search_to_menu', $options );
|
35 |
-
}
|
36 |
-
}
|
37 |
-
|
38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/class-add-search-to-menu-deactivator.php
DELETED
@@ -1,33 +0,0 @@
|
|
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
DELETED
@@ -1,52 +0,0 @@
|
|
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
DELETED
@@ -1,132 +0,0 @@
|
|
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
DELETED
@@ -1,240 +0,0 @@
|
|
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 |
-
$options = $this->options;
|
191 |
-
$display_in_header = isset( $options['add_search_to_menu_display_in_header'] ) ? $options['add_search_to_menu_display_in_header'] : 0;
|
192 |
-
$display_in_mobile_menu = $display_in_header && wp_is_mobile() ? true : false;
|
193 |
-
|
194 |
-
if ( $display_in_mobile_menu ) {
|
195 |
-
$this->loader->add_filter( 'wp_head', $public, 'add_search_to_menu_in_header', 99 );
|
196 |
-
} else {
|
197 |
-
$this->loader->add_filter( 'wp_nav_menu_items', $public, 'add_search_to_menu_items', 99, 2 );
|
198 |
-
}
|
199 |
-
|
200 |
-
if ( ! isset( $options['add_search_to_menu_gcse'] ) || $options['add_search_to_menu_gcse'] == '' ) {
|
201 |
-
$this->loader-> add_action( 'pre_get_posts', $public, 'add_search_to_menu_search_filter' );
|
202 |
-
}
|
203 |
-
|
204 |
-
$this->loader-> add_action( 'wp_footer', $public, 'add_search_to_menu_css' );
|
205 |
-
}
|
206 |
-
|
207 |
-
/**
|
208 |
-
* The name of the plugin used to uniquely identify it within the context of
|
209 |
-
* WordPress and to define internationalization functionality.
|
210 |
-
*
|
211 |
-
* @since 1.0.0
|
212 |
-
* @return string The name of the plugin.
|
213 |
-
*/
|
214 |
-
public function get_plugin_name() {
|
215 |
-
return $this->plugin_name;
|
216 |
-
}
|
217 |
-
|
218 |
-
|
219 |
-
/**
|
220 |
-
* Sets this class into motion.
|
221 |
-
*
|
222 |
-
* Executes the plugin by calling the run method of the loader class which will
|
223 |
-
* register all of the hooks and callback functions used throughout the plugin
|
224 |
-
* with WordPress.
|
225 |
-
*/
|
226 |
-
public function run() {
|
227 |
-
$this->loader->run();
|
228 |
-
}
|
229 |
-
|
230 |
-
|
231 |
-
/**
|
232 |
-
* Returns the current version of the plugin to the caller.
|
233 |
-
*
|
234 |
-
* @return string $this->version The current version of the plugin.
|
235 |
-
*/
|
236 |
-
public function get_version() {
|
237 |
-
return $this->version;
|
238 |
-
}
|
239 |
-
|
240 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/class-astm-activator.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fires during plugin activation.
|
4 |
+
*
|
5 |
+
* This class defines all code necessary to run during the plugin's activation.
|
6 |
+
*
|
7 |
+
* @since 1.0.0
|
8 |
+
* @package ASTM
|
9 |
+
* @subpackage ASTM/includes
|
10 |
+
* @author Free WPTP <freewptp@gmail.com>
|
11 |
+
*/
|
12 |
+
|
13 |
+
if ( ! class_exists( 'ASTM_Activator' ) ) {
|
14 |
+
|
15 |
+
class ASTM_Activator {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* The code that runs during plugin activation.
|
19 |
+
*
|
20 |
+
* @since 1.0.0
|
21 |
+
*/
|
22 |
+
public static function activate() {
|
23 |
+
|
24 |
+
$options = get_option( 'add_search_to_menu' );
|
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 |
+
$options['add_search_to_menu_locations'][ $menu_keys[0] ] = $menu_keys[0];
|
31 |
+
update_option( 'add_search_to_menu', $options );
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
if ( ! isset( $options['add_search_to_menu_posts'] ) ) {
|
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 |
+
$options['add_search_to_menu_posts'][ $post_key ] = $post_key;
|
41 |
+
}
|
42 |
+
update_option( 'add_search_to_menu', $options );
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
includes/class-astm-deactivator.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fires during plugin deactivation.
|
4 |
+
*
|
5 |
+
* This class defines all code necessary to run during the plugin's deactivation.
|
6 |
+
*
|
7 |
+
* @since 1.0.0
|
8 |
+
* @package ASTM
|
9 |
+
* @subpackage ASTM/includes
|
10 |
+
* @author Free WPTP <freewptp@gmail.com>
|
11 |
+
*/
|
12 |
+
|
13 |
+
if ( ! class_exists( 'ASTM_Deactivator' ) ) {
|
14 |
+
|
15 |
+
class ASTM_Deactivator {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* The code that runs during plugin deactivation.
|
19 |
+
*
|
20 |
+
* @since 1.0.0
|
21 |
+
*/
|
22 |
+
public static function deactivate() {
|
23 |
+
|
24 |
+
$options = get_option( 'add_search_to_menu' );
|
25 |
+
|
26 |
+
if ( isset( $options['dismiss_admin_notices'] ) ) {
|
27 |
+
unset( $options['dismiss_admin_notices'] );
|
28 |
+
update_option( 'add_search_to_menu', $options );
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
}
|
includes/class-astm-i18n.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Defines the internationalization functionality.
|
4 |
+
*
|
5 |
+
* Loads and defines the internationalization files for this plugin
|
6 |
+
* so that it is ready for translation.
|
7 |
+
*
|
8 |
+
* @since 1.0.0
|
9 |
+
* @package ASTM
|
10 |
+
* @subpackage ASTM/includes
|
11 |
+
* @author Free WPTP <freewptp@gmail.com>
|
12 |
+
*/
|
13 |
+
|
14 |
+
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 |
+
}
|
includes/class-astm-loader.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The class is the core plugin responsible for including and
|
4 |
+
* instantiating all of the code that composes the plugin.
|
5 |
+
*
|
6 |
+
* The class includes an instance to the plugin
|
7 |
+
* Loader which is responsible for coordinating the hooks that exist within the
|
8 |
+
* plugin.
|
9 |
+
*
|
10 |
+
* @since 1.0.0
|
11 |
+
* @package ASTM
|
12 |
+
*/
|
13 |
+
|
14 |
+
if ( ! class_exists( 'Add_Search_To_Menu' ) ) {
|
15 |
+
|
16 |
+
class Add_Search_To_Menu {
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Defines variable to store plugin options.
|
21 |
+
*/
|
22 |
+
public $options;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* A reference to the loader class that coordinates the hooks and callbacks
|
26 |
+
* throughout the plugin.
|
27 |
+
*
|
28 |
+
* @access protected
|
29 |
+
* @var Add_Search_To_Menu_Loader $loader Manages hooks between the WordPress hooks and the callback functions.
|
30 |
+
*/
|
31 |
+
protected $loader;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Instantiates the plugin by setting up the core properties and loading
|
35 |
+
* all necessary dependencies and defining the hooks.
|
36 |
+
*
|
37 |
+
* The constructor uses internal functions to import all the
|
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() ) {
|
49 |
+
$this->admin_hooks();
|
50 |
+
} else {
|
51 |
+
$this->public_hooks();
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* PHP 4 Compatible Constructor.
|
57 |
+
*/
|
58 |
+
function Add_Search_To_Menu() {
|
59 |
+
$this->__construct();
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Define the locale for this plugin for internationalization.
|
64 |
+
*
|
65 |
+
* Uses the ASTM_i18n class in order to set the domain and to register the hook
|
66 |
+
* with WordPress.
|
67 |
+
*
|
68 |
+
* @since 1.0.0
|
69 |
+
* @access private
|
70 |
+
*/
|
71 |
+
private function set_locale() {
|
72 |
+
$this->loader->add_action( 'plugins_loaded', new ASTM_i18n(), 'load_plugin_textdomain' );
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Defines the hooks and callback functions that are used for setting up the plugin's admin options.
|
77 |
+
*
|
78 |
+
* @access private
|
79 |
+
*/
|
80 |
+
private function admin_hooks() {
|
81 |
+
$options = $this->options;
|
82 |
+
$admin = new ASTM_Admin( ASTM_VERSION );
|
83 |
+
|
84 |
+
if ( ! isset( $options['dismiss_admin_notices'] ) || ! $options['dismiss_admin_notices'] ) {
|
85 |
+
$this->loader->add_action( 'all_admin_notices', $admin, 'setup_notice' );
|
86 |
+
}
|
87 |
+
|
88 |
+
$this->loader->add_action( 'plugin_action_links', $admin, 'plugin_settings_link', 10, 2 );
|
89 |
+
$this->loader->add_action( 'admin_menu', $admin, 'admin_menu_setup' );
|
90 |
+
$this->loader->add_action( 'wp_ajax_nopriv_dismiss_notice', $admin, 'dismiss_notice' );
|
91 |
+
$this->loader->add_action( 'wp_ajax_dismiss_notice', $admin, 'dismiss_notice' );
|
92 |
+
$this->loader->add_action( 'admin_enqueue_scripts', $admin, 'admin_script_style' );
|
93 |
+
$this->loader->add_action( 'admin_init', $admin, 'settings_init' );
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Defines the hooks and callback functions that are used for executing plugin functionality
|
98 |
+
* in the front end of site.
|
99 |
+
*
|
100 |
+
* @access private
|
101 |
+
*/
|
102 |
+
private function public_hooks() {
|
103 |
+
$options = $this->options;
|
104 |
+
$public = new ASTM_Public( ASTM_VERSION );
|
105 |
+
$this->loader->add_action( 'wp_enqueue_scripts', $public, 'enqueue_script_style' );
|
106 |
+
$display_in_header = isset( $options['add_search_to_menu_display_in_header'] ) ? $options['add_search_to_menu_display_in_header'] : 0;
|
107 |
+
$display_in_mobile_menu = $display_in_header && wp_is_mobile() ? true : false;
|
108 |
+
|
109 |
+
if ( $display_in_mobile_menu ) {
|
110 |
+
$this->loader->add_filter( 'wp_head', $public, 'search_in_header', 99 );
|
111 |
+
} else {
|
112 |
+
$this->loader->add_filter( 'wp_nav_menu_items', $public, 'search_menu_item', 99, 2 );
|
113 |
+
}
|
114 |
+
|
115 |
+
if ( isset( $options['add_search_to_menu_posts'] ) && ( ! isset( $options['add_search_to_menu_gcse'] ) || '' == $options['add_search_to_menu_gcse'] ) ) {
|
116 |
+
$this->loader->add_action( 'pre_get_posts', $public, 'search_filter' );
|
117 |
+
}
|
118 |
+
|
119 |
+
$this->loader->add_action( 'wp_footer', $public, 'custom_css' );
|
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 |
+
}
|
includes/index.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Nothing to see here.
|
4 |
+
*/
|
index.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Nothing to see here.
|
4 |
+
*/
|
languages/default.po
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
msgid ""
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: Add Search To Menu\n"
|
4 |
-
"POT-Creation-Date: 2017-08-
|
5 |
-
"PO-Revision-Date: 2017-08-
|
6 |
"Last-Translator: \n"
|
7 |
"Language-Team: Free WP TP <freewptp@gmail.com>\n"
|
8 |
"Language: en_US\n"
|
@@ -14,15 +14,15 @@ msgstr ""
|
|
14 |
"X-Poedit-Basepath: .\n"
|
15 |
"X-Poedit-SearchPath-0: ..\n"
|
16 |
|
17 |
-
#: ../admin/class-
|
18 |
msgid "Get Support"
|
19 |
msgstr ""
|
20 |
|
21 |
-
#: ../admin/class-
|
22 |
msgid "Settings"
|
23 |
msgstr ""
|
24 |
|
25 |
-
#: ../admin/class-
|
26 |
#, php-format
|
27 |
msgid ""
|
28 |
"To configure <em>Add Search To Menu plugin</em> please visit its <a href="
|
@@ -31,164 +31,163 @@ msgid ""
|
|
31 |
"target=\"_blank\">contact us page</a>."
|
32 |
msgstr ""
|
33 |
|
34 |
-
#: ../admin/class-
|
35 |
-
#: ../admin/class-add-search-to-menu-admin.php:153
|
36 |
msgid "Add Search To Menu Settings"
|
37 |
msgstr ""
|
38 |
|
39 |
-
#: ../admin/class-
|
40 |
msgid "Add Search To Menu"
|
41 |
msgstr ""
|
42 |
|
43 |
-
#: ../admin/class-
|
44 |
msgid "Like Add Search To Menu?"
|
45 |
msgstr ""
|
46 |
|
47 |
-
#: ../admin/class-
|
48 |
msgid "Give us a rating"
|
49 |
msgstr ""
|
50 |
|
51 |
-
#: ../admin/class-
|
52 |
msgid "Need Help or Have Suggestions?"
|
53 |
msgstr ""
|
54 |
|
55 |
-
#: ../admin/class-
|
56 |
msgid "contact us on"
|
57 |
msgstr ""
|
58 |
|
59 |
-
#: ../admin/class-
|
60 |
msgid "Plugin support forum"
|
61 |
msgstr ""
|
62 |
|
63 |
-
#: ../admin/class-
|
64 |
msgid "or"
|
65 |
msgstr ""
|
66 |
|
67 |
-
#: ../admin/class-
|
68 |
msgid "Contact us page"
|
69 |
msgstr ""
|
70 |
|
71 |
-
#: ../admin/class-
|
72 |
msgid "Access Plugin Documentation on"
|
73 |
msgstr ""
|
74 |
|
75 |
-
#: ../admin/class-
|
76 |
msgid "Add Search to Menu : "
|
77 |
msgstr ""
|
78 |
|
79 |
-
#: ../admin/class-
|
80 |
msgid "Search Post Types : "
|
81 |
msgstr ""
|
82 |
|
83 |
-
#: ../admin/class-
|
84 |
msgid "Search Form Style : "
|
85 |
msgstr ""
|
86 |
|
87 |
-
#: ../admin/class-
|
88 |
msgid "Search Menu Title : "
|
89 |
msgstr ""
|
90 |
|
91 |
-
#: ../admin/class-
|
92 |
msgid "Search Menu Classes : "
|
93 |
msgstr ""
|
94 |
|
95 |
-
#: ../admin/class-
|
96 |
msgid "Google CSE : "
|
97 |
msgstr ""
|
98 |
|
99 |
-
#: ../admin/class-
|
100 |
msgid "Mobile Display : "
|
101 |
msgstr ""
|
102 |
|
103 |
-
#: ../admin/class-
|
104 |
msgid "Close Icon: "
|
105 |
msgstr ""
|
106 |
|
107 |
-
#: ../admin/class-
|
108 |
msgid "Custom CSS : "
|
109 |
msgstr ""
|
110 |
|
111 |
-
#: ../admin/class-
|
112 |
msgid "Do not load plugin files : "
|
113 |
msgstr ""
|
114 |
|
115 |
-
#: ../admin/class-
|
116 |
msgid "Configure the Add Search To Menu plugin settings here."
|
117 |
msgstr ""
|
118 |
|
119 |
-
#: ../admin/class-
|
120 |
msgid "No navigation menu registered on your site."
|
121 |
msgstr ""
|
122 |
|
123 |
-
#: ../admin/class-
|
124 |
msgid "No post types registered on your site."
|
125 |
msgstr ""
|
126 |
|
127 |
-
#: ../admin/class-
|
128 |
msgid "Default"
|
129 |
msgstr ""
|
130 |
|
131 |
-
#: ../admin/class-
|
132 |
msgid "Dropdown"
|
133 |
msgstr ""
|
134 |
|
135 |
-
#: ../admin/class-
|
136 |
msgid "Sliding"
|
137 |
msgstr ""
|
138 |
|
139 |
-
#: ../admin/class-
|
140 |
msgid "Full Width"
|
141 |
msgstr ""
|
142 |
|
143 |
-
#: ../admin/class-
|
144 |
msgid ""
|
145 |
"If title field is not set then instead of title the search icon displays in "
|
146 |
"navigation menu."
|
147 |
msgstr ""
|
148 |
|
149 |
-
#: ../admin/class-
|
150 |
msgid "Add classes seperated by space."
|
151 |
msgstr ""
|
152 |
|
153 |
-
#: ../admin/class-
|
154 |
msgid ""
|
155 |
"Add only Google CSE search form code in the above text box that will replace "
|
156 |
"default search form."
|
157 |
msgstr ""
|
158 |
|
159 |
-
#: ../admin/class-
|
160 |
msgid "Display Search Form in Header on Mobile Devices"
|
161 |
msgstr ""
|
162 |
|
163 |
-
#: ../admin/class-
|
164 |
msgid ""
|
165 |
"It doesn not work with caching as this functionality uses WordPress "
|
166 |
"wp_is_mobile function."
|
167 |
msgstr ""
|
168 |
|
169 |
-
#: ../admin/class-
|
170 |
msgid "Display Search Form Close Icon"
|
171 |
msgstr ""
|
172 |
|
173 |
-
#: ../admin/class-
|
174 |
msgid "Add custom css code if any to style search form."
|
175 |
msgstr ""
|
176 |
|
177 |
-
#: ../admin/class-
|
178 |
msgid "Plugin CSS File"
|
179 |
msgstr ""
|
180 |
|
181 |
-
#: ../admin/class-
|
182 |
msgid "Plugin JavaScript File"
|
183 |
msgstr ""
|
184 |
|
185 |
-
#: ../admin/class-
|
186 |
msgid ""
|
187 |
"If checked, you have to add following plugin file code into your theme CSS "
|
188 |
"file."
|
189 |
msgstr ""
|
190 |
|
191 |
-
#: ../admin/class-
|
192 |
msgid ""
|
193 |
"If checked, you have to add following plugin file code into your theme "
|
194 |
"JavaScript file."
|
1 |
msgid ""
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: Add Search To Menu\n"
|
4 |
+
"POT-Creation-Date: 2017-08-12 00:41+0530\n"
|
5 |
+
"PO-Revision-Date: 2017-08-12 00:41+0530\n"
|
6 |
"Last-Translator: \n"
|
7 |
"Language-Team: Free WP TP <freewptp@gmail.com>\n"
|
8 |
"Language: en_US\n"
|
14 |
"X-Poedit-Basepath: .\n"
|
15 |
"X-Poedit-SearchPath-0: ..\n"
|
16 |
|
17 |
+
#: ../admin/class-astm-admin.php:62
|
18 |
msgid "Get Support"
|
19 |
msgstr ""
|
20 |
|
21 |
+
#: ../admin/class-astm-admin.php:63
|
22 |
msgid "Settings"
|
23 |
msgstr ""
|
24 |
|
25 |
+
#: ../admin/class-astm-admin.php:82
|
26 |
#, php-format
|
27 |
msgid ""
|
28 |
"To configure <em>Add Search To Menu plugin</em> please visit its <a href="
|
31 |
"target=\"_blank\">contact us page</a>."
|
32 |
msgstr ""
|
33 |
|
34 |
+
#: ../admin/class-astm-admin.php:103 ../admin/class-astm-admin.php:138
|
|
|
35 |
msgid "Add Search To Menu Settings"
|
36 |
msgstr ""
|
37 |
|
38 |
+
#: ../admin/class-astm-admin.php:103
|
39 |
msgid "Add Search To Menu"
|
40 |
msgstr ""
|
41 |
|
42 |
+
#: ../admin/class-astm-admin.php:119
|
43 |
msgid "Like Add Search To Menu?"
|
44 |
msgstr ""
|
45 |
|
46 |
+
#: ../admin/class-astm-admin.php:119
|
47 |
msgid "Give us a rating"
|
48 |
msgstr ""
|
49 |
|
50 |
+
#: ../admin/class-astm-admin.php:122
|
51 |
msgid "Need Help or Have Suggestions?"
|
52 |
msgstr ""
|
53 |
|
54 |
+
#: ../admin/class-astm-admin.php:122
|
55 |
msgid "contact us on"
|
56 |
msgstr ""
|
57 |
|
58 |
+
#: ../admin/class-astm-admin.php:122
|
59 |
msgid "Plugin support forum"
|
60 |
msgstr ""
|
61 |
|
62 |
+
#: ../admin/class-astm-admin.php:122
|
63 |
msgid "or"
|
64 |
msgstr ""
|
65 |
|
66 |
+
#: ../admin/class-astm-admin.php:122
|
67 |
msgid "Contact us page"
|
68 |
msgstr ""
|
69 |
|
70 |
+
#: ../admin/class-astm-admin.php:125
|
71 |
msgid "Access Plugin Documentation on"
|
72 |
msgstr ""
|
73 |
|
74 |
+
#: ../admin/class-astm-admin.php:140
|
75 |
msgid "Add Search to Menu : "
|
76 |
msgstr ""
|
77 |
|
78 |
+
#: ../admin/class-astm-admin.php:141
|
79 |
msgid "Search Post Types : "
|
80 |
msgstr ""
|
81 |
|
82 |
+
#: ../admin/class-astm-admin.php:142
|
83 |
msgid "Search Form Style : "
|
84 |
msgstr ""
|
85 |
|
86 |
+
#: ../admin/class-astm-admin.php:143
|
87 |
msgid "Search Menu Title : "
|
88 |
msgstr ""
|
89 |
|
90 |
+
#: ../admin/class-astm-admin.php:144
|
91 |
msgid "Search Menu Classes : "
|
92 |
msgstr ""
|
93 |
|
94 |
+
#: ../admin/class-astm-admin.php:145
|
95 |
msgid "Google CSE : "
|
96 |
msgstr ""
|
97 |
|
98 |
+
#: ../admin/class-astm-admin.php:146
|
99 |
msgid "Mobile Display : "
|
100 |
msgstr ""
|
101 |
|
102 |
+
#: ../admin/class-astm-admin.php:147
|
103 |
msgid "Close Icon: "
|
104 |
msgstr ""
|
105 |
|
106 |
+
#: ../admin/class-astm-admin.php:148
|
107 |
msgid "Custom CSS : "
|
108 |
msgstr ""
|
109 |
|
110 |
+
#: ../admin/class-astm-admin.php:149
|
111 |
msgid "Do not load plugin files : "
|
112 |
msgstr ""
|
113 |
|
114 |
+
#: ../admin/class-astm-admin.php:159
|
115 |
msgid "Configure the Add Search To Menu plugin settings here."
|
116 |
msgstr ""
|
117 |
|
118 |
+
#: ../admin/class-astm-admin.php:180
|
119 |
msgid "No navigation menu registered on your site."
|
120 |
msgstr ""
|
121 |
|
122 |
+
#: ../admin/class-astm-admin.php:205
|
123 |
msgid "No post types registered on your site."
|
124 |
msgstr ""
|
125 |
|
126 |
+
#: ../admin/class-astm-admin.php:218
|
127 |
msgid "Default"
|
128 |
msgstr ""
|
129 |
|
130 |
+
#: ../admin/class-astm-admin.php:219
|
131 |
msgid "Dropdown"
|
132 |
msgstr ""
|
133 |
|
134 |
+
#: ../admin/class-astm-admin.php:220
|
135 |
msgid "Sliding"
|
136 |
msgstr ""
|
137 |
|
138 |
+
#: ../admin/class-astm-admin.php:221
|
139 |
msgid "Full Width"
|
140 |
msgstr ""
|
141 |
|
142 |
+
#: ../admin/class-astm-admin.php:248
|
143 |
msgid ""
|
144 |
"If title field is not set then instead of title the search icon displays in "
|
145 |
"navigation menu."
|
146 |
msgstr ""
|
147 |
|
148 |
+
#: ../admin/class-astm-admin.php:260
|
149 |
msgid "Add classes seperated by space."
|
150 |
msgstr ""
|
151 |
|
152 |
+
#: ../admin/class-astm-admin.php:272
|
153 |
msgid ""
|
154 |
"Add only Google CSE search form code in the above text box that will replace "
|
155 |
"default search form."
|
156 |
msgstr ""
|
157 |
|
158 |
+
#: ../admin/class-astm-admin.php:284
|
159 |
msgid "Display Search Form in Header on Mobile Devices"
|
160 |
msgstr ""
|
161 |
|
162 |
+
#: ../admin/class-astm-admin.php:285
|
163 |
msgid ""
|
164 |
"It doesn not work with caching as this functionality uses WordPress "
|
165 |
"wp_is_mobile function."
|
166 |
msgstr ""
|
167 |
|
168 |
+
#: ../admin/class-astm-admin.php:297
|
169 |
msgid "Display Search Form Close Icon"
|
170 |
msgstr ""
|
171 |
|
172 |
+
#: ../admin/class-astm-admin.php:309
|
173 |
msgid "Add custom css code if any to style search form."
|
174 |
msgstr ""
|
175 |
|
176 |
+
#: ../admin/class-astm-admin.php:320
|
177 |
msgid "Plugin CSS File"
|
178 |
msgstr ""
|
179 |
|
180 |
+
#: ../admin/class-astm-admin.php:321
|
181 |
msgid "Plugin JavaScript File"
|
182 |
msgstr ""
|
183 |
|
184 |
+
#: ../admin/class-astm-admin.php:334
|
185 |
msgid ""
|
186 |
"If checked, you have to add following plugin file code into your theme CSS "
|
187 |
"file."
|
188 |
msgstr ""
|
189 |
|
190 |
+
#: ../admin/class-astm-admin.php:338
|
191 |
msgid ""
|
192 |
"If checked, you have to add following plugin file code into your theme "
|
193 |
"JavaScript file."
|
public/class-add-search-to-menu-public.php
DELETED
@@ -1,189 +0,0 @@
|
|
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 |
-
if ( isset( $options['add_search_to_menu_gcse'] ) && $options['add_search_to_menu_gcse'] != '' ) {
|
76 |
-
$items .= '<li class="gsc-cse-search-menu">' . $options['add_search_to_menu_gcse'] . '</li>';
|
77 |
-
} else {
|
78 |
-
$search_class = isset( $options['add_search_to_menu_classes'] ) ? $options['add_search_to_menu_classes'].' astm-search-menu ' : 'astm-search-menu ';
|
79 |
-
$search_class .= isset( $options['add_search_to_menu_style'] ) ? $options['add_search_to_menu_style'] : 'default';
|
80 |
-
$title = isset( $options['add_search_to_menu_title'] ) ? $options['add_search_to_menu_title'] : '';
|
81 |
-
$items .= '<li class="' . esc_attr( $search_class ) . '">';
|
82 |
-
|
83 |
-
if ( $options['add_search_to_menu_style'] != 'default' ){
|
84 |
-
|
85 |
-
$items .= '<a title="' . esc_attr( $title ) . '" href="#">';
|
86 |
-
|
87 |
-
if ( $title == '' ) {
|
88 |
-
$items .= '<svg width="20" height="20" class="search-icon" role="img" viewBox="2 9 20 5">
|
89 |
-
<path class="search-icon-path" d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path></svg>';
|
90 |
-
} else {
|
91 |
-
$items .= $title;
|
92 |
-
}
|
93 |
-
$items .= '</a>';
|
94 |
-
}
|
95 |
-
$items .= get_search_form( false );
|
96 |
-
|
97 |
-
if ( isset( $options['add_search_to_menu_close_icon'] ) && $options['add_search_to_menu_close_icon'] ) {
|
98 |
-
$items .= '<div class="search-close"></div>';
|
99 |
-
}
|
100 |
-
|
101 |
-
$items .= '</li>';
|
102 |
-
}
|
103 |
-
|
104 |
-
}
|
105 |
-
}
|
106 |
-
return $items;
|
107 |
-
}
|
108 |
-
|
109 |
-
/* Adds search in the mobile header in the front end of site */
|
110 |
-
function add_search_to_menu_in_header() {
|
111 |
-
$options = $this->options;
|
112 |
-
$items = '';
|
113 |
-
|
114 |
-
if ( isset( $options['add_search_to_menu_locations']['initial'] ) ) {
|
115 |
-
unset( $options['add_search_to_menu_locations']['initial'] );
|
116 |
-
$options['add_search_to_menu_locations'][$args->theme_location] = $args->theme_location;
|
117 |
-
update_option( 'add_search_to_menu', $options );
|
118 |
-
}
|
119 |
-
|
120 |
-
if ( isset( $options['add_search_to_menu_gcse'] ) && $options['add_search_to_menu_gcse'] != '' ) {
|
121 |
-
$items .= '<li class="gsc-cse-search-menu">' . $options['add_search_to_menu_gcse'] . '</li>';
|
122 |
-
} else {
|
123 |
-
$search_class = isset( $options['add_search_to_menu_classes'] ) ? $options['add_search_to_menu_classes'].' astm-search-menu ' : 'astm-search-menu ';
|
124 |
-
$search_class .= isset( $options['add_search_to_menu_style'] ) ? $options['add_search_to_menu_style'] : 'default';
|
125 |
-
$title = isset( $options['add_search_to_menu_title'] ) ? $options['add_search_to_menu_title'] : '';
|
126 |
-
$items .= '<div class="astm-search-menu-wrapper"><div>';
|
127 |
-
$items .= '<span class="' . esc_attr( $search_class ) . '">';
|
128 |
-
|
129 |
-
if ( $options['add_search_to_menu_style'] != 'default' ){
|
130 |
-
|
131 |
-
$items .= '<a title="' . esc_attr( $title ) . '" href="#">';
|
132 |
-
|
133 |
-
if ( $title == '' ) {
|
134 |
-
$items .= '<svg width="20" height="20" class="search-icon" role="img" viewBox="2 9 20 5">
|
135 |
-
<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>';
|
136 |
-
} else {
|
137 |
-
$items .= $title;
|
138 |
-
}
|
139 |
-
|
140 |
-
$items .= '</a>';
|
141 |
-
}
|
142 |
-
$items .= get_search_form( false );
|
143 |
-
|
144 |
-
if ( isset( $options['add_search_to_menu_close_icon'] ) && $options['add_search_to_menu_close_icon'] ) {
|
145 |
-
$items .= '<div class="search-close"></div>';
|
146 |
-
}
|
147 |
-
|
148 |
-
$items .= '</span></div></div>';
|
149 |
-
}
|
150 |
-
|
151 |
-
echo $items;
|
152 |
-
}
|
153 |
-
|
154 |
-
/* Filters search result */
|
155 |
-
function add_search_to_menu_search_filter( $query ) {
|
156 |
-
|
157 |
-
$options = $this->options;
|
158 |
-
|
159 |
-
if ( isset( $options['add_search_to_menu_posts']['initial'] ) ) {
|
160 |
-
$args = array( 'exclude_from_search' => false );
|
161 |
-
$posts = get_post_types( $args );
|
162 |
-
$post_keys = array_keys( $posts );
|
163 |
-
|
164 |
-
foreach ( $post_keys as $post_key ) {
|
165 |
-
$options['add_search_to_menu_posts'][ $post_key ] = $post_key;
|
166 |
-
}
|
167 |
-
|
168 |
-
unset( $options['add_search_to_menu_posts']['initial'] );
|
169 |
-
update_option( 'add_search_to_menu', $options );
|
170 |
-
}
|
171 |
-
|
172 |
-
if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) {
|
173 |
-
$query->set( 'post_type', $options['add_search_to_menu_posts'] );
|
174 |
-
}
|
175 |
-
}
|
176 |
-
|
177 |
-
/* Adds custom CSS code in the site front end */
|
178 |
-
function add_search_to_menu_css() {
|
179 |
-
$options = $this->options;
|
180 |
-
|
181 |
-
if ( isset( $options['add_search_to_menu_css'] ) && $options['add_search_to_menu_css'] != '' ) {
|
182 |
-
echo '<style type="text/css" media="screen">';
|
183 |
-
echo '/* Add search to menu custom CSS code */';
|
184 |
-
esc_html_e( $options['add_search_to_menu_css'] );
|
185 |
-
echo '</style>';
|
186 |
-
}
|
187 |
-
}
|
188 |
-
}
|
189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/class-astm-public.php
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This class defines all plugin functionality for the site front.
|
4 |
+
*
|
5 |
+
* @package ASTM
|
6 |
+
* @since 1.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'ASTM_Public' ) ) {
|
10 |
+
|
11 |
+
class ASTM_Public {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Defines variable to store plugin options.
|
15 |
+
*/
|
16 |
+
public $options;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Initializes this class and stores the plugin options.
|
20 |
+
*/
|
21 |
+
public function __construct() {
|
22 |
+
$this->options = get_option( 'add_search_to_menu' );
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* PHP 4 Compatible Constructor.
|
27 |
+
*/
|
28 |
+
function ASTM_Public() {
|
29 |
+
$this->__construct();
|
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( $options['do_not_load_plugin_files']['plugin-js-file'] ) && ( isset( $options['add_search_to_menu_style'] ) && $options['add_search_to_menu_style'] != 'default' ) ) {
|
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 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Displays search form in the navigation bar in the front end of site.
|
50 |
+
*/
|
51 |
+
function search_menu_item( $items, $args ) {
|
52 |
+
|
53 |
+
$options = $this->options;
|
54 |
+
|
55 |
+
if ( isset( $options['add_search_to_menu_locations'] ) ) {
|
56 |
+
|
57 |
+
if ( isset( $options['add_search_to_menu_locations'][ $args->theme_location ] ) ) {
|
58 |
+
|
59 |
+
if ( isset( $options['add_search_to_menu_gcse'] ) && $options['add_search_to_menu_gcse'] != '' ) {
|
60 |
+
$items .= '<li class="gsc-cse-search-menu">' . $options['add_search_to_menu_gcse'] . '</li>';
|
61 |
+
} else {
|
62 |
+
$search_class = isset( $options['add_search_to_menu_classes'] ) ? $options['add_search_to_menu_classes'].' astm-search-menu ' : 'astm-search-menu ';
|
63 |
+
$search_class .= isset( $options['add_search_to_menu_style'] ) ? $options['add_search_to_menu_style'] : 'default';
|
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 |
+
$items .= '</li>';
|
86 |
+
}
|
87 |
+
|
88 |
+
}
|
89 |
+
}
|
90 |
+
return $items;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
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( $options['add_search_to_menu_gcse'] ) && $options['add_search_to_menu_gcse'] != '' ) {
|
101 |
+
$items .= '<li class="gsc-cse-search-menu">' . $options['add_search_to_menu_gcse'] . '</li>';
|
102 |
+
} else {
|
103 |
+
$search_class = isset( $options['add_search_to_menu_classes'] ) ? $options['add_search_to_menu_classes'].' astm-search-menu ' : 'astm-search-menu ';
|
104 |
+
$search_class .= isset( $options['add_search_to_menu_style'] ) ? $options['add_search_to_menu_style'] : 'default';
|
105 |
+
$title = isset( $options['add_search_to_menu_title'] ) ? $options['add_search_to_menu_title'] : '';
|
106 |
+
$items .= '<div class="astm-search-menu-wrapper"><div>';
|
107 |
+
$items .= '<span class="' . esc_attr( $search_class ) . '">';
|
108 |
+
|
109 |
+
if ( $options['add_search_to_menu_style'] != 'default' ){
|
110 |
+
|
111 |
+
$items .= '<a title="' . esc_attr( $title ) . '" href="#">';
|
112 |
+
|
113 |
+
if ( '' == $title ) {
|
114 |
+
$items .= '<svg width="20" height="20" class="search-icon" role="img" viewBox="2 9 20 5">
|
115 |
+
<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>';
|
116 |
+
} else {
|
117 |
+
$items .= $title;
|
118 |
+
}
|
119 |
+
|
120 |
+
$items .= '</a>';
|
121 |
+
}
|
122 |
+
$items .= get_search_form( false );
|
123 |
+
|
124 |
+
if ( isset( $options['add_search_to_menu_close_icon'] ) && $options['add_search_to_menu_close_icon'] ) {
|
125 |
+
$items .= '<div class="search-close"></div>';
|
126 |
+
}
|
127 |
+
|
128 |
+
$items .= '</span></div></div>';
|
129 |
+
}
|
130 |
+
|
131 |
+
echo $items;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
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', $options['add_search_to_menu_posts'] );
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Adds custom CSS code in the site front end.
|
148 |
+
*/
|
149 |
+
function custom_css() {
|
150 |
+
$options = $this->options;
|
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( $options['add_search_to_menu_css'] ), ENT_QUOTES );
|
156 |
+
echo '</style>';
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
public/css/add-search-to-menu.css
CHANGED
@@ -98,7 +98,7 @@
|
|
98 |
|
99 |
.search-close {
|
100 |
cursor: pointer;
|
101 |
-
display:none;
|
102 |
height: 20px;
|
103 |
position: absolute;
|
104 |
right: -40%;
|
@@ -136,7 +136,7 @@
|
|
136 |
.astm-search-menu.dropdown form[style="display: block;"] + .search-close,
|
137 |
.astm-search-menu.full-width-menu.open .search-close,
|
138 |
.astm-search-menu.sliding.open .search-close {
|
139 |
-
display:block;
|
140 |
}
|
141 |
|
142 |
@media screen and ( max-width: 910px ) {
|
@@ -149,4 +149,4 @@
|
|
149 |
.astm-search-menu.full-width-menu.active-search {
|
150 |
position: relative;
|
151 |
}
|
152 |
-
}
|
98 |
|
99 |
.search-close {
|
100 |
cursor: pointer;
|
101 |
+
display: none;
|
102 |
height: 20px;
|
103 |
position: absolute;
|
104 |
right: -40%;
|
136 |
.astm-search-menu.dropdown form[style="display: block;"] + .search-close,
|
137 |
.astm-search-menu.full-width-menu.open .search-close,
|
138 |
.astm-search-menu.sliding.open .search-close {
|
139 |
+
display: block;
|
140 |
}
|
141 |
|
142 |
@media screen and ( max-width: 910px ) {
|
149 |
.astm-search-menu.full-width-menu.active-search {
|
150 |
position: relative;
|
151 |
}
|
152 |
+
}
|
public/index.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Nothing to see here.
|
4 |
+
*/
|
public/js/add-search-to-menu.js
CHANGED
@@ -1,33 +1,31 @@
|
|
1 |
-
|
2 |
( function( $ ) {
|
3 |
-
|
4 |
-
$(document).ready(function(){
|
5 |
|
6 |
$( '.astm-search-menu a' ).on( 'click', function( e ) {
|
7 |
|
8 |
-
//
|
9 |
e.stopPropagation();
|
10 |
e.preventDefault();
|
11 |
|
12 |
-
if ( $( this ).parent().parent().css( 'position' )
|
13 |
$( this ).parent().parent().css( 'position', 'relative' );
|
14 |
}
|
15 |
|
16 |
if ( $( this ).parent().hasClass( 'dropdown' ) ) {
|
17 |
$( this ).parent().find( 'form' ).fadeToggle();
|
18 |
} else if ( $( this ).parent().hasClass( 'sliding' ) ) {
|
19 |
-
$( this ).parent().find( 'form' ).animate( { width:'300' } );
|
20 |
$( this ).parent().find( 'form input[type="search"], form input[type="text"]' ).focus();
|
21 |
$( this ).parent().addClass( 'open' );
|
22 |
} else if ( $( this ).parent().hasClass( 'full-width-menu' ) ) {
|
23 |
-
$( this ).parent().addClass('active-search');
|
24 |
-
$( this ).parent().find( 'form' ).animate( { width:'100%' } );
|
25 |
$( this ).parent().addClass( 'open' );
|
26 |
$( this ).parent().find( 'form input[type="search"], form input[type="text"]' ).focus();
|
27 |
}
|
28 |
|
29 |
$( '.astm-search-menu form input[type="search"], .astm-search-menu form input[type="text"]' ).focus();
|
30 |
-
|
31 |
} );
|
32 |
} );
|
33 |
|
@@ -39,16 +37,16 @@
|
|
39 |
$( window ).click( function() {
|
40 |
if ( $( '.astm-search-menu' ).hasClass( 'open' ) ) {
|
41 |
$( '.astm-search-menu form' ).animate(
|
42 |
-
{ width:'0' },
|
43 |
400,
|
44 |
function() {
|
45 |
$( '.astm-search-menu' ).removeClass( 'active-search' );
|
46 |
$( '.astm-search-menu' ).removeClass( 'open' );
|
47 |
}
|
48 |
);
|
49 |
-
} else if ( $( '.astm-search-menu' ).hasClass( 'dropdown' ) ){
|
50 |
$( '.astm-search-menu form' ).fadeOut();
|
51 |
}
|
52 |
});
|
53 |
|
54 |
-
} )( jQuery );
|
|
|
1 |
( function( $ ) {
|
2 |
+
'use strict';
|
3 |
+
$( document ).ready( function() {
|
4 |
|
5 |
$( '.astm-search-menu a' ).on( 'click', function( e ) {
|
6 |
|
7 |
+
// Cancels the default actions.
|
8 |
e.stopPropagation();
|
9 |
e.preventDefault();
|
10 |
|
11 |
+
if ( 'static' === $( this ).parent().parent().css( 'position' ) ) {
|
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 |
$( '.astm-search-menu form input[type="search"], .astm-search-menu form input[type="text"]' ).focus();
|
|
|
29 |
} );
|
30 |
} );
|
31 |
|
37 |
$( window ).click( function() {
|
38 |
if ( $( '.astm-search-menu' ).hasClass( 'open' ) ) {
|
39 |
$( '.astm-search-menu form' ).animate(
|
40 |
+
{ width: '0' },
|
41 |
400,
|
42 |
function() {
|
43 |
$( '.astm-search-menu' ).removeClass( 'active-search' );
|
44 |
$( '.astm-search-menu' ).removeClass( 'open' );
|
45 |
}
|
46 |
);
|
47 |
+
} else if ( $( '.astm-search-menu' ).hasClass( 'dropdown' ) ) {
|
48 |
$( '.astm-search-menu form' ).fadeOut();
|
49 |
}
|
50 |
});
|
51 |
|
52 |
+
} )( jQuery );
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://freewptp.com/contact/
|
|
4 |
Tags: menu, search menu, plugin, search box to navigation bar, search to navigation menu, navigation bar search menu, search form to navigation bar
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 4.8
|
7 |
-
Stable tag: 3.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -56,12 +56,16 @@ Please make sure you have configured the plugin settings from Settings -> Add Se
|
|
56 |
* Resolved scrolling issue in fixed menu and made magnifying glass icon resizable.
|
57 |
|
58 |
= 3.0 =
|
59 |
-
* Added plugin options Search Post Types, Google CSE, Mobile Display and Custom CSS
|
60 |
-
* Styled it for default WordPress themes
|
61 |
|
62 |
= 3.1 =
|
63 |
-
* Resolved search icon background color issue
|
64 |
-
* Added search form close icon to close search form
|
|
|
|
|
|
|
|
|
65 |
|
66 |
== Upgrade Notice ==
|
67 |
|
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.2
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
56 |
* Resolved scrolling issue in fixed menu and made magnifying glass icon resizable.
|
57 |
|
58 |
= 3.0 =
|
59 |
+
* Added plugin options Search Post Types, Google CSE, Mobile Display and Custom CSS.
|
60 |
+
* Styled it for default WordPress themes.
|
61 |
|
62 |
= 3.1 =
|
63 |
+
* Resolved search icon background color issue.
|
64 |
+
* Added search form close icon to close search form.
|
65 |
+
|
66 |
+
= 3.2 =
|
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 |
|
uninstall.php
CHANGED
@@ -1,16 +1,11 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
*
|
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 |
-
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Fires when the plugin is uninstalled.
|
|
|
4 |
*
|
|
|
5 |
* @since 1.0.0
|
|
|
6 |
* @package ASTM
|
7 |
*/
|
8 |
|
|
|
9 |
if ( ! defined( 'ABSPATH' ) && ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
10 |
+
exit; // Exits if accessed directly.
|
11 |
+
}
|