11<?php
22class Latest_Posts_Hover_Widget extends \Elementor \Widget_Base
33{
4+
45 public function __construct ($ data = [], $ args = null )
56 {
67 parent ::__construct ($ data , $ args );
@@ -382,11 +383,30 @@ protected function _register_controls()
382383 ]
383384 );
384385
386+ $ this ->end_controls_section ();
387+ $ this ->start_controls_section (
388+ 'section_filter ' ,
389+ [
390+ 'label ' => esc_html__ ('Filter ' , 'Latest-Posts-Hover ' ),
391+ ]
392+ );
393+ $ this ->add_control (
394+ 'text_color_inactive ' ,
395+ [
396+ 'label ' => esc_html__ ('Color text inactive ' , 'Latest-Posts-Hover ' ),
397+ 'type ' => \Elementor \Controls_Manager::COLOR ,
398+ 'default ' => 'black ' ,
399+ 'selectors ' => [
400+ '{{WRAPPER}} .category-filter-button ' => ' color: {{VALUE}} !important; ' ,
401+ ],
402+ ]
403+ );
404+
385405 $ this ->end_controls_section ();
386406 }
387407 protected function render ()
408+
388409 {
389-
390410 $ settings = $ this ->get_settings_for_display ();
391411 if ($ settings ['posts_per_page ' ] == null ) {
392412 $ settings ['posts_per_page ' ] = 4 ;
@@ -426,6 +446,7 @@ protected function render()
426446 $ widht = $ flex - 1 ;
427447 $ title_color = $ settings ['Title_color ' ];
428448 if ($ posts ) {
449+
429450 echo '<div class="category-filter">
430451 <form method="get" action="">
431452 <button type="submit" name="category" value="all" class="category-filter-button ' ;
@@ -446,9 +467,8 @@ protected function render()
446467 echo '</form> </div> ' ;
447468 if (isset ($ _GET ['category ' ]) && $ _GET ['category ' ] != 'all ' ) {
448469 $ category = get_category_by_slug ($ _GET ['category ' ]);
449- echo '<p> ' . $ category ->name . '</p> ' ;
450470 }
451- echo '<div class="card2-container"> ' ;
471+ echo '<div class="card2-container"> ' ;
452472 if (wp_is_mobile ()) {
453473 // Codice da eseguire se la larghezza dello schermo è minore o uguale a 900 pixel
454474
@@ -475,7 +495,7 @@ protected function render()
475495 $ category_name = '' ;
476496 }
477497 echo '
478- <div class="card2" style="background-image: url( ' . $ featured_image . '); >
498+ <div class="card2" style="background-image: url( ' . $ featured_image . ')" >
479499 <div class="info">
480500 <a class="title" href=" ' . $ post_link . '"> ' . $ post_title . ' <a/>
481501 <p class="date"> ' . $ post_date . '</p> ' ;
@@ -510,8 +530,13 @@ protected function render()
510530 } else {
511531 $ category_name = '' ;
512532 }
533+ if (!is_admin ()){
534+ echo ' <div class="card2" style="background-image: url( ' . $ featured_image . '); "onclick= \'window.location.href=" ' . $ post_link . '" \'> ' ;
535+ }
536+ if (is_admin ()){
537+ echo '<div class="card2" style="background-image: url( ' . $ featured_image . ')"> ' ;
538+ }
513539 echo '
514- <div class="card2" style="background-image: url( ' . $ featured_image . '); "onclick= \'window.location.href=" ' . $ post_link . '" \'>
515540 <div class="info">
516541 <a class="title" href=" ' . $ post_link . '"> ' . $ post_title . ' <a/>
517542 <p class="date"> ' . $ post_date . '</p> ' ;
@@ -522,6 +547,7 @@ protected function render()
522547 </div>
523548 </div> ' ;
524549 }
550+
525551 wp_reset_postdata ();
526552 echo '</div> ' ;
527553 }
@@ -530,21 +556,36 @@ protected function render()
530556 echo '<div class="error-message"> ' ;
531557 echo esc_html__ ('Impossibile recuperare i post. Si è verificato un errore. ' , 'Latest-Posts-Hover ' );
532558 echo '</div> ' ;
533- }
559+ } if ( isset ($ _GET ['action ' ]) && $ _GET ['action ' ] === 'edit ' ){
560+ echo 'prova ' ;
561+ }
534562 echo '<style>
535- .category-filter-button {
536- background-color: green;
537- color: yellow;
538- padding: 10px 20px;
563+ .category-filter {
564+ display: flex;
565+ align-items: left;
566+ flex-wrap: wrap;
567+ margin-top: 50px;
568+ }
569+
570+ .category-filter-button {
571+ background-color: #007BFF;
572+ color: #fff;
539573 border: none;
540574 border-radius: 5px;
575+ padding: 10px 30px;
576+ font-size: 18px;
577+ font-weight: bold;
578+ margin: 10px;
541579 cursor: pointer;
542- margin-right: 10px ;
580+ transition: background-color 0.3s ease ;
543581}
544582
545- .category-filter-button.active {
546- background-color: red ;
583+ .category-filter-button:hover {
584+ background-color: green ;
547585}
586+ .category-filter-button.active {
587+ background-color: red;
588+ }
548589 .card2-link {
549590
550591 text-decoration: none;
@@ -662,5 +703,8 @@ protected function render()
662703 }
663704
664705 </style> ' ;
706+
665707 }
708+
709+
666710}
0 commit comments