Version Description
- Added ability to echo complete HTML output instead of just URL by using ShortCode
Download this release
Release Info
Developer | gagan0123 |
Plugin | Shortcode in Menus |
Version | 1.2 |
Comparing to | |
See all releases |
Code changes from version 1.1 to 1.2
- index.php +51 -19
- readme.txt +11 -2
index.php
CHANGED
@@ -1,40 +1,72 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
Plugin Name: Shortcodes 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: 1.
|
7 |
Author URI: http://gagan.pro
|
8 |
Author: Gagan Deep Singh
|
9 |
*/
|
10 |
|
11 |
-
if (
|
|
|
12 |
|
13 |
/**
|
14 |
* Allows shortcode to be saved in database
|
15 |
*/
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
21 |
}
|
22 |
|
23 |
-
function gs_sim_security_check(){
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
}
|
29 |
-
|
|
|
30 |
|
31 |
/**
|
32 |
* Allows shortcode to be processed and displayed
|
33 |
*/
|
34 |
-
function gs_sim_allow_display_shortcode_custom_links(
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
}
|
40 |
-
add_filter(
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
Plugin Name: Shortcodes in Menus
|
5 |
Description: Allows you to add shortcodes in WordPress Navigation Menus
|
6 |
Plugin URI: http://wordpress.org/plugins/shortcode-in-menus/
|
7 |
+
Version: 1.2
|
8 |
Author URI: http://gagan.pro
|
9 |
Author: Gagan Deep Singh
|
10 |
*/
|
11 |
|
12 |
+
if (!defined('ABSPATH'))
|
13 |
+
exit; // Exit if accessed directly
|
14 |
|
15 |
/**
|
16 |
* Allows shortcode to be saved in database
|
17 |
*/
|
18 |
+
|
19 |
+
function gs_sim_allow_saving_shortcode_custom_links($url, $orig_url, $context) {
|
20 |
+
if ($context == 'db') {
|
21 |
+
return $orig_url;
|
22 |
+
}
|
23 |
+
return $url;
|
24 |
}
|
25 |
|
26 |
+
function gs_sim_security_check() {
|
27 |
+
if (current_user_can('activate_plugins')) {
|
28 |
+
//Conditionally adding the function for database context for
|
29 |
+
add_filter('clean_url', 'gs_sim_allow_saving_shortcode_custom_links', 99, 3);
|
30 |
+
}
|
31 |
}
|
32 |
+
|
33 |
+
add_action('wp_loaded', 'gs_sim_security_check');
|
34 |
|
35 |
/**
|
36 |
* Allows shortcode to be processed and displayed
|
37 |
*/
|
38 |
+
function gs_sim_allow_display_shortcode_custom_links($url, $orig_url, $context) {
|
39 |
+
if ($context == 'display') {
|
40 |
+
return do_shortcode($orig_url);
|
41 |
+
}
|
42 |
+
return $url;
|
43 |
+
}
|
44 |
+
|
45 |
+
add_filter('clean_url', 'gs_sim_allow_display_shortcode_custom_links', 1, 3);
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Adding a test shortcode for testing this plugin
|
49 |
+
* */
|
50 |
+
add_shortcode('gs_test_shortcode', 'gs_sim_test_shortcode');
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Returns "Hello World" for testing the shortcode
|
54 |
+
*/
|
55 |
+
function gs_sim_test_shortcode($data) {
|
56 |
+
return "http://gagan.pro";
|
57 |
+
}
|
58 |
+
|
59 |
+
if (!function_exists('gs_sim_menu_item')) {
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Allows adding of full HTML supported shortcodes instead of just URL's
|
63 |
+
*/
|
64 |
+
function gs_sim_menu_item($item_output, $item) {
|
65 |
+
if ($item->post_title == 'FULL HTML OUTPUT') {
|
66 |
+
$item_output = do_shortcode($item->url);
|
67 |
+
}
|
68 |
+
return $item_output;
|
69 |
+
}
|
70 |
+
|
71 |
}
|
72 |
+
add_filter('walker_nav_menu_start_el', 'gs_sim_menu_item', 10, 2);
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: gagan0123
|
|
3 |
Tags: Shortcode, Menus, Custom Link
|
4 |
Requires at least: 3.5
|
5 |
Tested up to: 4.0
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -14,11 +14,17 @@ Allows you to add shortcodes in WordPress Navigation Menus
|
|
14 |
Allows you to add shortcodes in WordPress Navigation Menus so that you can
|
15 |
generate the links dynamically.
|
16 |
|
|
|
|
|
|
|
|
|
17 |
== Installation ==
|
18 |
|
19 |
1. Add the plugin's folder in the WordPress' plugin directory.
|
20 |
1. Activate the plugin.
|
21 |
-
1. You can now add
|
|
|
|
|
22 |
|
23 |
== Changelog ==
|
24 |
|
@@ -30,3 +36,6 @@ generate the links dynamically.
|
|
30 |
|
31 |
= 1.1 =
|
32 |
* Tested with WordPress 4.0
|
|
|
|
|
|
3 |
Tags: Shortcode, Menus, Custom Link
|
4 |
Requires at least: 3.5
|
5 |
Tested up to: 4.0
|
6 |
+
Stable tag: 1.2
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
14 |
Allows you to add shortcodes in WordPress Navigation Menus so that you can
|
15 |
generate the links dynamically.
|
16 |
|
17 |
+
To test this, you can add a custom link with a ShortCode [gs_test_shortcode] as link URL, if it points to http://gagan.pro, plugin is working, if not(even any other ShortCode), then please write a new support ticket with ticket with the ShortCode you used and from which plugin/function that ShortCode is from, so that I'll be able to help you better.
|
18 |
+
|
19 |
+
PLEASE NOTE: If you want to use a ShortCode that outputs not just the URL, but complete HTML sections, put "FULL HTML OUTPUT" in the "Link Text" option for that link and it will output the complete HTML without breaking your site.
|
20 |
+
|
21 |
== Installation ==
|
22 |
|
23 |
1. Add the plugin's folder in the WordPress' plugin directory.
|
24 |
1. Activate the plugin.
|
25 |
+
1. You can now add ShortCodes in the custom links of the menus.
|
26 |
+
1. To test this, you can add a custom link with a ShortCode [gs_test_shortcode] as link, if it points to http://gagan.pro, plugin is working
|
27 |
+
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.
|
28 |
|
29 |
== Changelog ==
|
30 |
|
36 |
|
37 |
= 1.1 =
|
38 |
* Tested with WordPress 4.0
|
39 |
+
|
40 |
+
= 1.2 =
|
41 |
+
* Added ability to echo complete HTML output instead of just URL by using ShortCode
|