From cf9cbd3d3fe1d4aa8e8ae6e114daa3ff853b547a Mon Sep 17 00:00:00 2001 From: Daddie2 <50950554+Daddie2@users.noreply.github.com> Date: Tue, 12 Mar 2024 09:37:15 +0100 Subject: [PATCH 1/6] Update Latest-Posts-Hover.php --- widgets/Latest-Posts-Hover.php | 252 +++++++++++++++++---------------- 1 file changed, 130 insertions(+), 122 deletions(-) diff --git a/widgets/Latest-Posts-Hover.php b/widgets/Latest-Posts-Hover.php index aceebbe..7eddce4 100644 --- a/widgets/Latest-Posts-Hover.php +++ b/widgets/Latest-Posts-Hover.php @@ -206,7 +206,7 @@ protected function _register_controls() 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => esc_html__('On', 'Latest-Posts-Hover'), 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), - 'return_value' => 'block', + 'return_value' => 'inline-block', 'default' => 'none', 'selectors' => [ '{{WRAPPER}} .date' => 'display: {{VALUE}};', @@ -314,7 +314,7 @@ protected function _register_controls() 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => esc_html__('On', 'Latest-Posts-Hover'), 'label_off' => esc_html__('Off', 'Latest-Posts-Hover'), - 'return_value' => 'block', + 'return_value' => 'inline-block', 'default' => 'none', 'selectors' => [ '{{WRAPPER}} .tag' => 'display: {{VALUE}};', @@ -507,7 +507,6 @@ protected function _register_controls() 'default' => 'left', 'toggle' => true, 'selectors' => [ - '{{WRAPPER}} .categories-links' => 'text-align: {{VALUE}};', '{{WRAPPER}} .category' => 'text-align: {{VALUE}};', @@ -519,6 +518,24 @@ protected function _register_controls() ], ] ); + $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', @@ -689,7 +706,7 @@ protected function _register_controls() [ 'label' => esc_html__('Inactive text color', 'Latest-Posts-Hover'), 'type' => \Elementor\Controls_Manager::COLOR, - 'default' => 'black', + 'default' => 'white', 'selectors' => [ '{{WRAPPER}} .category-filter-button' => ' color: {{VALUE}} !important;', ], @@ -756,7 +773,7 @@ protected function _register_controls() [ 'label' => esc_html__('Active text clor', 'Latest-Posts-Hover'), 'type' => \Elementor\Controls_Manager::COLOR, - 'default' => 'black', + 'default' => 'white', 'selectors' => [ '{{WRAPPER}} .category-filter-button.active' => ' color: {{VALUE}} !important;', ], @@ -778,7 +795,7 @@ protected function _register_controls() [ 'label' => esc_html__('Active background color', 'Latest-Posts-Hover'), 'type' => \Elementor\Controls_Manager::COLOR, - 'default' => 'black', + 'default' => 'red', 'selectors' => [ '{{WRAPPER}} .category-filter-button.active' => ' background-color: {{VALUE}};', ], @@ -823,7 +840,7 @@ protected function _register_controls() [ 'label' => esc_html__('Hover text color', 'Latest-Posts-Hover'), 'type' => \Elementor\Controls_Manager::COLOR, - 'default' => 'black', + 'default' => 'white', 'selectors' => [ '{{WRAPPER}} .category-filter-button:hover' => ' color: {{VALUE}} !important;', ], @@ -845,7 +862,7 @@ protected function _register_controls() [ 'label' => esc_html__('Hover background color', 'Latest-Posts-Hover'), 'type' => \Elementor\Controls_Manager::COLOR, - 'default' => 'black', + 'default' => 'orange', 'selectors' => [ '{{WRAPPER}} .category-filter-button:hover' => ' background-color: {{VALUE}};', ], @@ -889,6 +906,15 @@ protected function _register_controls() $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(); @@ -910,24 +936,23 @@ protected function render() $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") { - $args = [ - 'posts_per_page' => $settings['posts_per_page'], - ]; - } else { - $args = [ - 'posts_per_page' => $settings['posts_per_page'], - 'category_name' => isset($_GET['category']) ? sanitize_text_field($_GET['category']) : '', - + 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, - ]; + $args['posts_per_page'] = -1; } - + $args['category__not_in'] = $settings['exclude_categories']; + $args['category__in'] = $settings['categories_in']; $posts = get_posts($args); $cardColor = $settings['card_color']; $wordPc = $settings['content_word_pc']; @@ -939,11 +964,10 @@ protected function render() $flex = 25; } $widht = $flex - 1; - $title_color = $settings['Title_color']; if ($posts) { echo '
-
-
'; + } + if (!$posts) { // Gestisci il caso in cui $posts non è un array valido echo '
'; echo esc_html__('No post', 'Latest-Posts-Hover'); @@ -1133,6 +1140,7 @@ protected function render() background-position: center center; background-size: cover; cursor: pointer; + } .info { @@ -1181,11 +1189,11 @@ protected function render() } .tag { - margin-top: 0; + margin-top: 0px; margin-bottom: 0px; padding: 0 5px; font-size: 18px; - color: black; + color:black; display:none; text-align: left; } @@ -1250,4 +1258,4 @@ protected function render() '; } -} \ No newline at end of file +} From e1afc166893a4257ee6e54a24e211f84d6fde9b0 Mon Sep 17 00:00:00 2001 From: Daddie2 <50950554+Daddie2@users.noreply.github.com> Date: Tue, 12 Mar 2024 10:51:17 +0100 Subject: [PATCH 2/6] Active search --- widgets/Latest-Posts-Hover.php | 118 ++++++++++++++++++++++++++++----- 1 file changed, 100 insertions(+), 18 deletions(-) diff --git a/widgets/Latest-Posts-Hover.php b/widgets/Latest-Posts-Hover.php index 7eddce4..d08793b 100644 --- a/widgets/Latest-Posts-Hover.php +++ b/widgets/Latest-Posts-Hover.php @@ -659,7 +659,7 @@ protected function _register_controls() $this->add_control( 'filter_active', [ - 'label' => esc_html__('Filter Active', 'Latest-Posts-Hover'), + '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'), @@ -704,7 +704,7 @@ protected function _register_controls() $this->add_control( 'text_color_inactive', [ - 'label' => esc_html__('Inactive text color', 'Latest-Posts-Hover'), + 'label' => esc_html__('Button filter Inactive text color', 'Latest-Posts-Hover'), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => 'white', 'selectors' => [ @@ -715,7 +715,7 @@ protected function _register_controls() $this->add_control( 'text_font_inactive', [ - 'label' => esc_html__('Inactive text Font Family', 'Latest-Posts-Hover'), + 'label' => esc_html__('Button filter Inactive text Font Family', 'Latest-Posts-Hover'), 'type' => \Elementor\Controls_Manager::FONT, 'default' => "Work Sans", 'selectors' => [ @@ -726,7 +726,7 @@ protected function _register_controls() $this->add_control( 'background_color_inactive', [ - 'label' => esc_html__('Inactive background color', 'Latest-Posts-Hover'), + 'label' => esc_html__('Button filter Inactive background color', 'Latest-Posts-Hover'), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => 'black', 'selectors' => [ @@ -737,7 +737,7 @@ protected function _register_controls() $this->add_control( 'inactive_font_size', [ - 'label' => esc_html__('Inactive text Font Size', 'Latest-Posts-Hover'), + 'label' => esc_html__('Button filter Inactive text Font Size', 'Latest-Posts-Hover'), 'type' => \Elementor\Controls_Manager::SLIDER, 'default' => [ 'size' => 18, @@ -757,7 +757,7 @@ protected function _register_controls() $this->add_control( 'Text_inactive_bold', [ - 'label' => esc_html__('Inactive text bold', 'Latest-Posts-Hover'), + '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'), @@ -771,7 +771,7 @@ protected function _register_controls() $this->add_control( 'text_color_active', [ - 'label' => esc_html__('Active text clor', 'Latest-Posts-Hover'), + 'label' => esc_html__('Button filter Active text clor', 'Latest-Posts-Hover'), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => 'white', 'selectors' => [ @@ -782,7 +782,7 @@ protected function _register_controls() $this->add_control( 'text_font_active', [ - 'label' => esc_html__('Active text Font Family', 'Latest-Posts-Hover'), + 'label' => esc_html__('Button filter Active text Font Family', 'Latest-Posts-Hover'), 'type' => \Elementor\Controls_Manager::FONT, 'default' => "Work Sans", 'selectors' => [ @@ -793,7 +793,7 @@ protected function _register_controls() $this->add_control( 'background_color_active', [ - 'label' => esc_html__('Active background color', 'Latest-Posts-Hover'), + 'label' => esc_html__('Button filter Active background color', 'Latest-Posts-Hover'), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => 'red', 'selectors' => [ @@ -804,7 +804,7 @@ protected function _register_controls() $this->add_control( 'active_font_size', [ - 'label' => esc_html__('Active text Font Size', 'Latest-Posts-Hover'), + 'label' => esc_html__('Button filter Active text Font Size', 'Latest-Posts-Hover'), 'type' => \Elementor\Controls_Manager::SLIDER, 'default' => [ 'size' => 18, @@ -824,7 +824,7 @@ protected function _register_controls() $this->add_control( 'Text_active_bold', [ - 'label' => esc_html__('Active text bold ', 'Latest-Posts-Hover'), + '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'), @@ -838,7 +838,7 @@ protected function _register_controls() $this->add_control( 'text_color_hover', [ - 'label' => esc_html__('Hover text color', 'Latest-Posts-Hover'), + 'label' => esc_html__('Button filter Hover text color', 'Latest-Posts-Hover'), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => 'white', 'selectors' => [ @@ -849,7 +849,7 @@ protected function _register_controls() $this->add_control( 'text_font_hover', [ - 'label' => esc_html__('hover text Font Family', 'Latest-Posts-Hover'), + 'label' => esc_html__('Button filter hover text Font Family', 'Latest-Posts-Hover'), 'type' => \Elementor\Controls_Manager::FONT, 'default' => "Work Sans", 'selectors' => [ @@ -860,7 +860,7 @@ protected function _register_controls() $this->add_control( 'background_color_hover', [ - 'label' => esc_html__('Hover background color', 'Latest-Posts-Hover'), + 'label' => esc_html__('Button filter Hover background color', 'Latest-Posts-Hover'), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => 'orange', 'selectors' => [ @@ -872,7 +872,7 @@ protected function _register_controls() $this->add_control( 'hover_font_size', [ - 'label' => esc_html__('Hover text Font Size', 'Latest-Posts-Hover'), + 'label' => esc_html__('Button filter Hover text Font Size', 'Latest-Posts-Hover'), 'type' => \Elementor\Controls_Manager::SLIDER, 'default' => [ 'size' => 18, @@ -892,7 +892,7 @@ protected function _register_controls() $this->add_control( 'Text_hover_bold', [ - 'label' => esc_html__('Hover text Bold', 'Latest-Posts-Hover'), + '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'), @@ -903,7 +903,20 @@ protected function _register_controls() ], ] ); - + $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' => 'flex', + 'default' => 'none', + 'selectors' => [ + '{{WRAPPER}} .container2' => 'display: {{VALUE}};', + ], + ] + ); $this->end_controls_section(); } private function get_category() @@ -982,7 +995,12 @@ protected function render() } echo '">' . $category_name . ''; } - echo '
'; + echo '
+ +
'; echo '
'; $selected_page_id = $settings['selected_page']; @@ -1090,6 +1108,70 @@ protected function render() echo 'prova'; } echo ''; } } From 9330b56ce3152005941af830716333697822a535 Mon Sep 17 00:00:00 2001 From: Daddie2 <50950554+Daddie2@users.noreply.github.com> Date: Sun, 24 Mar 2024 22:21:35 +0100 Subject: [PATCH 4/6] Create Latest-Posts-Hover.php --- widgets/Latest-Posts-Hover.php | 1796 ++++++++++++++++++++++++++++++++ 1 file changed, 1796 insertions(+) create mode 100644 widgets/Latest-Posts-Hover.php diff --git a/widgets/Latest-Posts-Hover.php b/widgets/Latest-Posts-Hover.php new file mode 100644 index 0000000..f8ad88b --- /dev/null +++ b/widgets/Latest-Posts-Hover.php @@ -0,0 +1,1796 @@ +<<<<<<< HEAD + +======= + +>>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 +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', + ] + ); + $this->add_control( + 'card_opacity', + [ + 'label' => esc_html__('Card opacity', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::NUMBER, + 'default' => 0.8, + 'min' => 0, + 'max' => 1, + 'step' => 0.1, + 'selectors' => [ + '{{WRAPPER}} .title' => 'filter:{{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_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' => 'inline-block', + 'default' => 'none', + 'selectors' => [ + '{{WRAPPER}} .category' => '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' => [ +<<<<<<< HEAD + '{{WRAPPER}} .category-card2' => 'justify-content: {{VALUE}};', +======= + '{{WRAPPER}} .category' => 'text-align: {{VALUE}};', +>>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 + + + ], + '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}};', +<<<<<<< HEAD +======= + ], + ] + ); + $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', +>>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 + ], + ] + ); + + $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}};', + ], + ] + ); +<<<<<<< HEAD + +======= + +>>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 + $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->end_controls_section(); + $this->start_controls_section( + 'section_search', + [ +<<<<<<< HEAD + 'label' => esc_html__('Search', 'Latest-Posts-Hover'), + ] + ); +======= + 'label' => esc_html__('search', 'Latest-Posts-Hover'), + ] + ); +>>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 + $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}};', + ], + ] +<<<<<<< HEAD + ); +======= + ); +>>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 + $this->add_control( + 'background_color_input', + [ + 'label' => esc_html__('Input background color', 'Latest-Posts-Hover'), + 'type' => \Elementor\Controls_Manager::COLOR, + 'default' => 'red', + 'selectors' => [ + '{{WRAPPER}} +<<<<<<< HEAD + .container2 .search2 input:focus,.container2 .search2 input:active,.container2 .search2:hover input' => ' background-color: {{VALUE}};', + ], + ] + ); + + $this->end_controls_section(); +======= + .container2 .search input:focus,.container2 .search input:active,.container2 .search:hover input' => ' background-color: {{VALUE}};', + ], + ] + ); + + $this->end_controls_section(); + +>>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 + } + 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; + } +<<<<<<< HEAD + $selected_page_id = $settings['selected_page']; +======= +>>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 + $args['category__not_in'] = $settings['exclude_categories']; + $args['category__in'] = $settings['categories_in']; + $posts = get_posts($args); + $cardColor = $settings['card_color']; + $wordPc = $settings['content_word_pc']; + $wordMobile = $settings['content_word_mobile']; + if (count($posts) != 0) { + $flex = 100 / count($posts); + } + if (count($posts) > 4 || count($posts) == 0) { + $flex = 25; + } + $widht = $flex - 1; + if ($posts) { +<<<<<<< HEAD + echo '
'; + if ($selected_page_id != 0) { + $page_link = get_permalink($selected_page_id); + + echo '
'; + } else { + echo ' '; + } + 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 (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) { + $other_category_id = $settings['categories_in']; + $categories_with_posts = get_categories(array( + 'hide_empty' => 0, + 'child_of' => 0, + )); + foreach ($categories_with_posts as $category) { + $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 '
+ +
+
+ + +
+
+
'; + 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 (is_admin()) { + echo '
'; + } else { + if (wp_is_mobile()) { + 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 '
'; +======= + 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 || $args_C['include']==null && $settings['include_all']=='on'){ + echo ''; + + + } + + $categories = get_terms($args_C); + foreach ($categories as $category) { + 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){ +$other_category_id = $settings['categories_in']; + $categories_with_posts = get_categories(array( + 'hide_empty' => 0, + 'child_of' => 0, + )); +foreach ($categories_with_posts as $category) { + $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 '
+ +
'; + echo '
'; + $selected_page_id = $settings['selected_page']; + + 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 (is_admin()) { + echo '
'; + } else { + if (wp_is_mobile()) { + echo '
'; + } else { + echo '
'; + } + } + echo ' +
+ ' . $post_title . ' '; + if (!empty($tags)) { + if ($selected_page_id != 0) { + $page_link = get_permalink($selected_page_id); + foreach ($tags as $tag) { + $tag_link = add_query_arg('tags', $tag->slug, $page_link); + echo ' ' . $tag->name . ' '; + } + } else { + foreach ($tags as $tag) { + + echo '' . $tag->name . ' '; + } + } + } + $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)) { + foreach ($categories as $category) { + $category_link = add_query_arg('category', $category->slug, $page_link); + echo ' ' . $category->name . ' '; + } + } + } else { + $categories = get_the_category($post->ID); + if (!empty($categories)) { + foreach ($categories as $category) { + echo ' ' . $category->name . ' '; + } + } + } + echo '' . $post_content . ' +
+
'; + } + wp_reset_postdata(); + echo '
'; +>>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 + if (!$posts) { + // Gestisci il caso in cui $posts non è un array valido + echo '
'; + echo esc_html__('No post', 'Latest-Posts-Hover'); + echo '
'; + } + echo ''; + } +} +======= + + '; + } +} + } + } +>>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 From 2497838ffc261ae3d3546d568267b5c6d5ba1183 Mon Sep 17 00:00:00 2001 From: Daddie2 <50950554+Daddie2@users.noreply.github.com> Date: Tue, 26 Mar 2024 15:44:05 +0100 Subject: [PATCH 5/6] Update Latest-Posts-Hover.php --- widgets/Latest-Posts-Hover.php | 3336 ++++++++++++++++---------------- 1 file changed, 1625 insertions(+), 1711 deletions(-) diff --git a/widgets/Latest-Posts-Hover.php b/widgets/Latest-Posts-Hover.php index f8ad88b..470e903 100644 --- a/widgets/Latest-Posts-Hover.php +++ b/widgets/Latest-Posts-Hover.php @@ -1,1796 +1,1710 @@ -<<<<<<< HEAD - -======= - ->>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 -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', - ] - ); - $this->add_control( - 'card_opacity', - [ - 'label' => esc_html__('Card opacity', 'Latest-Posts-Hover'), - 'type' => \Elementor\Controls_Manager::NUMBER, - 'default' => 0.8, - 'min' => 0, - 'max' => 1, - 'step' => 0.1, - 'selectors' => [ - '{{WRAPPER}} .title' => 'filter:{{VALUE}}!important;', - ], - ] - ); + public function get_categories() + { + return ['OpenWidget']; + } - $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(); + protected function _register_controls() + { + $this->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(), + ], + 'selectors' => [ + '{{WRAPPER}} .info' => 'background-color:{{VALUE}}!important;', + ], + ] + ); + $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, + 'selectors' => [ + '{{WRAPPER}} .info' => 'filter:opacity({{VALUE}})!important;', + ], + ] + ); - $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' => 'inline-block', - 'default' => 'none', - 'selectors' => [ - '{{WRAPPER}} .category' => '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' => [ -<<<<<<< HEAD - '{{WRAPPER}} .category-card2' => 'justify-content: {{VALUE}};', -======= - '{{WRAPPER}} .category' => 'text-align: {{VALUE}};', ->>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 + $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}};', -<<<<<<< HEAD -======= - ], - ] - ); - $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', ->>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 - ], - ] - ); + ], + '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->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->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( - '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}};', - ], - ] - ); -<<<<<<< HEAD + $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}};', + ], + ] + ); -======= - ->>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 - $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->end_controls_section(); - $this->start_controls_section( - 'section_search', - [ -<<<<<<< HEAD - 'label' => esc_html__('Search', 'Latest-Posts-Hover'), - ] - ); -======= - 'label' => esc_html__('search', 'Latest-Posts-Hover'), - ] - ); ->>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 - $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}};', - ], - ] -<<<<<<< HEAD - ); -======= - ); ->>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 - $this->add_control( - 'background_color_input', - [ - 'label' => esc_html__('Input background color', 'Latest-Posts-Hover'), - 'type' => \Elementor\Controls_Manager::COLOR, - 'default' => 'red', - 'selectors' => [ - '{{WRAPPER}} -<<<<<<< HEAD - .container2 .search2 input:focus,.container2 .search2 input:active,.container2 .search2:hover input' => ' 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->end_controls_section(); -======= - .container2 .search input:focus,.container2 .search input:active,.container2 .search:hover input' => ' background-color: {{VALUE}};', - ], - ] - ); - - $this->end_controls_section(); + $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;', ->>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 - } - private function get_category() - { - $categories = get_categories(); - $options = []; - foreach ($categories as $category) { - $options[$category->term_id] = $category->name; + ], + ] + ); + $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(); } - 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; + 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 ?: []; } - 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, + 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']) : '', ]; - $args['date_query'] = $date_query; - } - if ($settings['all_post'] == 'all') { - $args['posts_per_page'] = -1; - } -<<<<<<< HEAD - $selected_page_id = $settings['selected_page']; -======= ->>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 - $args['category__not_in'] = $settings['exclude_categories']; - $args['category__in'] = $settings['categories_in']; - $posts = get_posts($args); - $cardColor = $settings['card_color']; - $wordPc = $settings['content_word_pc']; - $wordMobile = $settings['content_word_mobile']; - if (count($posts) != 0) { - $flex = 100 / count($posts); - } - if (count($posts) > 4 || count($posts) == 0) { - $flex = 25; - } - $widht = $flex - 1; - if ($posts) { -<<<<<<< HEAD - echo '
'; - if ($selected_page_id != 0) { - $page_link = get_permalink($selected_page_id); + 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']; - echo '
'; - } else { - echo ' '; + if (count($posts) != 0) { + $flex = 100 / count($posts); } - 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 ''; - } + 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); - $categories = get_terms($args_C); - foreach ($categories as $category) { - if (in_array($category->term_id, $settings['exclude_categories'])) { - continue; // Salta la categoria se è esclusa + 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 ''; } - // 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 ''; } - echo '">' . $category_name . ''; } } - } - if ($settings['related_category'] == 'on' && $settings['categories_in'] != null) { - $other_category_id = $settings['categories_in']; - $categories_with_posts = get_categories(array( - 'hide_empty' => 0, - 'child_of' => 0, - )); - foreach ($categories_with_posts as $category) { - $posts_in_category = get_posts(array( - 'category' => $category->term_id, - 'category__in' => $other_category_id, - 'posts_per_page' => 1, + 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, )); - if ($posts_in_category) { - $category_name = $category->name; - $category_slug = $category->slug; - echo ''; + } } - echo '">' . $category_name . ''; } } - } - } - 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 (is_admin()) { - echo '
'; - } else { - if (wp_is_mobile()) { - echo '
'; - } else { - echo '
'; - } - } - echo ' -
- ' . $post_title . ' '; - if (!empty($tags)) { + echo ' + +
'; if ($selected_page_id != 0) { - echo ''; - } else { - echo '
'; - - foreach ($tags as $tag) { - echo '' . $tag->name . ' '; - } - echo '
'; + echo '
'; + } else { + 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 '
'; + echo ' + +
+ + +
+
+
'; + echo '
'; - foreach ($date_parts as $part) { - if ($i == 1) { - $date_array[1] = $date_array[1] . '/01'; + 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); } - $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 . ' '; + $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']; } - echo '
'; - } - } else { - $categories = get_the_category($post->ID); - if (!empty($categories)) { - echo '
'; - foreach ($categories as $category) { - echo ' ' . $category->name . '
'; + if (is_admin()) { + echo '
'; + } else { + if (wp_is_mobile()) { + echo '
'; + } else { + echo '
'; + } } - } - echo '
'; - } - echo '

' . $post_content . '

-
-
'; - } - wp_reset_postdata(); - echo '
'; -======= - 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 || $args_C['include']==null && $settings['include_all']=='on'){ - echo ''; - + echo ' +
+ ' . $post_title . ' '; + if (!empty($tags)) { + if ($selected_page_id != 0) { + echo ''; + } else { + echo '
'; - } - - $categories = get_terms($args_C); - foreach ($categories as $category) { - 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){ -$other_category_id = $settings['categories_in']; - $categories_with_posts = get_categories(array( - 'hide_empty' => 0, - 'child_of' => 0, - )); -foreach ($categories_with_posts as $category) { - $posts_in_category = get_posts(array( - 'category' => $category->term_id, - 'category__in' => $other_category_id, - 'posts_per_page' => 1, - )); + foreach ($tags as $tag) { - if ($posts_in_category) { - $category_name = $category->name; - $category_slug = $category->slug; - echo ''; - } } -} - } -} - echo '
- -
'; - echo '
'; - $selected_page_id = $settings['selected_page']; + 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 ($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 (is_admin()) { - echo '
'; - } else { - if (wp_is_mobile()) { - 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 '
'; + echo '
'; + $i = 2; + foreach ($date_parts as $part) { + $date_link = home_url() . '/' . $date_array[$i]; + echo '' . ucfirst($part) . ''; + $i -= 1; + } + echo '
'; } - } - echo ' -
- ' . $post_title . ' '; - if (!empty($tags)) { + if ($selected_page_id != 0) { $page_link = get_permalink($selected_page_id); - foreach ($tags as $tag) { - $tag_link = add_query_arg('tags', $tag->slug, $page_link); - echo ' ' . $tag->name . ' '; + $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 { - foreach ($tags as $tag) { - - echo '' . $tag->name . ' '; + $categories = get_the_category($post->ID); + if (!empty($categories)) { + echo '
'; + foreach ($categories as $category) { + echo ' ' . $category->name . '
'; + } } + echo '
'; } + echo '

' . $post_content . '

+
+
'; } - $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]; + 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 '
'; - 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 ' '; + } + echo ' + +
+ + +
+
+
'; + } + } + echo ''; - } -} -======= - + .container2 .icon2 svg { + width: 100%; + height: 100%; + } + .submit-button, submit-bottom:focus,submit-bottom:hover{ + background-color: transparent!important; + border: none; + padding: 0; /* Remove default padding */ + color: green !important; + } '; - } -} } } ->>>>>>> fb75035c574edd38fcbb371b94878f49a8b99ba1 From 56e246fdecb0ab2f79060b9975372be3809a2e95 Mon Sep 17 00:00:00 2001 From: Daddie2 <50950554+Daddie2@users.noreply.github.com> Date: Tue, 26 Mar 2024 16:41:42 +0100 Subject: [PATCH 6/6] Update Latest-Posts-Hover.php --- widgets/Latest-Posts-Hover.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/widgets/Latest-Posts-Hover.php b/widgets/Latest-Posts-Hover.php index 470e903..0b26eb2 100644 --- a/widgets/Latest-Posts-Hover.php +++ b/widgets/Latest-Posts-Hover.php @@ -63,9 +63,6 @@ protected function _register_controls() 'default' => [ 'url' => \Elementor\Utils::get_placeholder_image_src(), ], - 'selectors' => [ - '{{WRAPPER}} .info' => 'background-color:{{VALUE}}!important;', - ], ] ); $this->add_control( @@ -87,6 +84,7 @@ protected function _register_controls() 'min' => 0, 'max' => 1, 'step' => 0.1, + 'default'=>0.8, 'selectors' => [ '{{WRAPPER}} .info' => 'filter:opacity({{VALUE}})!important;', ], @@ -134,7 +132,6 @@ protected function _register_controls() ] ); $this->end_controls_section(); - $this->start_controls_section( 'section_error', [ @@ -1336,15 +1333,12 @@ protected function render() // If not, use the custom default image $featured_image = $settings['default_image']['url']; } - if (is_admin()) { - echo '
'; - } else { - if (wp_is_mobile()) { + + if (wp_is_mobile() || is_admin()) { echo '