how to remove filter from wordpress shortcode output

Filters on the_content are not applied on a “per shortcode” basis. Post content is passed to the first filter, and then the altered post content is passed to the second filter, and then the content altered by the first two filters is passed to the third, and so on. You can’t remove a the_content filter, … Read more

Dynamically create shortcodes using add_shortcode and a callback

the shortcodes doesn’t shop up in the liste because it’s not a valid declaration with a valid function callback on the 2nd argument try this to see what append : // shortcode data add_filter(“shortcode_list”, function ($shortcode_list) { $shortcode_list[“slugA”] = array( “html” => “test html 1”, ); return $shortcode_list; }); add_filter(“shortcode_list”, function ($shortcode_list) { $shortcode_list[“slugB”] = … Read more

WordPress shortcodes & performance

You need to look at this from a couple of perspectives and then you have to weigh the odds against each other In general, shortcodes will be slower (we are talking milliseconds here) as they need to be parsed and processed by the shortcode handler. USAGE: [my_shortcode] in post editor Shortcodes in general are quite … Read more

Can a shortcode function this way

Yes. That result can be achieved by single shortcode function. Here is your code- function paragraph_shortcode( $atts, $content = null ) { $pull_atts = shortcode_atts( array( ‘value’ => 0 ), $atts ); return ‘You are reading paragraph ‘ . wp_kses_post( $pull_atts[ ‘value’ ] ) . ‘: ‘ . do_shortcode($content); } add_shortcode( ‘paragraph’, ‘paragraph_shortcode’ ); It’ll … Read more

How can I get the current user email instead of user ID?

you can get all logged in users details by below function <?php $current_user = wp_get_current_user(); /** * @example Safe usage: $current_user = wp_get_current_user(); * if ( !($current_user instanceof WP_User) ) * return; */ echo ‘Username: ‘ . $current_user->user_login . ‘<br />’; echo ‘User email: ‘ . $current_user->user_email . ‘<br />’; echo ‘User first name: ‘ … Read more

Get list of shortcodes from content

Here’s one way: You can look at has_shortcode() and find the parsing there: preg_match_all( “https://wordpress.stackexchange.com/” . get_shortcode_regex() . “https://wordpress.stackexchange.com/”, $content, $matches, PREG_SET_ORDER ); using the get_shortcode_regex() function for the regex pattern. For non empty matches, you can then loop through them and collect the full shortcode matches with: $shortcodes = []; foreach( $matches as $shortcode … Read more

Nested shortcodes

You cannot use shortcodes like this. The parser would not read that like you want. But there is a workaround: Hijack the shortcode dropbox-foldershare-hyno, run the callback function for the wp-members on the link and pass the result to the original dropbox-foldershare-hyno callback. Sample code, not tested: // wait until the other plugins are loaded … Read more

Adding body class when post contains a specific shortcode

I am doing something like this in one of my plugins: function my_body_class( $c ) { global $post; if( isset($post->post_content) && has_shortcode( $post->post_content, ‘your-shortcode’ ) ) { $c[] = ‘your-class’; } return $c; } add_filter( ‘body_class’, ‘my_body_class’ ); I’m not sure it was really necessary, but I probably can’t remove it now either. TheDeadMedic is … Read more