do_shortcode_tag

Regular Expression callable for do_shortcode() for calling shortcode hook.

Description

(string|false) do_shortcode_tag( (array) $m ); 

Returns (string|false)

False on failure.

Parameters (1)

0. $m (array)
Regular expression match array

Usage

  1. if ( !function_exists( 'do_shortcode_tag' ) ) { 
  2. require_once ABSPATH . WPINC . '/shortcodes.php'; 
  3.  
  4. // Regular expression match array 
  5. $m = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = do_shortcode_tag($m); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/shortcodes.php  
  1. function do_shortcode_tag( $m ) { 
  2. global $shortcode_tags; 
  3.  
  4. // allow [[foo]] syntax for escaping a tag 
  5. if ( $m[1] == '[' && $m[6] == ']' ) { 
  6. return substr($m[0], 1, -1); 
  7.  
  8. $tag = $m[2]; 
  9. $attr = shortcode_parse_atts( $m[3] ); 
  10.  
  11. if ( ! is_callable( $shortcode_tags[ $tag ] ) ) { 
  12. /** translators: %s: shortcode tag */ 
  13. $message = sprintf( __( 'Attempting to parse a shortcode without a valid callback: %s' ), $tag ); 
  14. _doing_it_wrong( __FUNCTION__, $message, '4.3.0' ); 
  15. return $m[0]; 
  16.  
  17. /** 
  18. * Filters whether to call a shortcode callback. 
  19. * Passing a truthy value to the filter will effectively short-circuit the 
  20. * shortcode generation process, returning that value instead. 
  21. * @since 4.7.0 
  22. * @param bool|string $return Short-circuit return value. Either false or the value to replace the shortcode with. 
  23. * @param string $tag Shortcode name. 
  24. * @param array $attr Shortcode attributes array,  
  25. * @param array $m Regular expression match array. 
  26. */ 
  27. $return = apply_filters( 'pre_do_shortcode_tag', false, $tag, $attr, $m ); 
  28. if ( false !== $return ) { 
  29. return $return; 
  30.  
  31. $content = isset( $m[5] ) ? $m[5] : null; 
  32.  
  33. $output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6]; 
  34.  
  35. /** 
  36. * Filters the output created by a shortcode callback. 
  37. * @since 4.7.0 
  38. * @param string $output Shortcode output. 
  39. * @param string $tag Shortcode name. 
  40. * @param array $attr Shortcode attributes array,  
  41. * @param array $m Regular expression match array. 
  42. */ 
  43. return apply_filters( 'do_shortcode_tag', $output, $tag, $attr, $m );