?? GreyFile — Mystic File Browser

Current path: home/webdevt/www/cryptoimpot.fr/wp-content/plugins/divi-contact-form-helper/app/Admin/Pages/



?? Go up: /home/webdevt/www/cryptoimpot.fr/wp-content/plugins/divi-contact-form-helper/app/Admin

?? Viewing: Page_Create_Post.php

<?php

namespace KS_PAC_DCFH\Admin\Pages;

use KS_PAC_DCFH\Admin\Handlers\Post_Meta_Handler;

if (!defined('ABSPATH')) {
    exit;
}

class Page_Create_Post
{
    private $_post_type;

    private $_post_id;

    public function init(): void
    {
        $this->_post_type = 'pwh_dcfh';
        $_page = ks_pac_dcfh_general_helper()::current_page();
        $this->_post_id = isset($_GET['post_id']) ? sanitize_key($_GET['post_id']) : null; // phpcs:ignore
        add_action('admin_menu', [$this, 'menu']);
        if (!empty($this->_post_id) && $_page === 'create_post') {
            if (empty(get_post($this->_post_id))) {
                wp_safe_redirect(add_query_arg(['post_type' => $this->_post_type], admin_url('edit.php')));
                exit();
            }
            add_action('admin_init', static function () {
                ob_start();
            });
            add_action('view_create_post', [$this, 'display_form']);
        }
        add_action('wp_ajax_terms_list', [new Post_Meta_Handler(), 'get_post_type_terms']);
        add_action('wp_ajax_meta_keys', [new Post_Meta_Handler(), 'get_post_meta_keys']);
    }

    public function menu(): void
    {
        add_submenu_page('edit.php?post_type=pwh_dcfh', __('Create Post', 'divi-contact-form-helper'), null, 'perform_entry_actions_pwh_dcfh', 'create_post', [$this, 'process_form']);
    }

