How do I escape a ‘]’ in a short code?

I don’t know of an official escape syntax for shortcodes and there likely isn’t one. When wordpress parses for shortcodes it looks for [ and ]. If you want to use square brackets within a shortcode, using the respective html ASCII entities escapes them. I.e. replacing [ by [ and ] by ]. WordPress will … Read more

What does extract( shortcode_atts( array( do?

shortcode_atts() works like array_merge(): It merges the second list of arguments into the first one. The difference is: It merges only keys present in the first argument ($default). extract() then takes the array keys, sets these as variable names and their values as variable values. ‘w’ => ‘500’ in your example becomes $w = ‘500’. … Read more

Conditionally Loading JavaScript/CSS for Shortcodes

Based on my own experience, I’ve used a combination of method 1 & 2 – the architecture and footer scripts of 1, and the ‘look-ahead’ technique of 2. For the look-ahead though, I use regex in place of stripos; personal preference, faster, and can check for ‘malformed’ shortcode; preg_match( ‘#\[ *shortcode([^\]])*\]#i’, $content ); If you’re … Read more

Enqueue Scripts / Styles when shortcode is present

I found an other way that works well for me: When initializing the plugin, do not enqueue your scripts and styles, but register them with wp_register_style and wp_register_script. Next you can load the script/style on demand. For example when you render a shortcode with wp_enqueue_style(“your_style”) and wp_enqueue_script(“your_script”). Here is an example plugin using this method … Read more

convert it into short code & explan how? [closed]

A function can be created that generates the output, then that function can be tied to a shortcode using the Shortcode API: /** * Returns –> Contact | Terms of Service | Privacy Policy | Careers * * @parm array $atts * @return string */ function wpse241695_arrow_contact_terms_of_service_privacy_policy_careers( $atts ) { return ‘–> Contact  |  Terms … Read more