Version Description
- Escaping of output within a lot of functions.
- Made the code WordPress PHPCS Compatible.
- Patch to make it work with Max Mega Menu plugin.
Download this release
Release Info
Developer | gagan0123 |
Plugin | Shortcode in Menus |
Version | 3.4 |
Comparing to | |
See all releases |
Code changes from version 3.3 to 3.4
- admin/class-shortcode-in-menus-admin.php +95 -87
- includes/class-shortcode-in-menus.php +55 -47
- languages/shortcode-in-menus.pot +13 -13
- readme.txt +8 -2
- shortcode-in-menus.php +12 -10
admin/class-shortcode-in-menus-admin.php
CHANGED
@@ -1,38 +1,44 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
// If this file is called directly, abort.
|
3 |
-
if ( !defined( 'ABSPATH' ) ) {
|
4 |
exit;
|
5 |
}
|
6 |
|
7 |
-
if ( !class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In_Menus' ) ) {
|
8 |
|
9 |
/**
|
10 |
* Handles admin side interactions of Shortcode in Menus plugin with WordPress.
|
11 |
-
*
|
12 |
* @since 3.3
|
13 |
*/
|
14 |
class Shortcode_In_Menus_Admin extends Shortcode_In_Menus {
|
15 |
|
16 |
/**
|
17 |
* Current instance of the class object.
|
18 |
-
*
|
19 |
* @since 3.3
|
20 |
* @access protected
|
21 |
* @static
|
22 |
-
*
|
23 |
* @var Shortcode_In_Menus_Admin
|
24 |
*/
|
25 |
protected static $instance = null;
|
26 |
|
27 |
/**
|
28 |
* Admin side hooks, filters and registers everything appropriately.
|
29 |
-
*
|
30 |
* @since 3.3
|
31 |
* @access public
|
32 |
*/
|
33 |
public function __construct() {
|
34 |
|
35 |
-
//Calling parent class' constructor.
|
36 |
parent::__construct();
|
37 |
|
38 |
// Setup the meta box.
|
@@ -44,7 +50,7 @@ if ( !class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In_
|
|
44 |
// Add an ajax hack to save the html content.
|
45 |
add_action( 'wp_ajax_gs_sim_description_hack', array( $this, 'description_hack' ) );
|
46 |
|
47 |
-
// Hook to allow saving of shortcode in custom link metabox for legacy support
|
48 |
add_action( 'wp_loaded', array( $this, 'security_check' ) );
|
49 |
|
50 |
// Hijack the ajax_add_menu_item function in order to save Shortcode menu item properly.
|
@@ -53,19 +59,19 @@ if ( !class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In_
|
|
53 |
|
54 |
/**
|
55 |
* Returns the current instance of the class Shortcode_In_Menus_Admin.
|
56 |
-
*
|
57 |
* @since 3.3
|
58 |
* @access public
|
59 |
* @static
|
60 |
-
*
|
61 |
-
* @return Shortcode_In_Menus_Admin Returns the current instance of the
|
62 |
-
*
|
63 |
*/
|
64 |
public static function get_instance() {
|
65 |
|
66 |
// If the single instance hasn't been set, set it now.
|
67 |
-
if ( null
|
68 |
-
self::$instance = new self;
|
69 |
}
|
70 |
|
71 |
return self::$instance;
|
@@ -73,10 +79,10 @@ if ( !class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In_
|
|
73 |
|
74 |
/**
|
75 |
* Register our custom meta box.
|
76 |
-
*
|
77 |
* @since 2.0
|
78 |
* @access public
|
79 |
-
*
|
80 |
* @return void
|
81 |
*/
|
82 |
public function setup_meta_box() {
|
@@ -85,18 +91,18 @@ if ( !class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In_
|
|
85 |
|
86 |
/**
|
87 |
* Enqueue our custom JS.
|
88 |
-
*
|
89 |
* @since 2.0
|
90 |
* @access public
|
91 |
-
*
|
92 |
* @param string $hook The current screen.
|
93 |
-
*
|
94 |
* @return void
|
95 |
*/
|
96 |
public function enqueue( $hook ) {
|
97 |
|
98 |
// Don't enqueue if it isn't the menu editor.
|
99 |
-
if ( 'nav-menus.php'
|
100 |
return;
|
101 |
}
|
102 |
|
@@ -104,18 +110,18 @@ if ( !class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In_
|
|
104 |
}
|
105 |
|
106 |
/**
|
107 |
-
* An AJAX based workaround to save descriptions without using the
|
108 |
* custom object type.
|
109 |
-
*
|
110 |
* @since 2.0
|
111 |
* @access public
|
112 |
-
*
|
113 |
* @return void
|
114 |
*/
|
115 |
public function description_hack() {
|
116 |
// Verify the nonce.
|
117 |
$nonce = filter_input( INPUT_POST, 'description-nonce' );
|
118 |
-
if ( !wp_verify_nonce( $nonce, 'gs-sim-description-nonce' ) ) {
|
119 |
wp_die();
|
120 |
}
|
121 |
|
@@ -123,45 +129,45 @@ if ( !class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In_
|
|
123 |
$item = filter_input( INPUT_POST, 'menu-item', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
|
124 |
|
125 |
// Save the description in a transient. This is what we'll use in setup_item().
|
126 |
-
set_transient( 'gs_sim_description_hack_' . $item[
|
127 |
|
128 |
// Increment the object id, so it can be used by JS.
|
129 |
-
$object_id = $this->new_object_id( $item[
|
130 |
|
131 |
-
echo $object_id;
|
132 |
|
133 |
wp_die();
|
134 |
}
|
135 |
|
136 |
/**
|
137 |
* Allows shortcodes into the custom link URL field.
|
138 |
-
*
|
139 |
* @since 1.0
|
140 |
-
*
|
141 |
* @return void
|
142 |
*/
|
143 |
public function security_check() {
|
144 |
if ( current_user_can( 'activate_plugins' ) ) {
|
145 |
-
//Conditionally adding the function for database context for
|
146 |
add_filter( 'clean_url', array( $this, 'save_shortcode' ), 99, 3 );
|
147 |
}
|
148 |
}
|
149 |
|
150 |
/**
|
151 |
* Ajax handler for add menu item request.
|
152 |
-
*
|
153 |
* This method is hijacked from WordPress default ajax_add_menu_item
|
154 |
* so need to be updated accordingly.
|
155 |
-
*
|
156 |
* @since 2.0
|
157 |
-
*
|
158 |
* @return void
|
159 |
*/
|
160 |
public function ajax_add_menu_item() {
|
161 |
|
162 |
check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
|
163 |
|
164 |
-
if ( !current_user_can( 'edit_theme_options' ) ) {
|
165 |
wp_die( -1 );
|
166 |
}
|
167 |
|
@@ -169,30 +175,30 @@ if ( !class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In_
|
|
169 |
|
170 |
// For performance reasons, we omit some object properties from the checklist.
|
171 |
// The following is a hacky way to restore them when adding non-custom items.
|
172 |
-
|
173 |
$menu_items_data = array();
|
174 |
-
|
|
|
175 |
if (
|
176 |
-
!empty( $menu_item_data[
|
177 |
-
'custom'
|
178 |
-
'gs_sim'
|
179 |
-
!empty( $menu_item_data[
|
180 |
) {
|
181 |
-
switch ( $menu_item_data[
|
182 |
-
case 'post_type'
|
183 |
-
$_object = get_post( $menu_item_data[
|
184 |
break;
|
185 |
|
186 |
-
case 'taxonomy'
|
187 |
-
$_object = get_term( $menu_item_data[
|
188 |
break;
|
189 |
}
|
190 |
|
191 |
$_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) );
|
192 |
-
$_menu_item
|
193 |
|
194 |
// Restore the missing menu item properties.
|
195 |
-
$menu_item_data[
|
196 |
}
|
197 |
|
198 |
$menu_items_data[] = $menu_item_data;
|
@@ -207,26 +213,28 @@ if ( !class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In_
|
|
207 |
|
208 |
foreach ( (array) $item_ids as $menu_item_id ) {
|
209 |
$menu_obj = get_post( $menu_item_id );
|
210 |
-
if ( !empty( $menu_obj->ID ) ) {
|
211 |
-
$menu_obj
|
212 |
-
$menu_obj->label = $menu_obj->title; // don't show "(pending)" in ajax-added items
|
213 |
-
$menu_items[]
|
214 |
}
|
215 |
}
|
216 |
|
|
|
217 |
/** This filter is documented in wp-admin/includes/nav-menu.php */
|
218 |
-
$walker_class_name
|
219 |
|
220 |
-
if ( !class_exists( $walker_class_name ) )
|
221 |
wp_die( 0 );
|
|
|
222 |
|
223 |
-
if ( !empty( $menu_items ) ) {
|
224 |
$args = array(
|
225 |
-
'after'
|
226 |
-
'before'
|
227 |
-
'link_after'
|
228 |
-
'link_before'
|
229 |
-
'walker'
|
230 |
);
|
231 |
echo walk_nav_menu_tree( $menu_items, 0, (object) $args );
|
232 |
}
|
@@ -235,18 +243,18 @@ if ( !class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In_
|
|
235 |
|
236 |
/**
|
237 |
* Method to allow saving of shortcodes in custom_link URL.
|
238 |
-
*
|
239 |
* @since 1.0
|
240 |
-
*
|
241 |
* @param string $url The processed URL for displaying/saving.
|
242 |
* @param string $orig_url The URL that was submitted, retreived.
|
243 |
* @param string $context Whether saving or displaying.
|
244 |
-
*
|
245 |
* @return string String containing the shortcode.
|
246 |
*/
|
247 |
public function save_shortcode( $url, $orig_url, $context ) {
|
248 |
|
249 |
-
if (
|
250 |
return $orig_url;
|
251 |
}
|
252 |
return $url;
|
@@ -254,26 +262,26 @@ if ( !class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In_
|
|
254 |
|
255 |
/**
|
256 |
* Gets a new object ID, given the current one
|
257 |
-
*
|
258 |
* @since 2.0
|
259 |
* @access public
|
260 |
-
*
|
261 |
-
* @param int $last_object_id The current/last object id
|
262 |
-
*
|
263 |
* @return int Returns new object ID.
|
264 |
*/
|
265 |
public function new_object_id( $last_object_id ) {
|
266 |
|
267 |
-
// make sure it's an integer
|
268 |
$object_id = (int) $last_object_id;
|
269 |
|
270 |
-
// increment it
|
271 |
-
$object_id++;
|
272 |
|
273 |
-
// if object_id was 0 to start off with, make it 1
|
274 |
$object_id = ($object_id < 1) ? 1 : $object_id;
|
275 |
|
276 |
-
// save into the options table
|
277 |
update_option( 'gs_sim_last_object_id', $object_id );
|
278 |
|
279 |
return $object_id;
|
@@ -281,36 +289,36 @@ if ( !class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In_
|
|
281 |
|
282 |
/**
|
283 |
* Display our custom meta box.
|
284 |
-
*
|
285 |
* @since 2.0
|
286 |
* @access public
|
287 |
-
*
|
288 |
* @global int $_nav_menu_placeholder A placeholder index for the menu item.
|
289 |
* @global int|string $nav_menu_selected_id (id, name or slug) of the currently-selected menu.
|
290 |
-
*
|
291 |
* @return void
|
292 |
*/
|
293 |
public function meta_box() {
|
294 |
global $_nav_menu_placeholder, $nav_menu_selected_id;
|
295 |
|
296 |
-
$
|
297 |
|
298 |
-
$last_object_id
|
299 |
-
$object_id
|
300 |
?>
|
301 |
<div class="gs-sim-div" id="gs-sim-div">
|
302 |
-
<input type="hidden" class="menu-item-db-id" name="menu-item[<?php echo $
|
303 |
-
<input type="hidden" class="menu-item-object-id" name="menu-item[<?php echo $
|
304 |
-
<input type="hidden" class="menu-item-object" name="menu-item[<?php echo $
|
305 |
-
<input type="hidden" class="menu-item-type" name="menu-item[<?php echo $
|
306 |
-
<input type="hidden" id="gs-sim-description-nonce" value="<?php echo wp_create_nonce( 'gs-sim-description-nonce' ) ?>" />
|
307 |
<p id="menu-item-title-wrap">
|
308 |
-
<label for="gs-sim-title"><?php
|
309 |
-
<input id="gs-sim-title" name="menu-item[<?php echo $
|
310 |
</p>
|
311 |
|
312 |
<p id="menu-item-html-wrap">
|
313 |
-
<textarea style="width:100%;" rows="9" id="gs-sim-html" name="menu-item[<?php echo $
|
314 |
</p>
|
315 |
|
316 |
<p class="button-controls">
|
@@ -326,4 +334,4 @@ if ( !class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In_
|
|
326 |
|
327 |
}
|
328 |
|
329 |
-
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Handles admin side interactions of the plugin with WordPress.
|
4 |
+
*
|
5 |
+
* @package Shortcode_In_Menus
|
6 |
+
*/
|
7 |
+
|
8 |
// If this file is called directly, abort.
|
9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
exit;
|
11 |
}
|
12 |
|
13 |
+
if ( ! class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In_Menus' ) ) {
|
14 |
|
15 |
/**
|
16 |
* Handles admin side interactions of Shortcode in Menus plugin with WordPress.
|
17 |
+
*
|
18 |
* @since 3.3
|
19 |
*/
|
20 |
class Shortcode_In_Menus_Admin extends Shortcode_In_Menus {
|
21 |
|
22 |
/**
|
23 |
* Current instance of the class object.
|
24 |
+
*
|
25 |
* @since 3.3
|
26 |
* @access protected
|
27 |
* @static
|
28 |
+
*
|
29 |
* @var Shortcode_In_Menus_Admin
|
30 |
*/
|
31 |
protected static $instance = null;
|
32 |
|
33 |
/**
|
34 |
* Admin side hooks, filters and registers everything appropriately.
|
35 |
+
*
|
36 |
* @since 3.3
|
37 |
* @access public
|
38 |
*/
|
39 |
public function __construct() {
|
40 |
|
41 |
+
// Calling parent class' constructor.
|
42 |
parent::__construct();
|
43 |
|
44 |
// Setup the meta box.
|
50 |
// Add an ajax hack to save the html content.
|
51 |
add_action( 'wp_ajax_gs_sim_description_hack', array( $this, 'description_hack' ) );
|
52 |
|
53 |
+
// Hook to allow saving of shortcode in custom link metabox for legacy support.
|
54 |
add_action( 'wp_loaded', array( $this, 'security_check' ) );
|
55 |
|
56 |
// Hijack the ajax_add_menu_item function in order to save Shortcode menu item properly.
|
59 |
|
60 |
/**
|
61 |
* Returns the current instance of the class Shortcode_In_Menus_Admin.
|
62 |
+
*
|
63 |
* @since 3.3
|
64 |
* @access public
|
65 |
* @static
|
66 |
+
*
|
67 |
+
* @return Shortcode_In_Menus_Admin Returns the current instance of the
|
68 |
+
* class object.
|
69 |
*/
|
70 |
public static function get_instance() {
|
71 |
|
72 |
// If the single instance hasn't been set, set it now.
|
73 |
+
if ( null === self::$instance ) {
|
74 |
+
self::$instance = new self();
|
75 |
}
|
76 |
|
77 |
return self::$instance;
|
79 |
|
80 |
/**
|
81 |
* Register our custom meta box.
|
82 |
+
*
|
83 |
* @since 2.0
|
84 |
* @access public
|
85 |
+
*
|
86 |
* @return void
|
87 |
*/
|
88 |
public function setup_meta_box() {
|
91 |
|
92 |
/**
|
93 |
* Enqueue our custom JS.
|
94 |
+
*
|
95 |
* @since 2.0
|
96 |
* @access public
|
97 |
+
*
|
98 |
* @param string $hook The current screen.
|
99 |
+
*
|
100 |
* @return void
|
101 |
*/
|
102 |
public function enqueue( $hook ) {
|
103 |
|
104 |
// Don't enqueue if it isn't the menu editor.
|
105 |
+
if ( 'nav-menus.php' !== $hook ) {
|
106 |
return;
|
107 |
}
|
108 |
|
110 |
}
|
111 |
|
112 |
/**
|
113 |
+
* An AJAX based workaround to save descriptions without using the
|
114 |
* custom object type.
|
115 |
+
*
|
116 |
* @since 2.0
|
117 |
* @access public
|
118 |
+
*
|
119 |
* @return void
|
120 |
*/
|
121 |
public function description_hack() {
|
122 |
// Verify the nonce.
|
123 |
$nonce = filter_input( INPUT_POST, 'description-nonce' );
|
124 |
+
if ( ! wp_verify_nonce( $nonce, 'gs-sim-description-nonce' ) ) {
|
125 |
wp_die();
|
126 |
}
|
127 |
|
129 |
$item = filter_input( INPUT_POST, 'menu-item', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
|
130 |
|
131 |
// Save the description in a transient. This is what we'll use in setup_item().
|
132 |
+
set_transient( 'gs_sim_description_hack_' . $item['menu-item-object-id'], $item['menu-item-description'] );
|
133 |
|
134 |
// Increment the object id, so it can be used by JS.
|
135 |
+
$object_id = $this->new_object_id( $item['menu-item-object-id'] );
|
136 |
|
137 |
+
echo esc_js( $object_id );
|
138 |
|
139 |
wp_die();
|
140 |
}
|
141 |
|
142 |
/**
|
143 |
* Allows shortcodes into the custom link URL field.
|
144 |
+
*
|
145 |
* @since 1.0
|
146 |
+
*
|
147 |
* @return void
|
148 |
*/
|
149 |
public function security_check() {
|
150 |
if ( current_user_can( 'activate_plugins' ) ) {
|
151 |
+
// Conditionally adding the function for database context for.
|
152 |
add_filter( 'clean_url', array( $this, 'save_shortcode' ), 99, 3 );
|
153 |
}
|
154 |
}
|
155 |
|
156 |
/**
|
157 |
* Ajax handler for add menu item request.
|
158 |
+
*
|
159 |
* This method is hijacked from WordPress default ajax_add_menu_item
|
160 |
* so need to be updated accordingly.
|
161 |
+
*
|
162 |
* @since 2.0
|
163 |
+
*
|
164 |
* @return void
|
165 |
*/
|
166 |
public function ajax_add_menu_item() {
|
167 |
|
168 |
check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
|
169 |
|
170 |
+
if ( ! current_user_can( 'edit_theme_options' ) ) {
|
171 |
wp_die( -1 );
|
172 |
}
|
173 |
|
175 |
|
176 |
// For performance reasons, we omit some object properties from the checklist.
|
177 |
// The following is a hacky way to restore them when adding non-custom items.
|
|
|
178 |
$menu_items_data = array();
|
179 |
+
$menu_item = filter_input( INPUT_POST, 'menu-item', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
|
180 |
+
foreach ( $menu_item as $menu_item_data ) {
|
181 |
if (
|
182 |
+
! empty( $menu_item_data['menu-item-type'] ) &&
|
183 |
+
'custom' !== $menu_item_data['menu-item-type'] &&
|
184 |
+
'gs_sim' !== $menu_item_data['menu-item-type'] &&
|
185 |
+
! empty( $menu_item_data['menu-item-object-id'] )
|
186 |
) {
|
187 |
+
switch ( $menu_item_data['menu-item-type'] ) {
|
188 |
+
case 'post_type':
|
189 |
+
$_object = get_post( $menu_item_data['menu-item-object-id'] );
|
190 |
break;
|
191 |
|
192 |
+
case 'taxonomy':
|
193 |
+
$_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] );
|
194 |
break;
|
195 |
}
|
196 |
|
197 |
$_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) );
|
198 |
+
$_menu_item = reset( $_menu_items );
|
199 |
|
200 |
// Restore the missing menu item properties.
|
201 |
+
$menu_item_data['menu-item-description'] = $_menu_item->description;
|
202 |
}
|
203 |
|
204 |
$menu_items_data[] = $menu_item_data;
|
213 |
|
214 |
foreach ( (array) $item_ids as $menu_item_id ) {
|
215 |
$menu_obj = get_post( $menu_item_id );
|
216 |
+
if ( ! empty( $menu_obj->ID ) ) {
|
217 |
+
$menu_obj = wp_setup_nav_menu_item( $menu_obj );
|
218 |
+
$menu_obj->label = $menu_obj->title; // don't show "(pending)" in ajax-added items.
|
219 |
+
$menu_items[] = $menu_obj;
|
220 |
}
|
221 |
}
|
222 |
|
223 |
+
$menu = filter_input( INPUT_POST, 'menu' );
|
224 |
/** This filter is documented in wp-admin/includes/nav-menu.php */
|
225 |
+
$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu );
|
226 |
|
227 |
+
if ( ! class_exists( $walker_class_name ) ) {
|
228 |
wp_die( 0 );
|
229 |
+
}
|
230 |
|
231 |
+
if ( ! empty( $menu_items ) ) {
|
232 |
$args = array(
|
233 |
+
'after' => '',
|
234 |
+
'before' => '',
|
235 |
+
'link_after' => '',
|
236 |
+
'link_before' => '',
|
237 |
+
'walker' => new $walker_class_name(),
|
238 |
);
|
239 |
echo walk_nav_menu_tree( $menu_items, 0, (object) $args );
|
240 |
}
|
243 |
|
244 |
/**
|
245 |
* Method to allow saving of shortcodes in custom_link URL.
|
246 |
+
*
|
247 |
* @since 1.0
|
248 |
+
*
|
249 |
* @param string $url The processed URL for displaying/saving.
|
250 |
* @param string $orig_url The URL that was submitted, retreived.
|
251 |
* @param string $context Whether saving or displaying.
|
252 |
+
*
|
253 |
* @return string String containing the shortcode.
|
254 |
*/
|
255 |
public function save_shortcode( $url, $orig_url, $context ) {
|
256 |
|
257 |
+
if ( 'db' === $context && $this->has_shortcode( $orig_url ) ) {
|
258 |
return $orig_url;
|
259 |
}
|
260 |
return $url;
|
262 |
|
263 |
/**
|
264 |
* Gets a new object ID, given the current one
|
265 |
+
*
|
266 |
* @since 2.0
|
267 |
* @access public
|
268 |
+
*
|
269 |
+
* @param int $last_object_id The current/last object id.
|
270 |
+
*
|
271 |
* @return int Returns new object ID.
|
272 |
*/
|
273 |
public function new_object_id( $last_object_id ) {
|
274 |
|
275 |
+
// make sure it's an integer.
|
276 |
$object_id = (int) $last_object_id;
|
277 |
|
278 |
+
// increment it.
|
279 |
+
$object_id ++;
|
280 |
|
281 |
+
// if object_id was 0 to start off with, make it 1.
|
282 |
$object_id = ($object_id < 1) ? 1 : $object_id;
|
283 |
|
284 |
+
// save into the options table.
|
285 |
update_option( 'gs_sim_last_object_id', $object_id );
|
286 |
|
287 |
return $object_id;
|
289 |
|
290 |
/**
|
291 |
* Display our custom meta box.
|
292 |
+
*
|
293 |
* @since 2.0
|
294 |
* @access public
|
295 |
+
*
|
296 |
* @global int $_nav_menu_placeholder A placeholder index for the menu item.
|
297 |
* @global int|string $nav_menu_selected_id (id, name or slug) of the currently-selected menu.
|
298 |
+
*
|
299 |
* @return void
|
300 |
*/
|
301 |
public function meta_box() {
|
302 |
global $_nav_menu_placeholder, $nav_menu_selected_id;
|
303 |
|
304 |
+
$nav_menu_placeholder = 0 > $_nav_menu_placeholder ? $_nav_menu_placeholder - 1 : -1;
|
305 |
|
306 |
+
$last_object_id = get_option( 'gs_sim_last_object_id', 0 );
|
307 |
+
$object_id = $this->new_object_id( $last_object_id );
|
308 |
?>
|
309 |
<div class="gs-sim-div" id="gs-sim-div">
|
310 |
+
<input type="hidden" class="menu-item-db-id" name="menu-item[<?php echo esc_attr( $nav_menu_placeholder ); ?>][menu-item-db-id]" value="0" />
|
311 |
+
<input type="hidden" class="menu-item-object-id" name="menu-item[<?php echo esc_attr( $nav_menu_placeholder ); ?>][menu-item-object-id]" value="<?php echo esc_attr( $object_id ); ?>" />
|
312 |
+
<input type="hidden" class="menu-item-object" name="menu-item[<?php echo esc_attr( $nav_menu_placeholder ); ?>][menu-item-object]" value="gs_sim" />
|
313 |
+
<input type="hidden" class="menu-item-type" name="menu-item[<?php echo esc_attr( $nav_menu_placeholder ); ?>][menu-item-type]" value="gs_sim" />
|
314 |
+
<input type="hidden" id="gs-sim-description-nonce" value="<?php echo esc_attr( wp_create_nonce( 'gs-sim-description-nonce' ) ); ?>" />
|
315 |
<p id="menu-item-title-wrap">
|
316 |
+
<label for="gs-sim-title"><?php esc_html_e( 'Title', 'shortcode-in-menus' ); ?></label>
|
317 |
+
<input id="gs-sim-title" name="menu-item[<?php echo esc_attr( $nav_menu_placeholder ); ?>][menu-item-title]" type="text" class="regular-text menu-item-textbox" title="<?php esc_attr_e( 'Title', 'shortcode-in-menus' ); ?>" style="width:100%" />
|
318 |
</p>
|
319 |
|
320 |
<p id="menu-item-html-wrap">
|
321 |
+
<textarea style="width:100%;" rows="9" id="gs-sim-html" name="menu-item[<?php echo esc_attr( $nav_menu_placeholder ); ?>][menu-item-description]" class="code menu-item-textbox" title="<?php esc_attr_e( 'Text/HTML/shortcode here!', 'shortcode-in-menus' ); ?>"></textarea>
|
322 |
</p>
|
323 |
|
324 |
<p class="button-controls">
|
334 |
|
335 |
}
|
336 |
|
337 |
+
}
|
includes/class-shortcode-in-menus.php
CHANGED
@@ -1,44 +1,49 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
// If this file is called directly, abort.
|
4 |
-
if ( !defined( 'ABSPATH' ) ) {
|
5 |
exit;
|
6 |
}
|
7 |
|
8 |
-
if ( !class_exists( 'Shortcode_In_Menus' ) ) {
|
9 |
|
10 |
/**
|
11 |
* Handles Shortcode in Menus plugin interactions with WordPress.
|
12 |
-
*
|
13 |
* @since 3.2
|
14 |
*/
|
15 |
class Shortcode_In_Menus {
|
16 |
|
17 |
/**
|
18 |
* Current instance of the class object.
|
19 |
-
*
|
20 |
* @since 3.2
|
21 |
* @access protected
|
22 |
* @static
|
23 |
-
*
|
24 |
* @var Shortcode_In_Menus
|
25 |
*/
|
26 |
protected static $instance = null;
|
27 |
|
28 |
/**
|
29 |
* Returns the current instance of the class Shortcode_In_Menus.
|
30 |
-
*
|
31 |
* @since 3.2
|
32 |
* @access public
|
33 |
* @static
|
34 |
-
*
|
35 |
* @return Shortcode_In_Menus Returns the current instance of the class object.
|
36 |
*/
|
37 |
public static function get_instance() {
|
38 |
|
39 |
// If the single instance hasn't been set, set it now.
|
40 |
-
if ( null
|
41 |
-
self::$instance = new self;
|
42 |
}
|
43 |
|
44 |
return self::$instance;
|
@@ -46,31 +51,34 @@ if ( !class_exists( 'Shortcode_In_Menus' ) ) {
|
|
46 |
|
47 |
/**
|
48 |
* Hooks, filters and registers everything appropriately.
|
49 |
-
*
|
50 |
* @since 3.2
|
51 |
* @access public
|
52 |
*/
|
53 |
public function __construct() {
|
54 |
|
55 |
-
// register a test shortcode for testing
|
56 |
add_shortcode( 'gs_test_shortcode', array( $this, 'shortcode' ) );
|
57 |
|
58 |
-
// filter the menu item output on frontend
|
59 |
add_filter( 'walker_nav_menu_start_el', array( $this, 'start_el' ), 20, 2 );
|
60 |
|
61 |
-
//
|
|
|
|
|
|
|
62 |
add_filter( 'clean_url', array( $this, 'display_shortcode' ), 1, 3 );
|
63 |
|
64 |
-
// filter the menu item before display in admin and in frontend
|
65 |
add_filter( 'wp_setup_nav_menu_item', array( $this, 'setup_item' ), 10, 1 );
|
66 |
}
|
67 |
|
68 |
/**
|
69 |
* Test shortcode. Output's WordPress.org URL.
|
70 |
-
*
|
71 |
* @since 1.2
|
72 |
* @access public
|
73 |
-
*
|
74 |
* @return string Returns WordPress.org URL.
|
75 |
*/
|
76 |
public function shortcode() {
|
@@ -80,12 +88,12 @@ if ( !class_exists( 'Shortcode_In_Menus' ) ) {
|
|
80 |
/**
|
81 |
* Check if the passed content has any shortcode. Inspired from the
|
82 |
* core's has_shortcode.
|
83 |
-
*
|
84 |
* @since 2.0
|
85 |
* @access public
|
86 |
-
*
|
87 |
* @param string $content The content to check for shortcode.
|
88 |
-
*
|
89 |
* @return boolean Returns true if the $content has shortcode, false otherwise.
|
90 |
*/
|
91 |
public function has_shortcode( $content ) {
|
@@ -94,7 +102,7 @@ if ( !class_exists( 'Shortcode_In_Menus' ) ) {
|
|
94 |
|
95 |
preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
|
96 |
|
97 |
-
if ( !empty( $matches ) ) {
|
98 |
return true;
|
99 |
}
|
100 |
}
|
@@ -103,30 +111,30 @@ if ( !class_exists( 'Shortcode_In_Menus' ) ) {
|
|
103 |
|
104 |
/**
|
105 |
* Modifies the menu item display on frontend.
|
106 |
-
*
|
107 |
* @since 2.0
|
108 |
-
*
|
109 |
* @param string $item_output The original html.
|
110 |
* @param object $item The menu item being displayed.
|
111 |
-
*
|
112 |
* @return string Modified menu item to display.
|
113 |
*/
|
114 |
public function start_el( $item_output, $item ) {
|
115 |
-
// if it isn't our custom object
|
116 |
-
if ( $item->object
|
117 |
|
118 |
-
// check the legacy hack
|
119 |
-
if (
|
120 |
|
121 |
-
// then just process as we used to
|
122 |
$item_output = do_shortcode( $item->url );
|
123 |
} else {
|
124 |
$item_output = do_shortcode( $item_output );
|
125 |
}
|
126 |
|
127 |
-
// if it is our object
|
128 |
} else {
|
129 |
-
// just process it
|
130 |
$item_output = do_shortcode( $item->description );
|
131 |
}
|
132 |
|
@@ -135,17 +143,17 @@ if ( !class_exists( 'Shortcode_In_Menus' ) ) {
|
|
135 |
|
136 |
/**
|
137 |
* Allows shortcode to be processed and displayed.
|
138 |
-
*
|
139 |
* @since 1.0
|
140 |
-
*
|
141 |
-
* @param string $url
|
142 |
-
* @param string $orig_url
|
143 |
-
* @param string $context
|
144 |
-
*
|
145 |
* @return string Output string after shortcode has been executed.
|
146 |
*/
|
147 |
public function display_shortcode( $url, $orig_url, $context ) {
|
148 |
-
if (
|
149 |
return do_shortcode( $orig_url );
|
150 |
}
|
151 |
return $url;
|
@@ -153,33 +161,33 @@ if ( !class_exists( 'Shortcode_In_Menus' ) ) {
|
|
153 |
|
154 |
/**
|
155 |
* Modify the menu item before display on Menu editor and in frontend.
|
156 |
-
*
|
157 |
* @since 2.0
|
158 |
* @access public
|
159 |
-
*
|
160 |
* @param object $item The menu item.
|
161 |
-
*
|
162 |
* @return object Modified menu item object.
|
163 |
*/
|
164 |
public function setup_item( $item ) {
|
165 |
-
if ( !is_object( $item ) ) {
|
166 |
return $item;
|
167 |
}
|
168 |
|
169 |
-
// only if it is our object
|
170 |
-
if ( $item->object
|
171 |
|
172 |
-
// setup our label
|
173 |
$item->type_label = __( 'Shortcode' );
|
174 |
|
175 |
-
if ( $item->post_content
|
176 |
$item->description = $item->post_content;
|
177 |
} else {
|
178 |
|
179 |
-
// set up the description from the transient
|
180 |
$item->description = get_transient( 'gs_sim_description_hack_' . $item->object_id );
|
181 |
|
182 |
-
// discard the transient
|
183 |
delete_transient( 'gs_sim_description_hack_' . $item->object_id );
|
184 |
}
|
185 |
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Main class of the plugin interacting with WordPress.
|
4 |
+
*
|
5 |
+
* @package Shortcode_In_Menus
|
6 |
+
*/
|
7 |
|
8 |
// If this file is called directly, abort.
|
9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
exit;
|
11 |
}
|
12 |
|
13 |
+
if ( ! class_exists( 'Shortcode_In_Menus' ) ) {
|
14 |
|
15 |
/**
|
16 |
* Handles Shortcode in Menus plugin interactions with WordPress.
|
17 |
+
*
|
18 |
* @since 3.2
|
19 |
*/
|
20 |
class Shortcode_In_Menus {
|
21 |
|
22 |
/**
|
23 |
* Current instance of the class object.
|
24 |
+
*
|
25 |
* @since 3.2
|
26 |
* @access protected
|
27 |
* @static
|
28 |
+
*
|
29 |
* @var Shortcode_In_Menus
|
30 |
*/
|
31 |
protected static $instance = null;
|
32 |
|
33 |
/**
|
34 |
* Returns the current instance of the class Shortcode_In_Menus.
|
35 |
+
*
|
36 |
* @since 3.2
|
37 |
* @access public
|
38 |
* @static
|
39 |
+
*
|
40 |
* @return Shortcode_In_Menus Returns the current instance of the class object.
|
41 |
*/
|
42 |
public static function get_instance() {
|
43 |
|
44 |
// If the single instance hasn't been set, set it now.
|
45 |
+
if ( null === self::$instance ) {
|
46 |
+
self::$instance = new self();
|
47 |
}
|
48 |
|
49 |
return self::$instance;
|
51 |
|
52 |
/**
|
53 |
* Hooks, filters and registers everything appropriately.
|
54 |
+
*
|
55 |
* @since 3.2
|
56 |
* @access public
|
57 |
*/
|
58 |
public function __construct() {
|
59 |
|
60 |
+
// register a test shortcode for testing.
|
61 |
add_shortcode( 'gs_test_shortcode', array( $this, 'shortcode' ) );
|
62 |
|
63 |
+
// filter the menu item output on frontend.
|
64 |
add_filter( 'walker_nav_menu_start_el', array( $this, 'start_el' ), 20, 2 );
|
65 |
|
66 |
+
// Making it work with Max Mega Menu Plugin.
|
67 |
+
add_filter( 'megamenu_walker_nav_menu_start_el', array( $this, 'start_el' ), 20, 2 );
|
68 |
+
|
69 |
+
// filter the output when shortcode is saved using custom links, for legacy support.
|
70 |
add_filter( 'clean_url', array( $this, 'display_shortcode' ), 1, 3 );
|
71 |
|
72 |
+
// filter the menu item before display in admin and in frontend.
|
73 |
add_filter( 'wp_setup_nav_menu_item', array( $this, 'setup_item' ), 10, 1 );
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
* Test shortcode. Output's WordPress.org URL.
|
78 |
+
*
|
79 |
* @since 1.2
|
80 |
* @access public
|
81 |
+
*
|
82 |
* @return string Returns WordPress.org URL.
|
83 |
*/
|
84 |
public function shortcode() {
|
88 |
/**
|
89 |
* Check if the passed content has any shortcode. Inspired from the
|
90 |
* core's has_shortcode.
|
91 |
+
*
|
92 |
* @since 2.0
|
93 |
* @access public
|
94 |
+
*
|
95 |
* @param string $content The content to check for shortcode.
|
96 |
+
*
|
97 |
* @return boolean Returns true if the $content has shortcode, false otherwise.
|
98 |
*/
|
99 |
public function has_shortcode( $content ) {
|
102 |
|
103 |
preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
|
104 |
|
105 |
+
if ( ! empty( $matches ) ) {
|
106 |
return true;
|
107 |
}
|
108 |
}
|
111 |
|
112 |
/**
|
113 |
* Modifies the menu item display on frontend.
|
114 |
+
*
|
115 |
* @since 2.0
|
116 |
+
*
|
117 |
* @param string $item_output The original html.
|
118 |
* @param object $item The menu item being displayed.
|
119 |
+
*
|
120 |
* @return string Modified menu item to display.
|
121 |
*/
|
122 |
public function start_el( $item_output, $item ) {
|
123 |
+
// if it isn't our custom object.
|
124 |
+
if ( 'gs_sim' !== $item->object ) {
|
125 |
|
126 |
+
// check the legacy hack.
|
127 |
+
if ( 'FULL HTML OUTPUT' === $item->post_title ) {
|
128 |
|
129 |
+
// then just process as we used to.
|
130 |
$item_output = do_shortcode( $item->url );
|
131 |
} else {
|
132 |
$item_output = do_shortcode( $item_output );
|
133 |
}
|
134 |
|
135 |
+
// if it is our object.
|
136 |
} else {
|
137 |
+
// just process it.
|
138 |
$item_output = do_shortcode( $item->description );
|
139 |
}
|
140 |
|
143 |
|
144 |
/**
|
145 |
* Allows shortcode to be processed and displayed.
|
146 |
+
*
|
147 |
* @since 1.0
|
148 |
+
*
|
149 |
+
* @param string $url The processed URL for displaying/saving.
|
150 |
+
* @param string $orig_url The URL that was submitted, retrieved.
|
151 |
+
* @param string $context Whether saving or displaying.
|
152 |
+
*
|
153 |
* @return string Output string after shortcode has been executed.
|
154 |
*/
|
155 |
public function display_shortcode( $url, $orig_url, $context ) {
|
156 |
+
if ( 'display' === $context && $this->has_shortcode( $orig_url ) ) {
|
157 |
return do_shortcode( $orig_url );
|
158 |
}
|
159 |
return $url;
|
161 |
|
162 |
/**
|
163 |
* Modify the menu item before display on Menu editor and in frontend.
|
164 |
+
*
|
165 |
* @since 2.0
|
166 |
* @access public
|
167 |
+
*
|
168 |
* @param object $item The menu item.
|
169 |
+
*
|
170 |
* @return object Modified menu item object.
|
171 |
*/
|
172 |
public function setup_item( $item ) {
|
173 |
+
if ( ! is_object( $item ) ) {
|
174 |
return $item;
|
175 |
}
|
176 |
|
177 |
+
// only if it is our object.
|
178 |
+
if ( 'gs_sim' === $item->object ) {
|
179 |
|
180 |
+
// setup our label.
|
181 |
$item->type_label = __( 'Shortcode' );
|
182 |
|
183 |
+
if ( ! empty( $item->post_content ) ) {
|
184 |
$item->description = $item->post_content;
|
185 |
} else {
|
186 |
|
187 |
+
// set up the description from the transient.
|
188 |
$item->description = get_transient( 'gs_sim_description_hack_' . $item->object_id );
|
189 |
|
190 |
+
// discard the transient.
|
191 |
delete_transient( 'gs_sim_description_hack_' . $item->object_id );
|
192 |
}
|
193 |
}
|
languages/shortcode-in-menus.pot
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
# Copyright (C) 2017 Gagan Deep Singh
|
2 |
-
# This file is distributed under the same license as the
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version:
|
6 |
"Report-Msgid-Bugs-To: "
|
7 |
"https://wordpress.org/support/plugin/shortcode-in-menus\n"
|
8 |
-
"POT-Creation-Date: 2017-
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=utf-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -15,30 +15,30 @@ msgstr ""
|
|
15 |
"Poedit: \n"
|
16 |
"X-Generator: grunt-wp-i18n1.0.0\n"
|
17 |
|
18 |
-
#: admin/class-shortcode-in-menus-admin.php:
|
19 |
-
#: includes/class-shortcode-in-menus.php:
|
20 |
msgid "Shortcode"
|
21 |
msgstr ""
|
22 |
|
23 |
-
#: admin/class-shortcode-in-menus-admin.php:
|
24 |
-
#: admin/class-shortcode-in-menus-admin.php:
|
25 |
msgid "Title"
|
26 |
msgstr ""
|
27 |
|
28 |
-
#: admin/class-shortcode-in-menus-admin.php:
|
29 |
msgid "Text/HTML/shortcode here!"
|
30 |
msgstr ""
|
31 |
|
32 |
-
#: admin/class-shortcode-in-menus-admin.php:
|
33 |
msgid "Add to Menu"
|
34 |
msgstr ""
|
35 |
|
36 |
-
#: includes/class-shortcode-in-menus.php:
|
37 |
msgid "https://wordpress.org"
|
38 |
msgstr ""
|
39 |
|
40 |
#. Plugin Name of the plugin/theme
|
41 |
-
msgid "
|
42 |
msgstr ""
|
43 |
|
44 |
#. Plugin URI of the plugin/theme
|
@@ -50,7 +50,7 @@ msgid "Allows you to add shortcodes in WordPress Navigation Menus"
|
|
50 |
msgstr ""
|
51 |
|
52 |
#. Author of the plugin/theme
|
53 |
-
msgid "Gagan Deep Singh
|
54 |
msgstr ""
|
55 |
|
56 |
#. Author URI of the plugin/theme
|
1 |
+
# Copyright (C) 2017 Gagan Deep Singh
|
2 |
+
# This file is distributed under the same license as the Shortcode in Menus package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Shortcode in Menus 3.3\n"
|
6 |
"Report-Msgid-Bugs-To: "
|
7 |
"https://wordpress.org/support/plugin/shortcode-in-menus\n"
|
8 |
+
"POT-Creation-Date: 2017-09-12 08:36:29+00:00\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=utf-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
15 |
"Poedit: \n"
|
16 |
"X-Generator: grunt-wp-i18n1.0.0\n"
|
17 |
|
18 |
+
#: admin/class-shortcode-in-menus-admin.php:89
|
19 |
+
#: includes/class-shortcode-in-menus.php:181
|
20 |
msgid "Shortcode"
|
21 |
msgstr ""
|
22 |
|
23 |
+
#: admin/class-shortcode-in-menus-admin.php:316
|
24 |
+
#: admin/class-shortcode-in-menus-admin.php:317
|
25 |
msgid "Title"
|
26 |
msgstr ""
|
27 |
|
28 |
+
#: admin/class-shortcode-in-menus-admin.php:321
|
29 |
msgid "Text/HTML/shortcode here!"
|
30 |
msgstr ""
|
31 |
|
32 |
+
#: admin/class-shortcode-in-menus-admin.php:326
|
33 |
msgid "Add to Menu"
|
34 |
msgstr ""
|
35 |
|
36 |
+
#: includes/class-shortcode-in-menus.php:85
|
37 |
msgid "https://wordpress.org"
|
38 |
msgstr ""
|
39 |
|
40 |
#. Plugin Name of the plugin/theme
|
41 |
+
msgid "Shortcode in Menus"
|
42 |
msgstr ""
|
43 |
|
44 |
#. Plugin URI of the plugin/theme
|
50 |
msgstr ""
|
51 |
|
52 |
#. Author of the plugin/theme
|
53 |
+
msgid "Gagan Deep Singh"
|
54 |
msgstr ""
|
55 |
|
56 |
#. Author URI of the plugin/theme
|
readme.txt
CHANGED
@@ -1,9 +1,10 @@
|
|
1 |
-
===
|
2 |
Contributors: gagan0123, saurabhshukla
|
|
|
3 |
Tags: Shortcode, Menus, Custom Link
|
4 |
Requires at least: 3.6
|
5 |
Tested up to: 4.8.1
|
6 |
-
Stable tag: 3.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -46,6 +47,11 @@ Also, see a [great tutorial](https://wordpress.org/support/topic/how-does-it-wor
|
|
46 |
|
47 |
== Changelog ==
|
48 |
|
|
|
|
|
|
|
|
|
|
|
49 |
= 3.3 =
|
50 |
* Fixed a compatibility issue with Twenty Fifteen theme.
|
51 |
* Minified JS.
|
1 |
+
=== Shortcode in Menus ===
|
2 |
Contributors: gagan0123, saurabhshukla
|
3 |
+
Donate Link: https://PayPal.me/gagan0123
|
4 |
Tags: Shortcode, Menus, Custom Link
|
5 |
Requires at least: 3.6
|
6 |
Tested up to: 4.8.1
|
7 |
+
Stable tag: 3.4
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
47 |
|
48 |
== Changelog ==
|
49 |
|
50 |
+
= 3.4 =
|
51 |
+
* Escaping of output within a lot of functions.
|
52 |
+
* Made the code WordPress PHPCS Compatible.
|
53 |
+
* Patch to make it work with Max Mega Menu plugin.
|
54 |
+
|
55 |
= 3.3 =
|
56 |
* Fixed a compatibility issue with Twenty Fifteen theme.
|
57 |
* Minified JS.
|
shortcode-in-menus.php
CHANGED
@@ -1,32 +1,34 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
-
* Plugin Name:
|
5 |
* Description: Allows you to add shortcodes in WordPress Navigation Menus
|
6 |
* Plugin URI: http://wordpress.org/plugins/shortcode-in-menus/
|
7 |
-
* Version: 3.
|
8 |
-
* Author: Gagan Deep Singh
|
9 |
* Author URI: https://gagan0123.com
|
10 |
* Text Domain: shortcode-in-menus
|
11 |
* Domain Path: /languages
|
|
|
|
|
12 |
*/
|
|
|
13 |
// If this file is called directly, abort.
|
14 |
-
if ( !defined( 'ABSPATH' ) ) {
|
15 |
exit;
|
16 |
}
|
17 |
|
18 |
-
if ( !defined( 'GS_SIM_PATH' ) ) {
|
19 |
/**
|
20 |
* Path to the plugin directory.
|
21 |
-
*
|
22 |
* @since 3.2
|
23 |
*/
|
24 |
define( 'GS_SIM_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
|
25 |
}
|
26 |
-
if ( !defined( 'GS_SIM_URL' ) ) {
|
27 |
/**
|
28 |
* URL to the plugin directory.
|
29 |
-
*
|
30 |
* @since 3.2
|
31 |
*/
|
32 |
define( 'GS_SIM_URL', trailingslashit( plugins_url( '', __FILE__ ) ) );
|
@@ -45,4 +47,4 @@ if ( is_admin() ) {
|
|
45 |
Shortcode_In_Menus_Admin::get_instance();
|
46 |
} else {
|
47 |
Shortcode_In_Menus::get_instance();
|
48 |
-
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
+
* Plugin Name: Shortcode in Menus
|
4 |
* Description: Allows you to add shortcodes in WordPress Navigation Menus
|
5 |
* Plugin URI: http://wordpress.org/plugins/shortcode-in-menus/
|
6 |
+
* Version: 3.4
|
7 |
+
* Author: Gagan Deep Singh
|
8 |
* Author URI: https://gagan0123.com
|
9 |
* Text Domain: shortcode-in-menus
|
10 |
* Domain Path: /languages
|
11 |
+
*
|
12 |
+
* @package Shortcode_In_Menus
|
13 |
*/
|
14 |
+
|
15 |
// If this file is called directly, abort.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
exit;
|
18 |
}
|
19 |
|
20 |
+
if ( ! defined( 'GS_SIM_PATH' ) ) {
|
21 |
/**
|
22 |
* Path to the plugin directory.
|
23 |
+
*
|
24 |
* @since 3.2
|
25 |
*/
|
26 |
define( 'GS_SIM_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
|
27 |
}
|
28 |
+
if ( ! defined( 'GS_SIM_URL' ) ) {
|
29 |
/**
|
30 |
* URL to the plugin directory.
|
31 |
+
*
|
32 |
* @since 3.2
|
33 |
*/
|
34 |
define( 'GS_SIM_URL', trailingslashit( plugins_url( '', __FILE__ ) ) );
|
47 |
Shortcode_In_Menus_Admin::get_instance();
|
48 |
} else {
|
49 |
Shortcode_In_Menus::get_instance();
|
50 |
+
}
|