diff --git a/widgets/Latest-Posts-Hover.php b/widgets/Latest-Posts-Hover.php new file mode 100644 index 0000000..f539954 --- /dev/null +++ b/widgets/Latest-Posts-Hover.php @@ -0,0 +1,1699 @@ + + start_controls_section( + 'section_general', + [ + 'label' => esc_html__('General', 'Latest-Posts-Hover'), + ] + ); + $this->add_control( + 'all_post', + [ + 'label' => esc_html__('All post', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SWITCHER, + 'label_on' => esc_html__('On', 'Latest-Posts-Hover'), + 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), + 'return_value' => 'all', + 'default' => 'normal', + ] + ); + $this->add_control( + 'posts_per_page', + [ + 'label' => esc_html__('Number of Posts', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::NUMBER, + 'default' => 4, + 'min' => 1, + ] + ); + $this->add_control( + 'default_image', + [ + 'label' => esc_html__('Default Image', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::MEDIA, + 'default' => [ + 'url' => \Elementor\Utils::get_placeholder_image_src(), + ], + ] + ); + $this->add_control( + 'card_color', + [ + 'label' => esc_html__('Background color', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::COLOR, + 'default' => '#f8f8f8', + 'selectors' => [ + '{{WRAPPER}} .info' => 'background-color:{{VALUE}}!important;', + ], + ] + ); + $this->add_control( + 'card_opacity', + [ + 'label' => esc_html__('Card opacity', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::NUMBER, + 'min' => 0, + 'max' => 1, + 'step' => 0.1, + 'default'=>0.8, + 'selectors' => [ + '{{WRAPPER}} .info' => 'filter:opacity({{VALUE}})!important;', + ], + ] + ); + + $this->add_control( + 'selected_page', + [ + 'label' => esc_html__(' Select Page if you have a page with all post, made with this widget for the links', 'OpenWidget'), + 'type' => \Elementor\Controls_Manager::SELECT, + 'options' => $this->get_pages(), + 'default' => 0, + ] + ); + $this->add_control( + 'filter_alignment', + [ + 'label' => esc_html__('Filter Alignment', 'OpenWidget'), + 'type' => \Elementor\Controls_Manager::CHOOSE, + 'options' => [ + 'left' => [ + 'title' => esc_html__('Left', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-alignleft', + ], + 'center' => [ + 'title' => esc_html__('Center', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-aligncenter', + ], + 'right' => [ + 'title' => esc_html__('Right', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-alignright', + ], + ], + 'default' => 'left', + 'toggle' => true, + 'selectors' => [ + '{{WRAPPER}} .category-filter' => 'justify-content: {{VALUE}};', + ], + 'icon_colors' => [ + 'left' => 'white', + 'center' => 'white', + 'right' => 'white', + ], + ] + ); + $this->end_controls_section(); + $this->start_controls_section( + 'section_error', + [ + 'label' => esc_html__('No post error', 'Latest-Posts-Hover'), + ] + ); + $this->add_control( + 'Error_color', + [ + 'label' => esc_html__('Text color', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::COLOR, + 'default' => 'black', + 'selectors' => [ + '{{WRAPPER}} .error-message' => 'color: {{VALUE}}!important;', + ], + ] + ); + $this->add_control( + 'Error_font_size', + [ + 'label' => esc_html__('Font Size', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SLIDER, + 'default' => [ + 'size' => 30, + 'unit' => 'px', + ], + 'range' => [ + 'px' => [ + 'min' => 1, + 'max' => 120, + ], + ], + 'selectors' => [ + '{{WRAPPER}} .error-message' => 'font-size: {{SIZE}}{{UNIT}};', + ], + ] + ); + $this->add_control( + 'error_font', + [ + 'label' => esc_html__('Font Family', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::FONT, + 'default' => "Work Sans", + 'selectors' => [ + '{{WRAPPER}} .error-message' => 'font-family: {{VALUE}}', + ], + ] + ); + $this->add_control( + 'error_bold', + [ + 'label' => esc_html__('Error Bold', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SWITCHER, + 'label_on' => esc_html__('On', 'Latest-Posts-Hover'), + 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), + 'return_value' => 'bold', + 'default' => 'normal', + 'selectors' => [ + '{{WRAPPER}} .error-message' => 'font-weight: {{VALUE}};', + ], + ] + ); + $this->add_control( + 'error_alignment', + [ + 'label' => esc_html__('Error Alignment', 'OpenWidget'), + 'type' => \Elementor\Controls_Manager::CHOOSE, + 'options' => [ + 'left' => [ + 'title' => esc_html__('Left', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-alignleft', + ], + 'center' => [ + 'title' => esc_html__('Center', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-aligncenter', + ], + 'right' => [ + 'title' => esc_html__('Right', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-alignright', + ], + ], + 'default' => 'left', + 'toggle' => true, + 'selectors' => [ + '{{WRAPPER}} .error-message' => 'text-align: {{VALUE}};', + ], + 'icon_colors' => [ + 'left' => 'white', + 'center' => 'white', + 'right' => 'white', + ], + ] + ); + $this->add_control( + 'error_message', + [ + 'type' => \Elementor\Controls_Manager::TEXT, + 'label' => esc_html__('Error message', 'textdomain'), + 'placeholder' => esc_html__('Error message', 'textdomain'), + 'default' => 'No post found', + ] + ); + $this->end_controls_section(); + $this->start_controls_section( + 'section_title', + [ + 'label' => esc_html__('Title', 'Latest-Posts-Hover'), + ] + ); + $this->add_control( + 'Title_color', + [ + 'label' => esc_html__('Color', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::COLOR, + 'default' => 'black', + 'selectors' => [ + '{{WRAPPER}} .title' => 'color: {{VALUE}}!important;', + ], + ] + ); + $this->add_control( + 'title_font_size', + [ + 'label' => esc_html__('Font Size', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SLIDER, + 'default' => [ + 'size' => 30, + 'unit' => 'px', + ], + 'range' => [ + 'px' => [ + 'min' => 1, + 'max' => 120, + ], + ], + 'selectors' => [ + '{{WRAPPER}} .title' => 'font-size: {{SIZE}}{{UNIT}};', + ], + ] + ); + $this->add_control( + 'title_font', + [ + 'label' => esc_html__('Font Family', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::FONT, + 'default' => "Work Sans", + 'selectors' => [ + '{{WRAPPER}} .title' => 'font-family: {{VALUE}}', + ], + ] + ); + $this->add_control( + 'title_bold', + [ + 'label' => esc_html__('Title Bold', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SWITCHER, + 'label_on' => esc_html__('On', 'Latest-Posts-Hover'), + 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), + 'return_value' => 'bold', + 'default' => 'normal', + 'selectors' => [ + '{{WRAPPER}} .title' => 'font-weight: {{VALUE}};', + ], + ] + ); + $this->add_control( + 'title_alignment', + [ + 'label' => esc_html__('Title Alignment', 'OpenWidget'), + 'type' => \Elementor\Controls_Manager::CHOOSE, + 'options' => [ + 'left' => [ + 'title' => esc_html__('Left', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-alignleft', + ], + 'center' => [ + 'title' => esc_html__('Center', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-aligncenter', + ], + 'right' => [ + 'title' => esc_html__('Right', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-alignright', + ], + ], + 'default' => 'left', + 'toggle' => true, + 'selectors' => [ + '{{WRAPPER}} .title' => 'text-align: {{VALUE}};', + ], + 'icon_colors' => [ + 'left' => 'white', + 'center' => 'white', + 'right' => 'white', + ], + ] + ); + $this->end_controls_section(); + $this->start_controls_section( + 'section_date', + [ + 'label' => esc_html__('Date', 'Latest-Posts-Hover'), + ] + ); + $this->add_control( + 'date_active', + [ + 'label' => esc_html__('Date Active', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SWITCHER, + 'label_on' => esc_html__('On', 'Latest-Posts-Hover'), + 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), + 'return_value' => 'inline-block', + 'default' => 'none', + 'selectors' => [ + '{{WRAPPER}} .date' => 'display: {{VALUE}};', + ], + ] + ); + $this->add_control( + 'Date_color', + [ + 'label' => esc_html__('Color', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::COLOR, + 'default' => 'black', + 'selectors' => [ + '{{WRAPPER}} .date' => 'color: {{VALUE}};', + ], + ] + ); + $this->add_control( + 'date_font_size', + [ + 'label' => esc_html__('Font Size', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SLIDER, + 'default' => [ + 'size' => 18, + 'unit' => 'px', + ], + 'range' => [ + 'px' => [ + 'min' => 1, + 'max' => 120, + ], + ], + 'selectors' => [ + '{{WRAPPER}} .date' => 'font-size: {{SIZE}}{{UNIT}};', + ], + ] + ); + $this->add_control( + 'date_font', + [ + 'label' => esc_html__('Font Date', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::FONT, + 'default' => "Work Sans", + 'selectors' => [ + '{{WRAPPER}} .date' => 'font-family: {{VALUE}}', + ], + ] + ); + $this->add_control( + 'date_bold', + [ + 'label' => esc_html__('Date Bold', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SWITCHER, + 'label_on' => esc_html__('On', 'Latest-Posts-Hover'), + 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), + 'return_value' => 'bold', + 'default' => 'normal', + 'selectors' => [ + '{{WRAPPER}} .date' => 'font-weight: {{VALUE}};', + ], + ] + ); + $this->add_control( + 'date_alignment', + [ + 'label' => esc_html__('Date Alignment', 'OpenWidget'), + 'type' => \Elementor\Controls_Manager::CHOOSE, + 'options' => [ + 'left' => [ + 'title' => esc_html__('Left', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-alignleft', + ], + 'center' => [ + 'title' => esc_html__('Center', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-aligncenter', + ], + 'right' => [ + 'title' => esc_html__('Right', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-alignright', + ], + ], + 'default' => 'left', + 'toggle' => true, + 'selectors' => [ + '{{WRAPPER}} .date-card2' => 'justify-content: {{VALUE}};', + ], + 'icon_colors' => [ + 'left' => 'white', + 'center' => 'white', + 'right' => 'white', + ], + ] + ); + $this->end_controls_section(); + $this->start_controls_section( + 'section_tag', + [ + 'label' => esc_html__('Tag', 'Latest-Posts-Hover'), + ] + ); + $this->add_control( + 'tag_active', + [ + 'label' => esc_html__('Tag Active', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SWITCHER, + 'label_on' => esc_html__('On', 'Latest-Posts-Hover'), + 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), + 'return_value' => 'inline-block', + 'default' => 'none', + 'selectors' => [ + '{{WRAPPER}} .tag' => 'display: {{VALUE}};', + ], + ] + ); + $this->add_control( + 'Tag_color', + [ + 'label' => esc_html__('Color Tag', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::COLOR, + 'default' => 'black', + 'selectors' => [ + '{{WRAPPER}} .tag' => 'color: {{VALUE}};', + ], + ] + ); + $this->add_control( + 'tag_font_size', + [ + 'label' => esc_html__('Size Tag', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SLIDER, + 'default' => [ + 'size' => 18, + 'unit' => 'px', + ], + 'range' => [ + 'px' => [ + 'min' => 1, + 'max' => 120, + ], + ], + 'selectors' => [ + '{{WRAPPER}} .tag' => 'font-size: {{SIZE}}{{UNIT}};', + ], + ] + ); + $this->add_control( + 'tag_font', + [ + 'label' => esc_html__('Font tag', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::FONT, + 'default' => "Work Sans", + 'selectors' => [ + '{{WRAPPER}} .tag' => 'font-family: {{VALUE}}', + ], + ] + ); + $this->add_control( + 'tag_bold', + [ + 'label' => esc_html__('Tag Bold', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SWITCHER, + 'label_on' => esc_html__('On', 'Latest-Posts-Hover'), + 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), + 'return_value' => 'bold', + 'default' => 'normal', + 'selectors' => [ + '{{WRAPPER}} .tag' => 'font-weight: {{VALUE}};', + ], + ] + ); + $this->add_control( + 'tag_alignment', + [ + 'label' => esc_html__('Tag Alignment', 'OpenWidget'), + 'type' => \Elementor\Controls_Manager::CHOOSE, + 'options' => [ + 'left' => [ + 'title' => esc_html__('Left', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-alignleft', + ], + 'center' => [ + 'title' => esc_html__('Center', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-aligncenter', + ], + 'right' => [ + 'title' => esc_html__('Right', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-alignright', + ], + ], + 'default' => 'left', + 'toggle' => true, + 'selectors' => [ + '{{WRAPPER}} .tag-card2' => 'justify-content: {{VALUE}};', + ], + 'icon_colors' => [ + 'left' => 'white', + 'center' => 'white', + 'right' => 'white', + ], + ] + ); + $this->end_controls_section(); + $this->start_controls_section( + 'section_category', + [ + 'label' => esc_html__('Category', 'Latest-Posts-Hover'), + ] + ); + $this->add_control( + 'category_active', + [ + 'label' => esc_html__('Category Active', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SWITCHER, + 'label_on' => esc_html__('On', 'Latest-Posts-Hover'), + 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), + 'return_value' => 'flex', + 'default' => 'none', + 'selectors' => [ + '{{WRAPPER}} .category' => 'display: {{VALUE}};', + '{{WRAPPER}} .category-card2' => 'display: {{VALUE}};', + ], + ] + ); + $this->add_control( + 'category_color', + [ + 'label' => esc_html__('Color', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::COLOR, + 'default' => 'black', + 'selectors' => [ + '{{WRAPPER}} .category' => 'color: {{VALUE}};', + ], + ] + ); + $this->add_control( + 'category_font_size', + [ + 'label' => esc_html__('Font Size', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SLIDER, + 'default' => [ + 'size' => 18, + 'unit' => 'px', + ], + 'range' => [ + 'px' => [ + 'min' => 1, + 'max' => 120, + ], + ], + 'selectors' => [ + '{{WRAPPER}} .category' => 'font-size: {{SIZE}}{{UNIT}};', + ], + ] + ); + $this->add_control( + 'category_font', + [ + 'label' => esc_html__('Font Family', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::FONT, + 'default' => "Work Sans", + 'selectors' => [ + '{{WRAPPER}} .category' => 'font-family: {{VALUE}}', + ], + ] + ); + $this->add_control( + 'category_bold', + [ + 'label' => esc_html__('category Bold', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SWITCHER, + 'label_on' => esc_html__('On', 'Latest-Posts-Hover'), + 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), + 'return_value' => 'bold', + 'default' => 'normal', + 'selectors' => [ + '{{WRAPPER}} .category' => 'font-weight: {{VALUE}};', + ], + ] + ); + $this->add_control( + 'category_alignment', + [ + 'label' => esc_html__('Category Alignment', 'OpenWidget'), + 'type' => \Elementor\Controls_Manager::CHOOSE, + 'options' => [ + 'left' => [ + 'title' => esc_html__('Left', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-alignleft', + ], + 'center' => [ + 'title' => esc_html__('Center', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-aligncenter', + ], + 'right' => [ + 'title' => esc_html__('Right', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-alignright', + ], + ], + 'default' => 'left', + 'toggle' => true, + 'selectors' => [ + '{{WRAPPER}} .category-card2' => 'justify-content: {{VALUE}};', + + + ], + 'icon_colors' => [ + 'left' => 'white', + 'center' => 'white', + 'right' => 'white', + ], + ] + ); + $this->add_control( + 'categories_in', + [ + 'label' => esc_html__('Select Categories to include', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SELECT2, + 'multiple' => true, + 'options' => $this->get_category(), + ] + ); + $this->add_control( + 'exclude_categories', + [ + 'label' => esc_html__('Select Categories to exclude', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SELECT2, + 'multiple' => true, + 'options' => $this->get_category(), + ] + ); + $this->end_controls_section(); + $this->start_controls_section( + 'section_content', + [ + 'label' => esc_html__('Content', 'Latest-Posts-Hover'), + ] + ); + $this->add_control( + 'content_word_pc', + [ + 'label' => esc_html__('Number of Word on pc', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::NUMBER, + 'default' => 15, + 'min' => 1, + ] + ); + $this->add_control( + 'content_word_mobile', + [ + 'label' => esc_html__('Number of Word on mobile', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::NUMBER, + 'default' => 15, + 'min' => 1, + ] + ); + $this->add_control( + 'text_color', + [ + 'label' => esc_html__('Color', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::COLOR, + 'default' => 'black', + 'selectors' => [ + '{{WRAPPER}} .description' => 'color: {{VALUE}} !important;', + ], + ] + ); + $this->add_control( + 'content_font_size', + [ + 'label' => esc_html__('Content Font Size', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SLIDER, + 'default' => [ + 'size' => 18, + 'unit' => 'px', + ], + 'range' => [ + 'px' => [ + 'min' => 1, + 'max' => 120, + ], + ], + 'selectors' => [ + '{{WRAPPER}} .description' => 'font-size: {{SIZE}}{{UNIT}};', + ], + ] + ); + $this->add_control( + 'content_font', + [ + 'label' => esc_html__('Content Font Family', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::FONT, + 'default' => "Work Sans", + 'selectors' => [ + '{{WRAPPER}} .description' => 'font-family: {{VALUE}}', + ], + ] + ); + $this->add_control( + 'content_bold', + [ + 'label' => esc_html__('category Bold', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SWITCHER, + 'label_on' => esc_html__('On', 'Latest-Posts-Hover'), + 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), + 'return_value' => 'bold', + 'default' => 'normal', + 'selectors' => [ + '{{WRAPPER}} .description' => 'font-weight: {{VALUE}};', + ], + ] + ); + $this->add_control( + 'content_alignment', + [ + 'label' => esc_html__('Content Alignment', 'OpenWidget'), + 'type' => \Elementor\Controls_Manager::CHOOSE, + 'options' => [ + 'left' => [ + 'title' => esc_html__('Left', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-alignleft', + ], + 'center' => [ + 'title' => esc_html__('Center', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-aligncenter', + ], + 'right' => [ + 'title' => esc_html__('Right', 'OpenWidget'), + 'icon' => 'mce-ico mce-i-alignright', + ], + ], + 'default' => 'left', + 'toggle' => true, + 'selectors' => [ + '{{WRAPPER}} .description' => 'text-align: {{VALUE}};', + ], + 'icon_colors' => [ + 'left' => 'white', + 'center' => 'white', + 'right' => 'white', + ], + ] + ); + + $this->end_controls_section(); + $this->start_controls_section( + 'section_Button_filter', + [ + 'label' => esc_html__('Button Filter', 'Latest-Posts-Hover'), + ] + ); + $this->add_control( + 'filter_active', + [ + 'label' => esc_html__('Button Filter Active', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SWITCHER, + 'label_on' => esc_html__('On', 'Latest-Posts-Hover'), + 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), + 'return_value' => 'inline-block', + 'default' => 'none', + 'selectors' => [ + '{{WRAPPER}} .category-filter-button' => 'display: {{VALUE}};', + ], + ] + ); + + $this->add_control( + 'text_color_inactive', + [ + 'label' => esc_html__('Button filter Inactive text color', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::COLOR, + 'default' => 'white', + 'selectors' => [ + '{{WRAPPER}} .category-filter-button' => ' color: {{VALUE}} !important;', + ], + ] + ); + $this->add_control( + 'text_font_inactive', + [ + 'label' => esc_html__('Button filter Inactive text Font Family', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::FONT, + 'default' => "Work Sans", + 'selectors' => [ + '{{WRAPPER}} .category-filter-button' => 'font-family: {{VALUE}}', + ], + ] + ); + $this->add_control( + 'background_color_inactive', + [ + 'label' => esc_html__('Button filter Inactive background color', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::COLOR, + 'default' => 'black', + 'selectors' => [ + '{{WRAPPER}} .category-filter-button' => ' background-color: {{VALUE}};', + ], + ] + ); + $this->add_control( + 'inactive_font_size', + [ + 'label' => esc_html__('Button filter Inactive text Font Size', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SLIDER, + 'default' => [ + 'size' => 18, + 'unit' => 'px', + ], + 'range' => [ + 'px' => [ + 'min' => 1, + 'max' => 120, + ], + ], + 'selectors' => [ + '{{WRAPPER}} .category-filter-button' => 'font-size: {{SIZE}}{{UNIT}};', + ], + ] + ); + $this->add_control( + 'Text_inactive_bold', + [ + 'label' => esc_html__('Button filter Inactive text bold', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SWITCHER, + 'label_on' => esc_html__('On', 'Latest-Posts-Hover'), + 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), + 'return_value' => 'bold', + 'default' => 'normal', + 'selectors' => [ + '{{WRAPPER}} .category-filter-button' => 'font-weight: {{VALUE}};', + ], + ] + ); + $this->add_control( + 'text_color_active', + [ + 'label' => esc_html__('Button filter Active text clor', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::COLOR, + 'default' => 'white', + 'selectors' => [ + '{{WRAPPER}} .category-filter-button.active' => ' color: {{VALUE}} !important;', + ], + ] + ); + $this->add_control( + 'text_font_active', + [ + 'label' => esc_html__('Button filter Active text Font Family', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::FONT, + 'default' => "Work Sans", + 'selectors' => [ + '{{WRAPPER}} .category-filter-button.active' => 'font-family: {{VALUE}}', + ], + ] + ); + $this->add_control( + 'background_color_active', + [ + 'label' => esc_html__('Button filter Active background color', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::COLOR, + 'default' => 'red', + 'selectors' => [ + '{{WRAPPER}} .category-filter-button.active' => ' background-color: {{VALUE}};', + ], + ] + ); + $this->add_control( + 'active_font_size', + [ + 'label' => esc_html__('Button filter Active text Font Size', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SLIDER, + 'default' => [ + 'size' => 18, + 'unit' => 'px', + ], + 'range' => [ + 'px' => [ + 'min' => 1, + 'max' => 120, + ], + ], + 'selectors' => [ + '{{WRAPPER}} .category-filter-button.active' => 'font-size: {{SIZE}}{{UNIT}};', + ], + ] + ); + $this->add_control( + 'Text_active_bold', + [ + 'label' => esc_html__('Button filter Active text bold ', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SWITCHER, + 'label_on' => esc_html__('On', 'Latest-Posts-Hover'), + 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), + 'return_value' => 'bold', + 'default' => 'normal', + 'selectors' => [ + '{{WRAPPER}} .category-filter-button.active' => 'font-weight: {{VALUE}};', + ], + ] + ); + $this->add_control( + 'text_color_hover', + [ + 'label' => esc_html__('Button filter Hover text color', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::COLOR, + 'default' => 'white', + 'selectors' => [ + '{{WRAPPER}} .category-filter-button:hover' => ' color: {{VALUE}} !important;', + ], + ] + ); + $this->add_control( + 'text_font_hover', + [ + 'label' => esc_html__('Button filter hover text Font Family', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::FONT, + 'default' => "Work Sans", + 'selectors' => [ + '{{WRAPPER}} .category-filter-button:hover' => 'font-family: {{VALUE}}', + ], + ] + ); + $this->add_control( + 'background_color_hover', + [ + 'label' => esc_html__('Button filter Hover background color', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::COLOR, + 'default' => 'orange', + 'selectors' => [ + '{{WRAPPER}} .category-filter-button:hover' => ' background-color: {{VALUE}};', + ], + ] + ); + + $this->add_control( + 'hover_font_size', + [ + 'label' => esc_html__('Button filter Hover text Font Size', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SLIDER, + 'default' => [ + 'size' => 18, + 'unit' => 'px', + ], + 'range' => [ + 'px' => [ + 'min' => 1, + 'max' => 120, + ], + ], + 'selectors' => [ + '{{WRAPPER}} .category-filter-button:hover' => 'font-size: {{SIZE}}{{UNIT}};', + ], + ] + ); + $this->add_control( + 'Text_hover_bold', + [ + 'label' => esc_html__(' Button filter Hover text Bold', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SWITCHER, + 'label_on' => esc_html__('On', 'Latest-Posts-Hover'), + 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), + 'return_value' => 'bold', + 'default' => 'normal', + 'selectors' => [ + '{{WRAPPER}} .category-filter-button:hover' => 'font-weight: {{VALUE}};', + ], + ] + ); + + $this->add_control( + 'related_category', + [ + 'label' => esc_html__('Show categories related to the one one you selected', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SWITCHER, + 'label_on' => esc_html__('On', 'Latest-Posts-Hover'), + 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), + 'return_value' => 'on', + 'default' => 'off', + ] + ); + $this->add_control( + 'include_all', + [ + 'label' => esc_html__('Show all even if someone is excluded', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SWITCHER, + 'label_on' => esc_html__('on', 'Latest-Posts-Hover'), + 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), + 'return_value' => 'on', + 'default' => 'off', + ] + ); + $this->add_control( + 'All_place', + [ + 'type' => \Elementor\Controls_Manager::TEXT, + 'label' => esc_html__('All button', 'textdomain'), + 'placeholder' => esc_html__('All button', 'textdomain'), + 'default' => 'All', + ] + ); + $this->end_controls_section(); + $this->start_controls_section( + 'section_search', + [ + 'label' => esc_html__('Search', 'Latest-Posts-Hover'), + ] + ); + $this->add_control( + 'search_active', + [ + 'label' => esc_html__('Search Active', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SWITCHER, + 'label_on' => esc_html__('On', 'Latest-Posts-Hover'), + 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), + 'return_value' => 'inline-block', + 'default' => 'none', + 'selectors' => [ + '{{WRAPPER}} .container2' => 'display: {{VALUE}};', + ], + ] + ); + $this->add_control( + 'background_color_input', + [ + 'label' => esc_html__('Background color', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::COLOR, + 'default' => 'orange', + 'selectors' => [ + '{{WRAPPER}} + .input2' => ' background: {{VALUE}} !important;', + '{{WRAPPER}} .input2:focus' => ' background: {{VALUE}}!important;', + '{{WRAPPER}} .input2:hover' => ' background: {{VALUE}}!important;', + ], + ] + ); + $this->add_control( + 'text_color_input', + [ + 'label' => esc_html__('Text color', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::COLOR, + 'default' => 'black', + 'selectors' => [ + '{{WRAPPER}} .input2' => ' color: {{VALUE}}!important;', + + ], + ] + ); + $this->add_control( + 'icon_color_', + [ + 'label' => esc_html__('Icon color', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::COLOR, + 'default' => 'black', + 'selectors' => [ + '{{WRAPPER}} .submit-button' => ' color: {{VALUE}}!important;', + ], + ] + ); + $this->add_control( + 'cursor_color_', + [ + 'label' => esc_html__('Cursor color', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::COLOR, + 'default' => 'black', + 'selectors' => [ + '{{WRAPPER}} .input2' => ' caret-color: {{VALUE}}!important;', + ], + ] + ); + $this->add_control( + 'search_font_size', + [ + 'label' => esc_html__('Search Font Size', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::SLIDER, + 'default' => [ + 'size' => 18, + 'unit' => 'px', + ], + 'range' => [ + 'px' => [ + 'min' => 1, + 'max' => 120, + ], + ], + 'selectors' => [ + '{{WRAPPER}} .input2' => 'font-size: {{SIZE}}{{UNIT}};', + ], + ] + ); + $this->add_control( + 'Search_place', + [ + 'type' => \Elementor\Controls_Manager::TEXT, + 'label' => esc_html__('Place', 'textdomain'), + 'placeholder' => esc_html__('Placeholder Search', 'textdomain'), + 'default' => 'search', + ] + ); + $this->end_controls_section(); + } + private function get_category() + { + $categories = get_categories(); + $options = []; + foreach ($categories as $category) { + $options[$category->term_id] = $category->name; + } + return $options; + } + private function get_pages() + { + $pages = get_pages(); + $options = []; + $options[0] = esc_html__('Default', 'OpenWidget'); + foreach ($pages as $page) { + $options[$page->ID] = $page->post_title; + } + return $options ?: []; + } + + + protected function render() + + { + $settings = $this->get_settings_for_display(); + if ($settings['posts_per_page'] == null) { + $settings['posts_per_page'] = 4; + } + $args = [ + 'posts_per_page' => $settings['posts_per_page'], + 'category_name' => isset($_GET['category']) ? sanitize_text_field($_GET['category']) : '', + 'tag' => isset($_GET['tags']) ? sanitize_text_field($_GET['tags']) : '', + ]; + if (isset($_GET['category']) && ($_GET['category']) == "all") { + unset($args['category_name']); + } + if (isset($_GET['date'])) { + $date_query = [ + 'after' => $_GET['date'], + 'inclusive' => true, + ]; + $args['date_query'] = $date_query; + } + if ($settings['all_post'] == 'all') { + $args['posts_per_page'] = -1; + } + $all = $settings['All_place']; + $selected_page_id = $settings['selected_page']; + $args['category__not_in'] = $settings['exclude_categories']; + $args['category__in'] = $settings['categories_in']; + if (isset($_GET['input2'])) { + $args['s'] = sanitize_text_field($_GET['input2']); + } + $posts = get_posts($args); + $wordPc = $settings['content_word_pc']; + $wordMobile = $settings['content_word_mobile']; + $place = $settings['Search_place']; + + if (count($posts) != 0) { + $flex = 100 / count($posts); + } + if (count($posts) > 4 || count($posts) == 0) { + $flex = 25; + } + $width = $flex - 1; + if ($posts) { + echo '
'; + if ($selected_page_id != 0) { + $page_link = get_permalink($selected_page_id); + + echo '
'; + } else { + echo ' '; + } + if ($settings['related_category'] != 'on' || $settings['related_category'] == 'on' && $settings['categories_in'] == null) { + $args_C['taxonomy'] = 'category'; + $args_C['hide_empty'] = true; + $args_C['exclude'] = $settings['exclude_categories']; + $args_C['include'] = $settings['categories_in']; + if ($args_C['include'] == null && $args_C['exclude'] == null || $settings['include_all'] == 'on') { + echo ''; + } + + $categories = get_terms($args_C); + foreach ($categories as $category) { + if (is_array($settings['exclude_categories'])) { + if (in_array($category->term_id, $settings['exclude_categories'])) { + continue; // Salta la categoria se è esclusa + } + } + // Controlla se la categoria ha almeno un post che non è escluso + $posts_in_category = get_posts(array( + 'category' => $category->term_id, + 'posts_per_page' => 1, // Controlla solo se ci sono post + 'category__not_in' => $settings['exclude_categories'], + )); + if ($posts_in_category) { + $category_name = $category->name; + $category_slug = $category->slug; + echo ''; + } + } + } + if ($settings['related_category'] == 'on' && $settings['categories_in'] != null) { + if ($settings['include_all'] == 'on') { + echo ''; + } + + $other_category_id = $settings['categories_in']; + $categories_with_posts = get_categories(array( + 'hide_empty' => 0, + 'child_of' => 0, + )); + + foreach ($categories_with_posts as $category) { + if (!in_array($category->term_id, $other_category_id)) { + $posts_in_category = get_posts(array( + 'category' => $category->term_id, + 'category__in' => $other_category_id, + 'posts_per_page' => 1, + )); + + if ($posts_in_category) { + $category_name = $category->name; + $category_slug = $category->slug; + echo ''; + } + } + } + } + + + echo '
+ +
'; + if ($selected_page_id != 0) { + $page_link = get_permalink($selected_page_id); + + echo '
'; + } else { + echo ' '; + } + echo ' + +
+ + +
+
+
'; + echo '
'; + + foreach ($posts as $post) { + $post_title = get_the_title($post->ID); + if (wp_is_mobile()) { + $post_content = wp_trim_words($post->post_content, $wordMobile); + } else { + $post_content = wp_trim_words($post->post_content, $wordPc); + } + $post_date = get_the_date('j F Y', $post->ID); + $post_link = get_permalink($post->ID); + $tags = get_the_tags($post->ID); + $post_numb = get_the_date('Y-m-d', $post->ID); + $date_array = explode('-', $post_numb); + // Check if the post has a featured image + $featured_image = get_the_post_thumbnail_url($post->ID); + if (!$featured_image) { + // If not, use the custom default image + $featured_image = $settings['default_image']['url']; + } + + if (wp_is_mobile() || is_admin()) { + echo '
'; + } else { + echo '
'; + } + echo ' +
+ ' . $post_title . ' '; + if (!empty($tags)) { + if ($selected_page_id != 0) { + echo ''; + } else { + echo '
'; + + foreach ($tags as $tag) { + + echo '' . $tag->name . ' '; + } + echo '
'; + } + } + $date_parts = explode(' ', $post_date); + $i = 2; + $date_array[1] = $date_array[0] . '/' . $date_array[1]; + $date_array[2] = $date_array[1] . '/' . $date_array[2]; + if ($selected_page_id != 0) { + $page_link = get_permalink($selected_page_id); + echo '
'; + + foreach ($date_parts as $part) { + if ($i == 1) { + $date_array[1] = $date_array[1] . '/01'; + } + $date_link = add_query_arg('date', $date_array[$i], $page_link); + echo ' ' . ucfirst($part) . ''; + $i -= 1; + } + echo '
'; + } else { + echo '
'; + $i = 2; + foreach ($date_parts as $part) { + $date_link = home_url() . '/' . $date_array[$i]; + echo '' . ucfirst($part) . ''; + $i -= 1; + } + echo '
'; + } + + if ($selected_page_id != 0) { + $page_link = get_permalink($selected_page_id); + $categories = get_the_category($post->ID); + if (!empty($categories)) { + echo '
'; + foreach ($categories as $category) { + $category_link = add_query_arg('category', $category->slug, $page_link); + echo ' ' . $category->name . ' '; + } + echo '
'; + } + } else { + $categories = get_the_category($post->ID); + if (!empty($categories)) { + echo '
'; + foreach ($categories as $category) { + echo ' ' . $category->name . '
'; + } + } + echo '
'; + } + echo '

' . $post_content . '

+
+
'; + } + wp_reset_postdata(); + echo '
'; + } + if (!$posts) { + + echo ''.$settings['error_message']; + echo ''; + if ($args['s']!=null) { + echo'
'; + if ($selected_page_id != 0) { + $page_link = get_permalink($selected_page_id); + + echo '
'; + } + else { + echo ' '; + } + echo ' + +
+ + +
+
+
'; + } + } + echo ''; + } + } \ No newline at end of file