WordPress.org

Make WordPress Core

Ticket #18558: shortcodes.patch

File shortcodes.patch, 1.5 KB (added by trevogre, 7 years ago)
  • wp-includes/shortcodes.php

    ### Eclipse Workspace Patch 1.0
    #P Shortcode Patch Development
     
    4040 * @var array
    4141 * @global array $shortcode_tags
    4242 */
    43 $shortcode_tags = array();
    4443
     44$shortcode_tags = get_option('wp_shortcodes', array());
     45
     46$default_shortcode = "unregistered_shortcode";
     47
     48function unregistered_shortcode($atts = null, $content = null) { return $content; }
     49
     50function register_shortcodes() {
     51                global $default_shortcode;
     52                global $shortcode_tags;
     53                foreach($shortcode_tags as $k => $v) {
     54                        $shortcode_tags[$k] = $default_shortcode;
     55                }
     56                update_option('wp_shortcodes', $shortcode_tags);
     57}
     58
     59add_action( 'shutdown', 'register_shortcodes');
     60
     61function register_default_shortcode($func) {
     62        global $default_shortcode;
     63        $default_shortcode = $func;
     64}
     65
    4566/**
    4667 * Add hook for shortcode tag.
    4768 *
     
    95116
    96117        if ( is_callable($func) )
    97118                $shortcode_tags[$tag] = $func;
     119
    98120}
    99121
    100122/**
     
    157179 * The regular expression combines the shortcode tags in the regular expression
    158180 * in a regex class.
    159181 *
    160  * The regular expression contains 6 different sub matches to help with parsing.
     182 * The regular expresion contains 6 different sub matches to help with parsing.
    161183 *
    162184 * 1/6 - An extra [ or ] to allow for escaping shortcodes with double [[]]
    163185 * 2 - The shortcode name