grid-columns icon indicating copy to clipboard operation
grid-columns copied to clipboard

bump add_filter "do_shortcode" to priority 11, follow core

Open lkraav opened this issue 11 years ago • 2 comments

See https://github.com/WordPress/WordPress/blob/3.8.1/wp-includes/shortcodes.php#L388

Because shortcode_unautop() is seriously lacking 1, sufficient cause exists to replace this function with a custom plugin until core gets better. Putting everything on priority 10 in GC creates unnecessary filter ordering problems when replacing built-in shortcode_unautop(), meaning one would also have to remove and re-add GC's "do_shortcode" filter, which must always run after "shortcode_unautop". Might as well do the right thing upstream.

lkraav avatar Feb 20 '14 22:02 lkraav

I don't really see how this patch will help anything in any way. I could see an argument for something like this:

add_filter( 'gc_column_content', 'wpautop', 5 );
add_filter( 'gc_column_content', 'shortcode_unautop', 10 );
add_filter( 'gc_column_content', 'do_shortcode', 15 );

That would give others better opportunities for hooking in. But, giving do_shortcode a priority of 11 makes no real difference. It's always going to run after shortcode_unautop in the current code:

add_filter( 'gc_column_content', 'wpautop' );
add_filter( 'gc_column_content', 'shortcode_unautop' );
add_filter( 'gc_column_content', 'do_shortcode' );

Am I missing something?

justintadlock avatar Feb 21 '14 04:02 justintadlock

First difference is increased consistency with core.

But primary impulse is, right now I have to do:

remove_filter( "gc_column_content", "shortcode_unautop" );
remove_filter( "gc_column_content", "do_shortcode" ); # without this, "do_shortcode" will move a step up towards "wpautop", and lose correct order with "my_custom_shortcode_unautop"
add_filter( "gc_column_content", "my_custom_shortcode_unautop" );
add_filter( "gc_column_content", "do_shortcode", 11 ); # yes 10 or 11, doesn't really matter but meh, shouldn't have to touch do_shortcode at all

Instead of just doing:

remove_filter( "gc_column_content", "shortcode_unautop" );
add_filter( "gc_column_content", "my_custom_shortcode_unautop" );

What can I say, I like less code.

Other than that, moving all of them to different priorities has a point, too. I just don't know a reason for playing with wpautop() right now and usually go about things step by small step.

lkraav avatar Feb 21 '14 09:02 lkraav