Changeset 23729 for trunk/wp-includes/shortcodes.php
- Timestamp:
- 03/16/2013 05:25:44 AM (13 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/shortcodes.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/shortcodes.php
r23626 r23729 126 126 127 127 $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 */ 139 function 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 */ 153 function 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; 128 166 } 129 167
Note: See TracChangeset
for help on using the changeset viewer.