-
-
Save eteubert/1376742 to your computer and use it in GitHub Desktop.
WordPress: Shortcodes in Text Widgets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ericteubert: ~/Sites/wordpress-single | |
| ➜ ack widget_text | |
| wp-admin/includes/schema.php | |
| 307: 'widget_text' => array(), | |
| wp-content/plugins/ikonum/class/class.custom-field-template.php | |
| 101: add_filter('widget_text', 'do_shortcode'); | |
| wp-includes/default-widgets.php | |
| 371: $widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML')); | |
| 379: $text = apply_filters( 'widget_text', $instance['text'], $instance ); | |
| wp-includes/widgets.php | |
| 405: 'wp_widget_text', | |
| 406: 'wp_widget_text_control', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) { | |
| global $wp_filter, $merged_filters; | |
| $idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority); | |
| $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); | |
| unset( $merged_filters[ $tag ] ); | |
| return true; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function do_shortcode($content) { | |
| global $shortcode_tags; | |
| if (empty($shortcode_tags) || !is_array($shortcode_tags)) | |
| return $content; | |
| $pattern = get_shortcode_regex(); | |
| return preg_replace_callback('/'.$pattern.'/s', 'do_shortcode_tag', $content); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'widget_text', 'do_shortcode' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'widget_title', 'do_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment