Changeset 30545 for trunk/src/wp-includes/shortcodes.php
- Timestamp:
- 11/24/2014 06:14:03 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/shortcodes.php
r30105 r30545 22 22 * To apply shortcode tags to content: 23 23 * 24 * <code> 25 * $out = do_shortcode($content); 26 * </code> 24 * $out = do_shortcode( $content ); 27 25 * 28 26 * @link http://codex.wordpress.org/Shortcode_API … … 53 51 * Simplest example of a shortcode tag using the API: 54 52 * 55 * <code>56 * // [footag foo="bar"]57 * function footag_func($atts){58 * return "foo = {$atts[foo]}";59 * }60 * add_shortcode('footag', 'footag_func');61 * </code>53 * // [footag foo="bar"] 54 * function footag_func( $atts ) { 55 * return "foo = { 56 * $atts[foo] 57 * }"; 58 * } 59 * add_shortcode( 'footag', 'footag_func' ); 62 60 * 63 61 * Example with nice attribute defaults: 64 62 * 65 * <code> 66 * // [bartag foo="bar"] 67 * function bartag_func($atts) { 68 * $args = shortcode_atts(array( 69 * 'foo' => 'no foo', 70 * 'baz' => 'default baz', 71 * ), $atts); 72 * 73 * return "foo = {$args['foo']}"; 74 * } 75 * add_shortcode('bartag', 'bartag_func'); 76 * </code> 63 * // [bartag foo="bar"] 64 * function bartag_func( $atts ) { 65 * $args = shortcode_atts( array( 66 * 'foo' => 'no foo', 67 * 'baz' => 'default baz', 68 * ), $atts ); 69 * 70 * return "foo = {$args['foo']}"; 71 * } 72 * add_shortcode( 'bartag', 'bartag_func' ); 77 73 * 78 74 * Example with enclosed content: 79 75 * 80 * <code> 81 * // [baztag]content[/baztag] 82 * function baztag_func($atts, $content='') { 83 * return "content = $content"; 84 * } 85 * add_shortcode('baztag', 'baztag_func'); 86 * </code> 76 * // [baztag]content[/baztag] 77 * function baztag_func( $atts, $content = '' ) { 78 * return "content = $content"; 79 * } 80 * add_shortcode( 'baztag', 'baztag_func' ); 87 81 * 88 82 * @since 2.5.0
Note: See TracChangeset
for help on using the changeset viewer.