metabox()->get(get_the_ID(), 'gallery'); $gallery = !empty($gallery) ? json_decode(urldecode($gallery), true) : []; if (empty($gallery) || !is_array($gallery)) { return; } $uid = Wpw::inst()->helpers()->uid('carousel-'); $config = get_theme_mod('wpw_carousel_element'); $config = json_decode(urldecode($config), true); if (!is_array($config)) { $config = []; } if (!(isset($config['enable_carousel']) && $config['enable_carousel'])) { $config = []; } // defaults $_enable_prev_next = !empty($config['carousel_enable_prev_next']) ? $config['carousel_enable_prev_next'] : 'disable'; $_enable_pagination = !empty($config['carousel_enable_pagination']) ? $config['carousel_enable_pagination'] : 'disable'; $_prev_position = !empty($config['carousel_prev_next_position']) ? $config['carousel_prev_next_position'] : 'on_slides'; $_pagination_position = !empty($config['carousel_pagination_position']) ? $config['carousel_pagination_position'] : 'under_slides'; $_pagination_preset = !empty($config['carousel_pagination_preset']) ? $config['carousel_pagination_preset'] : 'round_shadow'; // values $ith = Wpw::inst(); $formatter = $ith->formatter(); $render = $ith->resource(); $prev_icon_styles = $prev_hover_icon_styles = $slide_style = $next_styles = $_prev_styles = $prev_styles = $prev_item_styles = $prev_hover_item_styles = $prev_hover_styles = $pagination_styles = $pagination_active_styles = $pagination_hover_styles = []; $item_template = (isset($item_template) && !empty($item_template)) ? $item_template : 'none'; if (empty($item_template)) { $item_template = get_posts([ 'post_type' => 'vc_grid_item', 'posts_per_page' => 1, 'order' => 'ASC', ]); $item_template = !empty($item_template[0]->ID) ? $item_template[0]->ID : null; } $view_md = (isset($view_md) && !empty($view_md)) ? $view_md : null; $view_md = $formatter->from_slider($view_md, [ 'number' => 1, ]); $view_sm = (isset($view_sm) && !empty($view_sm)) ? $view_sm : null; $view_sm = $formatter->from_slider($view_sm, [ 'number' => 1, ]); $view_xs = (isset($view_xs) && !empty($view_xs)) ? $view_xs : null; $view_xs = $formatter->from_slider($view_xs, [ 'number' => 1, ]); $slide_speed = (isset($slide_speed) && is_numeric($slide_speed)) ? floatval($slide_speed) : 2000; $transition_speed = (isset($transition_speed) && is_numeric($transition_speed)) ? floatval($transition_speed) : 750; $loop = (isset($loop) && $loop); $partial = (isset($partial) && is_numeric($partial)) ? intval($partial) : 0; $enable_prev_next = !empty($enable_prev_next) ? $enable_prev_next : $_enable_prev_next; $enable_pagination = !empty($enable_pagination) ? $enable_pagination : $_enable_pagination; $autoplay = (isset($autoplay) && $autoplay); $_height = !empty($config['carousel_height']) ? $config['carousel_height'] : 'auto'; if (trim(strtolower($_height)) == 'auto' || empty($_height)) { $_height = ''; } else { $_height = floatval($_height); } $_gap = !empty($config['carousel_element_gap']) ? $config['carousel_element_gap'] : ''; $element_gap = !empty($element_gap) ? $element_gap : $_gap; $element_gap = $formatter->from_slider($element_gap); $element_gap = $element_gap['number']; // data settings $orderby = (isset($orderby) && !empty($orderby)) ? $orderby : 'date'; $order = (isset($order) && !empty($order)) ? $order : 'DESC'; $offset = (isset($offset) && is_numeric($offset)) ? intval($offset) : 0; $exclude = (isset($exclude) && !empty($exclude)) ? $exclude : null; // prev next styles $_prev_content_type = !empty($config['carousel_prev_content_type']) ? $config['carousel_prev_content_type'] : 'icon'; $carousel_prev_content_type = !empty($carousel_prev_content_type) ? $carousel_prev_content_type : $_prev_content_type; $_prev_icon = !empty($config['carousel_prev_icon']) ? $config['carousel_prev_icon'] : 'ib-288'; $carousel_prev_icon = !empty($carousel_prev_icon) ? $carousel_prev_icon : $_prev_icon; $_next_icon = !empty($config['carousel_next_icon']) ? $config['carousel_next_icon'] : 'ib-289'; $_prev_text = !empty($config['carousel_prev_text']) ? $config['carousel_prev_text'] : esc_html__('Prev', 'anadbry'); $_next_text = !empty($config['carousel_next_text']) ? $config['carousel_next_text'] : esc_html__('Next', 'anadbry'); /** * -------------------------- Data -------------------------------------- */ $font = Wpw::inst()->storage()->get('default_icon_font'); $class_stack = [ 'arrows-position-' . $_prev_position, 'pagination-position-' . $_pagination_position, 'pagination-preset-' . $_pagination_preset, $uid, ]; $settings = [ 'per_view_md' => $view_md, 'per_view_sm' => $view_sm, 'per_view_xs' => $view_xs, 'slide_speed' => $slide_speed, 'transition_speed' => $transition_speed, 'loop' => $loop, 'animation_direction' => !empty($animation_direction) ? $animation_direction : 'horizontal', 'partial' => $partial, 'autoplay' => $autoplay, 'enable_prev_next' => $enable_prev_next == 'enable', 'enable_pagination' => $enable_pagination == 'enable', 'arrows_position' => $_prev_position, 'pagination_position' => $_pagination_position, 'pagination_preset' => $_pagination_preset, 'height' => $_height, ]; $class_carousel = count($gallery) > 1 ? 'project-carousel__wrap' : 'owl-loaded'; $icon = Wpw::inst()->icon(); $font = Wpw::inst()->storage()->get('default_icon_font'); wp_add_inline_script('anadbry-main-script', /** @lang JavaScript */ ' if (!window.wpwConfig) { window.wpwConfig = {}; } if ( !window.wpwConfig.carousels ) { window.wpwConfig.carousels = {}; } window.wpwConfig.carousels[ "' . $uid . '" ] = ' . json_encode(array_merge([ 'gap' => $element_gap, 'font' => $font, 'content_type' => $carousel_prev_content_type, 'prev' => $carousel_prev_content_type == 'text' ? $_prev_text : $icon->generate_icon($font, $carousel_prev_icon), 'next' => $carousel_prev_content_type == 'text' ? $_next_text : $icon->generate_icon($font, $_next_icon), ], $settings)) . ';'); ?>