    public function process_form(): void
    {
        $post_request = [
            'to_post_type' => '',
            'post_status' => '',
            'post_term' => '',
            'copy_as' => '',
            'custom_field' => '',
            'custom_featured_img' => '',
            'custom_featured_img_url' => '',
            'send_email_to_submitter' => '',
        ];
        if (isset($_POST['btn_create_post'], $_POST['_wpnonce'], $_POST['to_post_type'])) {
            $post_request = $_POST; // phpcs:ignore
            $post_request['custom_featured_img_url'] = null;
            $validate_request = true;
            $to_post_type = sanitize_text_field($_POST['to_post_type']);
            $post_status = isset($_POST['post_status']) ? sanitize_text_field($_POST['post_status']) : 'pending';
            $post_term = isset($_POST['post_term']) ? sanitize_text_field($_POST['post_term']) : null;
            $copy_as = $_POST['copy_as'] ?? null; // phpcs:ignore
            $custom_featured_img = isset($_POST['custom_featured_img']) ? sanitize_text_field($_POST['custom_featured_img']) : null;
            $send_email_to_submitter = isset($_POST['send_email_to_submitter']) && sanitize_text_field($_POST['send_email_to_submitter']);
            $email_to = '';
            if (!empty($custom_featured_img)) {
                $post_request['custom_featured_img_url'] = wp_get_attachment_url($custom_featured_img);
            }
            if (!wp_verify_nonce(sanitize_text_field($_POST['_wpnonce']), 'create_post')) {
                wp_die(esc_html__('Unable to submit this form, please refresh and try again.', 'divi-contact-form-helper'));
            }
            if (empty($to_post_type)) {
                $validate_request = false;
                ks_pac_dcfh_alert()::add_error_message(__('Please select post type.', 'divi-contact-form-helper'));
            }
            $mapped_data = [];
            // Mapping Title and Content AND Field As Meta
            foreach ($copy_as as $copy_key => $copy_value) {
                if (!empty($_POST['post_data'][$copy_key])) {
                    $post_data = $_POST['post_data'][$copy_key]; // phpcs:ignore
                    if ('title' === $copy_value || 'content' === $copy_value) {
                        $mapped_data[$copy_value] = $post_data;
                    }
                }
                if ((!empty($_POST['custom_field'][$copy_key])) && !is_array($copy_value)) {
                    $meta_key = ks_pac_dcfh_general_helper()::sanitize_key(sanitize_text_field($_POST['custom_field'][$copy_key]));
                    if ($copy_value === 'custom_field') {
                        $mapped_data['meta_input'][$meta_key] = $post_data;
                    }
                }

            }
            if (empty($mapped_data)) {
                $validate_request = false;
                ks_pac_dcfh_alert()::add_error_message(__('Data is not mapped. Please contact administrator,', 'divi-contact-form-helper'));
            }
            if (!isset($mapped_data['title'], $mapped_data['content'])) {
                $validate_request = false;
                ks_pac_dcfh_alert()::add_error_message(__('Please map title and content of post.', 'divi-contact-form-helper'));
            }
            // Mapping File As Meta
            foreach ($copy_as as $copy_key => $copy_value) {
                if (is_array($copy_value)) {
                    foreach ($copy_value as $k => $v) {
                        $meta_key = ks_pac_dcfh_general_helper()::sanitize_key(sanitize_text_field($_POST['custom_field'][$copy_key][$k])); // phpcs:ignore
                        $attachment_dir = isset($_POST['post_data'][$copy_key.'_dir'][$k]) ? sanitize_text_field($_POST['post_data'][$copy_key.'_dir'][$k]) : null;
                        //$attachment_url = isset($_POST['post_data'][$copy_key.'_url'][$k])?sanitize_text_field($_POST['post_data'][$copy_key.'_url'][$k]):null;
                        $attachment_id = isset($_POST['post_data'][$copy_key.'_id'][$k]) ? sanitize_text_field($_POST['post_data'][$copy_key.'_id'][$k]) : null;
                        if (empty($attachment_id)) {
                            if ('custom_field' === $v && isset($_POST['custom_field'][$copy_key][$k])) {
                                $media_response = ks_pac_dcfh_file_helper()::upload_files_to_media_library($attachment_dir, $mapped_data['title']);
                                $mapped_data['meta_input'][$meta_key] = $media_response['attachment_url'];
                                $mapped_data['attachment_ids'][] = $media_response['attachment_id'];
                            } elseif ('featured_image' === $v) {
                                $media_response = ks_pac_dcfh_file_helper()::upload_files_to_media_library($attachment_dir, $mapped_data['title']);
                                $mapped_data['featured_image'] = $media_response['attachment_id'];
                            }
                        } else if ('custom_field' === $v && isset($_POST['custom_field'][$copy_key][$k])) {
                            $mapped_data['meta_input'][$meta_key] = wp_get_attachment_url($attachment_id);
                            $mapped_data['attachment_ids'][] = $attachment_id;
                        } elseif ('featured_image' === $v) {
                            $mapped_data['featured_image'] = $attachment_id;
                        }
                    }
                }
            }
            if ($validate_request) {
                $post_title = $mapped_data['title'];
                $post_content = $mapped_data['content'];
                $post_meta = $mapped_data['meta_input'] ?? null;
                $post_attachment_ids = $mapped_data['attachment_ids'] ?? null;
                $cloned_post_id = wp_insert_post([
                    'post_author' => get_current_user_id(),
                    'post_title' => $post_title,
                    'post_name' => $post_title,
                    'post_content' => $post_content,
                    'post_excerpt' => wp_trim_words(wp_trim_excerpt($post_content), 25),
                    'post_status' => $post_status,
                    'post_type' => $to_post_type,
                    'comment_status' => 'closed',
                    'ping_status' => 'closed',
                    'meta_input' => $post_meta,
                ], true);
                if (!is_wp_error($cloned_post_id)) {
                    // Term
                    if (!empty($post_term)) {
                        $term_id = (int)$post_term;
                        $term = get_term($term_id);
                        wp_set_post_terms($cloned_post_id, $term_id, $term->taxonomy);
                    }
                    // Clone History
                    ks_pac_dcfh_post_meta()::update_cloned_history($this->_post_id, $cloned_post_id);
                    if ($send_email_to_submitter && 'publish' === $post_status) {
                        $email_to = ks_pac_dcfh_user()::get_post_user_email($this->_post_id);
                        $this->send_email($email_to, $cloned_post_id);
                    }
                    // Featured Image
                    if ($custom_featured_img > 0) {
                        set_post_thumbnail($cloned_post_id, $custom_featured_img);
                    }
                    if (empty($custom_featured_img) && (!empty($mapped_data['featured_image']))) {
                        $featured_img_id = $mapped_data['featured_image'];
                        set_post_thumbnail($cloned_post_id, $featured_img_id);
                        wp_update_post([
                            'ID' => $featured_img_id,
                            'post_parent' => $cloned_post_id
                        ]);
                    }
                    // Update Attachment ID To Post
                    if (!empty($post_attachment_ids)) {
                        foreach ($post_attachment_ids as $post_attachment_id) {
                            wp_update_post([
                                'ID' => $post_attachment_id,
                                'post_parent' => $cloned_post_id
                            ]);
                        }
                    }
                    // Redirect
                    wp_safe_redirect(add_query_arg([
                        'post_type' => $this->_post_type,
                        'post' => $this->_post_id,
                        'success' => true,
                        'action' => 'edit',
                        '_wpnonce' => wp_create_nonce('entry_action'),
                        'cloned_post_id' => $cloned_post_id,
                        'email_sent_to' => $email_to,
                    ], admin_url('post.php')));
                    exit();
                }
                ks_pac_dcfh_alert()::add_error_message(__('Something went wrong. Please contact ', 'divi-contact-form-helper'));
            }
        }
        do_action('view_create_post', $post_request);
    }

