PATH:
home
/
lab2454c
/
fcxpro.com
/
wp-content
/
plugins
/
webon-core
/
inc
/
shortcodes
/
single-image
<?php if ( ! function_exists( 'webon_core_add_single_image_shortcode' ) ) { /** * Function that add shortcode into shortcodes list for registration * * @param array $shortcodes * * @return array */ function webon_core_add_single_image_shortcode( $shortcodes ) { $shortcodes[] = 'WebOnCoreSingleImageShortcode'; return $shortcodes; } add_filter( 'webon_core_filter_register_shortcodes', 'webon_core_add_single_image_shortcode' ); } if ( class_exists( 'WebOnCoreShortcode' ) ) { class WebOnCoreSingleImageShortcode extends WebOnCoreShortcode { public function __construct() { $this->set_layouts( apply_filters( 'webon_core_filter_single_image_layouts', array() ) ); $this->set_extra_options( apply_filters( 'webon_core_filter_single_image_extra_options', array() ) ); parent::__construct(); } public function map_shortcode() { $this->set_shortcode_path( WEBON_CORE_SHORTCODES_URL_PATH . '/single-image' ); $this->set_base( 'webon_core_single_image' ); $this->set_name( esc_html__( 'Single Image', 'webon-core' ) ); $this->set_description( esc_html__( 'Shortcode that adds single image element', 'webon-core' ) ); $this->set_category( esc_html__( 'WebOn Core', 'webon-core' ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'custom_class', 'title' => esc_html__( 'Custom Class', 'webon-core' ), ) ); $options_map = webon_core_get_variations_options_map( $this->get_layouts() ); $this->set_option( array( 'field_type' => 'select', 'name' => 'layout', 'title' => esc_html__( 'Layout', 'webon-core' ), 'options' => $this->get_layouts(), 'default_value' => $options_map['default_value'], 'visibility' => array( 'map_for_page_builder' => $options_map['visibility'] ) ) ); $this->set_option( array( 'field_type' => 'image', 'name' => 'image', 'title' => esc_html__( 'Image', 'webon-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'image_size', 'title' => esc_html__( 'Image Size', 'webon-core' ), 'description'=> esc_html__( 'For predefined image sizes input thumbnail, medium, large or full. If you wish to set a custom image size, type in the desired image dimensions in pixels (e.g. 400x400).', 'webon-core' ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'image_action', 'title' => esc_html__( 'Image Action', 'webon-core' ), 'options' => array( '' => esc_html__( 'No Action', 'webon-core' ), 'open-popup' => esc_html__( 'Open Popup', 'webon-core' ), 'custom-link' => esc_html__( 'Custom Link', 'webon-core' ) ) ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'link', 'title' => esc_html__( 'Custom Link', 'webon-core' ), 'dependency' => array( 'show' => array( 'image_action' => array( 'values' => 'custom-link', 'default_value' => '' ) ) ) ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'target', 'title' => esc_html__( 'Custom Link Target', 'webon-core' ), 'options' => webon_core_get_select_type_options_pool( 'link_target' ), 'default_value' => '_self', 'dependency' => array( 'show' => array( 'image_action' => array( 'values' => 'custom-link', 'default_value' => '' ) ) ) ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'image_vertical_offset', 'title' => esc_html__( 'Image Vertical Offset', 'webon-core' ) ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'image_horizontal_offset', 'title' => esc_html__( 'Image Horizontal Offset', 'webon-core' ) ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'enable_background_image', 'title' => esc_html__( 'Enable Background Image?', 'webon-core' ), 'options' => webon_core_get_select_type_options_pool('no_yes', false) ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'enable_background_image_parallax', 'title' => esc_html__( 'Enable Background Image Parallax?', 'webon-core' ), 'options' => webon_core_get_select_type_options_pool('no_yes', false) ) ); $this->set_option( array( 'field_type' => 'image', 'name' => 'image_background_image', 'title' => esc_html__( 'Background Image', 'webon-core' ), 'dependency' => array( 'show' => array( 'enable_background_image' => array( 'values' => 'yes', 'default_value' => '' ) ) ) ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'image_background_image_hide', 'title' => esc_html__( 'Hide Background Image?', 'webon-core' ), 'description' => esc_html__( 'Hide background image on touch devices', 'webon-core' ), 'options' => webon_core_get_select_type_options_pool( 'no_yes', false ), 'dependency' => array( 'show' => array( 'enable_background_image' => array( 'values' => 'yes', 'default_value' => '' ) ) ) ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'icon_type', 'title' => esc_html__( 'Icon Type', 'webon-core' ), 'options' => array( 'icon-pack' => esc_html__( 'Icon Pack', 'webon-core' ), 'custom-icon' => esc_html__( 'Custom Icon', 'webon-core' ) ), 'default_value' => 'icon-pack', 'group' => esc_html__( 'Icon', 'webon-core' ) ) ); $this->set_option( array( 'field_type' => 'image', 'name' => 'custom_icon', 'title' => esc_html__( 'Custom Icon', 'webon-core' ), 'group' => esc_html__( 'Icon', 'webon-core' ), 'dependency' => array( 'show' => array( 'icon_type' => array( 'values' => 'custom-icon', 'default_value' => 'icon-pack' ) ) ) ) ); $this->import_shortcode_options( array( 'shortcode_base' => 'webon_core_icon', 'exclude' => array( 'link', 'target', 'margin', 'vertical_offset' ), 'additional_params' => array( 'group' => esc_html__( 'Icon', 'webon-core' ), 'dependency' => array( 'show' => array( 'icon_type' => array( 'values' => 'icon-pack', 'default_value' => 'icon-pack' ) ) ) ) ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'vertical_offset', 'title' => esc_html__( 'Vertical Offset', 'webon-core' ), 'group' => esc_html__( 'Icon', 'webon-core' ) ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'horizontal_offset', 'title' => esc_html__( 'Horizontal Offset', 'webon-core' ), 'group' => esc_html__( 'Icon', 'webon-core' ) ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'shadow', 'title' => esc_html__( 'Icon Shadow', 'webon-core' ), 'options' => webon_core_get_select_type_options_pool( 'yes_no', false ), 'group' => esc_html__( 'Icon', 'webon-core' ), 'dependency' => array( 'show' => array( 'icon_layout' => array( 'values' => 'circle', 'default_value' => '' ) ) ) ) ); $this->map_extra_options(); } public static function call_shortcode( $params ) { $html = qode_framework_call_shortcode( 'webon_core_single_image', $params ); $html = str_replace( "\n", '', $html ); return $html; } public function render( $options, $content = null ) { parent::render( $options ); $atts = $this->get_atts(); $atts['holder_classes'] = $this->get_holder_classes( $atts ); $atts['image_params'] = $this->generate_image_params( $atts ); $atts['image_background_params'] = $this->generate_image_background_params( $atts ); $atts['icon_params'] = $this->generate_icon_params( $atts ); $atts['image_styles'] = $this->get_image_styles( $atts ); $atts['icon_styles'] = $this->get_icon_styles( $atts ); return webon_core_get_template_part( 'shortcodes/single-image', 'variations/' . $atts['layout'] . '/templates/' . $atts['layout'], '', $atts ); } private function get_holder_classes( $atts ) { $holder_classes = $this->init_holder_classes(); $holder_classes[] = 'qodef-single-image'; $holder_classes[] = ! empty ( $atts['layout'] ) ? 'qodef-layout--' . $atts['layout'] : ''; $holder_classes[] = ! empty( $atts['icon_type'] ) ? 'qodef--' . $atts['icon_type'] : ''; $holder_classes[] = $atts['shadow'] == 'yes' ? 'qodef--has-shadow' : ''; $holder_classes[] = $atts['enable_background_image_parallax'] == 'yes' ? 'qodef--parallax-background-image' : ''; $holder_classes[] = $atts['image_background_image_hide'] == 'yes' ? 'qodef--background-image-hidden' : ''; return implode( ' ', $holder_classes ); } public function load_assets() { wp_enqueue_script( 'parallax-images', WEBON_CORE_INC_URL_PATH . '/shortcodes/parallax-images/assets/js/plugins/jquery.parallax-scroll.js', array( 'jquery' ), true ); } private function generate_image_params( $atts ) { $image = array(); if ( ! empty( $atts['image'] ) ) { $id = $atts['image']; $image['image_id'] = intval( $id ); $image_original = wp_get_attachment_image_src( $id, 'full' ); $image['url'] = is_array($image_original) ? $image_original[0] : $image_original; $image['alt'] = get_post_meta( $id, '_wp_attachment_image_alt', true ); $image_size = trim( $atts['image_size'] ); preg_match_all( '/\d+/', $image_size, $matches ); /* check if numeral width and height are entered */ if ( in_array( $image_size, array( 'thumbnail', 'thumb', 'medium', 'large', 'full' ) ) ) { $image['image_size'] = $image_size; } elseif ( ! empty( $matches[0] ) ) { $image['image_size'] = array( $matches[0][0], $matches[0][1] ); } else { $image['image_size'] = 'full'; } } return $image; } private function generate_image_background_params( $atts ) { $image = array(); if ( ! empty( $atts['image_background_image'] ) ) { $id = $atts['image_background_image']; $image['image_id'] = intval( $id ); $image_original = wp_get_attachment_image_src( $id, 'full' ); $image['url'] = $image_original[0]; $image['alt'] = get_post_meta( $id, '_wp_attachment_image_alt', true ); $image['image_size'] = 'full'; } return $image; } private function generate_icon_params( $atts ) { $params = $this->populate_imported_shortcode_atts( array( 'shortcode_base' => 'webon_core_icon', 'exclude' => array( 'link', 'target', 'margin', 'vertical_offset' ), 'atts' => $atts, ) ); return $params; } private function get_image_styles( $atts ) { $styles = array(); if ( $atts['image_vertical_offset'] !== '' ) { $styles[] = 'top: ' . $atts['image_vertical_offset']; } if ( $atts['image_horizontal_offset'] !== '' ) { $styles[] = 'left: ' . $atts['image_horizontal_offset']; } return $styles; } private function get_icon_styles( $atts ) { $styles = array(); if ( $atts['vertical_offset'] !== '' ) { $styles[] = 'top: ' . $atts['vertical_offset']; } if ( $atts['horizontal_offset'] !== '' ) { $styles[] = 'left: ' . $atts['horizontal_offset']; } return $styles; } } }
[+]
..
[+]
variations
[+]
templates
[-] include.php
[edit]
[+]
assets
[-] single-image-elementor.php
[edit]
[-] single-image.php
[edit]