[wp-trac] [WordPress Trac] #25435: Introduce alternative to do_shortcode( '[shortcode]' )
WordPress Trac
noreply at wordpress.org
Thu Oct 15 07:17:33 UTC 2015
#25435: Introduce alternative to do_shortcode( '[shortcode]' )
-----------------------------+-----------------------------
Reporter: jdgrimes | Owner: rmccue
Type: feature request | Status: assigned
Priority: normal | Milestone: Future Release
Component: Shortcodes | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
-----------------------------+-----------------------------
Comment (by rmccue):
Rewrote the patch. Since this is intended for internal use, it now returns
a `WP_Error` on invalid arguments. (If you're doing output and would
rather ignore stuff, probably best to call `do_shortcode` still.)
If @nickciske's suggestion sounds OK, we could probably do it, but I think
it's more trouble than it's worth. It'd introduce a fair bit of complexity
into `do_shortcode` for an edge case that's better handled by a separate
function, IMO.
Testing shows it comes out barely faster than `do_shortcode`, but calling
it is a fair bit nicer for internal use:
{{{
$old = do_shortcode( '[gallery columns="2" ids="19,20,21,22"]' );
$new = do_single_shortcode( 'gallery', array( 'columns' => 2, 'ids' =>
'19,20,21,22' ) );
}}}
(Plus, the error returns mean you can actually handle invalid codes rather
than just getting back your input string.)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/25435#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list