Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @package Skeleton WordPress Theme Framework
- * @subpackage skeleton
- * @author Simple Themes - www.simplethemes.com
- **/
- function st_one_third( $atts, $content = null ) {
- return '<div class="one_third">' . do_shortcode($content) . '</div>';
- }
- add_shortcode('one_third', 'st_one_third');
- function st_one_third_last( $atts, $content = null ) {
- return '<div class="one_third last">' . do_shortcode($content) . '</div><div class="clear"></div>';
- }
- add_shortcode('one_third_last', 'st_one_third_last');
- function st_two_thirds( $atts, $content = null ) {
- return '<div class="two_thirds">' . do_shortcode($content) . '</div>';
- }
- add_shortcode('two_thirds', 'st_two_thirds');
- function st_two_thirds_last( $atts, $content = null ) {
- return '<div class="two_thirds last">' . do_shortcode($content) . '</div><div class="clear"></div>';
- }
- add_shortcode('two_thirds_last', 'st_two_thirds_last');
- // 1-4 col
- function st_one_half( $atts, $content = null ) {
- return '<div class="one_half">' . do_shortcode($content) . '</div>';
- }
- add_shortcode('one_half', 'st_one_half');
- function st_one_half_last( $atts, $content = null ) {
- return '<div class="one_half last">' . do_shortcode($content) . '</div><div class="clear"></div>';
- }
- add_shortcode('one_half_last', 'st_one_half_last');
- function st_one_fourth( $atts, $content = null ) {
- return '<div class="one_fourth">' . do_shortcode($content) . '</div>';
- }
- add_shortcode('one_fourth', 'st_one_fourth');
- function st_one_fourth_last( $atts, $content = null ) {
- return '<div class="one_fourth last">' . do_shortcode($content) . '</div><div class="clear"></div>';
- }
- add_shortcode('one_fourth_last', 'st_one_fourth_last');
- function st_three_fourths( $atts, $content = null ) {
- return '<div class="three_fourths">' . do_shortcode($content) . '</div>';
- }
- add_shortcode('three_fourths', 'st_three_fourths');
- function st_three_fourths_last( $atts, $content = null ) {
- return '<div class="three_fourths last">' . do_shortcode($content) . '</div><div class="clear"></div>';
- }
- add_shortcode('three_fourths_last', 'st_three_fourths_last');
- function st_one_fifth( $atts, $content = null ) {
- return '<div class="one_fifth">' . do_shortcode($content) . '</div>';
- }
- add_shortcode('one_fifth', 'st_one_fifth');
- function st_two_fifth( $atts, $content = null ) {
- return '<div class="two_fifth">' . do_shortcode($content) . '</div>';
- }
- add_shortcode('two_fifth', 'st_two_fifth');
- function st_three_fifth( $atts, $content = null ) {
- return '<div class="three_fifth">' . do_shortcode($content) . '</div>';
- }
- add_shortcode('three_fifth', 'st_three_fifth');
- function st_four_fifth( $atts, $content = null ) {
- return '<div class="four_fifth">' . do_shortcode($content) . '</div>';
- }
- add_shortcode('four_fifth', 'st_four_fifth');
- //
- function st_one_fifth_last( $atts, $content = null ) {
- return '<div class="one_fifth last">' . do_shortcode($content) . '</div><div class="clear"></div>';
- }
- add_shortcode('one_fifth_last', 'st_one_fifth_last');
- function st_two_fifth_last( $atts, $content = null ) {
- return '<div class="two_fifth last">' . do_shortcode($content) . '</div><div class="clear"></div>';
- }
- add_shortcode('two_fifth_last', 'st_two_fifth_last');
- function st_three_fifth_last( $atts, $content = null ) {
- return '<div class="three_fifth last">' . do_shortcode($content) . '</div><div class="clear"></div>';
- }
- add_shortcode('three_fifth_last', 'st_three_fifth_last');
- function st_four_fifth_last( $atts, $content = null ) {
- return '<div class="four_fifth last">' . do_shortcode($content) . '</div><div class="clear"></div>';
- }
- add_shortcode('four_fifth_last', 'st_four_fifth_last');
- // 1-6 col
- // one_sixth
- function st_one_sixth( $atts, $content = null ) {
- return '<div class="one_sixth">' . do_shortcode($content) . '</div>';
- }
- add_shortcode('one_sixth', 'st_one_sixth');
- function st_one_sixth_last( $atts, $content = null ) {
- return '<div class="one_sixth last">' . do_shortcode($content) . '</div><div class="clear"></div>';
- }
- add_shortcode('one_sixth_last', 'st_one_sixth_last');
- // five_sixth
- function st_five_sixth( $atts, $content = null ) {
- return '<div class="five_sixth">' . do_shortcode($content) . '</div>';
- }
- add_shortcode('five_sixth', 'st_five_sixth');
- function st_five_sixth_last( $atts, $content = null ) {
- return '<div class="five_sixth last">' . do_shortcode($content) . '</div><div class="clear"></div>';
- }
- add_shortcode('five_sixth_last', 'st_five_sixth_last');
- // Callouts
- function st_callout( $atts, $content = null ) {
- extract(shortcode_atts(array(
- 'width' => '',
- 'align' => ''
- ), $atts));
- $style;
- if ($width || $align) {
- $style .= 'style="';
- if ($width) $style .= 'width:'.$width.'px;';
- if ($align == 'left' || 'right') $style .= 'float:'.$align.';';
- if ($align == 'center') $style .= 'margin:0px auto;';
- $style .= '"';
- }
- return '<div class="cta" '.$style.'>' . do_shortcode($content) . '</div><div class="clear"></div>';
- }
- add_shortcode('callout', 'st_callout');
- // Buttons
- function st_button( $atts, $content = null ) {
- extract(shortcode_atts(array(
- 'link' => '',
- 'size' => 'medium',
- 'color' => '',
- 'target' => '_self',
- 'caption' => '',
- 'align' => 'right'
- ), $atts));
- $button;
- $button .= '<div class="button '.$size.' '. $align.'">';
- $button .= '<a target="'.$target.'" class="button" name="modal" '.$color.'" href="'.$link.'">';
- $button .= $content;
- if ($caption != '') {
- $button .= '<br /><span class="btn_caption">'.$caption.'</span>';
- };
- $button .= '</a></div>';
- return $button;
- }
- add_shortcode('button', 'st_button');
- // Tabs
- add_shortcode( 'tabgroup', 'st_tabgroup' );
- function st_tabgroup( $atts, $content ){
- $GLOBALS['tab_count'] = 0;
- do_shortcode( $content );
- if( is_array( $GLOBALS['tabs'] ) ){
- foreach( $GLOBALS['tabs'] as $tab ){
- $tabs[] = '<li><a href="#'.$tab['id'].'">'.$tab['title'].'</a></li>';
- $panes[] = '<li id="'.$tab['id'].'Tab">'.$tab['content'].'</li>';
- }
- $return = "\n".'<!-- the tabs --><ul class="tabs">'.implode( "\n", $tabs ).'</ul>'."\n".'<!-- tab "panes" --><ul class="tabs-content">'.implode( "\n", $panes ).'</ul>'."\n";
- }
- return $return;
- }
- add_shortcode( 'tab', 'st_tab' );
- function st_tab( $atts, $content ){
- extract(shortcode_atts(array(
- 'title' => '%d',
- 'id' => '%d'
- ), $atts));
- $x = $GLOBALS['tab_count'];
- $GLOBALS['tabs'][$x] = array(
- 'title' => sprintf( $title, $GLOBALS['tab_count'] ),
- 'content' => do_shortcode($content),
- 'id' => $id );
- $GLOBALS['tab_count']++;
- }
- // Toggle
- function st_toggle( $atts, $content = null ) {
- extract(shortcode_atts(array(
- 'title' => '',
- 'style' => 'list'
- ), $atts));
- output;
- $output .= '<div class="'.$style.'"><p class="trigger"><a href="#">' .$title. '</a></p>';
- $output .= '<div class="toggle_container"><div class="block">';
- $output .= do_shortcode($content);
- $output .= '</div></div></div>';
- return $output;
- }
- add_shortcode('toggle', 'st_toggle');
- /*-----------------------------------------------------------------------------------*/
- // Latest Posts
- // Example Use: [latest excerpt="true" thumbs="true" width="50" height="50" num="5" cat="8,10,11"]
- /*-----------------------------------------------------------------------------------*/
- function st_latest($atts, $content = null) {
- extract(shortcode_atts(array(
- "offset" => '',
- "num" => '5',
- "thumbs" => 'false',
- "excerpt" => 'false',
- "length" => '500',
- "morelink" => '',
- "width" => '100',
- "height" => '100',
- "type" => 'post',
- "parent" => '',
- "cat" => '',
- "orderby" => 'date',
- "order" => 'DESC'
- ), $atts));
- global $post;
- $do_not_duplicate[] = $post->ID;
- $args = array(
- 'post__not_in' => $do_not_duplicate,
- 'cat' => $cat,
- 'post_type' => $type,
- 'post_parent' => $parent,
- 'showposts' => $num,
- 'orderby' => $orderby,
- 'offset' => $offset,
- 'order' => $order
- );
- // query
- $myposts = new WP_Query($args);
- // container
- $result='<div id="category-'.$cat.'" class="latestposts">';
- while($myposts->have_posts()) : $myposts->the_post();
- // item
- $result.='<div class="latest-item clearfix">';
- // title
- if ($excerpt == 'true') {
- $result.='
- <h4>'.the_title("","",false).'
- </h4>
- ';
- } else {
- $result.='<div class="latest-title"><a href="'.get_permalink().'">'.the_title("","",false).'</a></div>';
- }
- // thumbnail
- if (has_post_thumbnail() && $thumbs == 'true') {
- $result.= '<img alt="'.get_the_title().'" class="alignleft latest-img" src="'.get_bloginfo('template_directory').'/thumb.php?src='.get_image_path().'&h='.$height.'&w='.$width.'"/>';
- }
- // excerpt
- if ($excerpt == 'true') {
- // allowed tags in excerpts
- $allowed_tags = '<a>,<i>,<em>,<b>,<strong>,<ul>,<ol>,<li>,<blockquote>,<img>,<span>,<p>';
- // filter the content
- $text = preg_replace('/\[.*\]/', '', strip_tags(get_the_excerpt(), $allowed_tags));
- // remove the more-link
- $pattern = '/(<a.*?class="more-link"[^>]*>)(.*?)(<\/a>)/';
- // display the new excerpt
- $content = preg_replace($pattern,"", $text);
- $result.= '
- <div class="latest-excerpt">
- <div class="my_room_meta">
- '.the_meta().'
- </div>
- '.st_limit_words($content,$length).'
- </div>';
- }
- // excerpt
- if ($morelink) {
- $result.= '<a class="more-link" href="'.get_permalink().'">L�s mer</a>';
- }
- // item close
- $result.='
- </div>
- ';
- endwhile;
- wp_reset_postdata();
- // container close
- $result.='</div>';
- return $result;
- }
- add_shortcode("latest", "st_latest");
- // Example Use: [latest excerpt="true" thumbs="true" width="50" height="50" num="5" cat="8,10,11"]
- /*-----------------------------------------------------------------------------------*/
- // Creates an additional hook to limit the excerpt
- /*-----------------------------------------------------------------------------------*/
- function st_limit_words($string, $word_limit) {
- // creates an array of words from $string (this will be our excerpt)
- // explode divides the excerpt up by using a space character
- $words = explode(' ', $string);
- // this next bit chops the $words array and sticks it back together
- // starting at the first word '0' and ending at the $word_limit
- // the $word_limit which is passed in the function will be the number
- // of words we want to use
- // implode glues the chopped up array back together using a space character
- return implode(' ', array_slice($words, 0, $word_limit));
- }
- // Related Posts - [related_posts]
- add_shortcode('related_posts', 'st_related_posts');
- function st_related_posts( $atts ) {
- extract(shortcode_atts(array(
- 'limit' => '5',
- ), $atts));
- global $wpdb, $post, $table_prefix;
- if ($post->ID) {
- $retval = '<div class="st_relatedposts">';
- $retval .= '<h4>Related Posts</h4>';
- $retval .= '<ul>';
- // Get tags
- $tags = wp_get_post_tags($post->ID);
- $tagsarray = array();
- foreach ($tags as $tag) {
- $tagsarray[] = $tag->term_id;
- }
- $tagslist = implode(',', $tagsarray);
- // Do the query
- $q = "SELECT p.*, count(tr.object_id) as count
- FROM $wpdb->term_taxonomy AS tt, $wpdb->term_relationships AS tr, $wpdb->posts AS p WHERE tt.taxonomy ='post_tag' AND tt.term_taxonomy_id = tr.term_taxonomy_id AND tr.object_id = p.ID AND tt.term_id IN ($tagslist) AND p.ID != $post->ID
- AND p.post_status = 'publish'
- AND p.post_date_gmt < NOW()
- GROUP BY tr.object_id
- ORDER BY count DESC, p.post_date_gmt DESC
- LIMIT $limit;";
- $related = $wpdb->get_results($q);
- if ( $related ) {
- foreach($related as $r) {
- $retval .= '<li><a title="'.wptexturize($r->post_title).'" href="'.get_permalink($r->ID).'">'.wptexturize($r->post_title).'</a></li>';
- }
- } else {
- $retval .= '
- <li>No related posts found</li>';
- }
- $retval .= '</ul>';
- $retval .= '</div>';
- return $retval;
- }
- return;
- }
- // Break
- function st_break( $atts, $content = null ) {
- return '<div class="clear"></div>';
- }
- add_shortcode('clear', 'st_break');
- // Line Break
- function st_linebreak( $atts, $content = null ) {
- return '<hr /><div class="clear"></div>';
- }
- add_shortcode('clearline', 'st_linebreak');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement