Shortcode in Menus - Version 3.5

Version Description

  • Resolved some WPCS compatibility issues.
  • Added resource version for static resources for busting cache in new releases.
  • Added text domain to localisable text strings.
  • Loading the custom JS in footer instead of header for performance benefit.
  • Handle PHP notice in custom cases when start_el is not passed with $item object.
Download this release

Release Info

Developer gagan0123
Plugin Icon 128x128 Shortcode in Menus
Version 3.5
Comparing to
See all releases

Code changes from version 3.4 to 3.5

admin/class-shortcode-in-menus-admin.php CHANGED
@@ -106,7 +106,7 @@ if ( ! class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In
106
  return;
107
  }
108
 
109
- wp_enqueue_script( 'gs-sim-admin', GS_SIM_URL . 'admin/js/shortcode-in-menus.min.js', array( 'nav-menu' ) );
110
  }
111
 
112
  /**
@@ -220,9 +220,9 @@ if ( ! class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In
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 );
@@ -230,11 +230,11 @@ if ( ! class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In
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
  }
@@ -279,7 +279,7 @@ if ( ! class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In
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 );
@@ -303,8 +303,8 @@ if ( ! class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In
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" />
106
  return;
107
  }
108
 
109
+ wp_enqueue_script( 'gs-sim-admin', GS_SIM_URL . 'admin/js/shortcode-in-menus.min.js', array( 'nav-menu' ), GS_SIM_RES, true );
110
  }
111
 
112
  /**
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 );
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
  }
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 );
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" />
includes/class-shortcode-in-menus.php CHANGED
@@ -120,11 +120,16 @@ if ( ! class_exists( 'Shortcode_In_Menus' ) ) {
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 );
@@ -133,7 +138,7 @@ if ( ! class_exists( 'Shortcode_In_Menus' ) ) {
133
  }
134
 
135
  // if it is our object.
136
- } else {
137
  // just process it.
138
  $item_output = do_shortcode( $item->description );
139
  }
@@ -178,7 +183,7 @@ if ( ! class_exists( 'Shortcode_In_Menus' ) ) {
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;
120
  * @return string Modified menu item to display.
121
  */
