Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*-----------------------------------------------------------------------------------*/
- /* Widgets
- /*-----------------------------------------------------------------------------------*/
- function my_widget_shortcode( $atts ) {
- // Configure defaults and extract the attributes into variables
- extract( shortcode_atts(
- array(
- 'name' => '',
- 'instance' => '',
- ),
- $atts
- ));
- $instance = str_ireplace("&", '&' ,$instance);
- $args = array(
- 'before_widget' => '<div class="page-widget">',
- 'after_widget' => '</div>',
- 'before_title' => '<h3>',
- 'after_title' => '</h3>',
- );
- ob_start();
- the_widget( $name, $instance, $args );
- $output = ob_get_clean();
- return $output;
- }
- add_shortcode( 'widget', 'my_widget_shortcode' );
- /*-----------------------------------------------------------------------------------*/
- /* Buttons
- /*-----------------------------------------------------------------------------------*/
- function button_shortcode( $atts, $content = null )
- {
- extract( shortcode_atts( array(
- 'color' => 'white',
- 'text' => '',
- 'url' => '',
- ), $atts ) );
- if($url) {
- return '<a class="button ' . $color . '" href="' . $url . '">' . $text . $content . '</a>';
- } else {
- return '<a class="button ' . $color . '" href="">' . $text . $content . '</a>';
- }
- }
- add_shortcode('button', 'button_shortcode');
- /*-----------------------------------------------------------------------------------*/
- /* Clear
- /*-----------------------------------------------------------------------------------*/
- function clear_shortcode() {
- return '<div class="clear"></div>';
- }
- add_shortcode( 'clear', 'clear_shortcode' );
- /*-----------------------------------------------------------------------------------*/
- /* Separator
- /*-----------------------------------------------------------------------------------*/
- function separator_shortcode() {
- return '<div class="separator"></div>';
- }
- add_shortcode( 'separator', 'separator_shortcode' );
- /*-----------------------------------------------------------------------------------*/
- /* Space
- /*-----------------------------------------------------------------------------------*/
- function space_shortcode() {
- return '<div class="space"></div>';
- }
- add_shortcode( 'space', 'space_shortcode' );
- /*-----------------------------------------------------------------------------------*/
- /* Line Break
- /*-----------------------------------------------------------------------------------*/
- function line_break_shortcode() {
- return '<br />';
- }
- add_shortcode( 'br', 'line_break_shortcode' );
- /*-----------------------------------------------------------------------------------*/
- /* Info Boxes
- /*-----------------------------------------------------------------------------------*/
- function box_shortcode( $atts, $content = null )
- {
- extract( shortcode_atts( array(
- 'type' => 'error',
- 'text' => ''
- ), $atts ) );
- return '<div class="box-' . $type . '"> ' . $text . $content .'</div>';
- }
- add_shortcode('box', 'box_shortcode');
- /*-----------------------------------------------------------------------------------*/
- /* Lists
- /*-----------------------------------------------------------------------------------*/
- function list_shortcode( $atts, $content = null )
- {
- extract( shortcode_atts( array(
- 'style' => 'tick',
- 'text' => ''
- ), $atts ) );
- return '<ul class="customlist ' . $style . '-list"> ' . $text . $content .'</ul>';
- }
- add_shortcode('list', 'list_shortcode');
- /*-----------------------------------------------------------------------------------*/
- /* Dropcaps
- /*-----------------------------------------------------------------------------------*/
- function dropcap_shortcode( $atts, $content = null )
- {
- extract( shortcode_atts( array(
- 'style' => '1',
- 'text' => ''
- ), $atts ) );
- return '<span class="dropcap' . $style . '">' . $text . $content .'</span>';
- }
- add_shortcode('dropcap', 'dropcap_shortcode');
- /*-----------------------------------------------------------------------------------*/
- /* Highlighted text
- /*-----------------------------------------------------------------------------------*/
- function highlighted_shortcode( $atts, $content = null )
- {
- extract( shortcode_atts( array(
- 'color' => 'dark',
- 'text' => ''
- ), $atts ) );
- return '<span class="highlight ' . $color . '">' . $text . $content .'</span>';
- }
- add_shortcode('highlighted', 'highlighted_shortcode');
- /*-----------------------------------------------------------------------------------*/
- /* Contact Form Wrapper
- /*-----------------------------------------------------------------------------------*/
- function contact_wrapper_shortcode( $atts, $content = null )
- {
- extract( shortcode_atts( array(
- 'class' => ''
- ), $atts ) );
- return '<div class="contactform '.$class.'">'.do_shortcode($content).'</div>';
- }
- add_shortcode('form-wrapper', 'contact_wrapper_shortcode');
- /*-----------------------------------------------------------------------------------*/
- /* Columns
- /*-----------------------------------------------------------------------------------*/
- function column_shortcode( $atts, $content = null )
- {
- extract( shortcode_atts( array(
- 'size' => 'one-half',
- 'text' => '',
- 'position' => ''
- ), $atts ) );
- if(!empty($position)) {
- return '<div class="percent-' . $size . ' column-' . $position . '"> '.do_shortcode($content).'</div>';
- } else {
- return '<div class="percent-' . $size . '"> ' .do_shortcode($content). '</div>';
- }
- }
- add_shortcode('column', 'column_shortcode');
- /*-----------------------------------------------------------------------------------*/
- /* Togggles
- /*-----------------------------------------------------------------------------------*/
- function toggle_shortcode( $atts, $content = null )
- {
- extract( shortcode_atts(
- array(
- 'title' => 'Toggle 1'
- ), $atts ) );
- return '<ul class="toggle-view"><li><span class="toggle-plus"></span><div></div><h3>'. $title .'</h3><div class="panel">' . do_shortcode($content) . '</div></li></ul>';
- }
- add_shortcode('toggle', 'toggle_shortcode');
- /*-----------------------------------------------------------------------------------*/
- /* Accordion
- /*-----------------------------------------------------------------------------------*/
- function accordion_shortcode( $atts, $content = null )
- {
- extract( shortcode_atts(
- array(
- 'title' => 'Accordion 1'
- ), $atts ) );
- return '<div class="accordion"><div class="ac-btn"><h3>'. $title .'</h3></div><div class="ac-content">' . do_shortcode($content) . '</div></div>';
- }
- add_shortcode('accordion', 'accordion_shortcode');
- /*-----------------------------------------------------------------------------------*/
- /* Tabs
- /*-----------------------------------------------------------------------------------*/
- function delicious_tab_group( $atts, $content ){
- $GLOBALS['tab_count'] = 0;
- do_shortcode( $content );
- if(!isset($GLOBALS['tabs'])) {
- $GLOBALS['tabs'] = "Assigned";
- }
- $return ="";
- if( is_array( $GLOBALS['tabs'] ) ){
- $i=1;
- foreach( $GLOBALS['tabs'] as $tab ){
- $tabs[] = '<li><a class="" href="#tab'. $i .'">'.$tab['title'].'</a></li>';
- $panes[] = '<div id="tab'. $i .'" class="tab-content">'.$tab['content'].'</div>';
- $i++;
- }
- $return = "\n".'<div class="tabs-wrapper"><ul class="tabs">'.implode( "\n", $tabs ).'</ul>'."\n".'<div class="tabs-container">'.implode( "\n", $panes ).'</div></div>'."\n";
- }
- return $return;
- }
- add_shortcode( 'tabgroup', 'delicious_tab_group' );
- function delicious_tab( $atts, $content ){
- extract(shortcode_atts(array(
- 'title' => 'Tab %d'
- ), $atts));
- $x = $GLOBALS['tab_count'];
- $GLOBALS['tabs'][$x] = array( 'title' => sprintf( $title, $GLOBALS['tab_count'] ), 'content' => $content );
- $GLOBALS['tab_count']++;
- }
- add_shortcode( 'tab', 'delicious_tab' );
- /*-----------------------------------------------------------------------------------*/
- /* Pricing Table
- /*-----------------------------------------------------------------------------------*/
- function delicious_pricing_table( $atts, $content = null ) {
- global $dt_table;
- extract(shortcode_atts(array(
- 'columns' => '5'
- ), $atts));
- $columnsNr = '';
- switch ($columns) {
- case '2':
- $columnsNr .= 'table-2';
- break;
- case '3':
- $columnsNr .= 'table-3';
- break;
- case '4':
- $columnsNr .= 'table-4';
- break;
- case '5':
- $columnsNr .= 'table-5';
- break;
- case '6':
- $columnsNr .= 'table-6';
- break;
- }
- do_shortcode($content);
- $columnContent = '';
- $noBorder = '';
- if (is_array($dt_table)) {
- for ($i = 0; $i < count($dt_table); $i++) {
- $columnClass = 'column'; $n = $i + 1;
- $columnClass .= ( $n % 2 ) ? '' : ' even-column';
- $columnClass .= ( $n == count($dt_table) ) ? ' last-column' : '';
- $columnClass .= ( $n == 1 ) ? ' first-column' : '';
- $noBorder .= 'no-border' ;
- $columnContent .= '<li class="'.$columnClass.' '.$columnsNr.'">';
- if ((empty($dt_table[$i]['title'])) || (empty($dt_table[$i]['price'])) || ($dt_table[$i]['title'] == '') || ($dt_table[$i]['price'] == '') ) {
- $columnContent .= '<div class="column-header '.$noBorder.'"><h3>'.$dt_table[$i]['title'].'</h3><span>'.$dt_table[$i]['price'].'</span></div>'; }
- else {
- $columnContent .= '<div class="column-header"><h3>'.$dt_table[$i]['title'].'</h3><span>'.$dt_table[$i]['price'].'</span></div>'; }
- $columnContent .= '<div class="column-body">'.str_replace(array("\r\n", "\n", "\r", "<p></p>"), array("", "", "", ""), $dt_table[$i]['content']).'</div>';
- $columnContent .= '</li>';
- }
- $finished_table = '<ul class="pricing-table">'.$columnContent.'</ul>';
- }
- $dt_table = '';
- return $finished_table;
- }
- add_shortcode('pricing-table', 'delicious_pricing_table');
- // Single Column
- function shortcode_pricing_column( $atts, $content = null ) {
- global $dt_table;
- extract(shortcode_atts(array(
- 'title' => '',
- 'price' => ''
- ), $atts));
- $column['title'] = $title;
- $column['price'] = $price;
- $column['content'] = do_shortcode($content);
- $dt_table[] = $column;
- }
- add_shortcode('pricing-column', 'shortcode_pricing_column');
- /*-----------------------------------------------------------------------------------*/
- /* Cross Button for Pricing Table
- /*-----------------------------------------------------------------------------------*/
- function cross_shortcode() {
- return '<img src="'.get_template_directory_uri().'/images/cross-button.png" alt="" />';
- }
- add_shortcode( 'cross', 'cross_shortcode' );
- /*-----------------------------------------------------------------------------------*/
- /* Tick Button for Pricing Table
- /*-----------------------------------------------------------------------------------*/
- function tick_shortcode() {
- return '<img src="'.get_template_directory_uri().'/images/tick-button.png" alt="" />';
- }
- add_shortcode( 'tick', 'tick_shortcode' );
- /*-----------------------------------------------------------------------------------*/
- /* Google Map
- /*-----------------------------------------------------------------------------------*/
- function delicious_googlemap($atts, $content = null) {
- extract(shortcode_atts(array(
- "width" => '940',
- "height" => '300',
- "src" => ''
- ), $atts));
- return '<div class="contact-map"><iframe width="'.$width.'" height="'.$height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.$src.'&output=embed"></iframe></div>';
- }
- add_shortcode("googlemap", "delicious_googlemap");
- /*-----------------------------------------------------------------------------------*/
- /* Services Item
- /*-----------------------------------------------------------------------------------*/
- function delicious_services($atts, $content = null) {
- extract(shortcode_atts(array(
- "id" => ''
- ), $atts));
- global $post;
- $args = array(
- 'post_type' => 'services',
- 'posts_per_page' => 1,
- 'p' => $id
- );
- $my_query = new WP_Query($args);
- if( $my_query->have_posts() ) :
- while ($my_query->have_posts()) : $my_query->the_post();
- $retour ='';
- $s_items = get_post_meta( get_the_ID(), 'haze_service_item_align', false );
- if ( in_array( 'left', $s_items ) )
- {
- $retour .='<div class="service-item content-left">';
- }
- else
- {
- $retour .='<div class="service-item content-center">';
- }
- $retour .= get_the_post_thumbnail( $id, 'service-thumb', array('class' => 'service-img') );
- $retour .='<h3 class="service">'.get_the_title().'</h3>';
- $retour .='<p class="clear">'.get_the_content().'</p>';
- $retour .='</div>';
- endwhile; else:
- $retour ='';
- $retour .= "nothing found.";
- endif;
- //Reset Query
- wp_reset_query();
- return $retour;
- }
- add_shortcode("service", "delicious_services");
- /*-----------------------------------------------------------------------------------*/
- /* Team Member
- /*-----------------------------------------------------------------------------------*/
- function delicious_member($atts, $content = null) {
- extract(shortcode_atts(array(
- "id" => ''
- ), $atts));
- global $post;
- $args = array(
- 'post_type' => 'team',
- 'posts_per_page' => 1,
- 'p' => $id
- );
- $team_query = new WP_Query($args);
- if( $team_query->have_posts() ) :
- while ($team_query->have_posts()) : $team_query->the_post();
- $position = get_post_meta($post->ID, 'haze_position', true);
- $twitter = get_post_meta($post->ID, 'haze_twitter', true);
- $facebook = get_post_meta($post->ID, 'haze_facebook', true);
- $linkedin = get_post_meta($post->ID, 'haze_linkedin', true);
- $retour ='';
- $retour .='<div class="team-member">';
- $retour .='<div class="team-details">';
- $retour .= get_the_post_thumbnail( $id, 'member-thumb', array('class' => 'team-avatar') );
- $retour .='<div class="team-social">';
- if(!empty($twitter)) {
- $retour .='<a class="team-twitter" href="'.$twitter.'"><img src="'. get_template_directory_uri() .'/images/team-twitter.png" alt="Twitter Page" /></a>'; }
- if(!empty($facebook)) {
- $retour .='<a class="team-facebook" href="'.$facebook.'"><img src="'. get_template_directory_uri() .'/images/team-facebook.png" alt="Facebook Profile" /></a>'; }
- if(!empty($linkedin)) {
- $retour .='<a class="team-linkedin" href="'.$linkedin.'"><img src="'. get_template_directory_uri() .'/images/team-linkedin.png" alt="Linkedin Profile" /></a>'; }
- $retour .='</div>';
- $retour .='</div>';
- $retour .='<div class="team-text">';
- $retour .='<h3>';
- $retour .= get_the_title();
- if(!empty($position)) {
- $retour .=' - <span>'.$position.'</span>'; }
- $retour .='</h3>';
- $retour .='</div>';
- $retour .='<p>'.get_the_content().'</p>';
- $retour .='</div>';
- endwhile; else:
- $retour ='';
- $retour .= "nothing found.";
- endif;
- //Reset Query
- wp_reset_query();
- return $retour;
- }
- add_shortcode("team-member", "delicious_member");
- /*-----------------------------------------------------------------------------------*/
- /* Shortcode Filter
- /*-----------------------------------------------------------------------------------*/
- add_filter('the_content', 'do_shortcode', 7);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement