Skip to content

Commit 97c75a0

Browse files
committed
Update Open-Elementor-Widget.php
1 parent c29dcea commit 97c75a0

1 file changed

Lines changed: 26 additions & 25 deletions

File tree

Open-Elementor-Widget.php

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,37 @@
11
<?php
22
/*
3-
Plugin Name:orWidget
3+
Plugin Name:OpenElementorWidget
44
Description: Custom widget for Elementor
55
Version: 1.0
66
Author: Davide
77
*/
88

99
// Register the custom widgets with Elementor
10-
add_filter('get_the_excerpt', function ($excerpt) {
11-
12-
$excerpt_length = 40; // Change excerpt length
13-
14-
global $post;
15-
16-
if (
17-
is_archive() || is_search()
18-
) {
19-
$post = get_post();
20-
}
21-
22-
if (
23-
has_excerpt($post)
24-
) {
25-
} else {
26-
$content = get_the_content();
27-
$first_word = substr($content, 0, strpos($content, ' '));
28-
$content = substr($content, strpos($content, ' ') + 2);
29-
$excerpt = wp_trim_words($content, $excerpt_length);
30-
$excerpt = $first_word . ' ' . $excerpt;
31-
}
32-
33-
return $excerpt;
10+
add_filter('the_excerpt', function ($excerpt) {
11+
12+
$excerpt_length = 40; // Change excerpt length
13+
14+
global $post;
15+
16+
if (
17+
is_archive() || is_search()
18+
) {
19+
$post = get_post();
20+
}
21+
22+
if (has_excerpt($post)) {
23+
echo "porva";
24+
}
25+
else {
26+
$content = get_the_content();
27+
$first_word = substr($content, 0, strpos($content, ' '));
28+
$content = substr($content, strpos($content, ' ') + 2);
29+
echo $first_word;
30+
$excerpt = wp_trim_words($content, $excerpt_length);
31+
$excerpt = $first_word . ' ' . $excerpt;
32+
}
33+
34+
return $excerpt;
3435
}, 10, 2);
3536
add_action('elementor/widgets/widgets_registered', 'register_OpenElementorWidget_widgets');
3637

0 commit comments

Comments
 (0)