[wp-trac] [WordPress Trac] #28030: cast $content as a string when calling do_shortcode()

WordPress Trac noreply at wordpress.org
Fri Apr 25 18:29:39 UTC 2014


#28030: cast $content as a string when calling do_shortcode()
--------------------------+------------------------------
 Reporter:  webstract     |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Shortcodes    |     Version:  3.9
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by webstract):

 There are numerous people getting this errors from themes and plugins...
 http://wordpress.org/support/topic/wp-39-warning-strpos-expects-
 parameter-1-to-be-string?replies=17

 In my case it was this function. `$atts` is an array but gets passed to
 `make_more_shortcodes($atts)` which runs `do_shortcode()` - this was
 created for nested shortcodes.
 {{{
 add_shortcode('action', 'sc_action');
 function sc_action($atts, $content=null) {
         $atts = make_more_shortcodes($atts);
         extract(shortcode_atts(array(
                 'name' => 'scroll_form',
                 'text' => 'click here to schedule'
         ), $atts));

         if($name == 'scroll_form') $anchor = '#bigOffer';

         return '<a href="'.$anchor.'">'.$text.'</a>';
 }
 }}}

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


More information about the wp-trac mailing list