Skip to content

Instantly share code, notes, and snippets.

@UVLabs
Last active March 26, 2017 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save UVLabs/165a095d0c8f367665e93286e10e35cf to your computer and use it in GitHub Desktop.
Save UVLabs/165a095d0c8f367665e93286e10e35cf to your computer and use it in GitHub Desktop.
WordPress, creating magic tags example
//get your data with the magic tags
$prefix_old_body = $_POST["field"];
//create the replacement variables
$magic_tag1 = "Data";
$magic_tag2 = "Data2";
//create the list of magic tags you're looking for
$prefix_magic_tags = array( "{magic_tag1}", "{magic_tag2}" );
//write your replacement variables in the same order of your magic tags
$prefix_magic_tags_replace = array( $magic_tag1, $magic_tag2 );
//get your new replaced data
$prefix_new_body = str_replace( $prefix_magic_tags, $prefix_magic_tags_replace, $prefix_old_body );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment