widget = $widget;
}
/**
* Renders the dynamic grid carousel content based on the provided settings.
*
* @param array $settings The widget settings array.
*/
public function render(array $settings): void
{
$document_id = intval($settings['dgrd_tmp'] ?? 0);
// Initial check and display error message
$error_msg = $this->get_template_error_message($document_id);
if (!empty($error_msg)) {
echo '
widget->render_attrs($settings) . '>';
echo wp_kses(AFEBHelper::front_notice($error_msg, 'error'), AFEBHelper::allowed_tags(['div']));
echo '
';
return;
}
// Handle carousel settings
$carousel_data = '';
if ($settings['dgrd_lyt'] === 'carousel') {
$slick_options = $this->get_carousel_slick_options($settings);
$this->widget->add_render_attribute('dynamic_carousel', 'data-slick', wp_json_encode($slick_options));
$carousel_data = $this->widget->get_render_attribute_string('dynamic_carousel');
}
// Prepare WP_Query arguments
$args = $this->prepare_wp_query_args($settings);
// Execute WP_Query
$query = new WP_Query($args);
Plugin::instance()->db->switch_to_query($args);
echo 'widget->render_attrs($settings) . '>'; // Start main container
$this->render_grid_filters($settings);
if ($query->have_posts()) {
$this->dom = new DOMDocument();
echo '
';
while ($query->have_posts()) {
$query->the_post();
$post_id = get_the_ID();
$content = Plugin::instance()->frontend->get_builder_content($document_id, true);
if (!empty($content)) {
// Sanitize and manipulate item content DOM
$processed_content = $this->process_item_content($content, $post_id);
// Get the default allowed tags for 'post' context
$allowed_tags = wp_kses_allowed_html('post');
// **Allow the