Shortcode in Menus - Version 0.1

Version Description

Download this release

Release Info

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

Version 0.1

Files changed (2) hide show
  1. index.php +40 -0
  2. readme.txt +24 -0
index.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: 0.1
7
+ Author URI: http://gagan.pro
8
+ Author: Gagan0123
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
12
+
13
+ /**
14
+ * Allows shortcode to be saved in database
15
+ */
16
+ function gs_allow_saving_shortcode_custom_links( $url, $orig_url, $context ){
17
+ if($context=='db'){
18
+ return $orig_url;
19
+ }
20
+ return $url;
21
+ }
22
+
23
+ function gs_sw_security_check(){
24
+ if(current_user_can('activate_plugins')){
25
+ //Conditionally adding the function for database context for
26
+ add_filter( 'clean_url', 'gs_allow_saving_shortcode_custom_links', 99, 3 );
27
+ }
28
+ }
29
+ add_action('wp_loaded','gs_sw_security_check');
30
+
31
+ /**
32
+ * Allows shortcode to be processed and displayed
33
+ */
34
+ function gs_allow_display_shortcode_custom_links( $url, $orig_url, $context ){
35
+ if( $context=='display' ){
36
+ return do_shortcode($orig_url);
37
+ }
38
+ return $url;
39
+ }
40
+ add_filter( 'clean_url', 'gs_allow_display_shortcode_custom_links', 1, 3 );
readme.txt ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Shortcodes in Menus ===
2
+ Contributors: Gagan0123
3
+ Tags: Shortcode, Menus, Custom Link
4
+ Requires at least: 3.5
5
+ Tested up to: 3.6.1
6
+ Stable tag: 0.1
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ Allows you to add shortcodes in WordPress Navigation Menus
11
+
12
+ == Description ==
13
+
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 shortcodes in the custom links of the menus
22
+
23
+ == Changelog ==
24
+ 0.1 Initial plugin