Skip to content

Instantly share code, notes, and snippets.

@flegfleg
Last active June 8, 2020 13:36
Show Gist options
  • Save flegfleg/7bc61ce07623f7e8a59dd023f33f0030 to your computer and use it in GitHub Desktop.
Save flegfleg/7bc61ce07623f7e8a59dd023f33f0030 to your computer and use it in GitHub Desktop.
tag system in cb
<?php
// add this to any template, e.g. booking-publish.php
// echo
CB::echo('item', 'mymeta'); // this is the item meta
CB::echo('item', 'mymethod'); // this is a method in class item
CB::echo('timeframe', 'myproperty'); // this is a property of class timeframe
CB::echo('booking', 'myproperty'); // 'booking' is substited with 'timeframe' in CB.php
?>
<?php
// getting
echo CB::get('item', 'mymeta');
?>
<?php
// using a template, useful for mailing
$template = '
<p>{{item_mymethod}}</p>
<i>{{item_testmeta}}</i><br>
<strong>{{timeframe_myproperty}}</strong>
';
echo cb_parse_template( $template );
?>
<?php
// using a shortcode, should be used only in the post editor screen
do_shortcode( '[cb tag="item_mymeta"]' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment