373 lines
17 KiB
PHP
373 lines
17 KiB
PHP
<?php
|
|
|
|
if (!class_exists('KD_ELEM_CONTENT_BOX')) {
|
|
|
|
class KD_ELEM_CONTENT_BOX extends KEYDESIGN_ADDON_CLASS {
|
|
|
|
function __construct() {
|
|
add_action('init', array($this, 'kd_contentbox_init'));
|
|
add_shortcode('tek_contentbox', array($this, 'kd_contentbox_shrt'));
|
|
}
|
|
|
|
// Element configuration in admin
|
|
|
|
function kd_contentbox_init() {
|
|
if (function_exists('vc_map')) {
|
|
vc_map(array(
|
|
"name" => esc_html__("Content box", "keydesign"),
|
|
"description" => esc_html__("Content box with icon or custom image.", "keydesign"),
|
|
"base" => "tek_contentbox",
|
|
"class" => "",
|
|
"icon" => plugins_url('assets/element_icons/content-box.png', dirname(__FILE__)),
|
|
"category" => esc_html__("KeyDesign Elements", "keydesign"),
|
|
"params" => array(
|
|
|
|
array(
|
|
"type" => "textarea",
|
|
"class" => "kd-back-desc",
|
|
"heading" => esc_html__("Box title", "keydesign"),
|
|
"param_name" => "cb_title",
|
|
"holder" => "div",
|
|
"value" => "",
|
|
"description" => esc_html__("Enter a box title text.", "keydesign")
|
|
),
|
|
|
|
array(
|
|
"type" => "textfield",
|
|
"class" => "",
|
|
"heading" => esc_html__("Box subtitle", "keydesign"),
|
|
"param_name" => "cb_subtitle",
|
|
"value" => "",
|
|
"description" => esc_html__("Enter a box subtitle text.", "keydesign")
|
|
),
|
|
|
|
array(
|
|
"type" => "textarea",
|
|
"class" => "",
|
|
"heading" => esc_html__("Box content text", "keydesign"),
|
|
"param_name" => "cb_content_text",
|
|
"value" => "",
|
|
"description" => esc_html__("Enter box content text here.", "keydesign")
|
|
),
|
|
|
|
array(
|
|
"type" => "dropdown",
|
|
"class" => "",
|
|
"heading" => esc_html__("Display icon","keydesign"),
|
|
"param_name" => "icon_type",
|
|
"value" => array(
|
|
"Icon Browser" => "icon_browser",
|
|
"Custom Image" => "custom_icon",
|
|
"No icon" => "no_icon",
|
|
),
|
|
"save_always" => true,
|
|
"description" => esc_html__("Select icon/image source. If no icon is selected the box hover effect will be disabled.", "keydesign")
|
|
),
|
|
|
|
array(
|
|
"type" => "iconpicker",
|
|
"heading" => esc_html__( "Icon", "keydesign" ),
|
|
"param_name" => "icon_iconsmind",
|
|
"settings" => array(
|
|
"type" => "iconsmind",
|
|
"iconsPerPage" => 50,
|
|
),
|
|
"dependency" => array(
|
|
"element" => "icon_type",
|
|
"value" => "icon_browser",
|
|
),
|
|
"description" => esc_html__( "Select icon from library.", "keydesign" ),
|
|
),
|
|
|
|
array(
|
|
"type" => "colorpicker",
|
|
"class" => "",
|
|
"heading" => esc_html__("Icon color", "keydesign"),
|
|
"param_name" => "icon_color",
|
|
"value" => "",
|
|
"dependency" => array(
|
|
"element" => "icon_type",
|
|
"value" => array("icon_browser")
|
|
),
|
|
"description" => esc_html__("Choose icon color. If none selected, the default theme color will be used.", "keydesign"),
|
|
),
|
|
|
|
array(
|
|
"type" => "textfield",
|
|
"class" => "",
|
|
"heading" => esc_html__("Icon size", "keydesign"),
|
|
"param_name" => "icon_size",
|
|
"value" => "",
|
|
"dependency" => array(
|
|
"element" => "icon_type",
|
|
"value" => array("icon_browser")
|
|
),
|
|
"description" => esc_html__("Enter icon size. (eg. 10px, 1em, 1rem)", "keydesign"),
|
|
),
|
|
|
|
array(
|
|
"type" => "dropdown",
|
|
"class" => "",
|
|
"heading" => esc_html__("Custom image source", "keydesign"),
|
|
"param_name" => "cb_image_source",
|
|
"value" => array(
|
|
"Media library" => "media_library",
|
|
"External link" => "external_link",
|
|
),
|
|
"dependency" => array(
|
|
"element" => "icon_type",
|
|
"value" => array("custom_icon"),
|
|
),
|
|
"description" => esc_html__("Select image source.", "keydesign"),
|
|
"save_always" => true,
|
|
),
|
|
|
|
array(
|
|
"type" => "attach_image",
|
|
"class" => "",
|
|
"heading" => esc_html__("Upload image icon", "keydesign"),
|
|
"param_name" => "icon_img",
|
|
"value" => "",
|
|
"description" => esc_html__("Upload custom image.", "keydesign"),
|
|
"dependency" => array(
|
|
"element" => "cb_image_source",
|
|
"value" => array("media_library"),
|
|
),
|
|
),
|
|
|
|
array(
|
|
"type" => "textfield",
|
|
"class" => "",
|
|
"heading" => esc_html__("Image external source", "keydesign"),
|
|
"param_name" => "cb_ext_image",
|
|
"value" => "",
|
|
"description" => esc_html__("Enter image external link.", "keydesign"),
|
|
"dependency" => array(
|
|
"element" => "cb_image_source",
|
|
"value" => array("external_link"),
|
|
),
|
|
),
|
|
|
|
array(
|
|
"type" => "dropdown",
|
|
"class" => "",
|
|
"heading" => esc_html__("Box link type", "keydesign"),
|
|
"param_name" => "cb_custom_link",
|
|
"value" => array(
|
|
esc_html__( 'No link', 'keydesign' ) => '#',
|
|
esc_html__( 'Full box link', 'keydesign' ) => 'box-link',
|
|
),
|
|
"save_always" => true,
|
|
"description" => esc_html__("You can add or remove the custom link.", "keydesign"),
|
|
),
|
|
|
|
array(
|
|
"type" => "href",
|
|
"class" => "",
|
|
"heading" => esc_html__("Link URL", "keydesign"),
|
|
"param_name" => "cb_box_link",
|
|
"value" => "",
|
|
"description" => esc_html__("Enter URL (Note: parameters like \"mailto:\" are also accepted).", "keydesign"),
|
|
"dependency" => array(
|
|
"element" => "cb_custom_link",
|
|
"value" => array( "box-link" ),
|
|
),
|
|
),
|
|
|
|
array(
|
|
'type' => 'dropdown',
|
|
'heading' => __( 'Link target', 'keydesign' ),
|
|
'param_name' => 'cb_link_target',
|
|
"value" => array(
|
|
esc_html__( 'Same window', 'keydesign' ) => '_self',
|
|
esc_html__( 'New window', 'keydesign' ) => '_blank',
|
|
),
|
|
"dependency" => array(
|
|
"element" => "cb_custom_link",
|
|
"value" => array( "box-link" ),
|
|
),
|
|
),
|
|
|
|
array(
|
|
"type" => "dropdown",
|
|
"class" => "",
|
|
"heading" => esc_html__("CSS Animation", "keydesign"),
|
|
"param_name" => "css_animation",
|
|
"value" => array(
|
|
"No" => "",
|
|
"Fade In" => "kd-animated fadeIn",
|
|
"Fade In Down" => "kd-animated fadeInDown",
|
|
"Fade In Left" => "kd-animated fadeInLeft",
|
|
"Fade In Right" => "kd-animated fadeInRight",
|
|
"Fade In Up" => "kd-animated fadeInUp",
|
|
"Zoom In" => "kd-animated zoomIn",
|
|
),
|
|
"save_always" => true,
|
|
"admin_label" => true,
|
|
"description" => esc_html__("Select type of animation for element to be animated when it enters the browsers viewport (Note: works only in modern browsers).", "keydesign"),
|
|
"group" => esc_html__( "Extras", "keydesign" ),
|
|
),
|
|
|
|
array(
|
|
"type" => "dropdown",
|
|
"class" => "",
|
|
"heading" => esc_html__("Animation Delay", "keydesign"),
|
|
"param_name" => "elem_animation_delay",
|
|
"value" => array(
|
|
"0 ms" => "",
|
|
"200 ms" => "200",
|
|
"400 ms" => "400",
|
|
"600 ms" => "600",
|
|
"800 ms" => "800",
|
|
"1 s" => "1000",
|
|
),
|
|
"dependency" => array(
|
|
"element" => "css_animation",
|
|
"value" => array ("kd-animated fadeIn", "kd-animated fadeInDown", "kd-animated fadeInLeft", "kd-animated fadeInRight", "kd-animated fadeInUp", "kd-animated zoomIn"),
|
|
),
|
|
"save_always" => true,
|
|
"admin_label" => true,
|
|
"description" => esc_html__("Enter animation delay in ms", "keydesign"),
|
|
"group" => esc_html__( "Extras", "keydesign" ),
|
|
),
|
|
|
|
array(
|
|
"type" => "textfield",
|
|
"class" => "",
|
|
"heading" => esc_html__("Extra class name", "keydesign"),
|
|
"param_name" => "cb_extra_class",
|
|
"value" => "",
|
|
"description" => esc_html__("If you wish to style particular content element differently, then use this field to add a class name and then refer to it in your css file.", "keydesign"),
|
|
"group" => esc_html__( "Extras", "keydesign" ),
|
|
),
|
|
|
|
)
|
|
));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Render the element on front-end
|
|
|
|
public function kd_contentbox_shrt($atts, $content = null) {
|
|
// Declare empty vars
|
|
$output = $content_icon = $icon_color_style = $icon_size_style = $src = $link = $image = $animation_delay = $icons = $a_attrs = $subtitle_class = $no_icon_class_fix = $wrapper_class = '';
|
|
|
|
extract(shortcode_atts(array(
|
|
'icon_type' => '',
|
|
'icon_iconsmind' => '',
|
|
'icon_color' => '',
|
|
'icon_size' => '',
|
|
'cb_image_source' => '',
|
|
'icon_img' => '',
|
|
'cb_ext_image' => '',
|
|
'cb_title' => '',
|
|
'cb_subtitle' => '',
|
|
'cb_content_text' => '',
|
|
'cb_custom_link' => '',
|
|
'cb_box_link' => '',
|
|
'cb_link_target' => '',
|
|
'cb_button_text' => '',
|
|
'css_animation' => '',
|
|
'elem_animation_delay' => '',
|
|
'cb_extra_class' => '',
|
|
), $atts));
|
|
|
|
if( $icon_type == 'icon_browser' ) {
|
|
// Enqueue needed icon font.
|
|
// vc_icon_element_fonts_enqueue( $icon_library );
|
|
wp_enqueue_style( 'kd_iconsmind' );
|
|
}
|
|
|
|
if (strlen($icon_iconsmind) > 0) {
|
|
$icons = $icon_iconsmind;
|
|
}
|
|
|
|
if ($icon_color !== '') {
|
|
$icon_color_style = 'color: '.$icon_color.';';
|
|
}
|
|
|
|
if ($icon_size !== '') {
|
|
$icon_size_style = 'font-size: '.$icon_size.';';
|
|
}
|
|
|
|
$image = wpb_getImageBySize($params = array(
|
|
'post_id' => NULL,
|
|
'attach_id' => $icon_img,
|
|
'thumb_size' => 'full',
|
|
'class' => ""
|
|
));
|
|
|
|
if ($cb_image_source == 'external_link' && !empty($cb_ext_image)) {
|
|
$src = $cb_ext_image;
|
|
list($width, $height) = getimagesize($src);
|
|
} elseif ($cb_image_source == 'media_library' && !empty($icon_img)) {
|
|
$link = wp_get_attachment_image_src( $icon_img, 'large' );
|
|
$link = $link[0];
|
|
$src = $link;
|
|
}
|
|
|
|
if( $icon_type == 'icon_browser' && !empty($icons) ) {
|
|
$content_icon = '<i class="'.$icons .' fa" style="'.$icon_size_style.' '.$icon_color_style.'"></i> ';
|
|
}
|
|
elseif($icon_type == 'custom_icon'){
|
|
if ($cb_image_source == 'external_link' && $cb_ext_image != '') {
|
|
$content_icon = '<div class="cb-customimg"><img src="'.$cb_ext_image.'" width="'.$width.'" height="'.$height.'" /></div>';
|
|
} elseif ($cb_image_source == 'media_library' && !empty($icon_img)) {
|
|
$content_icon = '<div class="cb-customimg">'.$image['thumbnail'].'</div>';
|
|
}
|
|
}
|
|
|
|
//CSS Animation
|
|
if ($css_animation == "no_animation") {
|
|
$css_animation = "";
|
|
}
|
|
|
|
// Animation delay
|
|
if ($elem_animation_delay) {
|
|
$animation_delay = 'data-animation-delay='.$elem_animation_delay;
|
|
}
|
|
|
|
if ($cb_subtitle) {
|
|
$subtitle_class = 'with-subtitle';
|
|
}
|
|
|
|
if ($cb_custom_link == "box-link") {
|
|
$output .= '<a href="'.$cb_box_link.'" target="'.$cb_link_target.'">';
|
|
}
|
|
|
|
if ($icon_type == "no_icon") {
|
|
$no_icon_class_fix = 'cb-no-icon';
|
|
}
|
|
|
|
$wrapper_class = implode(' ', array('cb-container', $no_icon_class_fix, $css_animation, $cb_extra_class));
|
|
|
|
$output .= '<div class="'.trim($wrapper_class).'" '.$animation_delay.'>';
|
|
if ($icon_type != "no_icon") {
|
|
$output .= '<div class="cb-img-area">'.$content_icon.'</div>';
|
|
}
|
|
$output .= '<div class="cb-text-area">
|
|
<h4 class="cb-heading '.$subtitle_class.'">'.$cb_title.'</h4>';
|
|
if ($cb_subtitle) {
|
|
$output .= '<h5 class="cb-subtitle">'.$cb_subtitle.'</h5>';
|
|
}
|
|
$output .= '<p>'.$cb_content_text.'</p>';
|
|
$output .= '</div>';
|
|
$output .= '</div>';
|
|
if ($cb_custom_link == "box-link") {
|
|
$output .= '</a>';
|
|
}
|
|
|
|
return $output;
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
if (class_exists('KD_ELEM_CONTENT_BOX')) {
|
|
$KD_ELEM_CONTENT_BOX = new KD_ELEM_CONTENT_BOX;
|
|
}
|
|
|
|
?>
|