', 'aihub-core' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'dark_articles_style_heading',
[
'label' => esc_html__( 'Articles', 'aihub-core' ),
'type' => Controls_Manager::HEADING,
]
);
$this->start_controls_tabs(
'dark_articles_style_tabs'
);
foreach ( [ 'normal', 'hover' ] as $state ) {
$this->start_controls_tab(
'dark_articles_style_tab' . ( $state === 'normal' ? '' : '_' . $state ),
[
'label' => esc_html__( strtoupper( $state ), 'aihub-core' ),
]
);
$this->add_articles_controls( $state, true );
$this->end_controls_tab();
}
$this->end_controls_tabs();
$this->add_control(
'dark_title_style_heading',
[
'label' => esc_html__( 'Title', 'aihub-core' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before'
]
);
$this->start_controls_tabs(
'dark_title_style_tabs'
);
foreach ( [ 'normal', 'hover' ] as $state ) {
$elementor_doc_selector = '.elementor';
$selector = '[data-lqd-page-color-scheme=dark] {{WRAPPER}} .lqd-post-title a, ' . $elementor_doc_selector . ' [data-lqd-color-scheme=dark].elementor-element.elementor-element-{{ID}} .lqd-post-title a, ' . $elementor_doc_selector . ' [data-lqd-color-scheme=dark] .elementor-element.elementor-element-{{ID}} .lqd-post-title a';
if ( $state === 'hover' ) {
$selector = '[data-lqd-page-color-scheme=dark] {{WRAPPER}} .lqd-post:hover .lqd-post-title a, ' . $elementor_doc_selector . ' [data-lqd-color-scheme=dark].elementor-element.elementor-element-{{ID}} .lqd-post:hover .lqd-post-title a, ' . $elementor_doc_selector . ' [data-lqd-color-scheme=dark] .elementor-element.elementor-element-{{ID}} .lqd-post:hover .lqd-post-title a';
}
$this->start_controls_tab(
'dark_title_style_tab' . ( $state === 'normal' ? '' : '_' . $state ),
[
'label' => esc_html__( strtoupper( $state ), 'aihub-core' ),
]
);
$this->add_text_controls( $state, 'title', $selector, true );
$this->end_controls_tab();
}
$this->end_controls_tabs();
$this->add_control(
'dark_meta_style_heading',
[
'label' => esc_html__( 'Meta', 'aihub-core' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before'
]
);
$this->start_controls_tabs(
'dark_meta_style_tabs'
);
foreach ( [ 'normal', 'hover' ] as $state ) {
$this->start_controls_tab(
'dark_meta_style_tab' . ( $state === 'normal' ? '' : '_' . $state ),
[
'label' => esc_html__( strtoupper( $state ), 'aihub-core' ),
]
);
$this->add_meta_controls( $state, $this, '.lqd-post-meta', '', '', true );
$this->end_controls_tab();
}
$this->end_controls_tabs();
$this->add_control(
'dark_excerpt_style_heading',
[
'label' => esc_html__( 'Excerpt', 'aihub-core' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before'
]
);
$this->start_controls_tabs(
'dark_excerpt_style_tabs'
);
foreach ( [ 'normal', 'hover' ] as $state ) {
$elementor_doc_selector = '.elementor';
$selector = '[data-lqd-page-color-scheme=dark] {{WRAPPER}} .lqd-post-excerpt, ' . $elementor_doc_selector . ' [data-lqd-color-scheme=dark].elementor-element.elementor-element-{{ID}} .lqd-post-excerpt, ' . $elementor_doc_selector . ' [data-lqd-color-scheme=dark] .elementor-element.elementor-element-{{ID}} .lqd-post-excerpt';
if ( $state === 'hover' ) {
$selector = '[data-lqd-page-color-scheme=dark] {{WRAPPER}} .lqd-post:hover .lqd-post-excerpt, ' . $elementor_doc_selector . ' [data-lqd-color-scheme=dark].elementor-element.elementor-element-{{ID}} .lqd-post:hover .lqd-post-excerpt, ' . $elementor_doc_selector . ' [data-lqd-color-scheme=dark] .elementor-element.elementor-element-{{ID}} .lqd-post:hover .lqd-post-excerpt';
}
$this->start_controls_tab(
'dark_excerpt_style_tab' . ( $state === 'normal' ? '' : '_' . $state ),
[
'label' => esc_html__( strtoupper( $state ), 'aihub-core' ),
]
);
$this->add_text_controls( $state, 'excerpt', $selector, true );
$this->end_controls_tab();
}
$this->end_controls_tabs();
foreach( $meta_part_options as $meta_style_key => $meta_style ) {
$this->add_control(
'dark_' . $meta_style_key . '_style_heading',
[
'label' => esc_html__( $meta_style, 'aihub-core' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before'
]
);
$this->start_controls_tabs(
'dark_' . $meta_style_key . '_items_style_tabs'
);
foreach ( [ 'normal', 'hover' ] as $state ) {
$this->start_controls_tab(
'dark_' . $meta_style_key . '_items_style_tab' . ( $state === 'normal' ? '' : '_' . $state ),
[
'label' => esc_html__( strtoupper( $state ), 'aihub-core' ),
]
);
$this->add_meta_controls( $state, $this, '[data-lqd-post-meta-part=' . $meta_style_key . ']', $meta_style_key, '', true );
$this->end_controls_tab();
}
$this->end_controls_tabs();
}
if ( class_exists( 'WooCommerce' ) ){
$this->add_control(
'dark_price_style_heading',
[
'label' => esc_html__( 'Price', 'aihub-core' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before'
]
);
$this->start_controls_tabs(
'dark_price_style_tabs'
);
foreach ( [ 'normal', 'hover' ] as $state ) {
$selector = '.lqd-product-price';
if ( $state === 'hover' ) {
$selector = '.lqd-post:hover .lqd-product-price';
}
$this->start_controls_tab(
'dark_price_style_tab' . ( $state === 'normal' ? '' : '_' . $state ),
[
'label' => esc_html__( strtoupper( $state ), 'aihub-core' ),
]
);
$this->add_tabbed_controls( $selector, 'price', $state, true );
$this->end_controls_tab();
}
$this->add_control(
'dark_add_to_cart_btn_style_heading',
[
'label' => esc_html__( 'Add to cart button', 'aihub-core' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before'
]
);
$this->end_controls_tabs();
$this->start_controls_tabs(
'dark_add_to_cart_btn_style_tabs'
);
foreach ( [ 'normal', 'hover' ] as $state ) {
$selector = '.lqd-product-btn .lqd-btn';
if ( $state === 'hover' ) {
$selector .= ':hover';
}
$this->start_controls_tab(
'dark_add_to_cart_btn_style_tab' . ( $state === 'normal' ? '' : '_' . $state ),
[
'label' => esc_html__( strtoupper( $state ), 'aihub-core' ),
]
);
$this->add_tabbed_controls( $selector, 'add_to_cart_btn', $state, true );
$this->end_controls_tab();
}
$this->end_controls_tabs();
} // if class_exists( 'WooCommerce' )
$this->end_controls_section();
// button styles
lqd_elementor_add_button_controls( $this, 'ib_', [], false, 'style' );
}
protected function get_post_link_attrs( $post_id ) {
$settings = $this->get_settings_for_display();
$post_type = $settings['post_type'] ? $settings['post_type'] : $GLOBALS['wp_query']->query['post_type'];
$page_settings_manager = \Elementor\Core\Settings\Manager::get_settings_managers( 'page' );
$page_settings_model = $page_settings_manager->get_model( $post_id );
$external_url_param = null;
switch ( $post_type ) {
case 'liquid-portfolio':
$external_url_param = $page_settings_model->get_settings( 'portfolio_website' );
break;
}
return ( $external_url_param && isset( $external_url_param['url'] ) && !empty( $external_url_param['url'] ) ) ?
$external_url_param :
[
'url' => get_the_permalink(),
'is_external' => '',
'nofollow' => '',
'custom_attributes' => ''
];
}
protected function render_part_media( $settings, $part, $part_index, $post_id ) {
if ( post_password_required() || is_attachment() || !has_post_thumbnail() ) {
return '';
}
$css_position = $part['part_absolute_with_thumbnail'] && !has_post_thumbnail() ? 'relative' : $part['part_position'];
$media_attrs_id = $this->get_repeater_setting_key( 'media', 'content_part', $part_index ) . '.' . $post_id;
$fig_attrs_id = $media_attrs_id . '-fig';
$media_classnames = [ 'lqd-post-media', $css_position, 'z-0', 'elementor-repeater-item-' . esc_attr( $part['_id'] ) ];
$fig_classnames = [ 'lqd-post-media-fig', 'rounded-inherit' ];
$media_link_attrs_id = $this->get_repeater_setting_key( 'media_link', 'content_part', $part_index ) . '.' . $post_id;
if ( $css_position === 'absolute' ) {
array_push( $media_classnames, 'h-full', 'rounded-inherit' );
array_push( $fig_classnames, 'h-full', 'rounded-inherit' );
}
if ( $part['part_appear_on_hover'] === 'yes' ) {
$media_classnames[] = 'lqd-post-part-visible-onhover';
$media_classnames[] = 'transition-all';
}
$media_attrs = [
'class' => $media_classnames
];
$fig_attrs = [
'class' => $fig_classnames
];
$parts_inside_media = array_filter( $settings['content_parts'], function( $content_part ) {
return $content_part['part_position_based_on_media'] === 'yes';
} );
$this->add_render_attribute( $media_attrs_id, $media_attrs );
$this->add_render_attribute( $fig_attrs_id, $fig_attrs );
if ( $part['part_enable_post_link'] === 'yes' ) {
$this->add_link_attributes( $media_link_attrs_id, $this->get_post_link_attrs( $post_id ) );
}
?>
get_repeater_setting_key( 'title', 'content_part', $part_index ) . '.' . $post_id;
$title_classnames = [ 'lqd-post-title', 'm-0', 'p-0', $css_position, 'z-1', 'elementor-repeater-item-' . esc_attr( $part['_id'] ) ];
$title_link_attrs_id = $this->get_repeater_setting_key( 'title_link', 'content_part', $part_index ) . '.' . $post_id;
if ( $part['part_appear_on_hover'] === 'yes' ) {
$title_classnames[] = 'lqd-post-part-visible-onhover';
$title_classnames[] = 'transition-all';
}
$title_attrs = [
'class' => $title_classnames
];
$this->add_render_attribute( $title_attrs_id, $title_attrs );
if ( $part['part_enable_post_link'] === 'yes' ) {
$this->add_link_attributes( $title_link_attrs_id, $this->get_post_link_attrs( $post_id ) );
}
the_title(
sprintf(
'<%1$s %2$s>%3$s',
$title_tag,
$this->get_render_attribute_string( $title_attrs_id ),
$part['part_enable_post_link'] === 'yes' ? sprintf( '', $this->get_render_attribute_string( $title_link_attrs_id ) ) : ''
),
sprintf(
'%2$s%1$s>',
$title_tag,
$part['part_enable_post_link'] === 'yes' ? '' : ''
)
);
}
protected function render_part_excerpt( $settings, $part, $part_index, $post_id ) {
$css_position = $part['part_absolute_with_thumbnail'] && !has_post_thumbnail() ? 'relative' : $part['part_position'];
$excerpt_attrs_id = $this->get_repeater_setting_key( 'excerpt', 'content_part', $part_index ) . '.' . $post_id;
$excerpt_classnames = [ 'lqd-post-excerpt', 'm-0', 'p-0', $css_position, 'z-1', 'elementor-repeater-item-' . esc_attr( $part['_id'] ) ];
if ( $part['part_appear_on_hover'] === 'yes' ) {
$excerpt_classnames[] = 'lqd-post-part-visible-onhover';
$excerpt_classnames[] = 'transition-all';
}
$excerpt_attrs = [
'class' => $excerpt_classnames
];
$this->add_render_attribute( $excerpt_attrs_id, $excerpt_attrs );
add_filter( 'excerpt_length', [ $this, 'excerpt_lengh' ], 999 );
add_filter( 'excerpt_more', [ $this, 'excerpt_more' ] );
?>
print_render_attribute_string( $excerpt_attrs_id ) ?>>
get_repeater_setting_key( 'button', 'content_part', $part_index ) . '.' . $post_id;
$button_classnames = [ 'lqd-post-btn', 'm-0', 'p-0', 'z-1', 'elementor-repeater-item-' . esc_attr( $part['_id'] ) ];
$button_attrs = [
'class' => $button_classnames
];
$this->add_render_attribute( $button_attrs_id, $button_attrs );
?>
print_render_attribute_string( $button_attrs_id ) ?>>
get_repeater_setting_key( 'price', 'content_part', $part_index ) . '.' . $post_id;
$price_classnames = [ 'lqd-product-price', 'm-0', 'p-0', $css_position, 'z-1', 'transition-all', 'elementor-repeater-item-' . esc_attr( $part['_id'] ) ];
if ( $part['part_appear_on_hover'] === 'yes' ) {
$price_classnames[] = 'lqd-post-part-visible-onhover';
$price_classnames[] = 'transition-all';
}
$price_attrs = [
'class' => $price_classnames
];
$this->add_render_attribute( $price_attrs_id, $price_attrs );
?>
print_render_attribute_string( $price_attrs_id ) ?>>
get_repeater_setting_key( 'price', 'content_part', $part_index ) . '.' . $post_id;
$btn_classnames = [ 'lqd-product-btn', 'm-0', 'p-0', $css_position, 'z-1', 'elementor-repeater-item-' . esc_attr( $part['_id'] ) ];
if ( $part['part_appear_on_hover'] === 'yes' ) {
$btn_classnames[] = 'lqd-post-part-visible-onhover';
$btn_classnames[] = 'transition-all';
}
$btn_attrs = [
'class' => $btn_classnames
];
$this->add_render_attribute( $btn_attrs_id, $btn_attrs );
?>
print_render_attribute_string( $btn_attrs_id ) ?>>
get_settings_for_display( 'excerpt_length' );
if( !isset( $excerpt_length ) ) {
return '20';
}
return $excerpt_length;
}
public function excerpt_more( $more ) {
$excerpt_length = $this->get_settings_for_display( 'excerpt_length' );
if( !isset( $excerpt_length ) ) {
return $more;
}
return '';
}
protected function render_tax( $part, $list, $type, $sr_text, $rel ) {
$separator = $part['meta_' . $type . '_separator'];
$count_option = $part['meta_' . $type . '_count'];
if ( ! is_array( $list ) ) return;
if ( $count_option === 0 || count( $list ) === 0 ) return;
if ( !empty( $count_option ) ) {
$list = array_slice( $list, 0, $count_option );
}
?>
$item ) : ?>
name );
if ( !empty( $separator) && $i !== count( $list ) - 1 ) :
?>
entry_custom_meta( 'inline-flex items-center reset-ul inline-ul relative z-3' );
}
}
if ( get_the_terms($post_id, $taxonomy) ){
$this->render_tax( $part, get_the_terms($post_id, $taxonomy), 'tags', esc_html__( 'Tags', 'aihub-core' ), 'tag' );
}
}
protected function render_meta_tags( $settings, $part, $post_id ) {
switch ( $settings['post_type'] ) {
case 'product':
$term = get_the_terms( $post_id, 'product_tag' );
break;
default:
$term = wp_get_post_tags( $post_id );
break;
}
if ( $term ){
$this->render_tax( $part, $term, 'tags', esc_html__( 'Tags', 'aihub-core' ), 'tag' );
}
}
protected function render_meta_categories( $settings, $part, $post_id ) {
$post_type = $settings['post_type'] ? $settings['post_type'] : $GLOBALS['wp_query']->query['post_type'];
switch ( $post_type ) {
case 'product':
$term = get_the_terms( $post_id, 'product_cat' );
break;
case 'liquid-portfolio':
$term = get_the_terms( $post_id, 'liquid-portfolio-category' );
break;
case 'liquid-listing':
$term = get_the_terms( $post_id, 'liquid-listing-category' );
break;
default:
$term = get_the_category( $post_id );
break;
}
if ( $term ) {
$this->render_tax( $part, $term, 'categories', esc_html__( 'Categories', 'aihub-core' ), 'category' );
}
}
protected function render_meta_author_avatar() {
echo get_avatar( get_the_author_meta( 'ID' ), '50', get_option( 'avatar_default', 'mystery' ), get_the_author(), [ 'class' => 'shrink-0 grow-0 basis-auto me-3' ] );
}
protected function render_meta_author_name() {
echo get_the_author();
}
protected function render_meta_author( $settings, $part ) {
if ( $part['meta_enable_author_avatar'] ) {
$this->render_meta_author_avatar();
}
$this->render_meta_author_name();
}
protected function render_meta_time( $settings ) {
printf( '', get_the_date( 'c' ), liquid_helper()->liquid_post_date() );
}
protected function render_part_meta( $settings, $part, $part_index, $post_id ) {
$css_position = $part['part_absolute_with_thumbnail'] && !has_post_thumbnail() ? 'relative' : $part['part_position'];
$meta_attrs_id = $this->get_repeater_setting_key( 'meta', 'content_part', $part_index ) . '.' . $post_id;
$meta_classnames = [ 'lqd-post-meta', 'flex', 'flex-wrap', 'items-center', $css_position, 'z-1', 'transition-colors', 'elementor-repeater-item-' . esc_attr( $part['_id'] ) ];
if ( $part['part_appear_on_hover'] === 'yes' ) {
$meta_classnames[] = 'lqd-post-part-visible-onhover';
$meta_classnames[] = 'transition-all';
}
$meta_attrs = [
'class' => $meta_classnames
];
$meta_parts = $part['meta_parts'];
$meta_separator = $part['meta_separator'];
$this->add_render_attribute( $meta_attrs_id, $meta_attrs );
if ( empty( $meta_parts ) ) return '';
?>
print_render_attribute_string( $meta_attrs_id ); ?>> $meta_part ) : ?>
{'render_meta_' . $meta_part}( $settings, $part, $post_id, $meta_part );
} else {
$this->render_meta_terms( $settings, $part, $post_id, $meta_part );
}
?>
{'render_part_' . $content_part}( $settings, $part, $part_index, $post_id );
}
protected function render_post( $settings ) {
$content_parts = $settings['content_parts'];
if ( empty( $content_parts ) ) return;
$post_classnames = [ 'lqd-post', 'relative', 'transition-all' ];
$post_id = get_the_ID();
$attributes = [
'id' => 'post-' . $post_id,
'class' => join( ' ', get_post_class( $post_classnames, get_the_ID() ) ),
'data-lqd-post-type' => esc_attr__( $settings['post_type'], 'aihub-core' )
];
$this->add_render_attribute( $post_id, $attributes );
?>
print_render_attribute_string( $post_id ) ?>> $part ) {
$this->render_part( $settings, $part, $part_index, $post_id );
}
?>
get_settings_for_display() );
$settings = [];
if( 'custom' === $data_source && ! empty( $custom_query ) ) {
$query = html_entity_decode( $custom_query , ENT_QUOTES, 'utf-8' );
$settings = wp_parse_args( $query );
}
elseif( 'ids' === $data_source ) {
if ( empty( $post_ids ) ) {
$post_ids = - 1;
}
$incposts = wp_parse_id_list( $post_ids );
$settings = [
'post__in' => $incposts,
'posts_per_page' => count( $incposts ),
'post_type' => 'any',
'orderby' => 'post__in',
];
}
elseif( 'related_posts' === $data_source ) {
$post_id = get_the_ID();
$post_type = get_post_type( $post_id );
$taxonomy = 'post' === $post_type ? 'category' : $post_type . '-category';
$item_array = array();
$item_cats = get_the_terms( $post_id, $taxonomy );
if ( $item_cats ) {
foreach( $item_cats as $item_cat ) {
if ( isset($item_cat->term_id) ){
$item_array[] = $item_cat->term_id;
}
}
}
$settings = [
'post_type' => $post_type,
'posts_per_page' => isset( $posts_per_page ) ? (int) $posts_per_page : 100,
'post__not_in' => [ $post_id ],
'ignore_sticky_posts' => 0,
'tax_query' => [
[
'field' => 'id',
'taxonomy' => $taxonomy,
'terms' => $item_array
]
]
];
}
else {
$settings = [
'posts_per_page' => isset( $posts_per_page ) ? (int) $posts_per_page : 100,
'orderby' => $orderby,
'order' => $order,
'meta_key' => in_array( $orderby, [
'meta_value',
'meta_value_num',
] ) ? $meta_key : '',
'post_type' => $post_type,
'ignore_sticky_posts' => true,
];
if ( !empty( $offset ) ){
$settings['offset'] = $offset;
}
if ( empty( $pagination ) ) {
$settings['no_found_rows'] = true;
} else {
$settings['paged'] = ld_helper()->get_paged();
}
if ( $settings['posts_per_page'] < 1 ) {
$settings['posts_per_page'] = 1000;
}
// elementor pro archive filter
if ( is_category() ){
$settings['cat'] = get_the_category()[0]->term_id;
}
// exlude
if ( $exclude_type === 'post' ) {
$exclude = $this->get_settings_for_display($post_type . '_exclude_post');
$settings['post__not_in'] = wp_parse_id_list( $exclude );
} elseif ( $exclude_type === 'cat' ) {
$taxonomies = $this->get_settings_for_display($post_type . '_exclude_cat');
$terms = get_terms( [
'hide_empty' => false,
'include' => $taxonomies,
] );
$settings['tax_query'] = [];
$tax_queries = []; // List of taxnonimes
foreach ( $terms as $t ) {
if ( ! isset( $tax_queries[ $t->taxonomy ] ) ) {
$tax_queries[ $t->taxonomy ] = [
'taxonomy' => $t->taxonomy,
'field' => 'id',
'terms' => [ $t->term_id ],
'relation' => 'IN',
];
} else {
$tax_queries[ $t->taxonomy ]['terms'][] = $t->term_id;
}
}
$settings['tax_query'] = array_values( $tax_queries );
$settings['tax_query']['relation'] = 'OR';
}
}
$settings['post_status'] = 'publish';
return $settings;
}
protected function render_pagination() {
switch ( $this->get_settings_for_display( 'pagination' ) ) {
case 'pagination':
$max = $GLOBALS['wp_query']->max_num_pages;
// Set up paginated links.
$links = paginate_links( array(
'type' => 'array',
// 'format' => '?page=%#%',
'prev_next' => true,
'prev_text' => '' . wp_kses( __( '', 'landinghub-core' ), 'svg' ) . '',
'next_text' => '' . wp_kses( __( '', 'landinghub-core' ), 'svg' ) . '',
) );
if ( !empty( $links ) ) {
printf( '', join( "\n\t", $links ) );
}
break;
case 'ajax':
$unique_id = 'blog-id-' . $this->get_id_int();
$ajax_wrapper = '.' . $unique_id;
$hash = [
'ajax' => 'lqd-btn lqd-btn-md ajax-load-more',
];
$url = get_next_posts_page_link( $GLOBALS['wp_query']->max_num_pages );
$attributes = [
'href' => add_query_arg( 'ajaxify', '1', $url ),
'rel' => 'nofollow',
'data-ajaxify' => true,
'data-ajaxify-options' => json_encode( [
'wrapper' => '.elementor-element-'. $this->get_id() .' > .elementor-widget-container',
'items' => 'article',
'trigger' => $this->get_settings_for_display( 'ajax_trigger' ),
] )
];
echo '';
break;
}
}
protected function render() {
$settings = $this->get_settings_for_display();
// Build Query
$GLOBALS['wp_query'] = new \WP_Query( $this->build_query() );
if ( have_posts() ) {
while( have_posts() ): the_post();
$this->render_post( $settings );
endwhile;
$this->render_pagination();
wp_reset_query();
} else {
echo esc_html_e( 'Sorry, no posts matched your criteria.' );
}
}
}
\Elementor\Plugin::instance()->widgets_manager->register( new LQD_Posts_List() );