[wp-trac] [WordPress Trac] #35216: Return empty string from wp.shortcode.replace() callback is ignored

WordPress Trac noreply at wordpress.org
Thu Dec 24 11:58:33 UTC 2015


#35216: Return empty string from wp.shortcode.replace() callback is ignored
----------------------------------------+-----------------------------
 Reporter:  prionkor                    |      Owner:
     Type:  defect (bug)                |     Status:  new
 Priority:  normal                      |  Milestone:  Awaiting Review
Component:  Shortcodes                  |    Version:  4.4
 Severity:  normal                      |   Keywords:
  Focuses:  javascript, administration  |
----------------------------------------+-----------------------------
 I was trying to just remove a shortcode by returning empty string from
 `wp.shortcode.replace()` callback.

 **For example**


 {{{
 var text = "This is some content with shortcode. [foo]some content[/foo]

 text = wp.shortcode.replace('foo', text, function(tag){

     // attributes and content values are broken.

     return '';

 });
 }}}

 The callback function simply get ignored. No replacement happened for the
 shortcode. If I return anything other then empty string for example `' '`
 (string with space) it does replace the shortcode.

 I am not sure if this behavior was intended or not.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35216>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list