    public function display_form($post_request): void
    {
        $post_obj = get_post($this->_post_id);
        if (is_serialized($post_obj->post_excerpt)) {
            $form_entries = ks_pac_dcfh_general_helper()::maybe_unserialize($post_obj->post_excerpt);
            if (!empty($form_entries) && is_array($form_entries)) { ?>
                <div class="wrap pwh-dcfh-page" id="page-create-post">
                    <h1 class="wp-heading-inline"><?php esc_html_e('Create Post', 'divi-contact-form-helper'); ?></h1>
                    <a href="<?php echo esc_url(add_query_arg(['post_type' => $this->_post_type], admin_url('edit.php'))); ?>" class="page-title-action"><?php esc_html_e('Entries',
                            'divi-contact-form-helper'); ?></a>
                    <hr class="wp-header-end">
                    <?php ks_pac_dcfh_alert()::show_admin_notice(); ?>
                    <span class="spinner"></span>
                    <div id="poststuff">
                        <div id="post-body" class="metabox-holder columns-2">
                            <div class="postbox-container">
                                <div class="postbox">
                                    <div class="inside">
                                        <form method="POST" autocomplete="off" enctype="application/x-www-form-urlencoded">
                                            <table class="form-table post-selection">
                                                <tbody>
                                                <tr>
                                                    <th><?php esc_html_e('Type:', 'divi-contact-form-helper'); ?>
                                                        <span class="required">*</span></th>
                                                    <td>
                                                        <select title="" class="form-control" name="to_post_type" id="to_post_type" required>;
                                                            <option value=""><?php esc_html_e('Please Select', 'divi-contact-form-helper'); ?></option>
                                                            <?php foreach (ks_pac_dcfh_wp_helper()::get_post_types() as $post_key => $posts_type) {
                                                                $posts_type = ucwords($posts_type); ?>
                                                                <option value="<?php echo esc_html($post_key); ?>" <?php selected($post_key, esc_html($post_request['to_post_type'])); ?>><?php echo esc_html($posts_type); ?></option>";
                                                            <?php } ?>
                                                        </select>
                                                    </td>
                                                    <th><?php esc_html_e('Status:', 'divi-contact-form-helper'); ?></th>
                                                    <td>
                                                        <select title="" class="form-control" name="post_status" id="post_status">;
                                                            <?php foreach (array_reverse(get_post_statuses()) as $status_key => $status) {
                                                                $status = ucwords($status); ?>
                                                                <option value="<?php echo esc_html($status_key); ?>" <?php selected($status_key, esc_html($post_request['post_status'])); ?>><?php echo esc_html($status); ?></option>";
                                                            <?php } ?>
                                                        </select>
                                                    </td>
                                                    <th><?php esc_html_e('Term:', 'divi-contact-form-helper'); ?></th>
                                                    <td>
                                                        <select title="" class="form-control" name="post_term" id="post_term" disabled>;
                                                            <option value=""><?php esc_html_e('Please Select', 'divi-contact-form-helper'); ?></option>
                                                        </select>
                                                    </td>
                                                </tr>
                                                </tbody>
                                            </table>
                                            <table class="form-table form-data">
                                                <thead class="d-none">
                                                <tr>
                                                    <th><?php esc_html_e('Field', 'divi-contact-form-helper'); ?></th>
                                                    <th><?php esc_html_e('Value', 'divi-contact-form-helper'); ?></th>
                                                    <th><?php esc_html_e('Type', 'divi-contact-form-helper'); ?></th>
                                                    <th><?php esc_html_e('Custom Field', 'divi-contact-form-helper'); ?></th>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                <?php
                                                $row_id = 0;
                                                foreach ($form_entries as $form_key => $form_entry) {
                                                    $row_id++;
                                                    $field_label = esc_html($form_entry['label']);
                                                    $field_type = esc_html($form_entry['type']);
                                                    $post_data = $post_request['post_data'][$form_key] ?? esc_html($form_entry['value']);
                                                    $copy_as = $post_request['copy_as'][$form_key] ?? null;
                                                    $custom_field = $post_request['custom_field'][$form_key] ?? null;
                                                    $readonly = empty($custom_field) ? 'readonly' : null;
                                                    $row_id = md5($row_id.$form_key.uniqid('', true));
                                                    if ('text' !== $field_type && 'file' !== $field_type && 'signature_pad' !== $field_type) {
                                                        ?>
                                                        <tr>
                                                            <th><?php echo esc_html("$field_label:"); ?></th>
                                                            <td>
                                                                <input title="" type="text" name="post_data[<?php echo esc_attr($form_key); ?>]" id="<?php echo esc_attr('post_data_'.$row_id); ?>" class="regular-text" value="<?php echo esc_attr($post_data); ?>">
                                                            </td>
                                                            <td>
                                                                <select title="" class="form-control copy-as" name="copy_as[<?php echo esc_attr($form_key); ?>]" id="<?php echo esc_attr("copy_as_$row_id"); ?>" data-row="<?php echo esc_attr($row_id); ?>">
                                                                    <?php foreach (ks_pac_dcfh_constant()::clone_types() as $key => $type) { ?>
                                                                        <option value="<?php echo esc_attr($key); ?>" <?php selected($key, $copy_as); ?>><?php echo esc_html($type); ?></option>
                                                                    <?php } ?>
                                                                </select>
                                                            </td>
                                                            <td>
                                                                <input title="" type="text" class="form-control" name="custom_field[<?php echo esc_attr($form_key); ?>]" id="<?php echo esc_attr($row_id); ?>" placeholder="<?php esc_html_e('Choose Custom Field', 'divi-contact-form-helper'); ?>" value="<?php echo esc_html($custom_field); ?>" <?php echo esc_attr($readonly); ?>>
                                                            </td>
                                                        </tr>
                                                    <?php } elseif ('file' === $field_type || 'signature_pad' === $field_type) {
                                                        $wp_upload_dir = wp_upload_dir();
                                                        $wp_subdir = isset($form_entry['subdir']) ? esc_html($form_entry['subdir']) : '';
                                                        $wp_basedir = rtrim($wp_upload_dir['basedir'], '/').'/'.$wp_subdir;
                                                        $wp_baseurl = rtrim($wp_upload_dir['baseurl'], '/').'/'.$wp_subdir;
                                                        $attachments = is_array($post_data) ? $post_data : explode(',', $post_data);
                                                        if (!empty($attachments) && is_array($attachments) && !empty($wp_subdir)) {
                                                            $row_id = 0;
                                                            $contact_form_id = ks_pac_dcfh_post_meta()::get_contact_form_id_meta_value($this->_post_id);
                                                            foreach ($attachments as $attachment) {
                                                                $row_id++;
                                                                $row_id = md5($row_id.$form_key.uniqid('', true));
                                                                if (isset($form_entry['is_media_library']) && $form_entry['is_media_library']) {
                                                                    $upload_dir = path_join($wp_basedir, $attachment);
                                                                    $upload_url = path_join($wp_baseurl, $attachment);
                                                                    $upload_id = ks_pac_dcfh_post_meta()::get_attachment_id_by_name($attachment);
                                                                } else {
                                                                    $upload_dir = ks_pac_dcfh_file_helper()::get_form_upload_dir($contact_form_id, $wp_subdir, $attachment);
                                                                    $upload_url = ks_pac_dcfh_file_helper()::get_form_upload_url($contact_form_id, $wp_subdir, $attachment);
                                                                    $upload_id = '';
                                                                }
                                                                if (et_()->WPFS()->is_file($upload_dir) && et_()->WPFS()->exists($upload_dir)) { ?>
                                                                    <tr>
                                                                        <th><?php echo esc_html("$field_label:"); ?></th>
                                                                        <td>
                                                                            <?php echo sprintf('<a href="%1$s" target="_blank">%2$s</a>', esc_url($upload_url), esc_html($attachment)); ?>
                                                                            <input type="hidden" name="post_data[<?php echo esc_attr($form_key); ?>_dir][<?php echo esc_attr($row_id); ?>]" value="<?php echo esc_attr($upload_dir); ?>">
                                                                            <input type="hidden" name="post_data[<?php echo esc_attr($form_key); ?>_url][<?php echo esc_attr($row_id); ?>]" value="<?php echo esc_attr($upload_url); ?>">
                                                                            <?php if (!empty($upload_id)) { ?>
                                                                                <input type="hidden" name="post_data[<?php echo esc_attr($form_key); ?>_id][<?php echo esc_attr($row_id); ?>]" value="<?php echo esc_attr($upload_id); ?>">
                                                                            <?php } ?>
                                                                        </td>
                                                                        <td>
                                                                            <select title="" class="form-control copy-as" name="copy_as[<?php echo esc_attr($form_key); ?>][<?php echo esc_attr($row_id); ?>]" data-row="<?php echo esc_attr($row_id); ?>">
                                                                                <?php foreach (ks_pac_dcfh_constant()::clone_types() as $key => $type) { ?>
                                                                                    <option value="<?php echo esc_html($key); ?>" <?php selected($key, $copy_as[$row_id] ?? ''); ?>><?php echo esc_html($type); ?></option>
                                                                                <?php } ?>
                                                                            </select>
                                                                        </td>
                                                                        <td>
                                                                            <input title="" type="text" class="form-control" name="custom_field[<?php echo esc_attr($form_key); ?>][<?php echo esc_attr($row_id); ?>]" id="<?php echo esc_attr($row_id); ?>" placeholder="<?php esc_html_e('Choose Custom Field', 'divi-contact-form-helper'); ?>" value="<?php echo esc_html($custom_field[$row_id] ?? ''); ?>" <?php echo esc_attr($readonly); ?>>
                                                                        </td>
                                                                    </tr>
                                                                    <?php
                                                                }
                                                            }
                                                        }
                                                    } else { ?>
                                                        <tr>
                                                            <th><?php echo esc_html($field_label); ?></th>
                                                            <td colspan="2">
                                                                <select title="" class="form-control copy-as" name="copy_as[<?php echo esc_attr($form_key); ?>]" id="<?php echo esc_attr("copy_as_$row_id"); ?>" data-row="<?php echo esc_attr($row_id); ?>">
                                                                    <?php foreach (ks_pac_dcfh_constant()::clone_types() as $key => $type) {
                                                                        $selected = $post_request['copy_as'][$form_key] ?? 'content'; ?>
                                                                        <option value="<?php echo esc_html($key); ?>" <?php selected($key, $selected); ?>><?php echo esc_html($type); ?></option>
                                                                    <?php } ?>
                                                                </select>
                                                            </td>
                                                            <td>
                                                                <input title="" type="text" class="form-control" name="custom_field[<?php echo esc_attr($form_key); ?>]" id="<?php echo esc_attr($row_id); ?>" placeholder="<?php esc_html_e('Choose Custom Field', 'divi-contact-form-helper'); ?>" readonly>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td colspan="4">
                                                                <?php wp_editor($post_data, 'post_data', [
                                                                    'wpautop' => true,
                                                                    'textarea_name' => "post_data[$form_key]",
                                                                    'textarea_rows' => 10
                                                                ]);
                                                                ?>
                                                            </td>
                                                        </tr>
                                                    <?php }
                                                } ?>
                                                </tbody>
                                            </table>
                                            <div class="media">
                                                <div class="featured-img" <?php echo empty($post_request['custom_featured_img_url']) ? ' style="display: none"' : ' style="display: block"'; // phpcs:ignore ?>>
                                                    <img src="<?php echo esc_url($post_request['custom_featured_img_url']); ?>" id="uploaded-featured-image-url" alt="">
                                                    <a href="javascript:void(0)" id="js-remove-featured-image"><?php esc_html_e('Remove', 'divi-contact-form-helper'); ?></a>
                                                </div>
                                                <a href="javascript:void(0)" class="button-secondary" id="upload-featured-image"><?php esc_html_e('Featured Image',
                                                        'divi-contact-form-helper'); ?></a>
                                                <input type="hidden" name="custom_featured_img" id="uploaded-featured-image-id" value="<?php echo esc_html($post_request['custom_featured_img']); ?>"/>
                                            </div>
                                            <?php if (!empty(ks_pac_dcfh_user()::get_post_user_email($this->_post_id))) { ?>
                                                <div class="send-email-to-submitter">
                                                    <label class="bulk-select-button" for="send_email_to_submitter">
                                                        <input type="checkbox" id="send_email_to_submitter" name="send_email_to_submitter" class="bulk-select-switcher" value="1">
                                                        <span class="bulk-select-button-label"><?php esc_html_e('Send Email To Submitter', 'divi-contact-form-helper'); ?></span>
                                                    </label>
                                                </div>
                                            <?php }
                                            wp_nonce_field('create_post');
                                            submit_button(__('Create Post', 'divi-contact-form-helper'), 'primary large', 'btn_create_post');
                                            ?>
                                        </form>
                                    </div>
                                </div>
                            </div>
                            <div id="postbox-container-1" class="postbox-container">
                                <?php
                                require_once dirname(__DIR__)."/template/documentation-widget.php";
                                require_once dirname(__DIR__)."/template/support-widget.php";
                                ?>
                            </div>
                        </div>
                        <br class="clear">
                    </div>
                </div>
                <?php
            }
        }
    }

