do_shortcode() doesn’t do shortcodes ;)
The shortcode functions just return a value, you need to echo or assign it to something. <?php echo do_shortcode(‘[div]’); ?>
The shortcode functions just return a value, you need to echo or assign it to something. <?php echo do_shortcode(‘[div]’); ?>
It seems you are working on the wrong end. Try sanitizing the user input, for instance by means of sanitize_text_field, not the shortcode output.
Shortcode functions are only called when the content of the visual editor is processed and displayed, so nothing in your shortcode function will run early enough. Have a look at the has_shortcode function. If you hook in early enough to send headers and late enough for the query to be set up you can check … Read more
Hope this helps someone: Instead of doing this: <a href=”https://example.com/folder/edit.php?action=someaction&id=[foocode parameter=”value”]&edittoken=[foocode parameter=”othervalue”]”>linktext</a> You can do this: [foocode parameter1=value parameter2=othervalue] and then do this: add_shortcode( ‘foocode’, ‘prefix_foocode’ ); function prefix_foocode( $atts ) { // Normalize $atts, set defaults and do whatever you want with $atts. $html=”<a href=”https://example.com/folder/edit.php?action=someaction&id=” . $atts[‘parameter1′] .’&edittoken=’ . $atts[‘parameter2’] . ‘”>linktext</a>’; return $html; … Read more
Try this function get_products($atts) { ob_start(); get_template_part(‘block-products-inline’); return ob_get_clean(); } add_shortcode(‘products’, ‘get_products’); Little explanation php just outputs your content right away when its see print statement. What we do here is, we are holding all the output in buffer and not giving it in print until the whole things finish. then we are returning the … Read more
The problem with what you’re trying to do is that you split a block type html element <p>. In your example you effectively have <p><div></p></div>, which is simply no good. So you cannot mix <p> and <div> in this way. You can, however use a combination of paragraphs and classes: <p>Text</p><p class=”hide-from-here”>More text</p> Where it … Read more
No, there is no core shortcode for this. The site name is available as an option, in facts get_option(‘blogname’) returns the blog name. Moreover, get_bloginfo(‘name’) / bloginfo(‘name’) can be used to get / echo the site name. Of course, you can’t use that functions as a shortcode by default, so if you want to obtain … Read more
If you want exactly this shortcode: to output nothing, then you can use the wp_video_shortcode_override filter or the wp_video_shortcode filter to achieve that. Here are two such examples: Example #1 /** * Let the shortcode output “almost” nothing (just a single space) for specific attributes */ add_filter( ‘wp_video_shortcode_override’, function ( $output, $attr, $content, $instance ) … Read more
Yes! Use the mce_buttons_2 filter to add buttons to the second row. Use the mce_buttons_3 filter to add buttons to the third row. Here’s an example of what I use: function mytheme_mce_buttons_row_3($buttons) { $buttons[] = ‘fontselect’; $buttons[] = ‘fontsizeselect’; $buttons[] = ‘code’; $buttons[] = ‘sup’; $buttons[] = ‘sub’; $buttons[] = ‘backcolor’; $buttons[] = ‘separator’; $buttons[] … Read more
The easiest way to do that is to hijack the gallery shortcode (no extra regex needed), store it somewhere and add it to the end. Prototype <?php # -*- coding: utf-8 -*- /** * Plugin Name: T5 Move Galleries To End Of Content */ add_action( ‘after_setup_theme’, array ( ‘T5_Move_Galleries’, ‘init’ ) ); class T5_Move_Galleries { … Read more