Last active
November 17, 2015 02:50
-
-
Save leowebguy/f97784565fa74f967543 to your computer and use it in GitHub Desktop.
Custom shortcode for Visual Composer on WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function vc_integrate_custom() { | |
vc_map( array ( | |
"name" => "Team", | |
"base" => "team", | |
"category" => 'Custom', | |
"icon" => "icon-wpb-team", | |
"allowed_container_element" => 'vc_row', | |
"params" => array( | |
array( | |
"type" => "attach_image", | |
"holder" => "div", | |
"class" => "", | |
"heading" => "Image", | |
"param_name" => "team_image" | |
), | |
array( | |
"type" => "textfield", | |
"holder" => "div", | |
"class" => "", | |
"heading" => "Name", | |
"param_name" => "team_name" | |
), | |
array( | |
"type" => "textfield", | |
"holder" => "div", | |
"class" => "", | |
"heading" => "Position", | |
"param_name" => "team_position" | |
), | |
array( | |
"type" => "textfield", | |
"holder" => "div", | |
"class" => "", | |
"heading" => "Link", | |
"param_name" => "team_link" | |
) | |
) | |
)); | |
} | |
add_action ( 'vc_after_init', 'vc_integrate_custom' ); | |
/* --------------------------------------------------------------------------- | |
* Team Shortcode | |
* --------------------------------------------------------------------------- */ | |
if (!function_exists('sc_team')) { | |
function sc_team($atts, $content = null) { | |
$args = array( | |
"team_image" => "", | |
"team_name" => "", | |
"team_position" => "", | |
"team_link" => "", | |
"title_tag" => "h4" | |
); | |
extract(shortcode_atts($args, $atts)); | |
if(is_numeric($team_image)) { | |
$team_image_src = wp_get_attachment_url( $team_image ); | |
} else { | |
$team_image_src = $team_image; | |
} | |
$html = "<div class='team'>"; | |
$html .= "<div class='team_inner'>"; | |
if($team_image != "") { | |
$html .= "<div class='team_image'>"; | |
if($team_link != "") { | |
$html .= "<a class='team_link_for_touch' href='$team_link' />"; | |
} | |
$html .= "<img src='$team_image_src' alt='' />"; | |
if($team_link != "") { | |
$html .= "</a>"; | |
} | |
$html .= "</div>"; | |
} | |
$html .= "<div class='team_text'>"; | |
$html .= "<div class='team_text_inner'>"; | |
$html .= "<div class='team_title_holder'>"; | |
$html .= "<$title_tag class='team_name'>"; | |
$html .= $team_name; | |
$html .= "</$title_tag>"; | |
if($team_position != "") { | |
$html .= "<span>" . $team_position . "</span>"; | |
} | |
$html .= "</div>"; //team_title_holder | |
$html .= "</div>"; //team_text_inner | |
$html .= "</div>"; //team_text | |
$html .= "</div>"; //team_inner | |
$html .= "</div>"; //team | |
return $html; | |
} | |
} | |
add_shortcode('team', 'sc_team'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment