Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function crazyland_static_content_display($attr, $content=null){
- extract(shortcode_atts(array(
- "tag" => "h1"
- ), $attr));
- return '<'.$tag.'>My static content</'.$tag.'>';
- }
- add_shortcode( "static-content", "crazyland_static_content_display");
- function crazyland_notice_shortcode($attr, $content=null){
- extract(shortcode_atts(array(
- "title" => "",
- "text" => "",
- "type" => "primary"
- ),$attr));
- return '
- <div class="alert alert-'.$type.'">
- <h3>'.$title.'</h3>
- '.$text.'
- </div>
- ';
- }
- add_shortcode( "notice", "crazyland_notice_shortcode" );
- function crazyland_image_shortcode($attr, $content=null){
- extract(shortcode_atts(array(
- "id" => "",
- "title" => "",
- "size" => "large"
- ),$attr));
- return '
- </h4>'.$title.'</h4>, <br/>, <img src="'.wp_get_attachment_url( $id, $size ).'" alt="">
- ';
- }
- add_shortcode( "img", "crazyland_image_shortcode" );
- function crazyland_list_shortcode($attr, $content=null){
- extract(shortcode_atts(array(
- "items" => ""
- ),$attr));
- $items_array = explode(',', $items);
- $my_html = '<ul>';
- foreach ($items_array as $item) {
- $my_html .= '<li>'.$item.'</li>';
- }
- $my_html .= '</ul>';
- return $my_html;
- }
- add_shortcode( "list", "crazyland_list_shortcode" );
- function crazyland_date_shortcode($attr, $content=null){
- extract(shortcode_atts(array(
- "format" => "M,D,Y"
- ),$attr));
- return date($format);
- }
- add_shortcode( "date", "crazyland_date_shortcode" );
- function crazyland_button_shortcode($attr, $content=null){
- extract(shortcode_atts(array(
- "style" => "",
- "text" => "",
- "type" => ""
- ),$attr));
- return '
- <button type="'.$type.'" class="btn btn-'.$style.'">'.$text.'</button>
- ';
- }
- add_shortcode("button", "crazyland_button_shortcode");
- function card_shortcode($atts, $content = null){
- extract(shortcode_atts(array(
- "width" => "288",
- "title" =>"",
- "text" => "",
- "type" => "btn",
- "style" =>"",
- "size" => "thumbnail",
- "id" =>"",
- "content" => ""
- ),$atts));
- return '<div class="card" style="width:'.$width.'px">
- <img class="card-img-top" src="'.wp_get_attachment_url($id, $size).'" alt="Card image cap">
- <div class="card-body">
- <h5 class="card-title">'.$title.'</h5>
- <p class="card-text">'.$content.'</p>
- <a href="#" class="'.$type.' btn-'.$style.'">'.$text.'</a>
- </div>
- </div>';
- }
- add_shortcode( "card", "card_shortcode" );
- function crazyland_maps_shortcode($atts) {
- $default = array(
- 'lat' => '22.9196383',
- 'lon' => '91.520781',
- 'zoom' => '16',
- 'width' => '600',
- 'height' => '400',
- );
- $map_data = shortcode_atts( $default, $atts);
- $img = '<img src="http://maps.google.com/maps/api/staticmap?center=%f,%f&zoom=%d&size=%dx%d" />';
- return sprintf($img,$map_data['lat'],$map_data['lon'],$map_data['zoom'],$map_data['width'],$map_data['height']);
- }
- add_shortcode( 'maps', 'crazyland_maps_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement