How to add AJAX in a custom PHP function using Google sheets API
How to add AJAX in a custom PHP function using Google sheets API
How to add AJAX in a custom PHP function using Google sheets API
I think, I would simply store all the definitions during the glossary_shortcode() execution in a global variable and serve them at the end of some hook like the_content. function glossary_shortcode( $atts = array(), $shortcode_content = null ) { // Your code can be kept identical, just store the $glossary_term_object somewhere. global $glossaries; $glossaries = $glossaries … Read more
shortcode_atts_{$shortcode} seems to be the WordPress filter you need. https://developer.wordpress.org/reference/hooks/shortcode_atts_shortcode/ It is used in the shortcode_atts() function: https://developer.wordpress.org/reference/functions/shortcode_atts/
I believe the following should work: <?php $content = apply_filters(‘the_content’, $content); $content = str_replace(‘]]>’, ‘]]>’, $content); ?> You could put this in the template of in a hooked functions. I’ve cribbed this from here and here, where the intention is to write content from get_the_content() (raw) in an equivalent way to the_content() (amongst other things: … Read more
I have no idea what goes wrong at your setup. Clearly shortcode is properly registered, but some specific case something prevents it from being parsed correctly. This is test code that roughly replicates how shortcode is parsed for execution : $content = get_option(“prc_speciall_offer_text”, true); $pattern = “https://wordpress.stackexchange.com/”.get_shortcode_regex().’/s’; preg_replace_callback( $pattern, ‘var_dump’, $content ); Array output should … Read more
Try this: // replaces [banner …] .. [/banner] with <!–banner ID–> before the_content filters run add_filter(‘the_content’, ‘protect_my_shortcode’, -100); function protect_my_shortcode($content){ return preg_replace_callback(‘/\[(banner)\b(.*?)(?:(\/))?\](.+?)\[\/\1\]/s’, ‘protect_my_shortcode_callback’, $content); } function protect_my_shortcode_callback($matches){ global $__banners; $id = ‘<!–banner ‘.count($__banners).’–>’; $__banners[$id] = do_shortcode($matches[0]); // or ‘[‘.$matches[1].’ ‘.$matches[2].’]’.$matches[4].'[/’.$matches[1].’]’ // if you need to run any filters on the shortcode content ($matches[4]) return $id; … Read more
You are correct in your thinking that because the loop evaluates after the header you will not be able to get the contents of the loop there. The easiest way to do this is probably with jQuery. Something like this: <script type=”text/javascript”> $(document).ready(function() { document.title=”blah”; }); </script> Place this code in your loop, and the … Read more
There’re two functions: is_user_logged_in() && current_user_can(‘capability_type’) that will help you to acchieve this.
How about this? <?php function btn($atts, $content = null) { extract(shortcode_atts(array(‘link’ => ‘#’, ‘color’ => ‘teal’ , ‘size’ => ‘large’), $atts)); return ‘<a class=”btn ‘.$size.'” href=”‘.$link.'” style=”background:’.$color.’;”><span>’ . $content . ‘</span></a>’; } add_shortcode(‘btn’, ‘btn’); ?>
Take a look at my latest plugin ShortCodes UI which lets you create shortcodes without coding, all you have to do is paste your loop inside the right field of the shortcode (PHP) and you are done.