PATH:
home
/
lab2454c
/
fcxpro.com
/
wp-content
/
plugins
/
webon-core
/
inc
/
shortcodes
/
image-gallery
<?php if ( ! function_exists( 'webon_core_add_image_gallery_shortcode' ) ) { /** * Function that add shortcode into shortcodes list for registration * * @param array $shortcodes * * @return array */ function webon_core_add_image_gallery_shortcode( $shortcodes ) { $shortcodes[] = 'WebOnCoreImageGalleryShortcode'; return $shortcodes; } add_filter( 'webon_core_filter_register_shortcodes', 'webon_core_add_image_gallery_shortcode' ); } if ( class_exists( 'WebOnCoreListShortcode' ) ) { class WebOnCoreImageGalleryShortcode extends WebOnCoreListShortcode { public function map_shortcode() { $this->set_shortcode_path( WEBON_CORE_SHORTCODES_URL_PATH . '/image-gallery' ); $this->set_base( 'webon_core_image_gallery' ); $this->set_name( esc_html__( 'Image Gallery', 'webon-core' ) ); $this->set_description( esc_html__( 'Shortcode that adds image gallery 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' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'tagline', 'title' => esc_html__( 'Tagline', 'webon-core' ), 'dependency' => array( 'show' => array( 'behavior' => array( 'values' => 'slider', 'default_value' => '' ) ) ), 'group' => esc_html__( 'Tagline', 'webon-core' ), ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'tagline_color', 'title' => esc_html__( 'Tagline Color', 'webon-core' ), 'dependency' => array( 'show' => array( 'behavior' => array( 'values' => 'slider', 'default_value' => '' ) ) ), 'group' => esc_html__( 'Tagline', 'webon-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'title', 'title' => esc_html__( 'Title', 'webon-core' ), 'dependency' => array( 'show' => array( 'behavior' => array( 'values' => 'slider', 'default_value' => '' ) ) ), 'group' => esc_html__( 'Title', 'webon-core' ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'title_tag', 'title' => esc_html__( 'Title Tag', 'webon-core' ), 'options' => webon_core_get_select_type_options_pool( 'title_tag' ), 'default_value' => 'h3', 'dependency' => array( 'show' => array( 'behavior' => array( 'values' => 'slider', 'default_value' => '' ) ) ), 'group' => esc_html__( 'Title', 'webon-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'title_margin_top', 'title' => esc_html__( 'Margin Top (px or %)', 'webon-core' ), 'dependency' => array( 'show' => array( 'behavior' => array( 'values' => 'slider', 'default_value' => '' ) ) ), 'group' => esc_html__( 'Title', 'webon-core' ) ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'title_margin_bottom', 'title' => esc_html__( 'Margin Bottom (px or %)', 'webon-core' ), 'dependency' => array( 'show' => array( 'behavior' => array( 'values' => 'slider', 'default_value' => '' ) ) ), 'group' => esc_html__( 'Title', 'webon-core' ) ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'title_color', 'title' => esc_html__( 'Color', 'webon-core' ), 'dependency' => array( 'show' => array( 'behavior' => array( 'values' => 'slider', 'default_value' => '' ) ) ), 'group' => esc_html__( 'Title', 'webon-core' ), ) ); $this->set_option( array( 'field_type' => 'image', 'name' => 'images', 'multiple' => 'yes', 'title' => esc_html__( 'Images', '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' => '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' => 'select', 'name' => 'enable_hover_animation', 'title' => esc_html__( 'Enable Hover Animation', 'webon-core' ), 'options' => webon_core_get_select_type_options_pool( 'no_yes', false ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'caption', 'title' => esc_html__( 'Caption', 'webon-core' ), 'options' => webon_core_get_select_type_options_pool('no_yes', false), 'group' => esc_html__( 'Caption', 'webon-core' ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'caption_tag', 'title' => esc_html__( 'Caption Tag', 'webon-core' ), 'options' => webon_core_get_select_type_options_pool( 'title_tag', false ), 'default_value' => 'h5', 'dependency' => array( 'show' => array( 'caption' => array( 'values' => 'yes', 'default_value' => '' ) ) ), 'group' => esc_html__( 'Caption', 'webon-core' ), ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'caption_color', 'title' => esc_html__( 'Caption Color', 'webon-core' ), 'dependency' => array( 'show' => array( 'caption' => array( 'values' => 'yes', 'default_value' => '' ) ) ), 'group' => esc_html__( 'Caption', 'webon-core' ), ) ); $this->map_list_options( array( 'exclude_behavior' => array( 'justified-gallery' ), 'exclude_option' => array( 'images_proportion' ), 'group' => esc_html__( 'Gallery Settings', 'webon-core' ) ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'navigation_skin', 'title' => esc_html__( 'Navigation Skin', 'webon-core' ), 'options' => array( '' => esc_html__( 'Default', 'webon-core' ), 'light' => esc_html__( 'Light', 'webon-core' ) ), 'dependency' => array( 'show' => array( 'behavior' => array( 'values' => 'slider', 'default_value' => '' ) ) ), 'group' => esc_html__( 'Gallery Settings', 'webon-core' ), ) ); } public static function call_shortcode( $params ) { $html = qode_framework_call_shortcode( 'webon_core_image_gallery', $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['item_classes'] = $this->get_item_classes( $atts ); $atts['tagline_styles'] = $this->get_tagline_styles( $atts ); $atts['title_styles'] = $this->get_title_styles( $atts ); $atts['caption_styles'] = $this->get_caption_styles( $atts ); $atts['slider_attr'] = $this->get_slider_data( $atts ); $atts['images'] = $this->generate_images_params( $atts ); return webon_core_get_template_part( 'shortcodes/image-gallery', 'templates/image-gallery', $atts['behavior'], $atts ); } private function get_holder_classes( $atts ) { $holder_classes = $this->init_holder_classes(); $holder_classes[] = 'qodef-image-gallery'; $holder_classes[] = ! empty( $atts['image_action'] ) && $atts['image_action'] == 'open-popup' ? 'qodef-magnific-popup qodef-popup-gallery' : ''; $holder_classes[] = ! empty( $atts['navigation_skin'] ) ? 'qodef-skin--light' : ''; $holder_classes[] = ( $atts['enable_hover_animation'] == 'yes' ) ? 'qodef-has-hover-animation': ''; $list_classes = $this->get_list_classes( $atts ); $holder_classes = array_merge( $holder_classes, $list_classes ); return implode( ' ', $holder_classes ); } public function get_item_classes( $atts ) { $item_classes = $this->init_item_classes(); $item_classes[] = 'qodef-image-wrapper'; $list_item_classes = $this->get_list_item_classes( $atts ); $item_classes = array_merge( $item_classes, $list_item_classes ); return implode( ' ', $item_classes ); } private function get_tagline_styles( $atts ) { $styles = array(); if ( ! empty( $atts['tagline_color'] ) ) { $styles[] = 'color: ' . $atts['tagline_color']; } return $styles; } private function get_title_styles( $atts ) { $styles = array(); if ( $atts['title_margin_top'] !== '' ) { if ( qode_framework_string_ends_with_space_units( $atts['title_margin_top'] ) ) { $styles[] = 'margin-top: ' . $atts['title_margin_top']; } else { $styles[] = 'margin-top: ' . intval( $atts['title_margin_top'] ) . 'px'; } } if ( $atts['title_margin_bottom'] !== '' ) { if ( qode_framework_string_ends_with_space_units( $atts['title_margin_bottom'] ) ) { $styles[] = 'margin-bottom: ' . $atts['title_margin_bottom']; } else { $styles[] = 'margin-bottom: ' . intval( $atts['title_margin_bottom'] ) . 'px'; } } if ( ! empty( $atts['title_color'] ) ) { $styles[] = 'color: ' . $atts['title_color']; } return $styles; } private function get_caption_styles( $atts ) { $styles = array(); if ( ! empty( $atts['caption_color'] ) ) { $styles[] = 'color: ' . $atts['caption_color']; } return $styles; } private function generate_images_params( $atts ) { $image_ids = array(); $images = array(); $i = 0; if ( $atts['images'] !== '' ) { $image_ids = explode( ',', $atts['images'] ); } $image_size = $this->generate_image_size( $atts ); foreach ( $image_ids as $id ) { $image['image_id'] = intval( $id ); $image_original = wp_get_attachment_image_src( $id, 'full' ); $image['url'] = $this->generate_image_url( $id, $atts, $image_original[0] ); $image['alt'] = get_post_meta( $id, '_wp_attachment_image_alt', true ); $image['image_size'] = $image_size; $images[ $i ] = $image; $i ++; } return $images; } private function generate_image_size( $atts ) { $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' ) ) ) { return $image_size; } elseif ( ! empty( $matches[0] ) ) { return array( $matches[0][0], $matches[0][1] ); } else { return 'full'; } } private function generate_image_url( $id, $atts, $default ) { if ( $atts['image_action'] == 'custom-link' ) { $url = get_post_meta( $id, 'qodef_image_gallery_custom_link', true ); if ( empty( $url ) ) { $url = $default; } } else { $url = $default; } return $url; } } }
[+]
..
[-] media-custom-fields.php
[edit]
[+]
templates
[-] include.php
[edit]
[+]
assets
[-] image-gallery.php
[edit]
[-] image-gallery-elementor.php
[edit]