Adding shortcodes
This file contains 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 | |
/* | |
Plugin Name: wpse32871 Shortcode tester | |
*/ | |
add_action( 'init', 'wpse32871_add_shortcodes' ); | |
function wpse32871_add_shortcodes() | |
{ | |
add_shortcode( 'wpse32871', 'wpse32871_shortcode_cb' ); | |
// add_option only works once, if the option is there, it doesn't do anything | |
add_option( 'wpse32871', '<h1>Header</h1><p>Paragraph</p>[wpse32871]' ); | |
} | |
function wpse32871_shortcode_cb( $atts, $content = null ) | |
{ | |
return 'this text has been replaced'; | |
} | |
add_action( 'wp_footer', 'wpse32871_testing123' ); | |
function wpse32871_testing123() | |
{ | |
echo do_shortcode( get_option( 'wpse32871' ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment