File: /home/adventp/www/wp-content/plugins/ut-shortcodes/shortcodes/person-module.php
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
if( !class_exists( 'UT_Person_Module' ) ) {
class UT_Person_Module {
private $shortcode;
private $link;
private $social;
private $social_border;
private $output;
private $name;
private $occupation;
private $content;
function __construct() {
/* shortcode base */
$this->shortcode = 'ut_person_module';
add_action( 'vc_before_init', array( $this, 'ut_map_shortcode' ) );
add_shortcode( $this->shortcode, array( $this, 'ut_create_shortcode' ) );
}
function ut_map_shortcode() {
vc_map(
array(
'name' => esc_html__( 'Person Module', 'ut_shortcodes' ),
'description' => esc_html__( 'Profile your team members or employees in a creative box.', 'ut_shortcodes' ),
'base' => $this->shortcode,
'category' => 'Community',
// 'icon' => 'fa fa-users ut-vc-module-icon',
'icon' => UT_SHORTCODES_URL . '/admin/img/vc_icons/team-member.png',
'class' => 'ut-vc-icon-module ut-community-module',
'content_element' => true,
'params' => array(
array(
'type' => 'attach_image',
'heading' => esc_html__( 'Avatar', 'ut_shortcodes' ),
'param_name' => 'avatar',
'group' => 'General'
),
array(
'type' => 'dropdown',
'heading' => esc_html__( 'Display Avatar in Portrait Format?', 'ut_shortcodes' ),
'param_name' => 'portrait',
'group' => 'General',
'value' => array(
esc_html__( 'no, thanks!', 'ut_shortcodes' ) => 'off',
esc_html__( 'yes, please!', 'ut_shortcodes' ) => 'on'
),
),
array(
'type' => 'textfield',
'heading' => esc_html__( 'Name', 'ut_shortcodes' ),
'param_name' => 'name',
'admin_label' => true,
'group' => 'General'
),
array(
'type' => 'textfield',
'heading' => esc_html__( 'Occupation', 'ut_shortcodes' ),
'param_name' => 'occupation',
'group' => 'General'
),
array(
'type' => 'vc_link',
'heading' => esc_html__( 'Link', 'ut_shortcodes' ),
'param_name' => 'link',
'group' => 'General'
),
array(
'type' => 'param_group',
'heading' => esc_html__( 'Social Profiles', 'ut_shortcodes' ),
'group' => 'General',
'param_name' => 'social',
'params' => array(
array(
'type' => 'iconpicker',
'heading' => esc_html__( 'Icon', 'ut_shortcodes' ),
'admin_label' => true,
'param_name' => 'icon'
),
array(
'type' => 'textfield',
'heading' => esc_html__( 'Title', 'ut_shortcodes' ),
'admin_label' => true,
'param_name' => 'title',
),
array(
'type' => 'vc_link',
'heading' => esc_html__( 'Profile Link', 'ut_shortcodes' ),
'param_name' => 'link',
),
),
),
/* box design */
array(
'type' => 'dropdown',
'heading' => esc_html__( 'Name Font Weight', 'ut_shortcodes' ),
'description' => esc_html__( 'Please keep in mind, that the font needs to support the font weight.', 'ut_shortcodes' ),
'param_name' => 'name_font_weight',
'group' => 'Box Design',
'value' => array(
esc_html__( 'Select Font Weight' , 'ut_shortcodes' ) => '',
esc_html__( 'lighter' , 'ut_shortcodes' ) => 'lighter',
esc_html__( 'normal' , 'ut_shortcodes' ) => 'normal',
esc_html__( 'bold' , 'ut_shortcodes' ) => 'bold',
esc_html__( 'bolder' , 'ut_shortcodes' ) => 'bolder',
esc_html__( '100' , 'ut_shortcodes' ) => '100',
esc_html__( '200' , 'ut_shortcodes' ) => '200',
esc_html__( '300' , 'ut_shortcodes' ) => '300',
esc_html__( '400' , 'ut_shortcodes' ) => '400',
esc_html__( '500' , 'ut_shortcodes' ) => '500',
esc_html__( '600' , 'ut_shortcodes' ) => '600',
esc_html__( '700' , 'ut_shortcodes' ) => '700',
esc_html__( '800' , 'ut_shortcodes' ) => '800',
esc_html__( '900' , 'ut_shortcodes' ) => '900',
),
),
array(
'type' => 'range_slider',
'heading' => esc_html__( 'Name Font Size', 'ut_shortcodes' ),
'param_name' => 'name_font_size',
'group' => 'Box Design',
'value' => array(
'default' => '18',
'min' => '0',
'max' => '50',
'step' => '1',
'unit' => 'px'
),
),
array(
'type' => 'colorpicker',
'heading' => esc_html__( 'Name Color', 'ut_shortcodes' ),
'param_name' => 'name_color',
'group' => 'Box Design',
),
array(
'type' => 'colorpicker',
'heading' => esc_html__( 'Name Decoration Line Color', 'ut_shortcodes' ),
'param_name' => 'name_decoration_line_color',
'group' => 'Box Design',
),
array(
'type' => 'range_slider',
'heading' => esc_html__( 'Ocupation Letter Spacing', 'ut_shortcodes' ),
'param_name' => 'ocupation_letter_spacing',
'group' => 'Box Design',
'value' => array(
'default' => '0',
'min' => '-0.2',
'max' => '0.2',
'step' => '0.01',
'unit' => 'em'
),
),
array(
'type' => 'dropdown',
'heading' => esc_html__( 'Ocupation Font Weight', 'ut_shortcodes' ),
'param_name' => 'ocupation_font_weight',
'group' => 'Box Design',
'value' => array(
esc_html__( 'Select Font Weight' , 'ut_shortcodes' ),
'lighter',
'normal',
'bold',
'bolder',
100,
200,
300,
400,
500,
600,
700,
800,
900,
),
),
array(
'type' => 'colorpicker',
'heading' => esc_html__( 'Occupation Color', 'ut_shortcodes' ),
'param_name' => 'ocupation_color',
'group' => 'Box Design'
),
array(
'type' => 'colorpicker',
'heading' => esc_html__( 'Social Icon Color', 'ut_shortcodes' ),
'param_name' => 'icon_color',
'group' => 'Box Design'
),
array(
'type' => 'colorpicker',
'heading' => esc_html__( 'Social Icon Hover Color', 'ut_shortcodes' ),
'param_name' => 'icon_color_hover',
'group' => 'Box Design'
),
array(
'type' => 'range_slider',
'heading' => esc_html__( 'Social Icon Size', 'ut_shortcodes' ),
'param_name' => 'icon_size',
'group' => 'Box Design',
'value' => array(
'default' => '16',
'min' => '16',
'max' => '30',
'step' => '1',
'unit' => 'px'
),
),
array(
'type' => 'gradient_picker',
'heading' => esc_html__( 'Overlay Color', 'ut_shortcodes' ),
'param_name' => 'overlay_color',
'group' => 'Box Design',
),
/* css */
array(
'type' => 'css_editor',
'param_name' => 'css',
'group' => esc_html__( 'Design Options', 'ut_shortcodes' ),
)
)
)
); // end mapping
}
function create_member_box_style_three() {
$this->output .= '<div class="bklyn5-team-member-overlay">';
$this->output .= '<div class="bklyn5-team-member-overlay-caption">';
$this->output .= '<div class="bklyn5-team-member-info">';
if( $this->name ) {
$this->output .= '<h3 class="bklyn5-team-member-name">' . $this->name . '</h3>';
}
if( $this->occupation ) {
$this->output .= '<div class="bklyn5-team-member-ocupation">' . $this->occupation . '</div>';
}
$this->create_social_link();
$this->output .= '</div>';
$this->output .= '</div>';
$this->output .= '</div>';
}
function create_social_link() {
if( !empty( $this->social ) && is_array( $this->social ) ) {
$this->output .= '<div class="bklyn5-team-member-social-icons ' . $this->social_border . '">';
$this->output .= '<ul>';
foreach( $this->social as $profile ) {
if( !empty( $profile['link'] ) ) {
/* link settings */
$link = vc_build_link( $profile['link'] );
$url = !empty( $link['url'] ) ? $link['url'] : '#';
$target = !empty( $link['target'] ) ? $link['target'] : '_self';
$title = !empty( $link['title'] ) ? $link['title'] : '';
$rel = !empty( $link['rel'] ) ? 'rel="' . esc_attr( trim( $link['rel'] ) ) . '"' : '';
/* profile icon */
$icon = !empty( $profile['icon'] )? $profile['icon'] : 'fa fa-circle';
$this->output .= '<li>';
$this->output .= '<a title="' . esc_attr( $title ) . '" href="' . esc_url( $url ) . '" target="' . esc_attr( $target ) . '" ' . $rel . '><i class="' . esc_attr( $icon ) . '"></i></a>';
$this->output .= '</li>';
}
}
$this->output .= '</ul>';
$this->output .= '</div>';
}
}
function create_placeholder_svg( $width , $height ){
// fallback values
$width = empty( $width ) ? '800' : $width;
$height = empty( $height ) ? '600' : $height;
return 'data:image/svg+xml;charset=utf-8,%3Csvg xmlns%3D\'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg\' viewBox%3D\'0 0 ' . esc_attr( $width ) . ' ' . esc_attr( $height ) . '\'%2F%3E';
}
function ut_create_shortcode( $atts, $content = NULL ) {
extract( shortcode_atts( array (
'style' => 'member-style-3',
'align' => 'left',
'avatar' => '',
'portrait' => 'off',
'name' => '',
'link' => '',
'name_color' => '',
'name_decoration_line_color' => '',
'name_font_size' => '',
'name_font_weight' => '',
'line' => 'on',
'line_color' => '',
'line_style' => '',
'line_width' => '',
'occupation' => '',
'ocupation_color' => '',
'ocupation_letter_spacing' => '',
'ocupation_font_weight' => '',
'description_color' => '',
'social' => '',
'icon_color' => '',
'icon_color_hover' => get_option('ut_accentcolor'),
'icon_size' => '',
'overlay_color' => '',
'css' => ''
), $atts ) );
$this->name = $name;
$this->occupation = $occupation;
$this->content = $content;
$this->social_border = $line == 'off' ? 'no-bklyn5-team-member-border' : '';
/* extract social items */
if( !empty( $social ) && function_exists('vc_param_group_parse_atts') && vc_param_group_parse_atts( $social ) ) {
$this->social = array_filter( vc_param_group_parse_atts( $social ) );
}
/* avatar */
$image_meta = get_post( $avatar );
$alt = '';
if( get_post( $avatar ) ) {
$alt = $image_meta->post_title;
}
if( $style == 'member-style-2' ) {
$avatar = ut_resize( wp_get_attachment_url( $avatar ) , '280', '280', true, true, true );
$align = 'center';
} else {
if( class_exists('UT_Adaptive_Image') ) {
if( $portrait == 'on' ) {
$avatar = UT_Adaptive_Image::create( $avatar, array( '1080', '1350' ), true, 'portrait' );
} else {
$avatar = UT_Adaptive_Image::create( $avatar, array( get_option('large_size_w'), get_option('large_size_h') ), true, 'landscape' );
}
} else {
$avatar = '';
}
}
/* fallback */
if( empty( $avatar ) ) {
$avatar = vc_asset_url( 'vc/no_image.png' );
}
/* link */
$member_link = false;
if( function_exists('vc_build_link') && $link ) {
$member_link = vc_build_link( $link );
}
if( $member_link ) {
$target = !empty( $member_link['target'] ) ? $member_link['target'] : '_self';
$title = !empty( $member_link['title'] ) ? $member_link['title'] : '';
$rel = !empty( $member_link['rel'] ) ? 'rel="' . esc_attr( trim( $member_link['rel'] ) ) . '"' : '';
$link = !empty( $member_link['url'] ) ? $member_link['url'] : false;
}
/* unique listz ID */
$id = uniqid("ut_tm_");
$css_style = '';
if( $name_color ) {
$css_style .= '#' . $id . ' .bklyn5-team-member-name { color: ' . $name_color . '; }';
}
if( $name_decoration_line_color ) {
$css_style .= '#' . $id . '.bklyn5-team-member .bklyn5-team-member-social-icons > *::before { background: ' . $name_decoration_line_color . '; }';
}
if( $name_font_size ) {
$css_style .= '#' . $id . ' .bklyn5-team-member-name { font-size: ' . $name_font_size . 'px; }';
}
if( $name_font_weight ) {
$css_style .= '#' . $id . ' .bklyn5-team-member-name { font-weight: ' . $name_font_weight . '; }';
}
if( $ocupation_color ) {
$css_style .= '#' . $id . ' .bklyn5-team-member-ocupation { color: ' . $ocupation_color . '; }';
}
if( $ocupation_font_weight ) {
$css_style .= '#' . $id . ' .bklyn5-team-member-ocupation { font-weight: ' . $ocupation_font_weight . '; }';
}
if( $ocupation_letter_spacing ) {
$css_style .= '#' . $id . ' .bklyn5-team-member-ocupation { letter-spacing: ' . $ocupation_letter_spacing . 'em; }';
}
if( $description_color ) {
$css_style .= '#' . $id . ' .bklyn5-team-member-description { color: ' . $description_color . '; }';
}
if( $icon_color ) {
$css_style .= '#' . $id . ' .bklyn5-team-member-social-icons a { color: ' . $icon_color . '; }';
$css_style .= '#' . $id . ' .bklyn5-team-member-social-icons a:visited { color: ' . $icon_color . '; }';
}
if( $icon_size ) {
$css_style .= '#' . $id . ' .bklyn5-team-member-social-icons a { font-size: ' . $icon_size . 'px; }';
}
$css_style .= '#' . $id . ' .bklyn5-team-member-social-icons a:hover { color: ' . $icon_color_hover . '; }';
$css_style .= '#' . $id . ' .bklyn5-team-member-social-icons a:focus { color: ' . $icon_color_hover . '; }';
$css_style .= '#' . $id . ' .bklyn5-team-member-social-icons a:active { color: ' . $icon_color_hover . '; }';
if( $overlay_color && ut_is_gradient( $overlay_color ) ) {
$css_style .= ut_create_gradient_css( $overlay_color, '#' . esc_attr( $id ) . ' .bklyn5-team-member-overlay', false, 'background' );
} elseif( $overlay_color ) {
$css_style .= '#' . $id . ' .bklyn5-team-member-overlay { background: ' . $overlay_color . '; }';
}
/* start output */
$this->output = '';
if( !empty( $css_style ) ) {
$this->output .= ut_minify_inline_css( '<style type="text/css">' . $css_style . '</style>' );
}
$this->output .= '<div id="' . esc_attr( $id ) . '" class="bklyn5-team-member bklyn5-team-' . esc_attr( $style ) . ' bklyn5-team-member-' . $align . '">';
if( !empty( $avatar ) ) {
if( $link ) {
$this->output .= '<a title="' . esc_attr( $title ) . '" href="' . esc_url( $link ) . '" target="' . esc_attr( $target ) . '" ' . $rel . '>';
}
$this->output .= '<div class="bklyn5-team-member-avatar">';
if ( $style == 'member-style-2' ) {
$this->output .= '<img alt="' . esc_attr( $this->name ) . '" src="' . esc_url( $avatar ) . '">';
} else {
$this->output .= $avatar;
}
$this->output .= '</div>';
if( $link ) {
$this->output .= '</a>';
}
$this->create_member_box_style_three();
}
$this->output .= '</div>';
return '<div class="wpb_content_element ' . apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, vc_shortcode_custom_css_class( $css, ' ' ), $this->shortcode, $atts ) . '">' . $this->output . '</div>';
}
}
}
new UT_Person_Module;
if ( class_exists( 'WPBakeryShortCode' ) ) {
class WPBakeryShortCode_ut_person_module extends WPBakeryShortCode {
function __construct( $settings ) {
parent::__construct( $settings );
$this->jsScripts();
}
public function jsScripts() {
wp_register_script( 'zoom', vc_asset_url( 'lib/bower/zoom/jquery.zoom.min.js' ), array(), WPB_VC_VERSION );
wp_register_script( 'vc_image_zoom', vc_asset_url( 'lib/vc_image_zoom/vc_image_zoom.min.js' ), array(
'jquery',
'zoom',
), WPB_VC_VERSION, true );
}
public function singleParamHtmlHolder( $param, $value ) {
$output = '';
$param_name = isset( $param['param_name'] ) ? $param['param_name'] : '';
$type = isset( $param['type'] ) ? $param['type'] : '';
$class = isset( $param['class'] ) ? $param['class'] : '';
if ( 'attach_image' === $param['type'] && 'avatar' === $param_name ) {
$output .= '<input type="hidden" class="wpb_vc_param_value ' . $param_name . ' ' . $type . ' ' . $class . '" name="' . $param_name . '" value="' . $value . '" />';
$element_icon = $this->settings( 'icon' );
$img = wpb_getImageBySize( array(
'attach_id' => (int) preg_replace( '/[^\d]/', '', $value ),
'thumb_size' => 'thumbnail',
) );
$this->setSettings( 'logo', ( $img ? $img['thumbnail'] : '<img width="150" height="150" src="' . vc_asset_url( 'vc/blank.gif' ) . '" class="attachment-thumbnail vc_general vc_element-icon" data-name="' . $param_name . '" alt="" title="" style="display: none;" />' ) . '<span class="no_image_image vc_element-icon' . ( ! empty( $element_icon ) ? ' ' . $element_icon : '' ) . ( $img && ! empty( $img['p_img_large'][0] ) ? ' image-exists' : '' ) . '" /><a href="#" class="column_edit_trigger' . ( $img && ! empty( $img['p_img_large'][0] ) ? ' image-exists' : '' ) . '">' . __( 'Add image', 'js_composer' ) . '</a>' );
$output .= $this->outputTitleTrue( $this->settings['name'] );
} elseif ( ! empty( $param['holder'] ) ) {
if ( 'input' === $param['holder'] ) {
$output .= '<' . $param['holder'] . ' readonly="true" class="wpb_vc_param_value ' . $param_name . ' ' . $type . ' ' . $class . '" name="' . $param_name . '" value="' . $value . '">';
} elseif ( in_array( $param['holder'], array( 'img', 'iframe' ) ) ) {
$output .= '<' . $param['holder'] . ' class="wpb_vc_param_value ' . $param_name . ' ' . $type . ' ' . $class . '" name="' . $param_name . '" src="' . $value . '">';
} elseif ( 'hidden' !== $param['holder'] ) {
$output .= '<' . $param['holder'] . ' class="wpb_vc_param_value ' . $param_name . ' ' . $type . ' ' . $class . '" name="' . $param_name . '">' . $value . '</' . $param['holder'] . '>';
}
}
if ( ! empty( $param['admin_label'] ) && true === $param['admin_label'] ) {
$output .= '<span class="vc_admin_label admin_label_' . $param['param_name'] . ( empty( $value ) ? ' hidden-label' : '' ) . '"><label>' . $param['heading'] . '</label>: ' . $value . '</span>';
}
return $output;
}
public function getImageSquareSize( $img_id, $img_size ) {
if ( preg_match_all( '/(\d+)x(\d+)/', $img_size, $sizes ) ) {
$exact_size = array(
'width' => isset( $sizes[1][0] ) ? $sizes[1][0] : '0',
'height' => isset( $sizes[2][0] ) ? $sizes[2][0] : '0',
);
} else {
$image_downsize = image_downsize( $img_id, $img_size );
$exact_size = array(
'width' => $image_downsize[1],
'height' => $image_downsize[2],
);
}
$exact_size_int_w = (int) $exact_size['width'];
$exact_size_int_h = (int) $exact_size['height'];
if ( isset( $exact_size['width'] ) && $exact_size_int_w !== $exact_size_int_h ) {
$img_size = $exact_size_int_w > $exact_size_int_h
? $exact_size['height'] . 'x' . $exact_size['height']
: $exact_size['width'] . 'x' . $exact_size['width'];
}
return $img_size;
}
protected function outputTitleTrue( $title ) {
return '';
}
}
}