Make WordPress Core


Ignore:
Timestamp:
03/16/2013 05:25:44 AM (13 years ago)
Author:
markjaquith
Message:

Introduce [audio] and [video] shortcodes, and use MediaElement.js to play them.

props wonderboymusic. see #23282.

File:
1 edited

Legend:

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

    r23626 r23729  
    126126
    127127    $shortcode_tags = array();
     128}
     129
     130/**
     131 * Whether a registered shortcode exists named $tag
     132 *
     133 * @since 3.6.0
     134 *
     135 * @global array $shortcode_tags
     136 * @param string $tag
     137 * @return boolean
     138 */
     139function shortcode_exists( $tag ) {
     140    global $shortcode_tags;
     141    return array_key_exists( $tag, $shortcode_tags );
     142}
     143
     144/**
     145 * Whether the passed content contains the specified shortcode
     146 *
     147 * @since 3.6.0
     148 *
     149 * @global array $shortcode_tags
     150 * @param string $tag
     151 * @return boolean
     152 */
     153function has_shortcode( $content, $tag ) {
     154    if ( shortcode_exists( $tag ) ) {
     155        $matches = array();
     156        preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
     157        if ( empty( $matches ) )
     158            return false;
     159
     160        foreach ( $matches as $shortcode ) {
     161            if ( $tag === $shortcode[2] )
     162                return true;
     163        }
     164    }
     165    return false;
    128166}
    129167
Note: See TracChangeset for help on using the changeset viewer.