'."\n";
}
}
// Replace WP autop formatting
if (!function_exists( "vpthemes_remove_wpautop")) {
function vpthemes_remove_wpautop($content) {
$content = do_shortcode( shortcode_unautop( $content ) );
$content = preg_replace( '#^<\/p>|^
|
$#', '', $content);
return $content;
}
}
/*----------------------------------------------------------------------------------*/
/* Output shortcode JS in footer */
/*----------------------------------------------------------------------------------*/
// Enqueue shortcode JS file.
add_action( 'init', 'vpthemes_enqueue_shortcode_js' );
function vpthemes_enqueue_shortcode_js () {
if ( is_admin() ) {} else {
wp_enqueue_script( 'vpthemes-shortcodes', get_template_directory_uri() . '/functions/js/shortcodes.js', array( 'jquery', 'jquery-ui-tabs' ), true );
} // End IF Statement
} // End vpthemes_enqueue_shortcode_js()
// Check if option to output shortcode JS is active
if (!function_exists( "vpthemes_check_shortcode_js")) {
function vpthemes_check_shortcode_js($shortcode) {
$js = get_option( "vpthemes_sc_js" );
if ( !$js )
vpthemes_add_shortcode_js($shortcode);
else {
if ( !in_array($shortcode, $js) ) {
$js[] = $shortcode;
update_option( "vpthemes_sc_js", $js);
}
}
}
}
// Add option to handle JS output
if (!function_exists( "vpthemes_add_shortcode_js")) {
function vpthemes_add_shortcode_js($shortcode) {
$update = array();
$update[] = $shortcode;
update_option( "vpthemes_sc_js", $update);
}
}
// Output queued shortcode JS in footer
if (!function_exists( "vpthemes_output_shortcode_js")) {
function vpthemes_output_shortcode_js() {
$option = get_option( 'vpthemes_sc_js' );
if ( $option ) {
// Toggle JS output
if ( in_array( 'toggle', $option) ) {
$output = '
';
echo $output;
}
// Reset option
delete_option( 'vpthemes_sc_js' );
}
}
}
add_action( 'wp_footer', 'vpthemes_output_shortcode_js' );
/*----------------------------------------------------------------------------------*/
/* Boxes - box */
/*----------------------------------------------------------------------------------*/
function vpthemes_shortcode_box($atts, $content = null) {
extract(shortcode_atts(array( 'type' => 'normal',
'size' => '',
'style' => '',
'border' => '',
'icon' => ''), $atts));
$custom = '';
if ( $icon == "none" )
$custom = ' style="padding-left:15px;background-image:none;"';
elseif ( $icon )
$custom = ' style="padding-left:50px;background-image:url( '.$icon.' ); background-repeat:no-repeat; background-position:20px 45%;"';
return '
' . do_shortcode( vpthemes_remove_wpautop($content) ) . '
';
}
add_shortcode( 'box', 'vpthemes_shortcode_box' );
/*----------------------------------------------------------------------------------*/
/* Buttons - button */
/*----------------------------------------------------------------------------------*/
function vpthemes_shortcode_button($atts, $content = null) {
extract(shortcode_atts(array( 'size' => '',
'style' => '',
'bg_color' => '',
'color' => '',
'border' => '',
'text' => '',
'class' => '',
'link' => '#',
'window' => ''), $atts));
// Set custom background and border color
$color_output = '';
if ( $color ) {
if ( $color == "red" OR
$color == "orange" OR
$color == "green" OR
$color == "aqua" OR
$color == "teal" OR
$color == "purple" OR
$color == "pink" OR
$color == "silver"
) {
$class .= " ".$color;
} else {
if ( $border )
$border_out = $border;
else
$border_out = $color;
$color_output = 'style="background:'.$color.';border-color:'.$border_out.'"';
// add custom class
$class .= " custom";
}
} else {
if ( $border )
$border_out = $border;
else
$border_out = $bg_color;
$color_output = 'style="background:'.$bg_color.';border-color:'.$border_out.'"';
// add custom class
$class .= " custom";
} // End IF Statement
$class_output = '';
// Set text color
if ( $text )
$class_output .= ' dark';
// Set class
if ( $class )
$class_output .= ' '.$class;
// Set Size
if ( $size )
$class_output .= ' '.$size;
if ( $window )
$window = 'target="_blank" ';
$output = '' . vpthemes_remove_wpautop($content) . '';
return $output;
}
add_shortcode( 'button', 'vpthemes_shortcode_button' );
/*----------------------------------------------------------------------------------*/
/* Twitter button - twitter */
/*----------------------------------------------------------------------------------*/
function vpthemes_shortcode_twitter($atts, $content = null) {
extract(shortcode_atts(array( 'url' => '',
'style' => 'vertical',
'source' => '',
'text' => '',
'related' => '',
'lang' => '',
'float' => 'left'), $atts));
$output = '';
if ( $url )
$output .= ' data-url="'.$url.'"';
if ( $source )
$output .= ' data-via="'.$source.'"';
if ( $text )
$output .= ' data-text="'.$text.'"';
if ( $related )
$output .= ' data-related="'.$related.'"';
if ( $lang )
$output .= ' data-lang="'.$lang.'"';
$output = '';
return $output;
}
add_shortcode( 'twitter', 'vpthemes_shortcode_twitter' );
/*-----------------------------------------------------------------------------------*/
/* Digg Button - digg
/*-----------------------------------------------------------------------------------*/
function vpthemes_shortcode_digg($atts, $content = null) {
extract(shortcode_atts(array( 'link' => '',
'title' => '',
'style' => 'medium',
'float' => 'left'), $atts));
$output = "
";
// Add custom URL
if ( $link ) {
// Add custom title
if ( $title )
$title = '&title='.urlencode( $title );
$link = ' href="http://digg.com/submit?url='.urlencode( $link ).$title.'"';
}
if ( $style == "large" )
$style = "Large";
elseif ( $style == "compact" )
$style = "Compact";
elseif ( $style == "icon" )
$style = "Icon";
else
$style = "Medium";
$output .= '';
return $output;
}
add_shortcode( 'digg', 'vpthemes_shortcode_digg' );
/*-----------------------------------------------------------------------------------*/
/* Facebook Like Button - fblike
/*-----------------------------------------------------------------------------------*/
function vpthemes_shortcode_fblike($atts, $content = null) {
extract(shortcode_atts(array( 'float' => 'none',
'url' => '',
'style' => 'standard',
'showfaces' => 'false',
'width' => '450',
'verb' => 'like',
'colorscheme' => 'light',
'font' => 'arial'), $atts));
global $post;
if ( ! $post ) {
$post = new stdClass();
$post->ID = 0;
} // End IF Statement
$allowed_styles = array( 'standard', 'button_count', 'box_count' );
if ( ! in_array( $style, $allowed_styles ) ) { $style = 'standard'; } // End IF Statement
if ( !$url )
$url = get_permalink($post->ID);
$height = '60';
if ( $showfaces == 'true')
$height = '100';
if ( ! $width || ! is_numeric( $width ) ) { $width = 450; } // End IF Statement
switch ( $float ) {
case 'left':
$float = 'fl';
break;
case 'right':
$float = 'fr';
break;
default:
break;
} // End SWITCH Statement
$output = '
';
return $output;
}
add_shortcode( 'fblike', 'vpthemes_shortcode_fblike' );
/*----------------------------------------------------------------------------------*/
/* Columns */
/*----------------------------------------------------------------------------------*/
/* ============= Two Columns ============= */
function vpthemes_shortcode_twocol_one($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'twocol_one', 'vpthemes_shortcode_twocol_one' );
function vpthemes_shortcode_twocol_one_last($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'twocol_one_last', 'vpthemes_shortcode_twocol_one_last' );
/* ============= Three Columns ============= */
function vpthemes_shortcode_threecol_one($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'threecol_one', 'vpthemes_shortcode_threecol_one' );
function vpthemes_shortcode_threecol_one_last($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'threecol_one_last', 'vpthemes_shortcode_threecol_one_last' );
function vpthemes_shortcode_threecol_two($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'threecol_two', 'vpthemes_shortcode_threecol_two' );
function vpthemes_shortcode_threecol_two_last($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'threecol_two_last', 'vpthemes_shortcode_threecol_two_last' );
/* ============= Four Columns ============= */
function vpthemes_shortcode_fourcol_one($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'fourcol_one', 'vpthemes_shortcode_fourcol_one' );
function vpthemes_shortcode_fourcol_one_last($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'fourcol_one_last', 'vpthemes_shortcode_fourcol_one_last' );
function vpthemes_shortcode_fourcol_two($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'fourcol_two', 'vpthemes_shortcode_fourcol_two' );
function vpthemes_shortcode_fourcol_two_last($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'fourcol_two_last', 'vpthemes_shortcode_fourcol_two_last' );
function vpthemes_shortcode_fourcol_three($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'fourcol_three', 'vpthemes_shortcode_fourcol_three' );
function vpthemes_shortcode_fourcol_three_last($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'fourcol_three_last', 'vpthemes_shortcode_fourcol_three_last' );
/* ============= Five Columns ============= */
function vpthemes_shortcode_fivecol_one($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'fivecol_one', 'vpthemes_shortcode_fivecol_one' );
function vpthemes_shortcode_fivecol_one_last($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'fivecol_one_last', 'vpthemes_shortcode_fivecol_one_last' );
function vpthemes_shortcode_fivecol_two($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'fivecol_two', 'vpthemes_shortcode_fivecol_two' );
function vpthemes_shortcode_fivecol_two_last($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'fivecol_two_last', 'vpthemes_shortcode_fivecol_two_last' );
function vpthemes_shortcode_fivecol_three($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'fivecol_three', 'vpthemes_shortcode_fivecol_three' );
function vpthemes_shortcode_fivecol_three_last($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'fivecol_three_last', 'vpthemes_shortcode_fivecol_three_last' );
function vpthemes_shortcode_fivecol_four($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'fivecol_four', 'vpthemes_shortcode_fivecol_four' );
function vpthemes_shortcode_fivecol_four_last($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'fivecol_four_last', 'vpthemes_shortcode_fivecol_four_last' );
/* ============= Six Columns ============= */
function vpthemes_shortcode_sixcol_one($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'sixcol_one', 'vpthemes_shortcode_sixcol_one' );
function vpthemes_shortcode_sixcol_one_last($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'sixcol_one_last', 'vpthemes_shortcode_sixcol_one_last' );
function vpthemes_shortcode_sixcol_two($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'sixcol_two', 'vpthemes_shortcode_sixcol_two' );
function vpthemes_shortcode_sixcol_two_last($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'sixcol_two_last', 'vpthemes_shortcode_sixcol_two_last' );
function vpthemes_shortcode_sixcol_three($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'sixcol_three', 'vpthemes_shortcode_sixcol_three' );
function vpthemes_shortcode_sixcol_three_last($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'sixcol_three_last', 'vpthemes_shortcode_sixcol_three_last' );
function vpthemes_shortcode_sixcol_four($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'sixcol_four', 'vpthemes_shortcode_sixcol_four' );
function vpthemes_shortcode_sixcol_four_last($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'sixcol_four_last', 'vpthemes_shortcode_sixcol_four_last' );
function vpthemes_shortcode_sixcol_five($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'sixcol_five', 'vpthemes_shortcode_sixcol_five' );
function vpthemes_shortcode_sixcol_five_last($atts, $content = null) {
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'sixcol_five_last', 'vpthemes_shortcode_sixcol_five_last' );
/*----------------------------------------------------------------------------------*/
/* Icon links - ilink */
/*----------------------------------------------------------------------------------*/
function vpthemes_shortcode_ilink($atts, $content = null) {
extract(shortcode_atts(array( 'style' => 'info', 'url' => '', 'icon' => ''), $atts));
$custom_icon = '';
if ( $icon )
$custom_icon = 'style="background:url( '.$icon.') no-repeat left 40%;"';
return '' . vpthemes_remove_wpautop($content) . '';
}
add_shortcode( 'ilink', 'vpthemes_shortcode_ilink' );
/*----------------------------------------------------------------------------------*/
/* List Styles - Unordered List - [unordered_list style=""][/unordered_list] */
/*----------------------------------------------------------------------------------*/
function vpthemes_shortcode_unorderedlist ( $atts, $content = null ) {
$defaults = array( 'style' => 'default' );
extract( shortcode_atts( $defaults, $atts ) );
return '' . do_shortcode( $content ) . '
' . "\n";
} // End vpthemes_shortcode_unorderedlist()
add_shortcode( 'unordered_list', 'vpthemes_shortcode_unorderedlist' );
/*----------------------------------------------------------------------------------*/
/* List Styles - Ordered List - [ordered_list style=""][/ordered_list] */
/*----------------------------------------------------------------------------------*/
function vpthemes_shortcode_orderedlist ( $atts, $content = null ) {
$defaults = array( 'style' => 'default' );
extract( shortcode_atts( $defaults, $atts ) );
return '' . do_shortcode( $content ) . '
' . "\n";
} // End vpthemes_shortcode_orderedlist()
add_shortcode( 'ordered_list', 'vpthemes_shortcode_orderedlist' );
/*--------------------------------------------------------------------------------------------*/
/* Social Icon - [social_icon url="" float="" icon_url="" title="" profile_type="" window=""] */
/*--------------------------------------------------------------------------------------------*/
function vpthemes_shortcode_socialicon ( $atts, $content = null ) {
$defaults = array( 'url' => '', 'float' => 'none', 'icon_url' => '', 'title' => '', 'profile_type' => '', 'window' => 'no' );
extract( shortcode_atts( $defaults, $atts ) );
if ( ! $url ) { return; } // End IF Statement - Don't run the shortcode if no URL has been supplied.
// Attempt to determine the location of the social profile.
// If no location is found, a default icon will be used.
$_default_icon = '';
$_supported_profiles = array(
'facebook' => 'facebook.com',
'twitter' => 'twitter.com',
'youtube' => 'youtube.com',
'delicious' => 'delicious.com',
'flickr' => 'flickr.com',
'linkedin' => 'linkedin.com'
);
$_profile_to_display = '';
$_alt_text = '';
$_classes = 'social-icon';
$_profile_match = false;
// If they've specified an icon, skip the automation.
if ( $profile_type != '' ) {
$_profile_match = true;
$_profile_to_display = $profile_type;
if ( $title ) { $_alt_text = $title; } else { $_alt_text = ucwords( $_profile_to_display ); $_alt_text = sprintf( __( 'My %s Profile', 'vpthemes' ), $_alt_text ); } // End IF Statement
$_profile_class = ' social-icon-' . $_profile_to_display;
if ( $icon_url ) {
$_img_url = $icon_url;
} else {
$_img_url = trailingslashit( get_template_directory_uri() ) . 'functions/images/' . $_profile_to_display . '.png';
} // End IF Statement
} // End IF Statement
// Create a special scenario for use with the RSS feed for this website.
if ( $url == 'feed' ) {
$_profile_match = true;
$_profile_to_display = 'rss';
if ( $title ) { $_alt_text = $title; } else { $_alt_text = __( 'Subscribe to our RSS feed', 'vpthemes' ); } // End IF Statement
$_classes .= ' social-icon-subscribe';
$url = get_bloginfo( 'rss2_url' );
if ( $icon_url ) {
$_img_url = $icon_url;
} else {
$_img_url = trailingslashit( get_template_directory_uri() ) . 'functions/images/ico-social-' . $_profile_to_display . '.png';
} // End IF Statement
} else {
foreach ( $_supported_profiles as $k => $v ) {
if ( $_profile_match == true ) { break; } // End IF Statement - Break out of the loop if we already have a match.
// Get host name from URL
preg_match( '@^(?:http://)?([^/]+)@i', $url, $matches );
$host = $matches[1];
if ( $host == $v ) {
$_profile_match = true;
$_profile_to_display = $k;
if ( $title ) { $_alt_text = $title; } else { $_alt_text = ucwords( $_profile_to_display ); $_alt_text = sprintf( __( 'My %s Profile', 'vpthemes' ), $_alt_text ); } // End IF Statement
$_profile_class = ' social-icon-' . $_profile_to_display;
if ( $icon_url ) {
$_img_url = $icon_url;
} else {
$_img_url = trailingslashit( get_template_directory_uri() ) . 'functions/images/' . $_profile_to_display . '.png';
} // End IF Statement
} else {
$_profile_to_display = 'default';
if ( $title ) { $_alt_text = $title; } else { $_alt_text = ucwords( $matches[1] ); $_alt_text = sprintf( __( 'My %s Profile', 'vpthemes' ), $_alt_text ); } // End IF Statement
$_host_bits = explode( '.', $matches[1] );
$_profile_class = ' social-icon-' . $_host_bits[0];
if ( $icon_url ) {
$_img_url = $icon_url;
} else {
$_img_url = trailingslashit( get_template_directory_uri() ) . 'functions/images/' . $_profile_to_display . '.png';
// Check if an image has been added for this social icon.
if ( file_exists( trailingslashit( get_stylesheet_directory() ) . 'images/' . $_host_bits[0] . '.png' ) ) {
$_img_url = trailingslashit( get_stylesheet_directory_uri() ) . 'images/' . $_host_bits[0] . '.png';
} // End IF Statement
} // End IF Statement
} // End IF Statement
} // End FOREACH Loop
$_classes .= $_profile_class;
// Determine the floating CSS class to be used.
switch ( $float ) {
case 'left':
$_classes .= ' fl';
break;
case 'right':
$_classes .= ' fr';
break;
default:
break;
} // End SWITCH Statement
} // End IF Statement
$target = '';
if ( $window == 'yes' ) { $target = ' target="_blank"'; } // End IF Statement
return '
' . "\n";
} // End vpthemes_shortcode_socialicon()
add_shortcode( 'social_icon', 'vpthemes_shortcode_socialicon' );
/*----------------------------------------------------------------------------------*/
/* Horizontal Rule / Divider - hr - divider */
/*----------------------------------------------------------------------------------*/
/*
Description: Use to separate text.
*/
function vp_shortcode_hr($atts, $content = null) {
return '';
}
add_shortcode( 'hr', 'vp_shortcode_hr' );
function vp_shortcode_divider($atts, $content = null) {
return '';
}
add_shortcode( 'divider', 'vp_shortcode_divider' );
function vp_shortcode_divider_flat($atts, $content = null) {
return '';
}
add_shortcode( 'divider_flat', 'vp_shortcode_divider_flat' );
/*----------------------------------------------------------------------------------*/
/* Quote - quote */
/*----------------------------------------------------------------------------------*/
/*
Optional arguments:
- style: boxed
- float: left, right
*/
function vp_shortcode_quote($atts, $content = null) {
extract(shortcode_atts(array( 'style' => '',
'float' => ''), $atts));
$class = '';
if ( $style )
$class .= ' '.$style;
if ( $float )
$class .= ' '.$float;
return '' . vpthemes_remove_wpautop($content) . '
';
}
add_shortcode( 'quote', 'vp_shortcode_quote' );
/*----------------------------------------------------------------------------------*/
/* Dropcap - [dropcap][/dropcap] */
/*----------------------------------------------------------------------------------*/
function vp_shortcode_dropcap ( $atts, $content = null ) {
$defaults = array();
extract( shortcode_atts( $defaults, $atts ) );
return '' . $content . '';
} // End vp_shortcode_dropcap()
add_shortcode( 'dropcap', 'vp_shortcode_dropcap' );
/*----------------------------------------------------------------------------------*/
/* Highlight - [highlight][/highlight] */
/*----------------------------------------------------------------------------------*/
function vp_shortcode_highlight ( $atts, $content = null ) {
$defaults = array();
extract( shortcode_atts( $defaults, $atts ) );
return '' . $content . '';
} // End vp_shortcode_highlight()
add_shortcode( 'highlight', 'vp_shortcode_highlight' );
/*----------------------------------------------------------------------------------*/
/* THE END */
/*----------------------------------------------------------------------------------*/
?>