Skip to content

Commit 757f2a1

Browse files
committed
2 parents 4763b84 + 306bebd commit 757f2a1

2 files changed

Lines changed: 42 additions & 20 deletions

File tree

Open-Elementor-Widget.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,37 @@
77
*/
88

99
// Register the custom widgets with Elementor
10+
function enqueue_font_awesome()
11+
{
12+
wp_enqueue_style('font-awesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.0/css/all.min.css', array(), '6.1.0');
13+
}
14+
add_action('elementor/frontend/after_enqueue_styles', 'enqueue_font_awesome');
1015
add_action('elementor/widgets/widgets_registered', 'register_OpenElementorWidget_widgets');
16+
<<<<<<< HEAD
17+
18+
function add_elementor_widget_categories($elements_manager)
19+
{
20+
=======
1121
function add_elementor_widget_categories( $elements_manager ) {
22+
>>>>>>> d490c19b4b50f0986a1212da8bccc90d5009ca3e
1223

1324
$elements_manager->add_category(
1425
'OpenWidget',
1526
[
16-
'title' => esc_html__( 'OpenWidget', 'open-elementor-widget' ),
27+
'title' => esc_html__('OpenWidget', 'open-elementor-widget'),
1728
'icon' => 'fa fa-plug',
1829
]
1930
);
20-
2131
}
22-
add_action( 'elementor/elements/categories_registered', 'add_elementor_widget_categories' );
32+
add_action('elementor/elements/categories_registered', 'add_elementor_widget_categories');
2333
function register_OpenElementorWidget_widgets($widgets_manager)
2434
{
35+
<<<<<<< HEAD
36+
// Include and register the latest-posts-hover widget
37+
require_once(plugin_dir_path(__FILE__) . 'widgets/Latest-Posts-Hover.php');
38+
$widgets_manager->register_widget_type(new \Latest_Posts_Hover_Widget());
39+
}
40+
=======
2541
add_action( 'elementor/element/before_render', function( $element, $element_id, $settings ) {
2642
if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
2743
// Disabilita il link solo se l'elemento contiene un link
@@ -36,4 +52,5 @@ function register_OpenElementorWidget_widgets($widgets_manager)
3652
require_once(plugin_dir_path(__FILE__) . 'widgets/Latest-Posts-Hover.php');
3753
$widgets_manager->register_widget_type(new \Latest_Posts_Hover_Widget());
3854

39-
}
55+
}
56+
>>>>>>> d490c19b4b50f0986a1212da8bccc90d5009ca3e

widgets/Latest-Posts-Hover.php

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
class Latest_Posts_Hover_Widget extends \Elementor\Widget_Base
33
{
4-
4+
55
public function __construct($data = [], $args = null)
66
{
77
parent::__construct($data, $args);
@@ -86,15 +86,17 @@ protected function _register_controls()
8686
],
8787
]
8888
);
89+
8990
$this->add_control(
9091
'selected_page',
9192
[
92-
'label' => esc_html__('Select Page if you have a page with all post, made with this widget', 'OpenWidget'),
93+
'label' => esc_html__(' Select Page if you have a page with all post, made with this widget for the links', 'OpenWidget'),
9394
'type' => \Elementor\Controls_Manager::SELECT,
9495
'options' => $this->get_pages(),
95-
'default' => '0',
96+
'default' => 0,
9697
]
9798
);
99+
98100
$this->end_controls_section();
99101
$this->start_controls_section(
100102
'section_title',
@@ -594,7 +596,7 @@ protected function _register_controls()
594596
'{{WRAPPER}} .category-filter-button' => 'font-family: {{VALUE}}',
595597
],
596598
]
597-
);
599+
);
598600
$this->add_control(
599601
'background_color_inactive',
600602
[
@@ -661,7 +663,7 @@ protected function _register_controls()
661663
'{{WRAPPER}} .category-filter-button.active' => 'font-family: {{VALUE}}',
662664
],
663665
]
664-
);
666+
);
665667
$this->add_control(
666668
'background_color_active',
667669
[
@@ -672,7 +674,7 @@ protected function _register_controls()
672674
'{{WRAPPER}} .category-filter-button.active' => ' background-color: {{VALUE}};',
673675
],
674676
]
675-
);
677+
);
676678
$this->add_control(
677679
'active_font_size',
678680
[
@@ -728,7 +730,7 @@ protected function _register_controls()
728730
'{{WRAPPER}} .category-filter-button:hover' => 'font-family: {{VALUE}}',
729731
],
730732
]
731-
);
733+
);
732734
$this->add_control(
733735
'background_color_hover',
734736
[
@@ -740,7 +742,7 @@ protected function _register_controls()
740742
],
741743
]
742744
);
743-
745+
744746
$this->add_control(
745747
'hover_font_size',
746748
[
@@ -775,7 +777,7 @@ protected function _register_controls()
775777
],
776778
]
777779
);
778-
780+
779781
$this->end_controls_section();
780782
}
781783
private function get_pages()
@@ -789,7 +791,7 @@ private function get_pages()
789791
return $options;
790792
}
791793
protected function render()
792-
794+
793795
{
794796
$settings = $this->get_settings_for_display();
795797
if ($settings['posts_per_page'] == null) {
@@ -814,6 +816,11 @@ protected function render()
814816
$args = [
815817
'posts_per_page' => -1,
816818
];
819+
echo '<script>
820+
const selectedPageControl = elementor.settings.page.controls.selected_page;
821+
822+
// Imposta il valore desiderato per il controllo
823+
selectedPageControl.setValue(' . get_the_ID() . '); </script>'; // Sostituisci 10 con l'ID pagina desiderato
817824
}
818825

819826
$posts = get_posts($args);
@@ -950,9 +957,10 @@ protected function render()
950957
echo '<div class="error-message">';
951958
echo esc_html__('Impossibile recuperare i post. Si è verificato un errore.', 'Latest-Posts-Hover');
952959
echo '</div>';
953-
} if ( isset($_GET['action']) && $_GET['action'] === 'edit' ){
954-
echo'prova';
955-
}
960+
}
961+
if (isset($_GET['action']) && $_GET['action'] === 'edit') {
962+
echo 'prova';
963+
}
956964
echo '<style>
957965
.category-filter {
958966
display: none;
@@ -1111,8 +1119,5 @@ protected function render()
11111119
}
11121120
11131121
</style>';
1114-
11151122
}
1116-
1117-
11181123
}

0 commit comments

Comments
 (0)