Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/bdthemes-element-pack/modules/post-grid/module.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
3
+
namespace ElementPack\Modules\PostGrid;
4
+
5
+
use ElementPack\Base\Element_Pack_Module_Base;
6
+
use Elementor\Icons_Manager;
7
+
8
+
if (!defined('ABSPATH')) exit; // Exit if accessed directly
9
+
10
+
class Module extends Element_Pack_Module_Base {
11
+
public function __construct() {
12
+
parent::__construct();
13
+
14
+
15
+
add_action('wp_ajax_nopriv_ep_loadmore_posts', [$this, 'callback_ajax_loadmore_posts']);
16
+
add_action('wp_ajax_ep_loadmore_posts', [$this, 'callback_ajax_loadmore_posts']);
17
+
}
18
+
19
+
public function get_name() {
20
+
return 'post-grid';
21
+
}
22
+
23
+
public function get_widgets() {
24
+
25
+
$widgets = [
26
+
'Post_Grid',
27
+
];
28
+
29
+
return $widgets;
30
+
}
31
+
32
+
33
+
public function callback_ajax_loadmore_posts() {
34
+
35
+
if (!isset($_POST['settings']['nonce']) || !wp_verify_nonce( sanitize_key( wp_unslash( $_POST['settings']['nonce'] ) ), 'bdt-post-grid-load-more-nonce')) {
36
+
exit;
37
+
}
38
+
$ajaxposts = element_pack_ajax_load_query_args();
39
+
$markup = '';
40
+
if ($ajaxposts->have_posts()) {
41
+
$item_index = 1;
42
+
while ($ajaxposts->have_posts()) :
43
+
$ajaxposts->the_post();
44
+
// $title = wp_trim_words(get_the_title(), $title_text_limit, '...');
45
+
$post_link = get_permalink();
46
+
$image_src = wp_get_attachment_image_url(get_post_thumbnail_id(), 'full');
47
+
// $category = upk_get_category($post_type);
48
+
$author_url = get_author_posts_url(get_the_author_meta('ID'));
49
+
$author_name = get_the_author();
50
+
$date = get_the_date();
51
+
$placeholder_image_src = \Elementor\Utils::get_placeholder_image_src();
52
+
$image_src = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
53
+
if (!$image_src) {
54
+
$image_src = $placeholder_image_src;
55
+
} else {
56
+
$image_src = $image_src[0];
57
+
}
58
+
59
+
60
+
61
+
62
+
$markup .= '<div class="nnn bdt-width-1-3@m bdt-width-1-3@s bdt-width-1-1 bdt-secondary bdt-grid-margin">';
63
+
$markup .= '<div class="bdt-post-grid-item bdt-transition-toggle bdt-position-relative">';
64
+
//image wrap
65
+
$markup .= '<div class="bdt-post-grid-img-wrap bdt-overflow-hidden">';
66
+
$markup .= '<a href="' . esc_url(get_permalink()) . '" class="bdt-transition-scale-up bdt-background-cover bdt-transition-opaque bdt-flex" title="' . esc_attr(get_the_title()) . '" style="background-image: url(' . esc_url($image_src) . ')">';
67
+
$markup .= '</a>';
68
+
$markup .= '</div>';
69
+
70
+
$markup .= '<div class="bdt-custom-overlay bdt-position-cover"></div>';
71
+
72
+
$markup .= '<div class="bdt-post-grid-desc bdt-position-medium bdt-position-bottom-left">';
73
+
$markup .= '<h2 class="bdt-post-grid-title">';
74
+
$markup .= '<a href="' . esc_url(get_permalink()) . '" class="bdt-post-grid-link" title="' . esc_attr(get_the_title()) . '">';
75
+
$markup .= esc_html__((get_the_title()), 'bdthemes-element-pack');
76
+
$markup .= '</a>';
77
+
$markup .= '</h2>';
78
+
$markup .= '<div class="bdt-post-grid-meta">';
79
+
$markup .= '<span class="bdt-post-grid-meta-item bdt-post-grid-meta-author">';
80
+
$markup .= '<a href="' . esc_url($author_url) . '" class="bdt-post-grid-meta-link">';
81
+
$markup .= esc_html($author_name);
82
+
$markup .= '</a>';
83
+
$markup .= '</span>';
84
+
$markup .= '<span class="bdt-post-grid-meta-item bdt-post-grid-meta-date">';
85
+
$markup .= '<a href="' . esc_url(get_permalink()) . '" class="bdt-post-grid-meta-link">';
86
+
$markup .= esc_html($date);
87
+
$markup .= '</a>';
88
+
$markup .= '</span>';
89
+
$markup .= '</div>';
90
+
/**
91
+
* Readmore Button
92
+
*/
93
+
if (isset($_POST['settings']['show_readmore']) && $_POST['settings']['show_readmore'] == 'yes') :
94
+
$readMore = isset($_POST['readMore']) ? sanitize_text_field( wp_unslash( $_POST['readMore'] ) ) : '';
95
+
96
+
$animation = isset($readmore_hover_animation) ? ' elementor-animation-' . $readmore_hover_animation : '';
97
+
98
+
if (!isset($settings['icon']) && !Icons_Manager::is_migration_allowed()) {
99
+
$settings['icon'] = 'fas fa-arrow-right';
100
+
}
101
+
102
+
$migrated = isset($settings['__fa4_migrated'][$readMore['post_grid_icon']]);
103
+
$is_new = empty($settings['icon']) && Icons_Manager::is_migration_allowed();
104
+
105
+
$markup .= '<a href="' . $post_link . '" class="bdt-post-grid-readmore bdt-display-inline-block ' . $animation . '">';
106
+
$markup .= '<span class="bdt-button-text">' . $readMore['readmore_text'] . '</span>';
107
+
if ($readMore['post_grid_icon']['value']) :
108
+
$markup .= '<span class="bdt-button-icon-align-' . $readMore['readmore_icon_align'] . '">';
109
+
if ($is_new || $migrated) :
110
+
ob_start();
111
+
Icons_Manager::render_icon($readMore['post_grid_icon'], ['aria-hidden' => 'true', 'class' => 'fa-fw']);
112
+
$markup .= ob_get_clean();
113
+
else :
114
+
$markup .= '<i class="' . $settings['icon'] . '" aria-hidden="true"></i>';
115
+
endif;
116
+
$markup .= '</span>';
117
+
endif;
118
+
$markup .= '</a>';
119
+
endif;
120
+
/**
121
+
* Readmore Button End
122
+
*/
123
+
124
+
$markup .= '</div>';
125
+
$markup .= '<div class="bdt-post-grid-category bdt-position-small bdt-position-top-left">';
126
+
$markup .= element_pack_get_category_list( isset($_POST['settings']['posts_source']) ? sanitize_text_field( wp_unslash( $_POST['settings']['posts_source'] ) ) : '' );
127
+
$markup .= '</div>';
128
+
129
+
$markup .= '</div>';
130
+
$markup .= '</div>';
131
+
$item_index++;
132
+
endwhile;
133
+
}
134
+
135
+
wp_reset_postdata();
136
+
$result = [
137
+
'markup' => $markup,
138
+
];
139
+
wp_send_json($result);
140
+
exit;
141
+
}
142
+
}
143
+