current_shortcode() detect currently used shortcode. I made my catch all handler accept a third argument, which is the shortcode name:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /** * Handler for all shortcodes. * * @param array $args * @param NULL $content Not used. * @param string $shortcode Name of the current shortcode. * @return string */ public function shortcode_handler( $args = array (), $content = NULL, $shortcode = '' ) { $key = $this->current_shortcode_key( $shortcode ); $args['print'] = FALSE; return $this->action_handler( $key, $args ); } /** * Returns the currently used shortcode. Sometimes. * * @return string */ protected function current_shortcode_key( $shortcode ) { return substr( $shortcode, 7 ); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.