122
  public function start_el( $item_output, $item ) {
123
+ // Rare case when $item is not an object, usually with custom themes.
124
+ if ( ! is_object( $item ) || ! isset( $item->object ) ) {
125
+ return $item_output;
126
+ }
127
+
128
  // if it isn't our custom object.
129
  if ( 'gs_sim' !== $item->object ) {
130
 
131
  // check the legacy hack.
132
+ if ( isset( $item->post_title ) && 'FULL HTML OUTPUT' === $item->post_title ) {
133
 
134
  // then just process as we used to.
135
  $item_output = do_shortcode( $item->url );
138
  }
139
 
140
  // if it is our object.
141
+ } elseif ( isset( $item->description ) ) {
142
  // just process it.
143
  $item_output = do_shortcode( $item->description );
144
  }
183
  if ( 'gs_sim' === $item->object ) {
184
 
185
  // setup our label.
186
+ $item->type_label = __( 'Shortcode', 'shortcode-in-menus' );
187
 
188
  if ( ! empty( $item->post_content ) ) {
189
  $item->description = $item->post_content;
languages/shortcode-in-menus.pot CHANGED
@@ -1,22 +1,22 @@
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"
12
- "PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\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
 
1
+ # Copyright (C) 2019 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.4\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://wordpress.org/support/plugin/shortcode-in-menus\n"
8
+ "POT-Creation-Date: 2019-02-21 17:26:38+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "PO-Revision-Date: 2019-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\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:186
20
  msgid "Shortcode"
21
  msgstr ""
22
 
readme.txt CHANGED
@@ -3,8 +3,9 @@ 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
 
@@ -25,6 +26,8 @@ Also, see a [great tutorial](https://wordpress.org/support/topic/how-does-it-wor
25
 
26
  * [Aurovrata Venet](https://wordpress.org/support/profile/aurovrata) for [this great tutorial](https://wordpress.org/support/topic/how-does-it-work-24/page/2/#post-4987738).
27
  * [Lee Willis](https://wordpress.org/support/profile/leewillis77) for finding out and helping in resolving [this bug](https://wordpress.org/support/topic/causes-urls-to-be-amended-in-undesired-ways).
 
 
28
 
29
  == Screenshots ==
30
 
@@ -47,6 +50,13 @@ Also, see a [great tutorial](https://wordpress.org/support/topic/how-does-it-wor
47
 
48
  == Changelog ==
49
 
 
 
 
 
 
 
 
50
  = 3.4 =
51
  * Escaping of output within a lot of functions.
52
  * Made the code WordPress PHPCS Compatible.
@@ -94,4 +104,4 @@ Also, see a [great tutorial](https://wordpress.org/support/topic/how-does-it-wor
94
  * Added prefix to function which was conflicting with another plugin.
95
 
96
  = 0.1 =
97
- * Initial Plugin uploaded.
3
  Donate Link: https://PayPal.me/gagan0123
4
  Tags: Shortcode, Menus, Custom Link
5
  Requires at least: 3.6
6
+ Requires PHP: 5.6
7
+ Tested up to: 5.1
8
+ Stable tag: 3.5
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
26
 
27
  * [Aurovrata Venet](https://wordpress.org/support/profile/aurovrata) for [this great tutorial](https://wordpress.org/support/topic/how-does-it-work-24/page/2/#post-4987738).
28
  * [Lee Willis](https://wordpress.org/support/profile/leewillis77) for finding out and helping in resolving [this bug](https://wordpress.org/support/topic/causes-urls-to-be-amended-in-undesired-ways).
29
+ * [Dennis Hunink](https://wordpress.org/support/users/dhunink/) for reporting [this bug](https://wordpress.org/support/?p=10325305).
30
+ * [@hbwarper](https://wordpress.org/support/users/hbwarper/) for providing a patch to Dennis' issue.
31
 
32
  == Screenshots ==
33
 
50
 
51
  == Changelog ==
52
 
53
+ = 3.5 =
54
+ * Resolved some WPCS compatibility issues.
55
+ * Added resource version for static resources for busting cache in new releases.
56
+ * Added text domain to localisable text strings.
57
+ * Loading the custom JS in footer instead of header for performance benefit.
58
+ * Handle PHP notice in custom cases when start_el is not passed with $item object.
59
+
60
  = 3.4 =
61
  * Escaping of output within a lot of functions.
62
  * Made the code WordPress PHPCS Compatible.
104
  * Added prefix to function which was conflicting with another plugin.
105
 
106
  = 0.1 =
107
+ * Initial Plugin uploaded.
shortcode-in-menus.php CHANGED
@@ -3,7 +3,7 @@
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
@@ -33,7 +33,14 @@ if ( ! defined( 'GS_SIM_URL' ) ) {
33
  */
34
  define( 'GS_SIM_URL', trailingslashit( plugins_url( '', __FILE__ ) ) );
35
  }
36
-
 
 
 
 
 
 
 
37
  /**
38
  * The core plugin class
39
  */
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.5
7
  * Author: Gagan Deep Singh
8
  * Author URI: https://gagan0123.com
9
  * Text Domain: shortcode-in-menus
33
  */
34
  define( 'GS_SIM_URL', trailingslashit( plugins_url( '', __FILE__ ) ) );
35
  }
36
+ if ( ! defined( 'GS_SIM_RES' ) ) {
37
+ /**
38
+ * Resource version for busting cache.
39
+ *
40
+ * @since 3.5
41
+ */
42
+ define( 'GS_SIM_RES', 1.0 );
43
+ }
44
  /**
45
  * The core plugin class
46
  */