Make WordPress Core


Ignore:
Timestamp:
10/04/2016 12:38:45 AM (9 years ago)
Author:
pento
Message:

Shortcodes: Add a do_shortcode_tag filter.

The addition of the pre_do_shortcode_tag in [38506] allows plugins to short-circuit the shortcode execution process, which is particularly helpful for caching expensive shortcodes.

The do_shortcode_tag is the corresponding part of that system - when a shortcode hasn't been executed previously, there needs to be a clean method of populating the cache.

Props flixos90.
Fixes #32790.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/shortcodes.php

    r38506 r38713  
    340340    }
    341341
    342     if ( isset( $m[5] ) ) {
    343         // enclosing tag - extra parameter
    344         return $m[1] . call_user_func( $shortcode_tags[$tag], $attr, $m[5], $tag ) . $m[6];
    345     } else {
    346         // self-closing tag
    347         return $m[1] . call_user_func( $shortcode_tags[$tag], $attr, null,  $tag ) . $m[6];
    348     }
     342    $content = isset( $m[5] ) ? $m[5] : null;
     343
     344    $output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];
     345
     346    /**
     347     * Filters the output created by a shortcode callback.
     348     *
     349     * @since 4.7.0
     350     *
     351     * @param string $output Shortcode output.
     352     * @param string $tag    Shortcode name.
     353     * @param array  $attr   Shortcode attributes array,
     354     * @param array  $m      Regular expression match array.
     355     */
     356    return apply_filters( 'do_shortcode_tag', $output, $tag, $attr, $m );
    349357}
    350358
Note: See TracChangeset for help on using the changeset viewer.