Import legacy nurinda.co.id website
This commit is contained in:
1 parent
3f59bb9038
commit
6e21646ac4
13389 files changed
+3246690
No files matched your search
@@ -0,0 +1,215 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Closing part of Grid output
|
||||
*/
|
||||
|
||||
$us_grid_index = isset( $us_grid_index ) ? intval( $us_grid_index ) : 0;
|
||||
$post_id = isset( $post_id ) ? $post_id : NULL;
|
||||
$filter_html = isset( $filter_html ) ? $filter_html : '';
|
||||
$is_widget = isset( $is_widget ) ? $is_widget : FALSE;
|
||||
|
||||
// Check Grid params and use default values from config, if its not set
|
||||
$default_grid_params = us_shortcode_atts( array(), 'us_grid' );
|
||||
foreach ( $default_grid_params as $param => $value ) {
|
||||
if ( ! isset( $$param ) ) {
|
||||
$$param = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Check Carousel params and use default values from config, if its not set
|
||||
if ( $type == 'carousel' ) {
|
||||
$default_carousel_params = us_shortcode_atts( array(), 'us_carousel' );
|
||||
foreach ( $default_carousel_params as $param => $value ) {
|
||||
if ( ! isset( $$param ) ) {
|
||||
$$param = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( ! $is_widget ) AND ( $post_id != NULL ) AND ( $type != 'carousel' ) ) {
|
||||
$us_grid_ajax_indexes[ $post_id ] = isset( $us_grid_ajax_indexes[ $post_id ] ) ? ( $us_grid_ajax_indexes[ $post_id ] ) : 1;
|
||||
} else {
|
||||
$us_grid_ajax_indexes = NULL;
|
||||
}
|
||||
|
||||
// Global preloader type
|
||||
$preloader_type = us_get_option( 'preloader' );
|
||||
if ( ! in_array( $preloader_type, array_merge( us_get_preloader_numeric_types(), array( 'custom' ) ) ) ) {
|
||||
$preloader_type = 1;
|
||||
}
|
||||
$preloader_image = us_get_option( 'preloader_image' );
|
||||
$preloader_image_html = '';
|
||||
$img = usof_get_image_src( $preloader_image, 'medium' );
|
||||
if ( $preloader_type == 'custom' AND $img[0] != '' ) {
|
||||
$preloader_image_html .= '<img src="' . esc_url( $img[0] ) . '"';
|
||||
if ( ! empty( $img[1] ) AND ! empty( $img[2] ) ) {
|
||||
// Image sizes may be missing when logo is a direct URL
|
||||
$preloader_image_html .= ' width="' . $img[1] . '" height="' . $img[2] . '"';
|
||||
}
|
||||
$preloader_image_html .= ' alt="' . us_get_image_alt( $preloader_image ) . '"/>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
// Output preloader for Carousel and Filter
|
||||
if ( $filter_html != '' ) {
|
||||
?>
|
||||
<div class="w-grid-preloader">
|
||||
<div class="g-preloader type_<?php echo $preloader_type; ?>">
|
||||
<div><?php echo $preloader_image_html ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
} elseif ( $type == 'carousel' ) {
|
||||
?>
|
||||
<div class="g-preloader type_<?php echo $preloader_type; ?>">
|
||||
<div><?php echo $preloader_image_html ?></div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
// Output pagination for not Carousel type
|
||||
if ( $wp_query->max_num_pages > 1 AND $type != 'carousel' ) {
|
||||
|
||||
// Next page elements may have sliders, so we preloading the needed assets now
|
||||
if ( us_get_option( 'ajax_load_js', 0 ) == 0 ) {
|
||||
wp_enqueue_script( 'us-royalslider' );
|
||||
}
|
||||
|
||||
if ( $pagination == 'infinite' ) {
|
||||
$is_infinite = TRUE;
|
||||
$pagination = 'ajax';
|
||||
}
|
||||
if ( $pagination == 'regular' ) {
|
||||
the_posts_pagination(
|
||||
array(
|
||||
'mid_size' => 3,
|
||||
'before_page_number' => '<span>',
|
||||
'after_page_number' => '</span>',
|
||||
)
|
||||
);
|
||||
} elseif ( $pagination == 'ajax' ) {
|
||||
$pagination_btn_css = us_prepare_inline_css( array( 'font-size' => $pagination_btn_size ) );
|
||||
if ( $pagination_btn_fullwidth ) {
|
||||
$loadmore_classes = ' width_full';
|
||||
} else {
|
||||
$loadmore_classes = '';
|
||||
}
|
||||
?>
|
||||
<div class="g-loadmore<?php echo $loadmore_classes; ?>">
|
||||
<div class="g-preloader type_<?php echo $preloader_type; ?>">
|
||||
<div></div>
|
||||
</div>
|
||||
<a class="w-btn us-btn-style_<?php echo $pagination_btn_style ?>"<?php echo $pagination_btn_css ?> href="javascript:void(0)">
|
||||
<span class="w-btn-label"><?php echo $pagination_btn_text ?></span>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
// Define and output all JSON data
|
||||
$json_data = array(
|
||||
|
||||
// Controller options
|
||||
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
||||
'permalink_url' => get_permalink(),
|
||||
'action' => 'us_ajax_grid',
|
||||
'max_num_pages' => $wp_query->max_num_pages,
|
||||
'infinite_scroll' => ( isset( $is_infinite ) ? $is_infinite : 0 ),
|
||||
|
||||
// Grid listing template variables that will be passed to this file in the next call
|
||||
'template_vars' => array(
|
||||
'query_args' => $query_args,
|
||||
'post_id' => $post_id,
|
||||
'us_grid_index' => $us_grid_index,
|
||||
'us_grid_ajax_index' => $us_grid_ajax_indexes[ $post_id ],
|
||||
'exclude_items' => $exclude_items,
|
||||
'items_offset' => $items_offset,
|
||||
'items_layout' => $items_layout,
|
||||
'type' => $type,
|
||||
'columns' => $columns,
|
||||
'img_size' => $img_size,
|
||||
'overriding_link' => $overriding_link,
|
||||
),
|
||||
);
|
||||
|
||||
// Carousel settings
|
||||
if ( $type == 'carousel' ) {
|
||||
$json_data = array_merge( $json_data, array(
|
||||
'carousel_settings' => array(
|
||||
'items' => $columns,
|
||||
'nav' => intval( ! ! $carousel_arrows ),
|
||||
'navNext' => '',
|
||||
'navPrev' => '',
|
||||
'dots' => intval( ! ! $carousel_dots ),
|
||||
'center' => intval( ! ! $carousel_center ),
|
||||
'autoplay' => ( $carousel_autoplay AND ( $items_count > $columns ) ) ? 1 : 0,
|
||||
'smooth_play' => intval( ! ! $carousel_autoplay_smooth ),
|
||||
'timeout' => intval( $carousel_interval * 1000 ),
|
||||
'speed' => intval( $carousel_speed ),
|
||||
'transition' => strip_tags( $carousel_transition ),
|
||||
'autoHeight' => ( $columns == 1 ) ? intval( $carousel_autoheight ) : 0,
|
||||
'slideby' => ( $carousel_slideby ? 'page' : '1' ),
|
||||
),
|
||||
'carousel_breakpoints' => array(
|
||||
intval( $breakpoint_1_width ) => array(
|
||||
'items' => intval( $columns ),
|
||||
),
|
||||
intval( $breakpoint_2_width ) => array(
|
||||
'items' => min( intval( $breakpoint_1_cols ), $columns ),
|
||||
'autoplay' => intval( ! ! $breakpoint_1_autoplay ),
|
||||
'autoplayHoverPause' => intval( ! ! $breakpoint_1_autoplay ),
|
||||
),
|
||||
intval( $breakpoint_3_width ) => array(
|
||||
'items' => min( intval( $breakpoint_2_cols ), $columns ),
|
||||
'autoplay' => intval( ! ! $breakpoint_2_autoplay ),
|
||||
'autoplayHoverPause' => intval( ! ! $breakpoint_2_autoplay ),
|
||||
),
|
||||
0 => array(
|
||||
'items' => min( intval( $breakpoint_3_cols ), $columns ),
|
||||
'autoplay' => intval( ! ! $breakpoint_3_autoplay ),
|
||||
'autoplayHoverPause' => intval( ! ! $breakpoint_3_autoplay ),
|
||||
'autoHeight' => ( $carousel_autoheight AND ! $breakpoint_3_autoplay ) ? 1 : 0,
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Add lang variable if WPML is active
|
||||
if ( class_exists( 'SitePress' ) ) {
|
||||
global $sitepress;
|
||||
if ( $sitepress->get_default_language() != $sitepress->get_current_language() ) {
|
||||
$json_data['template_vars']['lang'] = $sitepress->get_current_language();
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="w-grid-json hidden"<?php echo us_pass_data_to_js( $json_data ) ?>></div>
|
||||
<?php
|
||||
|
||||
// Output popup semantics
|
||||
if ( $overriding_link == 'popup_post' ) {
|
||||
?>
|
||||
<div class="l-popup">
|
||||
<div class="l-popup-overlay"></div>
|
||||
<div class="l-popup-wrap">
|
||||
<div class="l-popup-box">
|
||||
<div class="l-popup-box-content"<?php echo us_prepare_inline_css( array( 'max-width' => $popup_width ) ); ?>>
|
||||
<div class="g-preloader type_<?php echo $preloader_type; ?>">
|
||||
<div><?php echo $preloader_image_html ?></div>
|
||||
</div>
|
||||
<iframe class="l-popup-box-content-frame" allowfullscreen></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ( $popup_arrows ) { ?>
|
||||
<div class="l-popup-arrow to_next" title="Next"></div>
|
||||
<div class="l-popup-arrow to_prev" title="Previous"></div>
|
||||
<?php } ?>
|
||||
<div class="l-popup-closer"></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Output one post from Grid listing.
|
||||
*
|
||||
* (!) Should be called in WP_Query fetching loop only.
|
||||
* @link https://codex.wordpress.org/Class_Reference/WP_Query#Standard_Loop
|
||||
*
|
||||
* @var $post_classes string CSS classes
|
||||
*
|
||||
* @action Before the template: 'us_before_template:templates/grid/listing-post'
|
||||
* @action After the template: 'us_after_template:templates/grid/listing-post'
|
||||
* @filter Template variables: 'us_template_vars:templates/grid/listing-post'
|
||||
*/
|
||||
|
||||
global $us_grid_listing_post_atts;
|
||||
$grid_layout_settings = $us_grid_listing_post_atts['grid_layout_settings'];
|
||||
$type = $us_grid_listing_post_atts['type'];
|
||||
$is_widget = $us_grid_listing_post_atts['is_widget'];
|
||||
$overriding_link = $us_grid_listing_post_atts['overriding_link'];
|
||||
|
||||
$post_classes = 'w-grid-item';
|
||||
|
||||
// Aspect ratio class
|
||||
if ( us_arr_path( $grid_layout_settings, 'default.options.ratio' ) ) {
|
||||
$post_classes .= ' ratio_' . us_arr_path( $grid_layout_settings, 'default.options.ratio' );
|
||||
}
|
||||
|
||||
// Size class for Portfolio Pages
|
||||
if ( $type != 'carousel' AND ! $is_widget AND usof_meta( 'us_tile_size' ) != '' ) {
|
||||
$post_classes .= ' size_' . usof_meta( 'us_tile_size' );
|
||||
}
|
||||
|
||||
// Custom colors for Portfolio Pages
|
||||
$inline_css = us_prepare_inline_css(
|
||||
array(
|
||||
'background' => usof_meta( 'us_tile_bg_color' ),
|
||||
'color' => usof_meta( 'us_tile_text_color' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Generate Overriding Link semantics to the whole grid item
|
||||
$link_url = $link_atts = '';
|
||||
$link_title = FALSE;
|
||||
if ( $overriding_link == 'post' OR $overriding_link == 'popup_post' ) {
|
||||
// Force custom link from metabox option
|
||||
$tile_custom_link = json_decode( usof_meta( 'us_tile_link' ), TRUE );
|
||||
if ( $tile_custom_link AND ! empty( $tile_custom_link['url'] ) ) {
|
||||
$link_url = $tile_custom_link['url'];
|
||||
if ( ! empty( $tile_custom_link['target'] ) ) {
|
||||
$link_atts .= ' target="_blank"';
|
||||
// If link to an image, open it in a popup
|
||||
} elseif ( preg_match( "/\.(bmp|gif|jpeg|jpg|png)$/i", $link_url ) ) {
|
||||
$link_atts .= ' ref="magnificPopupGrid" title="' . esc_attr( strip_tags( get_the_title() ) ) . '"';
|
||||
$link_title = TRUE;
|
||||
}
|
||||
$post_classes .= ' custom-link';
|
||||
} else {
|
||||
$link_url = apply_filters( 'the_permalink', get_permalink() );
|
||||
$link_atts .= ' rel="bookmark"';
|
||||
}
|
||||
// Force opening in a new tab for "Link" post format
|
||||
if ( get_post_format() == 'link' ) {
|
||||
$link_atts .= ' target="_blank"';
|
||||
}
|
||||
} elseif ( $overriding_link == 'popup_post_image' ) {
|
||||
$tnail_id = get_post_thumbnail_id();
|
||||
$link_url = wp_get_attachment_image_url( $tnail_id, 'full' );
|
||||
if ( $link_url ) {
|
||||
// Use the Caption as a Title
|
||||
$attachment = get_post( $tnail_id );
|
||||
$img_title = trim( strip_tags( $attachment->post_excerpt ) );
|
||||
if ( empty( $img_title ) ) {
|
||||
// If not, Use the Alt
|
||||
$img_title = trim( strip_tags( get_post_meta( $attachment->ID, '_wp_attachment_image_alt', TRUE ) ) );
|
||||
}
|
||||
if ( empty( $img_title ) ) {
|
||||
// If no Alt, use the Title
|
||||
$img_title = trim( strip_tags( get_the_title() ) );
|
||||
}
|
||||
$link_atts .= ' ref="magnificPopupGrid" title="' . esc_attr( $img_title ) . '"';
|
||||
$link_title = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Add aria-label if "title" attribute is absent for accessibility support
|
||||
if ( ! $link_title ) {
|
||||
$link_atts .= ' aria-label="' . esc_attr( strip_tags( get_the_title() ) ) . '"';
|
||||
}
|
||||
|
||||
// Apply theme filter
|
||||
$post_classes = apply_filters( 'us_grid_item_classes', $post_classes, get_the_id() );
|
||||
?>
|
||||
<article <?php post_class( $post_classes ) ?> data-id="<?php the_ID() ?>">
|
||||
<div class="w-grid-item-h"<?php echo $inline_css ?>>
|
||||
<?php if ( $link_url ): ?>
|
||||
<a class="w-grid-item-anchor" href="<?php echo esc_url( $link_url ) ?>"<?php echo $link_atts ?>></a>
|
||||
<?php endif; ?>
|
||||
<?php us_output_builder_elms( $grid_layout_settings, 'default', 'middle_center', 'grid' ); ?>
|
||||
</div>
|
||||
</article>
|
||||
<?php
|
||||
@@ -0,0 +1,379 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Opening part of Grid output
|
||||
*/
|
||||
|
||||
// Variables defaults
|
||||
$list_classes = $css_listing = $css_layout = '';
|
||||
|
||||
$us_grid_index = isset( $us_grid_index ) ? intval( $us_grid_index ) : 0;
|
||||
$is_widget = isset( $is_widget ) ? $is_widget : FALSE;
|
||||
$classes = isset( $classes ) ? $classes : '';
|
||||
$filter_html = isset( $filter_html ) ? $filter_html : '';
|
||||
$data_atts = isset( $data_atts ) ? $data_atts : '';
|
||||
|
||||
// Check Grid params and use default values from config, if its not set
|
||||
$default_grid_params = us_shortcode_atts( array(), 'us_grid' );
|
||||
foreach ( $default_grid_params as $param => $value ) {
|
||||
if ( ! isset( $$param ) ) {
|
||||
$$param = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Check Carousel params and use default values from config, if its not set
|
||||
if ( $type == 'carousel' ) {
|
||||
$default_carousel_params = us_shortcode_atts( array(), 'us_carousel' );
|
||||
foreach ( $default_carousel_params as $param => $value ) {
|
||||
if ( ! isset( $$param ) ) {
|
||||
$$param = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set grid ID
|
||||
$grid_elm_id = ( ! empty( $el_id ) ) ? $el_id : 'us_grid_' . $us_grid_index;
|
||||
|
||||
// Calculate or not specific CSS for grid items depending on Grid Layout Aspect Ratio
|
||||
$grid_fixed_ratio = us_arr_path( $grid_layout_settings, 'default.options.fixed' );
|
||||
|
||||
// Additional classes for "w-grid"
|
||||
$classes .= ' type_' . $type;
|
||||
$classes .= ' layout_' . $items_layout;
|
||||
if ( $columns != 1 AND $type != 'carousel' ) {
|
||||
$classes .= ' cols_' . $columns;
|
||||
}
|
||||
if ( $items_valign ) {
|
||||
$classes .= ' valign_center';
|
||||
}
|
||||
if ( $pagination == 'regular' ) {
|
||||
$classes .= ' with_pagination';
|
||||
}
|
||||
if ( $grid_fixed_ratio ) {
|
||||
$classes .= ' height_fixed';
|
||||
} elseif ( us_arr_path( $grid_layout_settings, 'default.options.overflow' ) ) {
|
||||
$classes .= ' overflow_hidden';
|
||||
}
|
||||
if ( $overriding_link == 'popup_post' ) {
|
||||
$classes .= ' popup_page';
|
||||
}
|
||||
if ( $filter_html != '' ) {
|
||||
$classes .= ' with_filters';
|
||||
}
|
||||
|
||||
// Apply isotope script for Masonry type
|
||||
if ( $type == 'masonry' AND $columns > 1 ) {
|
||||
if ( us_get_option( 'ajax_load_js', 0 ) == 0 ) {
|
||||
wp_enqueue_script( 'us-isotope' );
|
||||
}
|
||||
$classes .= ' with_isotope';
|
||||
}
|
||||
|
||||
// Output attributes for Carousel type
|
||||
if ( $type == 'carousel' ) {
|
||||
if ( us_get_option( 'ajax_load_js', 0 ) == 0 ) {
|
||||
wp_enqueue_script( 'us-owl' );
|
||||
}
|
||||
|
||||
$list_classes .= ' owl-carousel';
|
||||
$list_classes .= ' navstyle_' . $carousel_arrows_style;
|
||||
$list_classes .= ' navpos_' . $carousel_arrows_pos;
|
||||
if ( $carousel_dots ) {
|
||||
$list_classes .= ' with_dots';
|
||||
}
|
||||
if ( $columns == 1 AND $carousel_autoheight ) {
|
||||
$list_classes .= ' autoheight';
|
||||
}
|
||||
|
||||
// Customize Carousel Arrows for current listing only
|
||||
if ( $carousel_arrows ) {
|
||||
if ( ! empty( $carousel_arrows_size ) AND $carousel_arrows_size != '1.8rem' ) {
|
||||
$css_listing .= '#' . $grid_elm_id . ' .owl-nav div { font-size: ' . strip_tags( $carousel_arrows_size ) . '}';
|
||||
}
|
||||
if ( ! empty( $carousel_arrows_offset ) ) {
|
||||
$css_listing .= '#' . $grid_elm_id . ' .owl-nav div { margin-left: ' . strip_tags( $carousel_arrows_offset ) . '; margin-right: ' . strip_tags( $carousel_arrows_offset ) . '}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Generate items gap via CSS
|
||||
if ( ! empty( $items_gap ) ) {
|
||||
if ( $columns != 1 ) {
|
||||
$css_listing .= '#' . $grid_elm_id . ' .w-grid-item { padding: ' . $items_gap . '}';
|
||||
if ( ! empty( $filter_html ) AND $pagination == 'none' ) {
|
||||
$css_listing .= '#' . $grid_elm_id . ' .w-grid-list { margin: ' . $items_gap . ' -' . $items_gap . ' -' . $items_gap . '}';
|
||||
}
|
||||
if ( ! empty( $filter_html ) AND $pagination != 'none' ) {
|
||||
$css_listing .= '#' . $grid_elm_id . ' .w-grid-list { margin: ' . $items_gap . ' -' . $items_gap . '}';
|
||||
}
|
||||
if ( empty( $filter_html ) AND $pagination != 'none' ) {
|
||||
$css_listing .= '#' . $grid_elm_id . ' .w-grid-list { margin: -' . $items_gap . ' -' . $items_gap . ' ' . $items_gap . '}';
|
||||
}
|
||||
if ( empty( $filter_html ) AND $pagination == 'none' ) {
|
||||
$css_listing .= '#' . $grid_elm_id . ' .w-grid-list { margin: -' . $items_gap . '}';
|
||||
}
|
||||
// Force gap between neighbour "w-grid" elements
|
||||
$css_listing .= '.w-grid + #' . $grid_elm_id . ' .w-grid-list { margin-top: ' . $items_gap . '}';
|
||||
// Force left & right gaps for grid-list in fullwidth section
|
||||
$css_listing .= '.l-section.width_full > div > div > .vc_col-sm-12 > div > div > #' . $grid_elm_id . ' .w-grid-list { margin-left: ' . $items_gap . '; margin-right: ' . $items_gap . '}';
|
||||
// Force top & bottom gaps for grid-list in fullheight section
|
||||
$css_listing .= '.l-section.height_auto > div > div > .vc_col-sm-12 > div > div > #' . $grid_elm_id . ':first-child .w-grid-list { margin-top: ' . $items_gap . '}';
|
||||
$css_listing .= '.l-section.height_auto > div > div > .vc_col-sm-12 > div > div > #' . $grid_elm_id . ':last-child .w-grid-list { margin-bottom: ' . $items_gap . '}';
|
||||
} elseif ( $type != 'carousel' ) {
|
||||
$css_listing .= '#' . $grid_elm_id . ' .w-grid-item:not(:last-child) { margin-bottom: ' . $items_gap . '}';
|
||||
$css_listing .= '#' . $grid_elm_id . ' .g-loadmore { margin-top: ' . $items_gap . '}';
|
||||
}
|
||||
} else {
|
||||
$classes .= ' no_gap';
|
||||
}
|
||||
|
||||
// Generate columns responsive CSS for 3 breakpoints
|
||||
if ( $type != 'carousel' AND ! $is_widget ) {
|
||||
for ( $i = 1; $i < 4; $i ++ ) {
|
||||
$responsive_cols = intval( ${ 'breakpoint_' . $i .'_cols' } );
|
||||
$responsive_width = intval( ${ 'breakpoint_' . $i . '_width' } );
|
||||
|
||||
if ( $columns > $responsive_cols ) {
|
||||
$css_listing .= '@media (max-width:' . ( $responsive_width - 1 ) . 'px) {';
|
||||
if ( $responsive_cols == 1 AND ! empty( $items_gap ) ) {
|
||||
$css_listing .= '#' . $grid_elm_id . ' .w-grid-list { margin: 0 }';
|
||||
}
|
||||
$css_listing .= '#' . $grid_elm_id . ' .w-grid-item { width:' . 100 / $responsive_cols . '%;';
|
||||
if ( $responsive_cols == 1 AND ! empty( $items_gap ) ) {
|
||||
$css_listing .= 'padding: 0; margin-bottom: ' . $items_gap;
|
||||
}
|
||||
$css_listing .= '}';
|
||||
if ( $responsive_cols != 1 AND $grid_fixed_ratio ) {
|
||||
$css_listing .= '#' . $grid_elm_id . ' .w-grid-item.size_2x1,';
|
||||
$css_listing .= '#' . $grid_elm_id . ' .w-grid-item.size_2x2 {';
|
||||
$css_listing .= 'width:' . 200 / $responsive_cols . '% }';
|
||||
}
|
||||
$css_listing .= '}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add Post Title font-size for current listing only
|
||||
if ( $title_size != '' ) {
|
||||
$css_listing .= '#' . $grid_elm_id . ' .w-post-elm.post_title { font-size: ' . strip_tags( $title_size ) . '}';
|
||||
}
|
||||
|
||||
// Calculate items aspect ratio
|
||||
if ( $grid_fixed_ratio ) {
|
||||
$grid_elm_ratio_w = $grid_elm_ratio_h = 1;
|
||||
|
||||
$grid_elm_ratio = us_arr_path( $grid_layout_settings, 'default.options.ratio' );
|
||||
if ( $grid_elm_ratio == '4x3' ) {
|
||||
$grid_elm_ratio_w = 4;
|
||||
$grid_elm_ratio_h = 3;
|
||||
} elseif ( $grid_elm_ratio == '3x2' ) {
|
||||
$grid_elm_ratio_w = 3;
|
||||
$grid_elm_ratio_h = 2;
|
||||
} elseif ( $grid_elm_ratio == '2x3' ) {
|
||||
$grid_elm_ratio_w = 2;
|
||||
$grid_elm_ratio_h = 3;
|
||||
} elseif ( $grid_elm_ratio == '3x4' ) {
|
||||
$grid_elm_ratio_w = 3;
|
||||
$grid_elm_ratio_h = 4;
|
||||
} elseif ( $grid_elm_ratio == '16x9' ) {
|
||||
$grid_elm_ratio_w = 16;
|
||||
$grid_elm_ratio_h = 9;
|
||||
} elseif ( $grid_elm_ratio == 'custom' ) {
|
||||
$grid_elm_ratio_w = floatval( str_replace( ',', '.', preg_replace( '/^[^\d.,]+$/', '', us_arr_path( $grid_layout_settings, 'default.options.ratio_width' ) ) ) );
|
||||
if ( $grid_elm_ratio_w <= 0 ) {
|
||||
$grid_elm_ratio_w = 1;
|
||||
}
|
||||
$grid_elm_ratio_h = floatval( str_replace( ',', '.', preg_replace( '/^[^\d.,]+$/', '', us_arr_path( $grid_layout_settings, 'default.options.ratio_height' ) ) ) );
|
||||
if ( $grid_elm_ratio_h <= 0 ) {
|
||||
$grid_elm_ratio_h = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply grid item aspect ratio
|
||||
$css_layout .= '#' . $grid_elm_id . ' .w-grid-item-h:before {';
|
||||
$css_layout .= 'padding-bottom: ' . number_format( $grid_elm_ratio_h / $grid_elm_ratio_w * 100, 4 ) . '%}';
|
||||
|
||||
// Fix aspect ratio regarding meta custom size and items gap
|
||||
if ( empty( $items_gap ) ) {
|
||||
$items_gap = '0px'; // needed for CSS calc function
|
||||
}
|
||||
if ( $type != 'carousel' AND ! $is_widget ) {
|
||||
$css_layout .= '@media (min-width:' . intval( $breakpoint_3_width ) . 'px) {';
|
||||
$css_layout .= '#' . $grid_elm_id . ' .w-grid-item.size_1x2 .w-grid-item-h:before {';
|
||||
$css_layout .= 'padding-bottom: calc(' . ( $grid_elm_ratio_h * 2 ) / $grid_elm_ratio_w * 100 . '% + ' . $items_gap . ' + ' . $items_gap . ')}';
|
||||
$css_layout .= '#' . $grid_elm_id . ' .w-grid-item.size_2x1 .w-grid-item-h:before {';
|
||||
$css_layout .= 'padding-bottom: calc(' . $grid_elm_ratio_h / ( $grid_elm_ratio_w * 2 ) * 100 . '% - ' . $items_gap . ' * ' . $grid_elm_ratio_h / $grid_elm_ratio_w . ')}';
|
||||
$css_layout .= '#' . $grid_elm_id . ' .w-grid-item.size_2x2 .w-grid-item-h:before {';
|
||||
$css_layout .= 'padding-bottom: calc(' . $grid_elm_ratio_h / $grid_elm_ratio_w * 100 . '% - ' . $items_gap . ' * ' . 2 * ( $grid_elm_ratio_h / $grid_elm_ratio_w - 1 ) . ')}';
|
||||
$css_layout .= '}';
|
||||
}
|
||||
}
|
||||
|
||||
// Generate Grid Layout settings CSS
|
||||
$item_bg_color = us_arr_path( $grid_layout_settings, 'default.options.color_bg' );
|
||||
$item_text_color = us_arr_path( $grid_layout_settings, 'default.options.color_text' );
|
||||
$item_border_radius = floatval( us_arr_path( $grid_layout_settings, 'default.options.border_radius' ) );
|
||||
$item_box_shadow = floatval( us_arr_path( $grid_layout_settings, 'default.options.box_shadow' ) );
|
||||
$item_box_shadow_hover = floatval( us_arr_path( $grid_layout_settings, 'default.options.box_shadow_hover' ) );
|
||||
|
||||
$css_layout .= '#' . $grid_elm_id . ' .w-grid-item-h {';
|
||||
if ( ! empty( $item_bg_color ) ) {
|
||||
$css_layout .= 'background:' . $item_bg_color . ';';
|
||||
}
|
||||
if ( ! empty( $item_text_color ) ) {
|
||||
$css_layout .= 'color:' . $item_text_color . ';';
|
||||
}
|
||||
if ( ! empty( $item_border_radius ) ) {
|
||||
$css_layout .= 'border-radius:' . $item_border_radius . 'rem;';
|
||||
$css_layout .= 'z-index: 3;';
|
||||
}
|
||||
if ( ! empty( $item_box_shadow ) OR ! empty( $item_box_shadow_hover ) ) {
|
||||
$css_layout .= 'box-shadow:';
|
||||
$css_layout .= '0 ' . number_format( $item_box_shadow / 10, 2 ) . 'rem ' . number_format( $item_box_shadow / 5, 2 ) . 'rem rgba(0,0,0,0.1),';
|
||||
$css_layout .= '0 ' . number_format( $item_box_shadow / 3, 2 ) . 'rem ' . number_format( $item_box_shadow, 2 ) . 'rem rgba(0,0,0,0.1);';
|
||||
$css_layout .= 'transition-duration: 0.3s;';
|
||||
}
|
||||
$css_layout .= '}';
|
||||
if ( $item_box_shadow_hover != $item_box_shadow ) {
|
||||
$css_layout .= '.no-touch #' . $grid_elm_id . ' .w-grid-item-h:hover { box-shadow:';
|
||||
$css_layout .= '0 ' . number_format( $item_box_shadow_hover / 10, 2 ) . 'rem ' . number_format( $item_box_shadow_hover / 5, 2 ) . 'rem rgba(0,0,0,0.1),';
|
||||
$css_layout .= '0 ' . number_format( $item_box_shadow_hover / 3, 2 ) . 'rem ' . number_format( $item_box_shadow_hover, 2 ) . 'rem rgba(0,0,0,0.15);';
|
||||
$css_layout .= 'z-index: 4;';
|
||||
$css_layout .= '}';
|
||||
}
|
||||
|
||||
// Generate Grid Layout elements CSS
|
||||
$css_data = array();
|
||||
foreach ( $grid_layout_settings['data'] as $elm_id => $elm ) {
|
||||
$elm_class = 'usg_' . str_replace( ':', '_', $elm_id );
|
||||
|
||||
// Elements settings
|
||||
$css_layout .= '#' . $grid_elm_id . ' .' . $elm_class . '{';
|
||||
$elm_tag = isset( $elm['tag'] ) ? $elm['tag'] : 'div';
|
||||
$css_layout .= us_prepare_inline_css(
|
||||
array(
|
||||
'font-family' => isset( $elm['font'] ) ? $elm['font'] : '',
|
||||
'font-weight' => isset( $elm['font_weight'] ) ? $elm['font_weight'] : '',
|
||||
'text-transform' => isset( $elm['text_transform'] ) ? $elm['text_transform'] : '',
|
||||
'font-style' => isset( $elm['font_style'] ) ? $elm['font_style'] : '',
|
||||
'font-size' => isset( $elm['font_size'] ) ? $elm['font_size'] : '',
|
||||
'line-height' => isset( $elm['line_height'] ) ? $elm['line_height'] : '',
|
||||
'border-radius' => isset( $elm['border_radius'] ) ? $elm['border_radius'] : '',
|
||||
'width' => isset( $elm['width'] ) ? $elm['width'] : '',
|
||||
'flex-shrink' => ! empty( $elm['width'] ) ? '0' : '',
|
||||
'background' => isset( $elm['color_bg'] ) ? $elm['color_bg'] : '',
|
||||
'border-color' => isset( $elm['color_border'] ) ? $elm['color_border'] : '',
|
||||
'color' => isset( $elm['color_text'] ) ? $elm['color_text'] : '',
|
||||
),
|
||||
$style_attr = FALSE,
|
||||
$elm_tag
|
||||
);
|
||||
$css_layout .= ( isset( $elm['bg_gradient'] ) AND $elm['bg_gradient'] AND ! empty( $elm['color_grad'] ) ) ? 'background: linear-gradient( transparent, ' . $elm['color_grad'] . ');' : '';
|
||||
$css_layout .= '}';
|
||||
if ( ! empty( $elm['font_size_mobiles'] ) ) {
|
||||
$css_layout .= '@media (max-width:' . ( intval( $breakpoint_3_width ) - 1 ) . 'px) {';
|
||||
$css_layout .= '#' . $grid_elm_id . ' .' . $elm_class . '{';
|
||||
$css_layout .= 'font-size:' . $elm['font_size_mobiles'] . ' !important;';
|
||||
$css_layout .= '}}';
|
||||
}
|
||||
if ( ! empty( $elm['line_height_mobiles'] ) ) {
|
||||
$css_layout .= '@media (max-width:' . ( intval( $breakpoint_3_width ) - 1 ) . 'px) {';
|
||||
$css_layout .= '#' . $grid_elm_id . ' .' . $elm_class . '{';
|
||||
$css_layout .= 'line-height:' . $elm['line_height_mobiles'] . ' !important;';
|
||||
$css_layout .= '}}';
|
||||
}
|
||||
if ( isset( $elm['hide_below'] ) AND intval( $elm['hide_below'] ) != 0 ) {
|
||||
$css_layout .= '@media (max-width:' . ( intval( $elm['hide_below'] ) - 1 ) . 'px) {';
|
||||
$css_layout .= '#' . $grid_elm_id . ' .' . $elm_class . '{ display: none !important; }';
|
||||
$css_layout .= '}';
|
||||
}
|
||||
|
||||
// CSS of Hover effects
|
||||
if ( isset( $elm['hover'] ) AND $elm['hover'] ) {
|
||||
$css_layout .= '#' . $grid_elm_id . ' .' . $elm_class . '{';
|
||||
$css_layout .= isset( $elm['transition_duration'] ) ? 'transition-duration:' . $elm['transition_duration'] . ';' : '';
|
||||
if ( isset( $elm['scale'] ) AND isset( $elm['translateX'] ) AND isset( $elm['translateY'] ) ) {
|
||||
$css_layout .= 'transform: scale(' . $elm['scale'] . ') translate(' . $elm['translateX'] . ',' . $elm['translateY'] . ');';
|
||||
}
|
||||
$css_layout .= ( isset( $elm['opacity'] ) AND intval( $elm['opacity'] ) != 1 ) ? 'opacity:' . $elm['opacity'] . ';' : '';
|
||||
$css_layout .= '}';
|
||||
|
||||
$css_layout .= '#' . $grid_elm_id . ' .w-grid-item-h:hover .' . $elm_class . '{';
|
||||
if ( isset( $elm['scale_hover'] ) AND isset( $elm['translateX_hover'] ) AND isset( $elm['translateY_hover'] ) ) {
|
||||
$css_layout .= 'transform: scale(' . $elm['scale_hover'] . ') translate(' . $elm['translateX_hover'] . ',' . $elm['translateY_hover'] . ');';
|
||||
}
|
||||
$css_layout .= isset( $elm['opacity_hover'] ) ? 'opacity:' . $elm['opacity_hover'] . ';' : '';
|
||||
$css_layout .= ( ! empty( $elm['color_bg_hover'] ) ) ? 'background:' . $elm['color_bg_hover'] . ';' : '';
|
||||
$css_layout .= ( ! empty( $elm['color_border_hover'] ) ) ? 'border-color:' . $elm['color_border_hover'] . ';' : '';
|
||||
$css_layout .= ( ! empty( $elm['color_text_hover'] ) ) ? 'color:' . $elm['color_text_hover'] . ';' : '';
|
||||
$css_layout .= '}';
|
||||
}
|
||||
|
||||
// CSS Design Options
|
||||
if ( ! empty( $elm['design_options'] ) AND is_array( $elm['design_options'] ) ) {
|
||||
foreach ( $elm['design_options'] as $key => $value ) {
|
||||
if ( $value === '' ) {
|
||||
continue;
|
||||
}
|
||||
$key = explode( '_', $key );
|
||||
if ( ! isset( $css_data[ $key[2] ] ) ) {
|
||||
$css_data[ $key[2] ] = array();
|
||||
}
|
||||
if ( ! isset( $css_data[ $key[2] ][ $elm_class ] ) ) {
|
||||
$css_data[ $key[2] ][ $elm_class ] = array();
|
||||
}
|
||||
if ( ! isset( $css_data[ $key[2] ][ $elm_class ][ $key[0] ] ) ) {
|
||||
$css_data[ $key[2] ][ $elm_class ][ $key[0] ] = array();
|
||||
}
|
||||
$css_data[ $key[2] ][ $elm_class ][ $key[0] ][ $key[1] ] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( array( 'default' ) as $state ) {
|
||||
if ( ! isset( $css_data[ $state ] ) ) {
|
||||
continue;
|
||||
}
|
||||
foreach ( $css_data[ $state ] as $elm_class => $props ) {
|
||||
$css_layout .= '#' . $grid_elm_id . ' .' . $elm_class . '{';
|
||||
foreach ( $props as $prop => $values ) {
|
||||
// Add absolute positioning if its values not empty
|
||||
if ( $prop === 'position' AND ! empty( $values ) ) {
|
||||
$css_layout .= 'position: absolute;';
|
||||
}
|
||||
// Add solid border if its values not empty
|
||||
if ( $prop === 'border' AND ! empty( $values ) ) {
|
||||
$css_layout .= 'border-style: solid; border-width: 0;';
|
||||
}
|
||||
if ( count( $values ) == 4 AND count( array_unique( $values ) ) == 1 AND $prop !== 'position' ) {
|
||||
// All the directions have the same value, so grouping them together
|
||||
$values = array_values( $values );
|
||||
|
||||
if ( $prop === 'border' ) {
|
||||
$css_layout .= $prop . '-width:' . $values[0] . ';';
|
||||
} else {
|
||||
$css_layout .= $prop . ':' . $values[0] . ';';
|
||||
}
|
||||
} else {
|
||||
foreach ( $values as $dir => $val ) {
|
||||
if ( $prop === 'position' ) {
|
||||
$css_prop = $dir;
|
||||
} elseif ( $prop === 'border' ) {
|
||||
$css_prop = $prop . '-' . $dir . '-width';
|
||||
} else {
|
||||
$css_prop = $prop . '-' . $dir;
|
||||
}
|
||||
$css_layout .= $css_prop . ':' . $val . ';';
|
||||
}
|
||||
}
|
||||
}
|
||||
$css_layout .= "}";
|
||||
}
|
||||
}
|
||||
|
||||
// Output the Grid semantics
|
||||
echo '<div class="w-grid' . $classes . '" id="' . esc_attr( $grid_elm_id ) . '">';
|
||||
echo '<style id="' . $grid_elm_id . '_css">' . us_minify_css( $css_listing ) . '</style>';
|
||||
echo '<style>' . us_minify_css( $css_layout ) . '</style>'; // TODO make this depends on the previous Grid Layout of a page
|
||||
echo $filter_html;
|
||||
echo '<div class="w-grid-list' . $list_classes . '"' . $data_atts . '>';
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Output one term from Grid listing
|
||||
*/
|
||||
|
||||
global $us_grid_listing_post_atts, $us_grid_term;
|
||||
$grid_layout_settings = $us_grid_listing_post_atts['grid_layout_settings'];
|
||||
$overriding_link = $us_grid_listing_post_atts['overriding_link'];
|
||||
|
||||
$term_classes = 'w-grid-item type_term';
|
||||
|
||||
// Aspect ratio class
|
||||
if ( us_arr_path( $grid_layout_settings, 'default.options.ratio' ) ) {
|
||||
$term_classes .= ' ratio_' . us_arr_path( $grid_layout_settings, 'default.options.ratio' );
|
||||
}
|
||||
|
||||
// Generate Overriding Link semantics to the whole grid item
|
||||
$link_url = $link_atts = '';
|
||||
$link_title = FALSE;
|
||||
|
||||
if ( $overriding_link == 'post' OR $overriding_link == 'popup_post' ) {
|
||||
|
||||
$link_url = apply_filters( 'the_permalink', get_term_link( $us_grid_term ) );
|
||||
$link_atts .= ' rel="bookmark"';
|
||||
|
||||
} elseif ( $overriding_link == 'popup_post_image' ) {
|
||||
|
||||
$tnail_id = get_term_meta( $us_grid_term->term_id, 'thumbnail_id', TRUE );
|
||||
$link_url = wp_get_attachment_image_url( $tnail_id, 'full' );
|
||||
if ( $link_url ) {
|
||||
// Use the Caption as a Title
|
||||
$attachment = get_post( $tnail_id );
|
||||
$img_title = trim( strip_tags( $attachment->post_excerpt ) );
|
||||
if ( empty( $img_title ) ) {
|
||||
// If not, Use the Alt
|
||||
$img_title = trim( strip_tags( get_post_meta( $attachment->ID, '_wp_attachment_image_alt', TRUE ) ) );
|
||||
}
|
||||
if ( empty( $img_title ) ) {
|
||||
// If no Alt, use the Term name
|
||||
$img_title = $us_grid_term->name;
|
||||
}
|
||||
$link_atts .= ' ref="magnificPopupGrid" title="' . esc_attr( $img_title ) . '"';
|
||||
$link_title = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Add aria-label if "title" attribute is absent for accessibility support
|
||||
if ( ! $link_title ) {
|
||||
$link_atts .= ' aria-label="' . esc_attr( strip_tags( $us_grid_term->name ) ) . '"';
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="<?php echo $term_classes ?>">
|
||||
<div class="w-grid-item-h">
|
||||
<?php if ( $link_url ): ?>
|
||||
<a class="w-grid-item-anchor" href="<?php echo esc_url( $link_url ) ?>"<?php echo $link_atts ?>></a>
|
||||
<?php endif; ?>
|
||||
<?php us_output_builder_elms( $grid_layout_settings, 'default', 'middle_center', 'grid_term' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
@@ -0,0 +1,270 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Output a single Grid listing. The universal template that is used by all the possible Grid listings.
|
||||
*
|
||||
* (!) $query_args should be filtered before passing to this template.
|
||||
*
|
||||
* @action Before the template: 'us_before_template:templates/us_grid/listing'
|
||||
* @action After the template: 'us_after_template:templates/us_grid/listing'
|
||||
* @filter Template variables: 'us_template_vars:templates/us_grid/listing'
|
||||
*/
|
||||
|
||||
$us_grid_index = isset( $us_grid_index ) ? intval( $us_grid_index ) : 0;
|
||||
$grid_elm_id = isset( $el_id ) ? $el_id : 'us_grid_' . $us_grid_index;
|
||||
$post_id = isset( $post_id ) ? $post_id : NULL;
|
||||
$is_widget = isset( $is_widget ) ? $is_widget : FALSE;
|
||||
$classes = isset( $classes ) ? $classes : '';
|
||||
$filter_taxonomy_name = isset( $filter_taxonomy_name ) ? $filter_taxonomy_name : '';
|
||||
$terms = isset( $terms ) ? $terms : array();
|
||||
|
||||
// Check Grid params and use default values from config, if its not set
|
||||
$default_grid_params = us_shortcode_atts( array(), 'us_grid' );
|
||||
foreach ( $default_grid_params as $param => $value ) {
|
||||
if ( ! isset( $$param ) ) {
|
||||
$$param = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Check Carousel params and use default values from config, if its not set
|
||||
if ( $type == 'carousel' ) {
|
||||
$default_carousel_params = us_shortcode_atts( array(), 'us_carousel' );
|
||||
foreach ( $default_carousel_params as $param => $value ) {
|
||||
if ( ! isset( $$param ) ) {
|
||||
$$param = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $is_widget AND $post_id != NULL AND $type != 'carousel' ) {
|
||||
$us_grid_ajax_indexes[ $post_id ] = isset( $us_grid_ajax_indexes[ $post_id ] ) ? ( $us_grid_ajax_indexes[ $post_id ] ) : 1;
|
||||
} else {
|
||||
$us_grid_ajax_indexes = NULL;
|
||||
}
|
||||
|
||||
// Determine Grid Layout
|
||||
if ( ! empty( $items_layout ) ) {
|
||||
if ( $templates_config = us_config( 'grid-templates', array(), TRUE ) AND isset( $templates_config[ $items_layout ] ) ) {
|
||||
$grid_layout_settings = us_fix_grid_settings( $templates_config[ $items_layout ] );
|
||||
} elseif ( $grid_layout = get_post( (int) $items_layout ) ) {
|
||||
if ( $grid_layout instanceof WP_Post AND $grid_layout->post_type === 'us_grid_layout' ) {
|
||||
if ( ! empty( $grid_layout->post_content ) AND substr( strval( $grid_layout->post_content ), 0, 1 ) === '{' ) {
|
||||
try {
|
||||
$grid_layout_settings = json_decode( $grid_layout->post_content, TRUE );
|
||||
}
|
||||
catch ( Exception $e ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Output "No Grid Layout"
|
||||
if ( ! isset( $grid_layout_settings ) OR empty( $grid_layout_settings ) ) {
|
||||
echo '<div>Selected Grid Layout is not found. Check the element settings.</div>';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set items offset to WP Query flow
|
||||
* Needed both for regular us_grid element on page and it's AJAX pagination.
|
||||
*/
|
||||
if ( $exclude_items == 'offset' AND abs( intval( $items_offset ) ) > 0 ) {
|
||||
global $us_grid_items_offset;
|
||||
$us_grid_items_offset = abs( intval( $items_offset ) );
|
||||
$query_args['_id'] = 'us_grid';
|
||||
add_action( 'pre_get_posts', 'us_grid_query_offset', 1 );
|
||||
add_filter( 'found_posts', 'us_grid_adjust_offset_pagination', 1, 2 );
|
||||
}
|
||||
|
||||
// Filter and execute database query
|
||||
global $wp_query, $us_grid_skip_ids;
|
||||
if ( empty ( $us_grid_index ) OR ! is_array( $us_grid_skip_ids ) ) {
|
||||
$us_grid_skip_ids = array();
|
||||
}
|
||||
$use_custom_query = isset( $query_args ) AND is_array( $query_args ) AND ! empty( $query_args );
|
||||
if ( $use_custom_query ) {
|
||||
us_open_wp_query_context();
|
||||
$wp_query = new WP_Query( $query_args );
|
||||
} else {
|
||||
$query_args = $wp_query->query;
|
||||
|
||||
// Extracting query arguments from WP_Query that are not shown but relevant
|
||||
if ( ! isset( $query_args['post_type'] ) ) {
|
||||
$request_where = substr( $wp_query->request, strpos( $wp_query->request, 'WHERE' ) );
|
||||
if ( preg_match_all( '~\.post_type = \'([a-z0-9\_\-]+)\'~', $request_where, $matches ) ) {
|
||||
$query_args['post_type'] = $matches[1];
|
||||
} elseif ( preg_match( '~\.post_type IN (\((\'([a-z0-9\_\-]+)\'(, )?)+\))~', $request_where, $matches ) ) {
|
||||
$post_types_str = substr( $matches[1], 2, - 2 );
|
||||
$post_types = explode( "', '", $post_types_str );
|
||||
$query_args['post_type'] = $post_types;
|
||||
}
|
||||
|
||||
}
|
||||
if ( ! isset( $query_args['post_status'] ) AND preg_match_all( '~\.post_status = \'([a-z]+)\'~', $wp_query->request, $matches ) ) {
|
||||
$query_args['post_status'] = $matches[1];
|
||||
}
|
||||
// Fetching additional params for WooCommerce Products
|
||||
if ( $query_args['post_type'] == 'product' ) {
|
||||
if ( ! isset( $query_args['posts_per_page'] ) AND ! empty( $wp_query->query_vars['posts_per_page'] ) ) {
|
||||
$query_args['posts_per_page'] = $wp_query->query_vars['posts_per_page'];
|
||||
}
|
||||
if ( ! isset( $query_args['order'] ) AND ! empty( $wp_query->query_vars['order'] ) ) {
|
||||
$query_args['order'] = $wp_query->query_vars['order'];
|
||||
}
|
||||
if ( ! isset( $query_args['orderby'] ) AND ! empty( $wp_query->query_vars['orderby'] ) ) {
|
||||
$query_args['orderby'] = $wp_query->query_vars['orderby'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Check if the grid have items to output, separately for posts and terms
|
||||
$no_results = FALSE;
|
||||
if ( in_array( $post_type, array( 'taxonomy_terms', 'current_child_terms' ) ) ) {
|
||||
if ( empty( $terms ) ) {
|
||||
$no_results = TRUE;
|
||||
}
|
||||
} elseif ( ! have_posts() ) {
|
||||
$no_results = TRUE;
|
||||
}
|
||||
|
||||
// Output No results
|
||||
if ( $no_results ) {
|
||||
|
||||
// Output No results message if it is not empty
|
||||
if ( ! empty( $no_items_message ) ) {
|
||||
echo '<h4 class="w-grid-none">' . strip_tags( $no_items_message, '<br><strong>' ) . '</h4>';
|
||||
}
|
||||
if ( $use_custom_query ) {
|
||||
us_close_wp_query_context();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Setting global variable for Image size to use in grid elements
|
||||
if ( ! empty( $img_size ) AND $img_size != 'default' ) {
|
||||
global $us_grid_img_size;
|
||||
$us_grid_img_size = $img_size;
|
||||
}
|
||||
|
||||
// Filter Bar HTML
|
||||
$filter_html = $data_atts = '';
|
||||
$filter_classes = $filter_style . ' align_' . $filter_align;
|
||||
if ( $filter_taxonomy_name != '' AND $type != 'carousel' AND $pagination != 'regular' AND ! $is_widget ) {
|
||||
|
||||
// $categories_names already contains only the used categories
|
||||
if ( count( $filter_taxonomies ) > 1 ) {
|
||||
$filter_html .= '<div class="g-filters ' . $filter_classes . '"><div class="g-filters-list">';
|
||||
|
||||
$active_tab = ' active';
|
||||
// Output "All" item
|
||||
if ( $filter_show_all ) {
|
||||
$filter_html .= '<a class="g-filters-item' . $active_tab . '" href="javascript:void(0)" data-taxonomy="*">';
|
||||
$filter_html .= '<span>' . __( 'All', 'us' ) . '</span>';
|
||||
$filter_html .= '</a>';
|
||||
$active_tab = '';
|
||||
}
|
||||
|
||||
// Output taxonomy Items
|
||||
foreach ( $filter_taxonomies as $filter_taxonomy ) {
|
||||
$filter_html .= '<a class="g-filters-item' . $active_tab . '" href="javascript:void(0)"';
|
||||
$filter_html .= ' data-taxonomy="' . $filter_taxonomy->slug . '"';
|
||||
$filter_html .= ' data-amount="' . $filter_taxonomy->count . '"';
|
||||
$filter_html .= '>';
|
||||
$filter_html .= '<span>' . $filter_taxonomy->name . '</span>';
|
||||
$filter_html .= '<span class="g-filters-item-amount">' . $filter_taxonomy->count . '</span>';
|
||||
$filter_html .= '</a>';
|
||||
$active_tab = '';
|
||||
}
|
||||
|
||||
$filter_html .= '</div></div>';
|
||||
|
||||
$data_atts .= ' data-filter_taxonomy_name="' . $filter_taxonomy_name . '"';
|
||||
if ( ! $filter_show_all ) {
|
||||
$filter_default_taxonomies = $filter_taxonomies[0]->slug;
|
||||
$data_atts .= ' data-filter_default_taxonomies="' . $filter_default_taxonomies . '"';
|
||||
} elseif ( ! empty( $filter_default_taxonomies ) ) {
|
||||
$data_atts .= ' data-filter_default_taxonomies="' . $filter_default_taxonomies . '"';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get all needed variables to pass into listing-start & listing-end templates
|
||||
$template_vars = array(
|
||||
'grid_layout_settings' => $grid_layout_settings,
|
||||
'us_grid_index' => $us_grid_index,
|
||||
'classes' => $classes,
|
||||
'filter_html' => $filter_html,
|
||||
'is_widget' => $is_widget,
|
||||
'data_atts' => $data_atts,
|
||||
'query_args' => $query_args,
|
||||
'post_id' => $post_id,
|
||||
'us_grid_ajax_indexes' => $us_grid_ajax_indexes,
|
||||
'wp_query' => $wp_query,
|
||||
);
|
||||
// Add default values for unset variables from Grid config
|
||||
foreach ( $default_grid_params as $param => $value ) {
|
||||
$template_vars[ $param ] = isset( $$param ) ? $$param : $value;
|
||||
}
|
||||
// Add default values for unset variables from Carousel config
|
||||
if ( $type == 'carousel' ) {
|
||||
foreach ( $default_carousel_params as $param => $value ) {
|
||||
$template_vars[ $param ] = isset( $$param ) ? $$param : $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Load listing Start
|
||||
us_load_template( 'templates/us_grid/listing-start', $template_vars );
|
||||
|
||||
// Load posts
|
||||
global $us_grid_listing_post_atts;
|
||||
$us_grid_listing_post_atts = array(
|
||||
'grid_layout_settings' => $grid_layout_settings,
|
||||
'type' => $type,
|
||||
'is_widget' => $is_widget,
|
||||
'overriding_link' => $overriding_link,
|
||||
);
|
||||
if ( empty( $terms ) ) {
|
||||
$template_vars[ 'items_count' ] = $wp_query->post_count;
|
||||
while ( have_posts() ) {
|
||||
the_post();
|
||||
$us_grid_skip_ids[] = get_the_ID();
|
||||
us_load_template( 'templates/us_grid/listing-post' );
|
||||
}
|
||||
} else {
|
||||
global $us_grid_term;
|
||||
$template_vars[ 'items_count' ] = count( $terms );
|
||||
foreach ( $terms as $term ) {
|
||||
$us_grid_term = $term;
|
||||
$us_grid_skip_ids[] = $term->term_id;
|
||||
us_load_template( 'templates/us_grid/listing-term' );
|
||||
}
|
||||
}
|
||||
|
||||
// Load listing End
|
||||
us_load_template( 'templates/us_grid/listing-end', $template_vars );
|
||||
|
||||
// If we are in front end editor mode, apply JS to the current grid
|
||||
if ( function_exists( 'vc_is_page_editable' ) AND vc_is_page_editable() ) {
|
||||
echo '<script>
|
||||
jQuery(function($){
|
||||
if (typeof $us !== "undefined" && typeof $us.WGrid === "function") {
|
||||
var $gridContainer = $("#' . $grid_elm_id . '");
|
||||
$gridContainer.wGrid();
|
||||
}
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
|
||||
if ( $use_custom_query ) {
|
||||
// Cleaning up
|
||||
us_close_wp_query_context();
|
||||
}
|
||||
|
||||
// Reset image size for the next grid element
|
||||
if ( isset( $us_grid_img_size ) ) {
|
||||
$us_grid_img_size = 'default';
|
||||
}
|
||||
Reference in new issue
Block a user