@@ -652,9 +652,9 @@ protected function _register_controls()
652652
653653 $ this ->end_controls_section ();
654654 $ this ->start_controls_section (
655- 'section_filter ' ,
655+ 'section_Button_filter ' ,
656656 [
657- 'label ' => esc_html__ ('Filter ' , 'Latest-Posts-Hover ' ),
657+ 'label ' => esc_html__ ('Button Filter ' , 'Latest-Posts-Hover ' ),
658658 ]
659659 );
660660 $ this ->add_control (
@@ -904,6 +904,36 @@ protected function _register_controls()
904904 ],
905905 ]
906906 );
907+
908+ $ this ->add_control (
909+ 'related_category ' ,
910+ [
911+ 'label ' => esc_html__ ('Show categories related to the one one you selected ' , 'Latest-Posts-Hover ' ),
912+ 'type ' => \Elementor \Controls_Manager::SWITCHER ,
913+ 'label_on ' => esc_html__ ('On ' , 'Latest-Posts-Hover ' ),
914+ 'label_off ' => esc_html__ ('Off ' , 'Latest-Posts-Hover ' ),
915+ 'return_value ' => 'on ' ,
916+ 'default ' => 'off ' ,
917+ ]
918+ );
919+ $ this ->add_control (
920+ 'include_all ' ,
921+ [
922+ 'label ' => esc_html__ ('Show all even if someone is excluded ' , 'Latest-Posts-Hover ' ),
923+ 'type ' => \Elementor \Controls_Manager::SWITCHER ,
924+ 'label_on ' => esc_html__ ('on ' , 'Latest-Posts-Hover ' ),
925+ 'label_off ' => esc_html__ ('Off ' , 'Latest-Posts-Hover ' ),
926+ 'return_value ' => 'on ' ,
927+ 'default ' => 'off ' ,
928+ ]
929+ );
930+ $ this ->end_controls_section ();
931+ $ this ->start_controls_section (
932+ 'section_search ' ,
933+ [
934+ 'label ' => esc_html__ ('search ' , 'Latest-Posts-Hover ' ),
935+ ]
936+ );
907937 $ this ->add_control (
908938 'search_active ' ,
909939 [
@@ -917,19 +947,22 @@ protected function _register_controls()
917947 '{{WRAPPER}} .container2 ' => 'display: {{VALUE}}; ' ,
918948 ],
919949 ]
920- );
950+ );
921951 $ this ->add_control (
922- 'related_category ' ,
952+ 'background_color_input ' ,
923953 [
924- 'label ' => esc_html__ ('Show categories related to the one one you selected ' , 'Latest-Posts-Hover ' ),
925- 'type ' => \Elementor \Controls_Manager::SWITCHER ,
926- 'label_on ' => esc_html__ ('On ' , 'Latest-Posts-Hover ' ),
927- 'label_off ' => esc_html__ ('Off ' , 'Latest-Posts-Hover ' ),
928- 'return_value ' => 'on ' ,
929- 'default ' => 'off ' ,
954+ 'label ' => esc_html__ ('Input background color ' , 'Latest-Posts-Hover ' ),
955+ 'type ' => \Elementor \Controls_Manager::COLOR ,
956+ 'default ' => 'red ' ,
957+ 'selectors ' => [
958+ '{{WRAPPER}}
959+ .container2 .search input:focus,.container2 .search input:active,.container2 .search:hover input ' => ' background-color: {{VALUE}}; ' ,
960+ ],
930961 ]
931962 );
963+
932964 $ this ->end_controls_section ();
965+
933966 }
934967 private function get_category ()
935968 {
@@ -997,7 +1030,7 @@ protected function render()
9971030 $ args_C ['hide_empty ' ] = true ;
9981031 $ args_C ['exclude ' ]= $ settings ['exclude_categories ' ];
9991032 $ args_C ['include ' ] = $ settings ['categories_in ' ];
1000- if ($ args_C ['include ' ]==null && $ args_C ['exclude ' ]==null ){
1033+ if ($ args_C ['include ' ]==null && $ args_C ['exclude ' ]==null || $ args_C [ ' include ' ]== null && $ settings [ ' include_all ' ]== ' on ' ){
10011034 echo '<button type="submit" name="category" value="all" class="category-filter-button ' ;
10021035 if (isset ($ _GET ['category ' ]) && $ _GET ['category ' ] == 'all ' ) {
10031036 echo ' active ' ;
@@ -1009,15 +1042,26 @@ protected function render()
10091042
10101043 $ categories = get_terms ($ args_C );
10111044 foreach ($ categories as $ category ) {
1045+ if (in_array ($ category ->term_id , $ settings ['exclude_categories ' ])) {
1046+ continue ; // Salta la categoria se è esclusa
1047+ }
1048+
1049+ // Controlla se la categoria ha almeno un post che non è escluso
1050+ $ posts_in_category = get_posts (array (
1051+ 'category ' => $ category ->term_id ,
1052+ 'posts_per_page ' => 1 , // Controlla solo se ci sono post
1053+ 'category__not_in ' => $ settings ['exclude_categories ' ],
1054+ ));
1055+ if ($ posts_in_category ) {
10121056 $ category_name = $ category ->name ;
10131057 $ category_slug = $ category ->slug ;
10141058 echo '<button type="submit" name="category" value=" ' . $ category_slug . '" class="category-filter-button ' ;
10151059 if (isset ($ _GET ['category ' ]) && $ _GET ['category ' ] == $ category_slug ) {
10161060 echo ' active ' ;
10171061 }
10181062 echo '"> ' . $ category_name . '</button> ' ;
1019- }
1020- }
1063+
1064+
10211065 if ($ settings ['related_category ' ]=='on ' && $ settings ['categories_in ' ]!=null ){
10221066$ other_category_id = $ settings ['categories_in ' ];
10231067 $ categories_with_posts = get_categories (array (
@@ -1040,6 +1084,8 @@ protected function render()
10401084 }
10411085 echo '"> ' . $ category_name . '</button> ' ;
10421086 } }
1087+ }
1088+ }
10431089}
10441090 echo '</form> <div class="container2">
10451091 <div class="search">
@@ -1149,12 +1195,9 @@ protected function render()
11491195 echo esc_html__ ('No post ' , 'Latest-Posts-Hover ' );
11501196 echo '</div> ' ;
11511197 }
1152- if (isset ($ _GET ['action ' ]) && $ _GET ['action ' ] === 'edit ' ) {
1153- echo 'prova ' ;
1154- }
11551198 echo '<style>
11561199.container2 {
1157- width: 394px ;
1200+ width: 100% ;
11581201 height: 50px;
11591202 display: none;
11601203 justify-content: end; ' ;
@@ -1183,11 +1226,13 @@ protected function render()
11831226button{
11841227 pointer-events: fill;
11851228}
1229+
11861230.container2 input[type="text"]:focus {
11871231 caret-color: white;
1188-
11891232 }
1190-
1233+ .container2 button i {
1234+ margin-right: 5px; }
1235+
11911236 .search input {
11921237 width: 50px;
11931238 height: 50px;
@@ -1203,21 +1248,24 @@ protected function render()
12031248 box-shadow: none;
12041249 transition: all 0.6s cubic-bezier(0, 2, 1, -1);
12051250 margin: 5;
1251+ align-items: center;
12061252}
1253+
12071254 .search button {
12081255 width: 50px;
12091256 height: 50px;
12101257 position: absolute;
12111258 right: calc(50% - 35px);
12121259 top: 0;
1213- margin: 5 ;
1260+ padding: 0 15px ;
12141261 background: #2d2926;
12151262 color: #fff;
12161263 font-size: 15px;
12171264 border: 0;
12181265 border-radius: 50%;
12191266 cursor: pointer;
12201267 transition:all 0.6s cubic-bezier(0, 2, 1, -1);
1268+
12211269}
12221270.search input:focus {
12231271 right: 0;
@@ -1227,25 +1275,22 @@ protected function render()
12271275 }
12281276.container2 .search input:focus,
12291277.container2 .search input:active,
1230- .container2 .search:hover input { ' ;
1231- if (wp_is_mobile ()){
1232- echo ' width: 300px; ' ;
1233-
1234- }
1235- else {
1236- echo ' width: 400px; ' ;
1237-
1238- }
1239- echo '
1278+ .container2 .search:hover input {
1279+ width: 100%;
12401280 right:0%;
1241- background:red;
12421281}
1282+
12431283.container2 .search input:focus + button,
12441284.container2 .search input:active + button,
12451285.container2 .search:hover button {
12461286 right: 0;
12471287}
12481288
1289+ .container2 .search input {
1290+ padding-right: 70px;
1291+
1292+ }
1293+
12491294 .category-filter {
12501295 display: flex;
12511296 justify-content:right;
@@ -1412,8 +1457,9 @@ protected function render()
14121457 flex-basis: 100%;
14131458 }
14141459 }
1415-
1460+
14161461 </style> ' ;
14171462 }
14181463}
1419- }
1464+ }
1465+ }
0 commit comments