    private function send_email($email_to, $created_post_id): void
    {
        $subject = apply_filters('dcfh_f_create_post_email_subject', __('Your Submission Has Been Published – See It Live!', 'divi-contact-form-helper'));
        $heading = apply_filters('dcfh_f_create_post_email_heading', __('🎉 Your Post Is Live on Our Website!', 'divi-contact-form-helper'));
        $headers = ['Content-Type: text/html; charset=UTF-8'];
        $message = strtr($this->get_message_tpl(), [
            '%%site_title%%' => get_bloginfo('name'),
            '%%heading%%' => $heading,
            '%%post_type%%' => get_post_type($created_post_id),
            '%%post_title%%' => get_the_title($created_post_id),
            '%%post_url%%' => get_the_permalink($created_post_id),
            '%%post_date%%' => date_i18n('l, F j, Y \a\t g:i A', strtotime(get_the_date($created_post_id))),
        ]);
        wp_mail($email_to, $subject, $message, $headers);
    }

    private function get_message_tpl(): string
    {
        ob_start();
        ?>
        <div style="margin: 0; padding: 30px; font-family: Arial, sans-serif; background-color: #f4f4f4;">
            <div style="max-width: 550px; margin: 0 auto; background-color: #ffffff; border: 1px solid #e0e0e0; border-radius: 10px; padding: 30px;">
                <!-- Heading -->
                <h2 style="margin-top: 0; color: #2c3e50; font-size: 24px; font-weight: bold;">%%heading%%</h2>
                <!-- Greeting -->
                <p style="font-size: 16px; color: #2c3e50;">Dear Submitter,</p>
                <!-- Message body -->
                <p style="font-size: 16px; color: #2c3e50;line-height: 24px">
                    Thank you for your recent submission! We’re excited to let you know that your content has been
                    successfully published as a post on our website, %%site_title%%.
                </p>
                <p style="font-size: 16px; color: #2c3e50;">
                    Below are the details of your submission for your records:
                </p>
                <!-- Submission details box -->
                <div style="margin: 20px 0; padding: 20px; background-color: #f9f9f9; border-left: 4px solid #3498db; border-radius: 6px;">
                    <p style="margin: 8px 0; font-size: 15px; color: #34495e;"><strong>Title:</strong> %%post_title%%
                    </p>
                    <p style="margin: 8px 0; font-size: 15px; color: #34495e;"><strong>Link:</strong>
                        <a href="%%post_url%%" style="color: #2980b9; text-decoration: none;" target="_blank">%%post_url%%</a>
                    </p>
                    <p style="margin: 8px 0; font-size: 15px; color: #34495e;"><strong>Published Date:</strong>
                        %%post_date%%</p>
                </div>
                <!-- Final note -->
                <p style="font-size: 13px; color: #7f8c8d; text-align: center; margin-top: 40px;">
                    This is an automated message—please do not reply to this email.
                </p>
            </div>
        </div>
        <?php
        return ob_get_clean();
    }
}


??

??