~ubuntu-branches/debian/jessie/wordpress/jessie

« back to all changes in this revision

Viewing changes to wp-includes/shortcodes.php

  • Committer: Package Import Robot
  • Author(s): Craig Small
  • Date: 2014-04-17 20:56:19 UTC
  • mfrom: (1.2.35)
  • Revision ID: package-import@ubuntu.com-20140417205619-nurbet6eho4yvwfv
Tags: 3.9+dfsg-1
* New upstream release
* 3.9 seems to handle different locations for plugins so the
  plugin directory handling patches have been cut back.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 *
30
30
 * @package WordPress
31
31
 * @subpackage Shortcodes
32
 
 * @since 2.5
 
32
 * @since 2.5.0
33
33
 */
34
34
 
35
35
/**
36
36
 * Container for storing shortcode tags and their hook to call for the shortcode
37
37
 *
38
 
 * @since 2.5
 
38
 * @since 2.5.0
 
39
 *
39
40
 * @name $shortcode_tags
40
41
 * @var array
41
42
 * @global array $shortcode_tags
84
85
 * add_shortcode('baztag', 'baztag_func');
85
86
 * </code>
86
87
 *
87
 
 * @since 2.5
 
88
 * @since 2.5.0
 
89
 *
88
90
 * @uses $shortcode_tags
89
91
 *
90
92
 * @param string $tag Shortcode tag to be searched in post content.
100
102
/**
101
103
 * Removes hook for shortcode.
102
104
 *
103
 
 * @since 2.5
 
105
 * @since 2.5.0
 
106
 *
104
107
 * @uses $shortcode_tags
105
108
 *
106
109
 * @param string $tag shortcode tag to remove hook for.
118
121
 * shortcodes global by a empty array. This is actually a very efficient method
119
122
 * for removing all shortcodes.
120
123
 *
121
 
 * @since 2.5
 
124
 * @since 2.5.0
 
125
 *
122
126
 * @uses $shortcode_tags
123
127
 */
124
128
function remove_all_shortcodes() {
151
155
 * @return boolean
152
156
 */
153
157
function has_shortcode( $content, $tag ) {
 
158
        if ( false === strpos( $content, '[' ) ) {
 
159
                return false;
 
160
        }
 
161
 
154
162
        if ( shortcode_exists( $tag ) ) {
155
163
                preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
156
164
                if ( empty( $matches ) )
171
179
 * without any filtering. This might cause issues when plugins are disabled but
172
180
 * the shortcode will still show up in the post or content.
173
181
 *
174
 
 * @since 2.5
 
182
 * @since 2.5.0
 
183
 *
175
184
 * @uses $shortcode_tags
176
185
 * @uses get_shortcode_regex() Gets the search pattern for searching shortcodes.
177
186
 *
181
190
function do_shortcode($content) {
182
191
        global $shortcode_tags;
183
192
 
 
193
        if ( false === strpos( $content, '[' ) ) {
 
194
                return $content;
 
195
        }
 
196
 
184
197
        if (empty($shortcode_tags) || !is_array($shortcode_tags))
185
198
                return $content;
186
199
 
203
216
 * 5 - The content of a shortcode when it wraps some content.
204
217
 * 6 - An extra ] to allow for escaping shortcodes with double [[]]
205
218
 *
206
 
 * @since 2.5
 
219
 * @since 2.5.0
 
220
 *
207
221
 * @uses $shortcode_tags
208
222
 *
209
223
 * @return string The shortcode search regular expression
250
264
 * Regular Expression callable for do_shortcode() for calling shortcode hook.
251
265
 * @see get_shortcode_regex for details of the match array contents.
252
266
 *
253
 
 * @since 2.5
 
267
 * @since 2.5.0
254
268
 * @access private
255
269
 * @uses $shortcode_tags
256
270
 *
284
298
 * attribute as the value in the key/value pair. This allows for easier
285
299
 * retrieval of the attributes, since all attributes have to be known.
286
300
 *
287
 
 * @since 2.5
 
301
 * @since 2.5.0
288
302
 *
289
303
 * @param string $text
290
304
 * @return array List of attributes and their value.
322
336
 * If the $atts list has unsupported attributes, then they will be ignored and
323
337
 * removed from the final returned list.
324
338
 *
325
 
 * @since 2.5
 
339
 * @since 2.5.0
326
340
 *
327
341
 * @param array $pairs Entire list of supported attributes and their defaults.
328
342
 * @param array $atts User defined attributes in shortcode tag.
359
373
/**
360
374
 * Remove all shortcode tags from the given content.
361
375
 *
362
 
 * @since 2.5
 
376
 * @since 2.5.0
 
377
 *
363
378
 * @uses $shortcode_tags
364
379
 *
365
380
 * @param string $content Content to remove shortcode tags.
368
383
function strip_shortcodes( $content ) {
369
384
        global $shortcode_tags;
370
385
 
 
386
        if ( false === strpos( $content, '[' ) ) {
 
387
                return $content;
 
388
        }
 
389
 
371
390
        if (empty($shortcode_tags) || !is_array($shortcode_tags))
372
391
                return $content;
373
392