[Plugin: Post Snippets] Add support for exisiting shortcodes
-
Great plugin.
I would love to see this implemented in the next release — it is such a small code change but it would help those how want to run their own shortcodes.
For example I have an email shortcode that is setup like this:
[email mailbox="name" url="domain" subject="subject" display_text="click me!"]
My own shortcode needs to run in order to obfuscate the input. So If I leave the Snippet Description empty it should run MY OWN shortcode rather than the Post Snippet Plugin.
So therefore this function should change as so:
/** * Create the functions for shortcodes dynamically and register them * */ function create_shortcodes() { $snippets = get_option($this->plugin_options); if (!empty($snippets)) { for ($i=0; $i < count($snippets); $i++) { if ($snippets[$i]['shortcode'] == true) { if( $snippets[$i]['snippet'] == '') continue; // no description so therefore don't do anything, grab the next shortcode and process. $vars = explode(",",$snippets[$i]['vars']); $vars_str = ''; for ($j=0; $j < count($vars); $j++) { $vars_str = $vars_str . '"'.$vars[$j].'" => "",'; } add_shortcode($snippets[$i]['title'], create_function('$atts', '$shortcode_symbols = array('.$vars_str.'); extract(shortcode_atts($shortcode_symbols, $atts)); $newArr = compact( array_keys($shortcode_symbols) ); $snippet = "'. addslashes($snippets[$i]["snippet"]) .'"; $snippet = str_replace("&", "&", $snippet); foreach ($newArr as $key => $val) { $snippet = str_replace("{".$key."}", $val, $snippet); } return stripslashes($snippet);') ); } } } }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘[Plugin: Post Snippets] Add support for exisiting shortcodes’ is closed to new replies.