[ // entrance animations 'condition' => [ 'animation_assets' => 'false' ], 'external' => true, ] ]; } public function get_scripts() { return [ 'advanced-post-grid', 'entrance' => [ 'condition' => [ 'animate_items' => 'ui-e-grid-animate' ], ], 'ajax-request' => [ 'condition' => [ 'pagination_type' => 'load_more' ] ] ]; } private function filter_missing_taxonomies($settings) { $taxonomy_filter_args = [ 'show_in_nav_menus' => true, ]; if (!empty($settings['posts-filter_post_type'])) { $taxonomy_filter_args['object_type'] = [$settings['posts-filter_post_type']]; } $taxonomies = get_taxonomies($taxonomy_filter_args, 'objects'); foreach ($taxonomies as $taxonomy => $object) { $controll_id = 'posts-filter_' . $taxonomy . '_ids'; \error_log($controll_id); \error_log(print_r($settings[$controll_id], true)); if (!isset($settings[$controll_id]) || empty($settings[$controll_id])) { continue; } //if is set check if this id still exists $settings[$controll_id] = array_filter($settings[$controll_id], function ($term_id) use ($object) { return term_exists($term_id, $object->name); }); if (empty($settings[$controll_id])) { $settings[$controll_id] = null; } } return $settings; } public function on_import($element) { $element['settings'] = $this->filter_missing_taxonomies($element['settings']); return $element; } public function get_query() { return $this->_query; } public function query_posts($posts_per_page, $type = null) { if (!Plugin::$instance->editor->is_edit_mode() && $this->get_settings('posts-filter_post_type') === 'current' && !isset($_GET['uicore-tb'])) { global $wp_query; $this->_query = $wp_query; } elseif ($this->get_settings('posts-filter_post_type') === 'related') { $this->_query = Helper::get_related('random', $posts_per_page); } else { $query_args = Query::get_query_args('posts-filter', $this->get_settings(), get_the_ID()); if ($type === 'portfolio') { $query_args['orderby'] = 'menu_order date'; } if ($type === 'current') { unset($query_args['posts_per_page']); } $this->_query = new \WP_Query($query_args); } } protected function register_controls() { // Query(curent/custom/related/manual) // /Pagination (filtering?) // /Aditional (no posts) $this->start_controls_section( 'section_layout', [ 'label' => esc_html__('Grid', 'uicore-elements'), ] ); $this->TRAIT_register_entrace_asset_helper(); // Animation asset condition $this->register_grid_layout_controls(false, [], true); // Grid Layouts with old masonry control $this->end_controls_section(); $this->start_controls_section( 'section_item_content', [ 'label' => esc_html__('Item', 'uicore-elements'), ] ); $this->add_control( 'box_style', [ 'label' => __('Item Style', 'uicore-elements'), 'type' => Controls_Manager::SELECT, 'default' => 'classic', 'options' => [ 'classic' => __('Classic', 'uicore-elements'), 'split' => __('Split', 'uicore-elements'), 'overlay' => __('Overlay', 'uicore-elements'), ], 'prefix_class' => 'ui-e-apg-', ] ); $this->add_control( 'image', [ 'label' => __('Image', 'uicore-elements'), 'type' => Controls_Manager::SWITCHER, 'separator' => 'before', 'default' => 'yes' ] ); $this->add_control( 'image_size_select', [ 'label' => __('Image Size', 'uicore-elements'), 'type' => Controls_Manager::SELECT, 'default' => 'uicore-medium', 'options' => self::get_images_sizes(), 'condition' => [ 'image' => 'yes', ] ] ); // $this->add_control('cat_type',[ // 'label' => __( 'Cat Type', 'uicore-elements' ), // 'type' => Controls_Manager::SELECT, // 'default' => 'category', // 'options' => [ // 'category' => __( 'Category', 'uicore-elements' ), // 'custom' => __( 'Custom Taxonomy', 'uicore-elements' ), // ], // 'condition' => array( // 'category' => 'yes', // ), // ] // ); // $this->add_control('cat_type_name',[ // 'label' => __( 'Taxonomy', 'uicore-elements' ), // 'type' => Controls_Manager::TEXT, // 'placeholder' => __( 'my_custom_tax', 'uicore-elements' ), // 'condition' => array( // 'cat_type' => 'custom', // ), // ] // ); $this->add_control( 'title', [ 'label' => __('Title', 'uicore-elements'), 'type' => Controls_Manager::SWITCHER, 'separator' => 'before', 'default' => 'yes' ] ); $this->add_control( 'excerpt', [ 'label' => __('Excerpt', 'uicore-elements'), 'type' => Controls_Manager::SWITCHER, 'separator' => 'before', 'default' => 'yes' ] ); $this->add_control( 'excerpt_trim', [ 'label' => __('Excerpt Length (words)', 'uicore-elements'), 'type' => Controls_Manager::NUMBER, 'min' => 5, 'max' => 100, 'step' => 1, 'default' => 55, 'condition' => array( 'excerpt' => 'yes', ), ] ); $this->add_control( 'show_button', [ 'label' => __('Read More Button', 'uicore-elements'), 'type' => Controls_Manager::SWITCHER, 'separator' => 'before', 'default' => 'no' ] ); $this->end_controls_section(); $this->start_controls_section( 'section_button_content', [ 'label' => esc_html__('Button', 'uicore-elements'), 'condition' => array( 'show_button' => 'yes', ), ] ); $this->register_button_content_controls(['section_condition' => ['show_button' => 'yes'], 'button_default_text' => 'Read More']); $this->remove_control('button_type'); $this->remove_control('link'); $this->remove_control('button_css_id'); $this->remove_control('size'); $this->remove_control('align'); $this->end_controls_section(); $this->start_controls_section( 'section_extra_item_content', [ 'label' => esc_html__('Meta', 'uicore-elements'), ] ); $this->add_control( 'top_meta', [ 'label' => esc_html__('Top Meta', 'uicore-elements'), 'type' => \Elementor\Controls_Manager::REPEATER, 'fields' => $this->get_meta_content_controls(), 'default' => [ [ 'type' => 'author' ], ], 'title_field' => '{{{ type }}}', 'prevent_empty' => false, 'separator' => 'before' ] ); $this->add_control( 'before_title_meta', [ 'label' => esc_html__('Before Title Meta', 'uicore-elements'), 'type' => \Elementor\Controls_Manager::REPEATER, 'fields' => $this->get_meta_content_controls(), 'default' => [ [ 'type' => 'author' ], ], 'title_field' => '{{{ type }}}', 'prevent_empty' => false, 'separator' => 'before', ] ); $this->add_control( 'after_title_meta', [ 'label' => esc_html__('After Title Meta', 'uicore-elements'), 'type' => \Elementor\Controls_Manager::REPEATER, 'fields' => $this->get_meta_content_controls(), 'default' => [ [ 'type' => 'author' ], ], 'title_field' => '{{{ type }}}', 'prevent_empty' => false, 'separator' => 'before', ] ); $this->add_control( 'bottom_meta', [ 'label' => esc_html__('Bottom Meta', 'uicore-elements'), 'type' => \Elementor\Controls_Manager::REPEATER, 'fields' => $this->get_meta_content_controls(), 'default' => [ [ 'type' => 'author' ], ], 'title_field' => '{{{ type }}}', 'prevent_empty' => false, 'separator' => 'before', ] ); $this->end_controls_section(); $this->start_controls_section( 'section_post_grid_def', [ 'label' => esc_html__('Query', 'uicore-elements'), ] ); $this->add_group_control( Post_Filter::get_type(), [ 'name' => 'posts-filter', 'label' => esc_html__('Posts', 'uicore-elements'), 'description' => esc_html__('Current Query Settings > Reading', 'uicore-elements'), ] ); $this->add_control('item_limit', [ 'label' => esc_html__('Item Limit', 'uicore-elements'), 'type' => Controls_Manager::SLIDER, 'reder_type' => 'template', 'range' => [ 'px' => [ 'min' => -1, 'max' => 100, ], ], 'default' => [ 'size' => 3, ], 'condition' => array( 'posts-filter_post_type!' => 'current', ), ]); $this->add_control('offset', [ 'label' => esc_html__('Query Offset', 'uicore-elements'), 'type' => Controls_Manager::SLIDER, 'render_type' => 'template', 'range' => [ 'px' => [ 'min' => -1, 'max' => 10, ], ], 'default' => [ 'size' => 0, ], 'condition' => [ 'pagination_type' => 'numbers', ] ]); $this->add_control( 'offset_alert', [ 'type' => Controls_Manager::ALERT, 'alert_type' => 'info', 'content' => esc_html__('Offset is disabled with Load More pagination.', 'uicore-elements'), 'condition' => [ 'pagination_type!' => 'numbers', ] ] ); $this->add_control('sticky', [ 'label' => esc_html__('Sticky Posts', 'uicore-elements'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => esc_html__('Show', 'uicore-elements'), 'label_off' => esc_html__('Hide', 'uicore-elements'), 'description' => esc_html__('Sticky posts works only on the front-end.', 'uicore-elements'), 'return_value' => 1, 'default' => 0, 'condition' => array( 'pagination!' => 'yes', ), ]); $this->end_controls_section(); $this->start_controls_section( 'section_filters', [ 'label' => esc_html__('Filters', 'uicore-elements'), ] ); $this->TRAIT_register_filter_controls(); $this->end_controls_section(); $this->start_controls_section( 'section_pagination', [ 'label' => esc_html__('Pagination', 'uicore-elements'), ] ); $this->TRAIT_register_pagination_controls(); $this->end_controls_section(); //STYLE $this->start_controls_section( 'section_style_item', [ 'label' => __('Item Style', 'uicore-elements'), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'item_radius', [ 'label' => esc_html__('Border Radius', 'uicore-elements'), 'type' => Controls_Manager::DIMENSIONS, 'selectors' => [ '{{WRAPPER}} ' => '--ui-e-border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;' ], ] ); $this->start_controls_tabs( 'item_border_shadow' ); $this->start_controls_tab( 'item_bs_normal_tab', [ 'label' => esc_html__('Normal', 'plugin-name'), ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'item_border', 'selector' => '{{WRAPPER}} .ui-e-item article', 'separator' => 'before', ] ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), [ 'name' => 'item_shadow', 'selector' => '{{WRAPPER}} .ui-e-item article', ] ); $this->end_controls_tab(); $this->start_controls_tab( 'item_bs_hover_tab', [ 'label' => esc_html__('Hover', 'plugin-name'), ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'item_border_hover', 'selector' => '{{WRAPPER}} .ui-e-item:hover article', 'separator' => 'before', ] ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), [ 'name' => 'item_shadow_hover', 'selector' => '{{WRAPPER}} .ui-e-item:hover article', ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->end_controls_section(); $this->start_controls_section( 'section_style_content', [ 'label' => __('Content Style', 'uicore-elements'), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'image_size', [ 'label' => __('Image Height (%)', 'uicore-elements'), 'type' => Controls_Manager::NUMBER, 'min' => 1, 'max' => 500, 'step' => 1, 'default' => 57, 'condition' => array( 'masonry!' => 'ui-e-maso', ), 'selectors' => [ '{{WRAPPER}} .ui-e-post-top' => '--ui-e-img-size: {{VALUE}}', ], ] ); $this->add_control( 'image_overflow', [ 'label' => __('Independent Border Radius and Shadow', 'uicore-elements'), 'type' => Controls_Manager::SWITCHER, 'default' => 'no', 'prefix_class' => 'ui-e-post-ovf-', 'condition' => array( 'box_style!' => 'overlay', ), ] ); $this->add_control( 'image_radius', [ 'label' => esc_html__('Border Radius', 'uicore-elements'), 'type' => Controls_Manager::DIMENSIONS, 'selectors' => [ '{{WRAPPER}} .ui-e-post-top' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;' ], 'condition' => array( 'image_overflow' => 'yes', ), ] ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), [ 'name' => 'image_shadow', 'label' => esc_html__('Box Shadow', 'uicore-elements'), 'selector' => '{{WRAPPER}} .ui-e-post-top', 'condition' => array( 'image_overflow' => 'yes', ), ] ); $this->add_responsive_control( 'content_align', [ 'label' => esc_html__('Content Alignment', 'uicore-elements'), 'type' => Controls_Manager::CHOOSE, 'options' => [ 'left' => [ 'title' => esc_html__('Left', 'uicore-elements'), 'icon' => 'eicon-text-align-left', ], 'center' => [ 'title' => esc_html__('Center', 'uicore-elements'), 'icon' => 'eicon-text-align-center', ], 'stretch' => [ 'title' => esc_html__('Justified', 'uicore-elements'), 'icon' => 'eicon-text-align-justify', ], ], 'selectors' => [ '{{WRAPPER}} .ui-e-post-content' => 'align-items: {{VALUE}}; text-align: {{VALUE}};', ], ] ); $this->add_control( 'title_color', [ 'label' => esc_html__('Title Color', 'uicore-elements'), 'type' => Controls_Manager::COLOR, 'default' => '', 'separator' => 'before', 'selectors' => [ '{{WRAPPER}} .ui-e-post-title' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'title_hcolor', [ 'label' => esc_html__('Title Hover Color', 'uicore-elements'), 'type' => Controls_Manager::COLOR, 'default' => '', 'selectors' => [ '{{WRAPPER}} .ui-e-post-title:hover' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'title_typography', 'label' => esc_html__('Title Typography', 'uicore-elements'), 'selector' => '{{WRAPPER}} .ui-e-post-title', ] ); $this->add_control( 'title_gap', [ 'label' => __('Title Top Space', 'uicore-elements'), 'type' => Controls_Manager::SLIDER, 'size_units' => ['em'], 'separator' => 'after', 'range' => [ 'px' => [ 'min' => 0, 'max' => 3, 'step' => 0.1, ], ], 'default' => [ 'unit' => 'em', 'size' => 1.2, ], 'selectors' => [ '{{WRAPPER}} .ui-e-post-title' => 'margin-top: {{SIZE}}em;', ], ] ); $this->add_control( 'text_color', [ 'label' => esc_html__('Excerpt Color', 'uicore-elements'), 'type' => Controls_Manager::COLOR, 'default' => '', 'selectors' => [ '{{WRAPPER}} .ui-e-post-text' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'text_typography', 'label' => esc_html__('Excerpt Typography', 'uicore-elements'), 'selector' => '{{WRAPPER}} .ui-e-post-text', ] ); $this->add_control( 'text_gap', [ 'label' => __('Excerpt Top Space', 'uicore-elements'), 'type' => Controls_Manager::SLIDER, 'size_units' => ['em'], 'separator' => 'after', 'range' => [ 'px' => [ 'min' => 0, 'max' => 3, 'step' => 0.1, ], ], 'default' => [ 'unit' => 'em', 'size' => 0.8, ], 'selectors' => [ '{{WRAPPER}} .ui-e-post-text' => 'margin-top: {{SIZE}}em;', ], ] ); $this->add_responsive_control( 'content_padding', [ 'label' => esc_html__('Content Padding', 'uicore-elements'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => ['px', 'em', '%'], 'selectors' => [ '{{WRAPPER}} .ui-e-post-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ] ] ); $this->add_control( 'content_gap', [ 'label' => __('Content Space', 'uicore-elements'), 'type' => Controls_Manager::SLIDER, 'size_units' => ['em'], 'separator' => 'after', 'range' => [ 'px' => [ 'min' => 0, 'max' => 3, 'step' => 0.1, ], ], 'default' => [ 'unit' => 'em', 'size' => 0, ], 'selectors' => [ '{{WRAPPER}} ' => '--ui-e-content-space: {{SIZE}}em;', ], ] ); $this->add_group_control( Group_Control_Background::get_type(), [ 'name' => 'content_bg', 'selector' => '{{WRAPPER}} .ui-e-post-content', ] ); $this->end_controls_section(); $this->start_controls_section( 'section_button_style', [ 'label' => esc_html__('Button Style', 'uicore-elements'), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => array( 'show_button' => 'yes', ), ] ); $this->register_button_style_controls(['section_condition' => ['show_button' => 'yes']]); $this->add_control( 'button_gap', [ 'label' => __('Button Top Space', 'uicore-elements'), 'type' => Controls_Manager::SLIDER, 'size_units' => ['em'], 'range' => [ 'px' => [ 'min' => 0, 'max' => 3, 'step' => 0.1, ], ], 'default' => [ 'unit' => 'em', 'size' => 0.8, ], 'selectors' => [ '{{WRAPPER}} .elementor-button' => 'margin-top: {{SIZE}}em;', ], ] ); $this->end_controls_section(); $this->start_controls_section( 'section_style_extra_content', [ 'label' => __('Meta Style', 'uicore-elements'), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->start_controls_tabs('style_extra_tabs'); $this->start_controls_tab( 'style_top_tab', [ 'label' => esc_html__('Top', 'uicore-elements'), ] ); $this->get_meta_style_controls('top'); $this->end_controls_tab(); $this->start_controls_tab( 'style_before_title_tab', [ 'label' => esc_html__('Before Title', 'uicore-elements'), ] ); $this->get_meta_style_controls('before_title'); $this->end_controls_tab(); $this->start_controls_tab( 'style_after_title_tab', [ 'label' => esc_html__('After Title', 'uicore-elements'), ] ); $this->get_meta_style_controls('after_title'); $this->end_controls_tab(); $this->start_controls_tab( 'style_bottom_tab', [ 'label' => esc_html__('Bottom', 'uicore-elements'), ] ); $this->get_meta_style_controls('bottom'); $this->end_controls_tab(); $this->end_controls_tabs(); $this->end_controls_section(); $this->TRAIT_register_filter_style_controls(); $this->start_controls_section( 'section_style_pagination', [ 'label' => __('Pagination Style', 'uicore-elements'), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => [ 'pagination' => 'yes', ], ] ); $this->TRAIT_register_pagination_style_controls(); $this->end_controls_section(); $this->start_controls_section( 'section_style_animations', [ 'label' => __('Animations', 'uicore-elements'), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->TRAIT_register_entrance_animations_controls(); $this->TRAIT_register_hover_animation_control( 'Item Hover Animation', [], ['underline'], 'anim_item' ); $this->add_control( 'anim_image', [ 'label' => __('Image Hover Animation', 'uicore-elements'), 'type' => Controls_Manager::SELECT, 'label_block' => true, 'default' => 'ui-e-img-anim-zoom', 'options' => [ '' => __('None', 'uicore-elements'), 'ui-e-img-anim-zoom' => __('Zoom', 'uicore-elements'), ], 'prefix_class' => '', ] ); $this->add_control( 'anim_meta', [ 'label' => __('Meta Hover Animation', 'uicore-elements'), 'type' => Controls_Manager::SELECT, 'label_block' => true, 'default' => '', 'options' => [ '' => __('None', 'uicore-elements'), 'ui-e-meta-anim-show' => __('Show', 'uicore-elements'), ], 'prefix_class' => '', ] ); $this->add_control( 'important_note', [ 'label' => esc_html__('Important Note', 'uicore-elements'), 'type' => \Elementor\Controls_Manager::RAW_HTML, 'raw' => '