11<?php
2- class Latest_4_Posts_Hover_Widget extends \Elementor \Widget_Base {
3-
4- public function get_style_depends () {
5- return [ 'lastest-4-post ' ];
6- }
2+ class Latest_Posts_Hover_Widget extends \Elementor \Widget_Base {
73 public function __construct ($ data = [], $ args = null ) {
84 parent ::__construct ($ data , $ args );
95 }
106
117 public function get_name () {
12- return 'latest-4- posts-hover ' ;
8+ return 'latest-posts-hover ' ;
139 }
1410
1511 public function get_title () {
16- return esc_html__ ('Latest 4 Posts Hover ' , 'latest-4 -posts-hover ' );
12+ return esc_html__ ('Latest Posts Hover ' , 'latest-posts-hover ' );
1713 }
1814
1915 public function get_icon () {
2016 return 'eicon-post-list ' ;
2117 }
2218
2319 public function get_categories () {
24- return ['basic ' ];
20+ return ['OpenWidget ' ];
2521 }
26-
2722 protected function _register_controls () {
2823 $ this ->start_controls_section (
29- 'section_content ' ,
24+ 'section_general ' ,
3025 [
31- 'label ' => esc_html__ ('Content ' , 'latest-4-posts-hover ' ),
26+ 'label ' => esc_html__ ('General ' , 'Latest-Posts-Hover ' ),
3227 ]
3328 );
3429
3530 $ this ->add_control (
3631 'posts_per_page ' ,
3732 [
38- 'label ' => esc_html__ ('Number of Posts ' , 'latest-4-posts-hover ' ),
33+ 'label ' => esc_html__ ('Number of Posts ' , 'Latest-Posts-Hover ' ),
3934 'type ' => \Elementor \Controls_Manager::NUMBER ,
4035 'default ' => 4 ,
4136 'max ' => 4 ,
@@ -45,14 +40,77 @@ protected function _register_controls() {
4540 $ this ->add_control (
4641 'default_image ' ,
4742 [
48- 'label ' => esc_html__ ('Default Image ' , 'latest-4-posts-hover ' ),
43+ 'label ' => esc_html__ ('Default Image ' , 'Latest-Posts-Hover ' ),
4944 'type ' => \Elementor \Controls_Manager::MEDIA ,
5045 'default ' => [
5146 'url ' => \Elementor \Utils::get_placeholder_image_src (),
5247 ],
5348 ]
5449 );
5550 $ this ->end_controls_section ();
51+ $ this ->start_controls_section (
52+ 'section_title ' ,
53+ [
54+ 'label ' => esc_html__ ('Title ' , 'Latest-Posts-Hover ' ),
55+ ]
56+ );
57+ $ this ->add_control (
58+ 'Title_color ' ,
59+ [
60+ 'label ' => esc_html__ ('Color ' , 'Latest-Posts-Hover ' ),
61+ 'type ' => \Elementor \Controls_Manager::COLOR ,
62+ 'default ' => 'black ' ,
63+ 'selectors ' => [
64+ '{{WRAPPER}} .title ' => 'color: {{VALUE}}; ' ,
65+ ],
66+ ]
67+ );
68+ $ this ->add_control (
69+ 'title_font_size ' ,
70+ [
71+ 'label ' => esc_html__ ('Font Size ' , 'Latest-Posts-Hover ' ),
72+ 'type ' => \Elementor \Controls_Manager::SLIDER ,
73+ 'default ' => [
74+ 'size ' => 30 ,
75+ 'unit ' => 'px ' ,
76+ ],
77+ 'range ' => [
78+ 'px ' => [
79+ 'min ' => 1 ,
80+ 'max ' => 120 ,
81+ ],
82+ ],
83+ 'selectors ' => [
84+ '{{WRAPPER}} .title ' => 'font-size: {{SIZE}}{{UNIT}}; ' ,
85+ ],
86+ ]
87+ );
88+ $ this ->add_control (
89+ 'title_font ' ,
90+ [
91+ 'label ' => esc_html__ ( 'Font Family ' , 'Latest-Posts-Hover ' ),
92+ 'type ' => \Elementor \Controls_Manager::FONT ,
93+ 'default ' => "Work Sans " ,
94+ 'selectors ' => [
95+ '{{WRAPPER}} .title ' => 'font-family: {{VALUE}} ' ,
96+ ],
97+ ]
98+ );
99+ $ this ->add_control (
100+ 'title_bold ' ,
101+ [
102+ 'label ' => esc_html__ ('Title Bold ' , 'Latest-Posts-Hover ' ),
103+ 'type ' => \Elementor \Controls_Manager::SWITCHER ,
104+ 'label_on ' => esc_html__ ('On ' , 'Latest-Posts-Hover ' ),
105+ 'label_off ' => esc_html__ ('Off ' , 'Latest-Posts-Hover ' ),
106+ 'return_value ' => 'yes ' ,
107+ 'default ' => 'yes ' ,
108+ 'selectors ' => [
109+ '{{WRAPPER}} .title ' => 'font-weight: {{VALUE}}; ' ,
110+ ],
111+ ]
112+ );
113+ $ this ->end_controls_section ();
56114 }
57115 protected function render () {
58116 $ settings = $ this ->get_settings_for_display ();
@@ -65,7 +123,7 @@ protected function render() {
65123 $ posts = get_posts ($ args );
66124 $ flex =100 /$ settings ['posts_per_page ' ];
67125 $ widht =$ flex -1 ;
68-
126+ $ title_color = $ settings [ ' Title_color ' ];
69127 if ($ posts ) {
70128 echo '<div class="card2-container"> ' ;
71129 if (wp_is_mobile ()) {
@@ -97,7 +155,7 @@ protected function render() {
97155 echo '<div class="card2"style="background-image: url( ' . $ featured_image . ');">
98156 <div class="info">
99157 <a href=" ' . $ post_link . '" class="card2-link" style="display: block;">
100- <h1 class="title"> ' . $ post_title . '</h1><a class="date"> ' . $ post_date . '</a > ' ;
158+ <b class="title"> ' . $ post_title . '</b><p class="date"> ' . $ post_date . '</p > ' ;
101159 if ($ category_name != '' ){
102160 echo '<p class="category"href=" ' . $ category_link . '"> Categoria: ' . $ category_name . '</p> ' ;
103161
@@ -131,7 +189,7 @@ protected function render() {
131189 echo '
132190 <div class="card2"style="background-image: url( ' . $ featured_image . ');">
133191 <a href=" ' . $ post_link . '" class="card2-link">
134- <div class="info"> <h1 class="title"> ' . $ post_title . '</h1><a class="date"> ' . $ post_date . '</a > ' ;
192+ <div class="info"> <b class="title"> ' . $ post_title . '</b><p class="date"> ' . $ post_date . '</p > ' ;
135193 if ($ category_name != '' ){
136194 echo '<p class="category"href=" ' . $ category_link . '"> Categoria: ' . $ category_name . '</p> ' ;
137195
@@ -145,7 +203,7 @@ protected function render() {
145203 else {
146204 // Gestisci il caso in cui $posts non è un array valido
147205 echo '<div class="error-message"> ' ;
148- echo esc_html__ ('Impossibile recuperare i post. Si è verificato un errore. ' , 'latest-4-posts-hover ' );
206+ echo esc_html__ ('Impossibile recuperare i post. Si è verificato un errore. ' , 'Latest-Posts-Hover ' );
149207 echo '</div> ' ;
150208 }
151209 echo '<style>
@@ -204,12 +262,13 @@ protected function render() {
204262 font-size: 32px;
205263 padding: 0 5px;
206264 margin-bottom: 0px;
207- color: rgba(0, 0, 0, 0.87) ;
265+ color: black ;
208266 overflow-wrap: break-word;
209267 }
210268
211269 .date {
212270 margin-top: 0;
271+ margin-bottom: 0;
213272 padding: 0 5px;
214273 font-size: 18px;
215274 color:black;
0 commit comments