Version Description
- Change plugin constants to follow naming conventions as recommended by WordPress Guidelines.
- Strict input filters for admin pages, for user input values.
- Adhere to more strict PHPCS ruleset.
Download this release
Release Info
Developer | gagan0123 |
Plugin | Shortcode in Menus |
Version | 3.5.1 |
Comparing to | |
See all releases |
Code changes from version 3.5 to 3.5.1
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',
|
110 |
}
|
111 |
|
112 |
/**
|
@@ -120,13 +120,14 @@ if ( ! class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In
|
|
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 |
|
128 |
-
// Get the menu item.
|
129 |
-
|
|
|
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'] );
|
@@ -176,7 +177,9 @@ if ( ! class_exists( 'Shortcode_In_Menus_Admin' ) && class_exists( 'Shortcode_In
|
|
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 |
-
|
|
|
|
|
180 |
foreach ( $menu_item as $menu_item_data ) {
|
181 |
if (
|
182 |
! empty( $menu_item_data['menu-item-type'] ) &&
|
@@ -220,8 +223,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 ) ) {
|
106 |
return;
|
107 |
}
|
108 |
|
109 |
+
wp_enqueue_script( 'gs-sim-admin', SHORTCODE_IN_MENUS_URL . 'admin/js/shortcode-in-menus.min.js', array( 'nav-menu' ), SHORTCODE_IN_MENUS_RES, true );
|
110 |
}
|
111 |
|
112 |
/**
|
120 |
*/
|
121 |
public function description_hack() {
|
122 |
// Verify the nonce.
|
123 |
+
$nonce = filter_input( INPUT_POST, 'description-nonce', FILTER_SANITIZE_STRING );
|
124 |
if ( ! wp_verify_nonce( $nonce, 'gs-sim-description-nonce' ) ) {
|
125 |
wp_die();
|
126 |
}
|
127 |
|
128 |
+
// Get the menu item. We need this unfiltered, so using FILTER_UNSAFE_RAW.
|
129 |
+
// phpcs:ignore WordPressVIPMinimum.Security.PHPFilterFunctions.RestrictedFilter
|
130 |
+
$item = filter_input( INPUT_POST, 'menu-item', FILTER_UNSAFE_RAW, FILTER_REQUIRE_ARRAY );
|
131 |
|
132 |
// Save the description in a transient. This is what we'll use in setup_item().
|
133 |
set_transient( 'gs_sim_description_hack_' . $item['menu-item-object-id'], $item['menu-item-description'] );
|
177 |
// For performance reasons, we omit some object properties from the checklist.
|
178 |
// The following is a hacky way to restore them when adding non-custom items.
|
179 |
$menu_items_data = array();
|
180 |
+
// Get the menu item. We need this unfiltered, so using FILTER_UNSAFE_RAW.
|
181 |
+
// phpcs:ignore WordPressVIPMinimum.Security.PHPFilterFunctions.RestrictedFilter
|
182 |
+
$menu_item = filter_input( INPUT_POST, 'menu-item', FILTER_UNSAFE_RAW, FILTER_REQUIRE_ARRAY );
|
183 |
foreach ( $menu_item as $menu_item_data ) {
|
184 |
if (
|
185 |
! empty( $menu_item_data['menu-item-type'] ) &&
|
223 |
}
|
224 |
}
|
225 |
|
226 |
+
$menu = filter_input( INPUT_POST, 'menu', FILTER_SANITIZE_NUMBER_INT );
|
227 |
/** This filter is documented in wp-admin/includes/nav-menu.php */
|
228 |
+
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
|
229 |
$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu );
|
230 |
|
231 |
if ( ! class_exists( $walker_class_name ) ) {
|
admin/js/shortcode-in-menus.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
jQuery("document").ready(function(){function
|
2 |
//# sourceMappingURL=shortcode-in-menus.min.js.map
|
1 |
+
jQuery("document").ready(function(){jQuery("#submit-gs-sim").on("click",function(e){wpNavMenu.registerChange(),function(){description=jQuery("#gs-sim-html").val(),menuItems={},processMethod=wpNavMenu.addMenuItemToBottom;var t=jQuery(".gs-sim-div");t.find(".spinner").show(),re=/menu-item\[([^\]]*)/,m=t.find(".menu-item-db-id"),listItemDBIDMatch=re.exec(m.attr("name")),listItemDBID=void 0===listItemDBIDMatch[1]?0:parseInt(listItemDBIDMatch[1],10),menuItems[listItemDBID]=t.getItemData("add-menu-item",listItemDBID),menuItems[listItemDBID]["menu-item-description"]=description,""===menuItems[listItemDBID]["menu-item-title"]&&(menuItems[listItemDBID]["menu-item-title"]="(Untitled)");nonce=jQuery("#gs-sim-description-nonce").val(),params={action:"gs_sim_description_hack","description-nonce":nonce,"menu-item":menuItems[listItemDBID]},jQuery.post(ajaxurl,params,function(e){jQuery("#gs-sim-div .menu-item-object-id").val(e),wpNavMenu.addItemToMenu(menuItems,processMethod,function(){t.find(".spinner").hide(),jQuery("#gs-sim-title").val("").blur(),jQuery("#gs-sim-html").val("")})})}()})});
|
2 |
//# sourceMappingURL=shortcode-in-menus.min.js.map
|
admin/js/shortcode-in-menus.min.js.map
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"version":3,"sources":["shortcode-in-menus.js"],"names":["jQuery","ready","
|
1 |
+
{"version":3,"sources":["shortcode-in-menus.js"],"names":["jQuery","ready","on","e","wpNavMenu","registerChange","description","val","menuItems","processMethod","addMenuItemToBottom","t","find","show","re","m","listItemDBIDMatch","exec","attr","listItemDBID","parseInt","getItemData","nonce","params","action","description-nonce","menu-item","post","ajaxurl","objectId","addItemToMenu","hide","blur","gsSimAddWidgettoMenu"],"mappings":"AAAAA,OAAQ,YAAaC,MAAO,WAE3BD,OAAQ,kBAAmBE,GAAI,QAAS,SAAWC,GAElDC,UAAUC,iBAWX,WAGCC,YAAcN,OAAQ,gBAAiBO,MAGvCC,UAAY,GAGZC,cAAgBL,UAAUM,oBAE1B,IAAIC,EAAIX,OAAQ,eAGhBW,EAAEC,KAAM,YAAaC,OAGrBC,GAAK,sBAELC,EAAIJ,EAAEC,KAAM,oBAEZI,kBAAoBF,GAAGG,KAAMF,EAAEG,KAAM,SACpCC,kBAAe,IAAsBH,kBAAkB,GAAK,EAAII,SAAUJ,kBAAkB,GAAI,IAGjGR,UAAUW,cAAgBR,EAAEU,YAAa,gBAAiBF,cAC1DX,UAAUW,cAAc,yBAA2Bb,YAEC,KAA/CE,UAAUW,cAAc,qBAC5BX,UAAUW,cAAc,mBAAqB,cAI9CG,MAAQtB,OAAQ,6BAA8BO,MAG9CgB,OAAS,CACRC,OAAU,0BACVC,oBAAqBH,MACrBI,YAAalB,UAAUW,eAIxBnB,OAAO2B,KAAMC,QAASL,OAAQ,SAAWM,GAGxC7B,OAAQ,oCAAqCO,IAAKsB,GAGlDzB,UAAU0B,cAAetB,UAAWC,cAAe,WAElDE,EAAEC,KAAM,YAAamB,OAErB/B,OAAQ,iBAAkBO,IAAK,IAAKyB,OACpChC,OAAQ,gBAAiBO,IAAK,QA9DhC0B","file":"shortcode-in-menus.min.js"}
|
languages/shortcode-in-menus.pot
CHANGED
@@ -1,35 +1,35 @@
|
|
1 |
-
# Copyright (C)
|
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.
|
6 |
"Report-Msgid-Bugs-To: "
|
7 |
"https://wordpress.org/support/plugin/shortcode-in-menus\n"
|
8 |
-
"POT-Creation-Date:
|
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:
|
13 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
15 |
"Poedit: \n"
|
16 |
-
"X-Generator: grunt-wp-
|
17 |
|
18 |
#: admin/class-shortcode-in-menus-admin.php:89
|
19 |
#: includes/class-shortcode-in-menus.php:186
|
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 |
|
1 |
+
# Copyright (C) 2021 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.5\n"
|
6 |
"Report-Msgid-Bugs-To: "
|
7 |
"https://wordpress.org/support/plugin/shortcode-in-menus\n"
|
8 |
+
"POT-Creation-Date: 2021-01-03 14:24:28+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: 2021-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-i18n 1.0.3\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 |
|
23 |
+
#: admin/class-shortcode-in-menus-admin.php:320
|
24 |
+
#: admin/class-shortcode-in-menus-admin.php:321
|
25 |
msgid "Title"
|
26 |
msgstr ""
|
27 |
|
28 |
+
#: admin/class-shortcode-in-menus-admin.php:325
|
29 |
msgid "Text/HTML/shortcode here!"
|
30 |
msgstr ""
|
31 |
|
32 |
+
#: admin/class-shortcode-in-menus-admin.php:330
|
33 |
msgid "Add to Menu"
|
34 |
msgstr ""
|
35 |
|
readme.txt
CHANGED
@@ -4,8 +4,8 @@ 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.
|
8 |
-
Stable tag: 3.5
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -48,8 +48,35 @@ Also, see a [great tutorial](https://wordpress.org/support/topic/how-does-it-wor
|
|
48 |
1. To test this, you can add a custom link with a ShortCode [gs_test_shortcode] as link, if it points to https://wordpress.org, plugin is working
|
49 |
1. If you want to use a ShortCode that outputs not just the url, but complete HTML sections, please make use of the title 'FULL HTML OUTPUT' for that link and it will output the complete HTML without breaking your site.
|
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.
|
4 |
Tags: Shortcode, Menus, Custom Link
|
5 |
Requires at least: 3.6
|
6 |
Requires PHP: 5.6
|
7 |
+
Tested up to: 5.9
|
8 |
+
Stable tag: 3.5.1
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
48 |
1. To test this, you can add a custom link with a ShortCode [gs_test_shortcode] as link, if it points to https://wordpress.org, plugin is working
|
49 |
1. If you want to use a ShortCode that outputs not just the url, but complete HTML sections, please make use of the title 'FULL HTML OUTPUT' for that link and it will output the complete HTML without breaking your site.
|
50 |
|
51 |
+
== Frequently Asked Questions ==
|
52 |
+
|
53 |
+
= How to enter shortcode =
|
54 |
+
|
55 |
+
You can add enter shortcodes in the "Custom Link" menu item, or you can use "Shortcode" menu shortcodes in menus.
|
56 |
+
|
57 |
+
Screencast for using WordPress' default "Custom Links" menu item:
|
58 |
+
|
59 |
+
https://www.youtube.com/watch?v=NIu-e9XjEXM
|
60 |
+
|
61 |
+
Screencast for using "Shortcode" menu item:
|
62 |
+
|
63 |
+
https://www.youtube.com/watch?v=a7oZq1fgDO4
|
64 |
+
|
65 |
+
= How to view/edit "Shortcode" menu item =
|
66 |
+
|
67 |
+
You will need to enable displaying of "Description" in order to view/edit "Shortcode" menu item.
|
68 |
+
|
69 |
+
Here's a screencast for the same:
|
70 |
+
|
71 |
+
https://www.youtube.com/watch?v=IzaUf5KHehg
|
72 |
+
|
73 |
== Changelog ==
|
74 |
|
75 |
+
= 3.5.1 =
|
76 |
+
* Change plugin constants to follow naming conventions as recommended by WordPress Guidelines.
|
77 |
+
* Strict input filters for admin pages, for user input values.
|
78 |
+
* Adhere to more strict PHPCS ruleset.
|
79 |
+
|
80 |
= 3.5 =
|
81 |
* Resolved some WPCS compatibility issues.
|
82 |
* Added resource version for static resources for busting cache in new releases.
|
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.5
|
7 |
* Author: Gagan Deep Singh
|
8 |
* Author URI: https://gagan0123.com
|
9 |
* Text Domain: shortcode-in-menus
|
@@ -17,40 +17,40 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
17 |
exit;
|
18 |
}
|
19 |
|
20 |
-
if ( ! defined( '
|
21 |
/**
|
22 |
* Path to the plugin directory.
|
23 |
*
|
24 |
* @since 3.2
|
25 |
*/
|
26 |
-
define( '
|
27 |
}
|
28 |
-
if ( ! defined( '
|
29 |
/**
|
30 |
* URL to the plugin directory.
|
31 |
*
|
32 |
* @since 3.2
|
33 |
*/
|
34 |
-
define( '
|
35 |
}
|
36 |
-
if ( ! defined( '
|
37 |
/**
|
38 |
* Resource version for busting cache.
|
39 |
*
|
40 |
* @since 3.5
|
41 |
*/
|
42 |
-
define( '
|
43 |
}
|
44 |
/**
|
45 |
* The core plugin class
|
46 |
*/
|
47 |
-
require_once
|
48 |
|
49 |
/**
|
50 |
* Load the admin class if its the admin dashboard
|
51 |
*/
|
52 |
if ( is_admin() ) {
|
53 |
-
require_once
|
54 |
Shortcode_In_Menus_Admin::get_instance();
|
55 |
} else {
|
56 |
Shortcode_In_Menus::get_instance();
|
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.1
|
7 |
* Author: Gagan Deep Singh
|
8 |
* Author URI: https://gagan0123.com
|
9 |
* Text Domain: shortcode-in-menus
|
17 |
exit;
|
18 |
}
|
19 |
|
20 |
+
if ( ! defined( 'SHORTCODE_IN_MENUS_PATH' ) ) {
|
21 |
/**
|
22 |
* Path to the plugin directory.
|
23 |
*
|
24 |
* @since 3.2
|
25 |
*/
|
26 |
+
define( 'SHORTCODE_IN_MENUS_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
|
27 |
}
|
28 |
+
if ( ! defined( 'SHORTCODE_IN_MENUS_URL' ) ) {
|
29 |
/**
|
30 |
* URL to the plugin directory.
|
31 |
*
|
32 |
* @since 3.2
|
33 |
*/
|
34 |
+
define( 'SHORTCODE_IN_MENUS_URL', trailingslashit( plugins_url( '', __FILE__ ) ) );
|
35 |
}
|
36 |
+
if ( ! defined( 'SHORTCODE_IN_MENUS_RES' ) ) {
|
37 |
/**
|
38 |
* Resource version for busting cache.
|
39 |
*
|
40 |
* @since 3.5
|
41 |
*/
|
42 |
+
define( 'SHORTCODE_IN_MENUS_RES', 1.0 );
|
43 |
}
|
44 |
/**
|
45 |
* The core plugin class
|
46 |
*/
|
47 |
+
require_once SHORTCODE_IN_MENUS_PATH . 'includes/class-shortcode-in-menus.php';
|
48 |
|
49 |
/**
|
50 |
* Load the admin class if its the admin dashboard
|
51 |
*/
|
52 |
if ( is_admin() ) {
|
53 |
+
require_once SHORTCODE_IN_MENUS_PATH . 'admin/class-shortcode-in-menus-admin.php';
|
54 |
Shortcode_In_Menus_Admin::get_instance();
|
55 |
} else {
|
56 |
Shortcode_In_Menus::get_instance();
|