[wp-trac] [WordPress Trac] #29029: get_shortcodes() - retrieve the shortcode instances from content

WordPress Trac noreply at wordpress.org
Fri Jul 25 22:54:25 UTC 2014


#29029: get_shortcodes() - retrieve the shortcode instances from content
-------------------------+------------------------------
 Reporter:  ericlewis    |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Shortcodes   |     Version:  trunk
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:
-------------------------+------------------------------
Changes (by ericlewis):

 * keywords:   => has-patch


Comment:

 In attachment:29029.diff,

 introduce `get_shortcodes()`, which will pass back an array like this:

 {{{
 [
   [
     'tag' => 'gallery',
     'attrs' =>
       [
         'ids' => '1,2,3',
         'order' => 'DESC',
         'columns' => '4'
       ]
   ],
   [
     'tag' => 'video',
     'attrs' =>
       [
         'src' => 'http://ericandrewlewis.com/video.mp4',
         'loop' => 'off',
         'autoplay' => 'on'
       ]
   ],
   [
     'tag' => 'gallery',
     'attrs' =>
       [
         'ids' => '4,5,3',
         'order' => 'ASC',
         'columns' => '3'
       ]
   ]
 ]
 }}}

 `get_shortcode_regex()` now accepts an optional array, which you can pass
 specific tags to build the shortcode regex with. This means we can do fun
 stuff like this:

 `get_shortcodes( $content, 'gallery' )`

 which would only return you gallery shortcode instances.

 or

 `get_shortcodes( $content, array( 'gallery', 'audio' ) )`

 which would return you shortcode instances of either gallery or audio.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29029#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list