'5', 'style' => '1' ), $atts ) ); $multitask = ' '; $multitask.= ''; return $multitask; } add_shortcode('featured-posts', 'featured_posts'); /////////////////GALLERIES function featured_galleries($atts, $content = null) { global $post, $wpdb, $wp_query, $query_string; extract( shortcode_atts( array( 'number' => '5', 'style' => '1' ), $atts ) ); $multitask = ' '; $multitask.= ''; return $multitask; } add_shortcode('featured-galleries', 'featured_galleries'); //PORTFOLIOS function featured_portfolios($atts, $content = null) { global $post, $wpdb, $wp_query, $query_string; extract( shortcode_atts( array( 'number' => '5', 'style' => '1' ), $atts ) ); $multitask = ' '; $multitask.= ''; return $multitask; } add_shortcode('featured-portfolios', 'featured_portfolios'); //PRODUCTS function featured_products($atts, $content = null) { global $post, $wpdb, $wp_query, $query_string; extract( shortcode_atts( array( 'number' => '5', 'style' => '1' ), $atts ) ); $multitask = ' '; $multitask.= ''; return $multitask; } add_shortcode('featured-products', 'featured_products'); //SERVICES function featured_services($atts, $content = null) { global $post, $wpdb, $wp_query, $query_string; extract( shortcode_atts( array( 'number' => '5', 'style' => '1' ), $atts ) ); $multitask = ' '; $multitask.= ''; return $multitask; } add_shortcode('featured-services', 'featured_services'); //Testimonials function testimonials($atts, $content = null) { global $post, $wpdb, $wp_query, $query_string; extract( shortcode_atts( array( 'number' => '3', 'stylebox' => '1', 'stylequote' => '1', 'quotecolor' => 'gray' ), $atts ) ); $multitask = ' '; $multitask.= ''; return $multitask; } add_shortcode('testimonials', 'testimonials'); add_filter( 'widget_text', 'shortcode_unautop'); add_filter( 'widget_text', 'do_shortcode'); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function featured_wtg( $atts, $content = null ){ global $wpdb,$post; extract( shortcode_atts( array( 'type' => 'product', 'columns'=>"3", 'excerpt'=>"true", 'fontsize'=>"12" ), $atts ) ); $options['post_type']='wts'.$type; $options['posts_per_page']=-1; // $options['numberposts']=999; // $get_posts = new WP_Query($options); // var_dump($get_posts); $html=''; return $html; } add_shortcode('featured', 'featured_wtg'); /*******************************/ /* Custom Post Type - Gallery */ /*****************************/ function getPostTypeGallery($atts, $content = null) { global $post, $wpdb; extract( shortcode_atts( array( 'taxonomy' => '', 'wptg_post_type' => 'gallery', 'style'=>"shadow" ), $atts ) ); $multitask = ''; if($wptg_post_type=='gallery'){ $multitask .= ' '; } if($taxonomy == ''){ $multitask .= ''; } switch($wptg_post_type){ case 'gallery': $taxo = 'galleries'; $post_type = 'wtsgallery'; break; case 'services': $taxo = 'brochures'; $post_type = 'wtsservice'; break; case 'portfolio': $taxo = 'portfolios'; $post_type = 'wtsportfolio'; break; } $results = get_terms($taxo); ob_start(); if($taxonomy == ''){?>
$post_type, $taxo=>$taxonomy, 'showposts' => -1)); if (have_posts()): while ( have_posts() ): the_post();{ $term_slugs = wp_get_post_terms($post->ID, $taxo, array("fields" => "slugs")); $cats = implode(" ", $term_slugs); switch($wptg_post_type){ case 'gallery': $linkAttr = array('href'=> 'global', 'class'=> 'class="popup"', 'rel'=>'rel="all_items"'); break; case 'services': case 'portfolio': $linkAttr = array('href'=> get_permalink( $id ), 'class'=> '', 'rel'=>''); break; }?>

ID);?>
'.ob_get_clean(); $multitask .= '
'; $multitask .= '
'; return $multitask; } add_shortcode('wptg-cpt', 'getPostTypeGallery'); add_filter( 'widget_text', 'shortcode_unautop'); add_filter( 'widget_text', 'do_shortcode'); /** * Copyright (c) 2011 Host Like Toast * All rights reserved. * * "Wordpress Bootstrap CSS" is distributed under the GNU General Public License, Version 2, * June 1991. Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin * St, Fifth Floor, Boston, MA 02110, USA * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ class HLT_BootstrapShortcodes { protected $sTwitterBootstrapVersion; public function __construct( $sVersion = '2' ) { $aMethods = get_class_methods( $this ); $aExclude = array( 'idHtml', 'def', 'noEmptyHtml' ); foreach ( $aMethods as $sMethod ) { if ( !in_array( $sMethod, $aExclude ) ) { add_shortcode( 'TBS_'.strtoupper( $sMethod ), array( $this, $sMethod ) ); } } $this->sTwitterBootstrapVersion = $sVersion; add_filter( 'the_content', array( $this, 'filterTheContent' ), 10 ); add_filter( 'the_content', array( $this, 'filterTheContentToFixNamedAnchors' ), 99 ); /** * Move the wpautop until after the shortcodes have been run! * remove_filter( 'the_content', 'wpautop' ); * add_filter( 'the_content', 'wpautop' , 99 ); * add_filter( 'the_content', 'shortcode_unautop', 100 ); */ /** * Disable wpautop globally! * remove_filter( 'the_content', 'wpautop' ); * remove_filter( 'comment_text', 'wpautop' ); */ } /** * Prints the necessary HTML for Twitter Bootstrap Labels * * Class may be one of: Default Primary Info Success Danger * * @param $inaAtts * @param $insContent */ public function button( $inaAtts = array(), $insContent = '' ) { $sElementType = 'a'; if ( !isset( $inaAtts['link'] ) ) { $sElementType = 'button'; } $this->def( $inaAtts, 'id' ); $this->def( $inaAtts, 'class', '' ); $this->def( $inaAtts, 'style' ); $this->def( $inaAtts, 'link_title' ); $this->def( $inaAtts, 'value', '0' ); if ( $this->sTwitterBootstrapVersion == '2' && !preg_match( '/^btn-/', $inaAtts['class'] ) ) { $inaAtts['class'] = 'btn-'.$inaAtts['class']; } $sReturn = '<'.$sElementType.' '.$this->noEmptyHtml( $inaAtts['style'], 'style' ).' class="btn '.$inaAtts['class']. '"'.$this->idHtml( $inaAtts['id'] ); if ( $sElementType == 'a' ) { $sReturn .= ' href="'.$inaAtts['link'].'" title="' .$inaAtts['link_title']. '"'; } else { $sReturn .= ' type="button" value="'.$inaAtts['value']. '"'; } $sReturn .= '>'.$this->doShortcode( $insContent ).''; return $sReturn; } /** * Prints the necessary HTML for Twitter Bootstrap Labels * * class may be one of: default, success, warning, important, notice * * @param $inaAtts * @param $insContent */ public function label( $inaAtts = array(), $insContent = '' ) { $this->def( $inaAtts, 'style' ); $this->def( $inaAtts, 'id' ); $this->def( $inaAtts, 'class' ); if ( $this->sTwitterBootstrapVersion == '2' && !preg_match( '/^label-/', $inaAtts['class'] ) ) { $inaAtts['class'] = 'label-'.$inaAtts['class']; } $sReturn = 'noEmptyHtml( $inaAtts['style'], 'style' ).' class="label '.$inaAtts['class'].'"'.$this->idHtml( $inaAtts['id'] ).'>'.$this->doShortcode( $insContent ).''; return $sReturn; } public function blockquote( $inaAtts = array(), $insContent = '' ) { $this->def( $inaAtts, 'style' ); $this->def( $inaAtts, 'id' ); $this->def( $inaAtts, 'class' ); $this->def( $inaAtts, 'source' ); if ($inaAtts['source'] != '') { $inaAtts['source'] = ''.$inaAtts['source'].''; } $sReturn = '
noEmptyHtml( $inaAtts['style'], 'style' ).' '.$this->noEmptyHtml( $inaAtts['class'], 'class' ).' '.$this->idHtml( $inaAtts['id'] ).'>

'.$this->doShortcode( $insContent ).'

'.$inaAtts['source'].'
'; return $sReturn; } /** * class may be one of: error, warning, success, info * * @param $inaAtts * @param $insContent */ public function alert( $inaAtts = array(), $insContent = '' ) { $this->def( $inaAtts, 'style' ); $this->def( $inaAtts, 'id' ); $this->def( $inaAtts, 'class' ); $this->def( $inaAtts, 'type', 'alert' ); //Twitter 1.4.0 only supports this one variation if ( $this->sTwitterBootstrapVersion == '1' ) { $inaAtts['type'] ='alert-message'; } if ( $this->sTwitterBootstrapVersion == '2' && !preg_match( '/^alert-/', $inaAtts['class'] ) ) { $inaAtts['class'] = 'alert-'.$inaAtts['class']; } $sReturn = '
noEmptyHtml( $inaAtts['style'], 'style' ) .' class="'.$inaAtts['type'].' '.$inaAtts['class'].'" ' .$this->noEmptyHtml( $inaAtts['id'], 'id' ).'>'.$this->doShortcode($insContent).'
'; return $sReturn ; } /** * DEPRECATED: To BE EVENTUALLY REMOVED AS UNSUPPORTED IN Twitter Bootstrap 2+ * * Uses alert() function but just adds the class "block-message" * * class may be one of: error, warning, success, info * * @param $inaAtts * @param $insContent */ public function block( $inaAtts = array(), $insContent = '' ) { $this->def( $inaAtts, 'style' ); $this->def( $inaAtts, 'id' ); $this->def( $inaAtts, 'class' ); return $this->doShortcode( '[TBS_ALERT '.'class="block-message ' .$inaAtts['class'].'" ' .$this->noEmptyHtml( $inaAtts['id'], 'id' ).' ' .$this->noEmptyHtml( $inaAtts['style'], 'style' ).']'.$insContent.'[/TBS_ALERT]' ); } public function code( $inaAtts = array(), $insContent = '' ) { $this->def( $inaAtts, 'style' ); $this->def( $inaAtts, 'id' ); $sReturn = '
idHtml( $inaAtts['id'] ).' '.$this->noEmptyHtml( $inaAtts['style'], 'style' ).'>'.$insContent.'
'; return $sReturn; } /** * DEPRECATED: To BE EVENTUALLY REMOVED AS UNSUPPORTED IN Twitter Bootstrap 2+ * * Options for 'placement' are above | below | left | right * * @param $inaAtts * @param $insContent */ public function twipsy( $inaAtts = array(), $insContent = '' ) { return $this->tooltip($inaAtts, $insContent); } /** * Options for 'placement' are top | bottom | left | right */ public function tooltip( $inaAtts = array(), $insContent = '' ) { $this->def( $inaAtts, 'style' ); $this->def( $inaAtts, 'id' ); $this->def( $inaAtts, 'class' ); $this->def( $inaAtts, 'placement', 'top' ); $this->def( $inaAtts, 'title' ); $this->def( $inaAtts, 'rel', 'tooltip' ); //could set to 'twipsy' for bootstrap 1.4.0 //backward comnpatibility with Twitter Bootstrap v1.0 if ( $this->sTwitterBootstrapVersion == '1' ) { $inaAtts['rel'] = 'twipsy'; if ( $inaAtts['placement'] == 'top' ) { $inaAtts['placement'] = 'above'; } if ( $inaAtts['placement'] == 'bottom' ) { $inaAtts['placement'] = 'below'; } } else { //Twitter Bootstrap v2.0 changed position names if ( $inaAtts['placement'] == 'above' ) { $inaAtts['placement'] = 'top'; } if ( $inaAtts['placement'] == 'below' ) { $inaAtts['placement'] = 'bottom'; } } $sReturn = $insContent; if ( $inaAtts['title'] != '' ) { $sReturn = 'noEmptyHtml( $inaAtts['id'], 'id' ) .$this->noEmptyHtml( $inaAtts['class'], 'class' ) .$this->noEmptyHtml( $inaAtts['style'], 'style' ).'>'.$this->doShortcode($insContent).''; } return $sReturn; } /** * Options for 'placement' are top | bottom | left | right */ public function popover( $inaAtts = array(), $insContent = '' ) { $this->def( $inaAtts, 'style' ); $this->def( $inaAtts, 'id' ); $this->def( $inaAtts, 'class' ); $this->def( $inaAtts, 'placement', 'right' ); $this->def( $inaAtts, 'title' ); $this->def( $inaAtts, 'content' ); $sReturn = 'noEmptyHtml( $inaAtts['id'], 'id' ) .$this->noEmptyHtml( $inaAtts['class'], 'class' ) .$this->noEmptyHtml( $inaAtts['style'], 'style' ).'>'.$this->doShortcode( $insContent ).''; return $sReturn; } public function dropdown( $inaAtts = array(), $insContent = '' ) { $this->def( $inaAtts, 'name', 'Undefined' ); $insContent = ' '; return $this->doShortcode( $insContent ); } /** * This is used by both dropdown and tabgroup/tab */ public function dropdown_option( $inaAtts = array(), $insContent = '' ) { $this->def( $inaAtts, 'name', 'Undefined' ); $this->def( $inaAtts, 'link', '#' ); $insContent = '
  • '.$inaAtts['name'].'
  • '; return $this->doShortcode( $insContent ); } public function tabgroup( $inaAtts = array(), $insContent ) { $aTabs = array(); $aMatches = array(); $nOffsetAdjustment = 0; $i = 0; /** * Because there are 2 separate sections of HTML for the tabs to work, we need to * look for the TBS_TAB shortcodes now, to create the buttons. The $insContent is * passed onwards and will be used to create the tab content panes. * * PREG_OFFSET_CAPTURE requires PHP 4.3.0 */ if ( preg_match_all( '/\[TBS_TAB([^\]]*)\]/', $insContent, $aMatches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE ) ) { foreach ( $aMatches as $aMatch ) { //aMatch = Array ( [0] => Array ( [0] => [TBS_TAB page_id="53" name="test1"] [1] => 1 ) [1] => Array ( [0] => page_id="53" name="test1" [1] => 9 ) ) if ( !isset( $aMatch[1] ) ) { continue; } $sName = "Undefined"; if ( preg_match( '/name\s*=\s*("|\')(.+)\g{-2}+/i', $aMatch[1][0], $aSubMatches ) ) { $sName = $aSubMatches[2]; } $sType = "page"; if ( preg_match( '/type\s*=\s*("|\')(page|dropdown)\g{-2}+/i', $aMatch[1][0], $aSubMatches ) ) { $sType = $aSubMatches[2]; } if ( $sType == "page" ) { $aTabs[] = '
  • '.$sName.'
  • '; } else { /** * Handle the dropdowns as the tab() shortcode handles the tab contents only */ $nOffsetTemp = $aMatch[0][1] + $nOffsetAdjustment; $sRemainder = substr( $insContent, $nOffsetTemp + strlen( $aMatch[0][0] ) ); $nPos = strpos( $sRemainder, '[/TBS_TAB]' ); $sRemainder = substr( $sRemainder, 0, $nPos ); // match all dropdowns until [/TBS_TAB] if ( !preg_match_all( '/\[TBS_DROPDOWN_OPTION([^\]]*)\]/', $sRemainder, $aSubMatches, PREG_SET_ORDER ) ) { continue; } $aOptions = array(); foreach ( $aSubMatches as $aSubMatch ) { $sLink = '#'; if ( preg_match( '/link\s*=\s*("|\')(.*)\g{-2}+/i', $aSubMatch[1][0], $aSubMatches ) ) { $sLink = $aSubMatches[2]; } $sName = 'Undefined'; if ( preg_match( '/name\s*=\s*("|\')(.*)\g{-2}+/i', $aSubMatch[1][0], $aSubMatches ) ) { $sName = $aSubMatches[2]; } $aOptions[] = '
  • '.$sName.'
  • '; } $aTabs[] = ' '; } $nOffset = $aMatch[0][1] + $nOffsetAdjustment; $nLength = strlen( $aMatch[0][0] ); $sAddition = ' id="TbsTabId'.$i.'"'; $insContent = substr_replace( $insContent, '[TBS_TAB'.($aMatch[1][0]).$sAddition.']', $nOffset, $nLength ); $nOffsetAdjustment += strlen( $sAddition ); $i++; } } $insContent = '
      '.implode( "\n", $aTabs ).'
    '.$insContent.'
    '; return $this->doShortcode( $insContent ); } /** * Reference: http://codex.wordpress.org/Function_Reference/get_page */ public function tab( $inaAtts = array(), $insContent = '' ) { $this->def( $inaAtts, 'page_id', 0 ); $this->def( $inaAtts, 'type', 'page' ); // can be either page or dropdown // If this value is never not set, then the tabgroup method didn't do it's job! $this->def( $inaAtts, 'id', 'TbsTabId_' ); // Actually not used as the tab name is used by the TabGroup $this->def( $inaAtts, 'name', 'Undefined' ); if ( $inaAtts['page_id'] > 0 ) { $oPage = get_page( $inaAtts['page_id'] ); if ( !is_null( $oPage ) ) { $insContent = $oPage->post_content; } } $nIndex = intval( str_replace( 'TbsTabId', '', $inaAtts['id'] ) ); $insContent = '
    '.$insContent.'
    '; return $this->doShortcode( $insContent ); } public function row( $inaAtts = array(), $insContent = '' ) { $sReturn = '
    '; $sReturn .= $this->doShortcode( $insContent ); $sReturn .= '
    '; return $sReturn; }//row public function column( $inaAtts = array(), $insContent = '' ) { $this->def( $inaAtts, 'size', 1 ); $this->def( $inaAtts, 'style' ); $this->def( $inaAtts, 'id' ); $this->def( $inaAtts, 'class' ); $sReturn = '
    noEmptyHtml( $inaAtts['id'], 'id' ) .$this->noEmptyHtml( $inaAtts['style'], 'style' ).'>'; $sReturn .= $this->doShortcode( $insContent ); $sReturn .= '
    '; return $sReturn; }//row /** * Public, but should never be directly accessed other than by the WP add_filter method. * @param $insContent */ public function filterTheContent( $insContent = "" ) { // Remove

    's that get added to [TBS...] by wpautop. $insContent = preg_replace( '|(

    \s*)?(\[/?TBS[^\]]+\])(\s*

    )?|', "$2", $insContent ); return $insContent; } public function filterTheContentToFixNamedAnchors( $insContent = "" ) { $sPattern = '/((.*)<\/a>)/'; $insContent = preg_replace( $sPattern, '$1$3', $insContent ); return $insContent; } /** * name collision on "default" */ protected function def( $aSrc, $insKey, $insValue = '' ) { if ( !isset( $aSrc[$insKey] ) ) { $aSrc[$insKey] = $insValue; } } protected function idHtml( $insId ) { return (($insId != '')? ' id="'.$insId.'" ' : '' ); } protected function noEmptyHtml( $insContent, $insAttr ) { return (($insContent != '')? ' '.$insAttr.'="'.$insContent.'" ' : '' ); } /** * Only implemented for possible future customisation * @param unknown_type $insContent */ protected function doShortcode( $insContent ) { return do_shortcode( $insContent ); } } $oShortCodes = new HLT_BootstrapShortcodes('2'); //var_dump($oShortCodes); ?>