<?php
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
function bwdcv_render_style_sixteen( $attributes, $content ) {

    if ( !function_exists( 'formatDateDisplay' ) ) {
        function formatDateDisplay( $dateString ) {
            if ( empty( $dateString ) ) {
                return '';
            }

            $dateParts = explode( '-', $dateString );
            if ( count( $dateParts ) < 2 ) {
                return $dateString;
            }
            $year = $dateParts[0];
            $month = str_pad( $dateParts[1], 2, '0', STR_PAD_LEFT );
            return $year . '/' . $month;
        }
    }
    $placeholder_image_url = plugin_dir_url( __FILE__ ) . '../../../../includes/assets/img/profile-image.png';
    $signature_image = plugin_dir_url( __FILE__ ) . '../../../../includes/assets/img/sign-white.png';
    $style = isset( $attributes['style'] ) ? $attributes['style'] : 'style1';
    $unique_id = isset( $attributes['uniqueId'] ) ? $attributes['uniqueId'] : '';
    $linkedin_url = isset( $attributes['linkedinUrl'] ) ? $attributes['linkedinUrl'] : '#';
    $phone_number = isset( $attributes['phoneNumber'] ) ? $attributes['phoneNumber'] : '+00 952 165';
    $profile_image = isset( $attributes['profileImage']['url'] ) ? $attributes['profileImage']['url'] : '';
    $footer_link = isset( $attributes['footerLink'] ) ? $attributes['footerLink'] : '#';
    $signature = isset( $attributes['signature'] ) ? $attributes['signature'] : null;
    $footer_btn_text = isset( $attributes['footerBtnText'] ) ? $attributes['footerBtnText'] : 'Contact Me';
    $footer_btn_link = isset( $attributes['footerBtnLink'] ) ? $attributes['footerBtnLink'] : '#';
    $showQRCode = isset( $attributes['showQRCode'] ) ? $attributes['showQRCode'] : false;
    $sectionCountSixteen = isset( $attributes['sectionCountSixteen'] ) ? $attributes['sectionCountSixteen'] : 4;
    $isFooterVisible = isset( $attributes['isFooterVisible'] ) ? $attributes['isFooterVisible'] : true;
    $social_icon = isset( $attributes['socialIcon'] ) ? $attributes['socialIcon'] : [
        [
            'id'   => 1,
            'icon' => 'Facebook-f',
            'link' => '',
        ],
        [
            'id'   => 2,
            'icon' => 'Instagram-line',
            'link' => '',
        ],
        [
            'id'   => 3,
            'icon' => 'Twitter',
            'link' => '',
        ],
        [
            'id'   => 4,
            'icon' => 'Linkedin-in',
            'link' => '',
        ],
    ];
    $default_value = apply_filters( 'bwdcv_section_item_default_value', [
        [
            'id'              => '1',
            'type'            => 'contact',
            'title'           => 'Contact',
            'phoneNumber'     => '+00 952 165',
            'showPhoneNumber' => true,
            'email'           => 'info20@gmail.com',
            'showEmail'       => true,
            'address'         => '123 Main Street',
            'showAddress'     => true,
            'website'         => 'www.example.com',
            'showWebsite'     => true,
            'country'         => 'USA',
            'showCountry'     => true,
            'city'            => 'New York',
            'showCity'        => true,
            'postalCode'      => '10001',
            'showPostalCode'  => true,
            'socialIcon'      => [
                ['id' => 1, 'icon' => 'Linkedin-in', 'link' => '#'],
            ],
        ],
        [
            'id'    => '2',
            'type'  => 'skills',
            'title' => 'Skills',
            'items' => [
                ['name' => 'JavaScript', 'percentage' => 80],
                ['name' => 'HTML', 'percentage' => 90],
                ['name' => 'CSS', 'percentage' => 70],
                ['name' => 'React', 'percentage' => 85],
                ['name' => 'WordPress', 'percentage' => 75],
                ['name' => 'PHP', 'percentage' => 95],
                ['name' => 'Python', 'percentage' => 85],
                ['name' => 'AI', 'percentage' => 79],
                ['name' => 'API', 'percentage' => 74],
            ],
        ],

        [
            'id'    => '3',
            'type'  => 'languages',
            'title' => 'Languages',
            'items' => [
                ['name' => 'English', 'percentage' => 90],
                ['name' => 'Spanish', 'percentage' => 75],
                ['name' => 'Arabic', 'percentage' => 75],
            ],
        ],
        [
            'id'    => '4',
            'type'  => 'hobbies',
            'title' => 'Hobbies',
            'items' => [
                ['name' => 'Music', 'icon' => 'Music'],
                ['name' => 'Movie', 'icon' => 'Movie'],
                ['name' => 'Writing', 'icon' => 'Writing'],
                ['name' => 'Football', 'icon' => 'Football'],
            ],
        ],
        [
            'id'          => '5',
            'type'        => 'about',
            'title'       => 'About Me',
            'description' => 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Rerum a incidunt, voluptatibus doloribus quod praesentium quibusdam provident?',
            'dateOfBirth' => '01/01/2001',
            'nationality' => 'USA',
        ],
        [
            'id'    => '6',
            'type'  => 'education',
            'title' => 'Education',
            'items' => [
                [
                    'institution'          => 'University of California',
                    'name'                 => 'Computer Science',
                    'degree'               => 'Bachelor',
                    'city'                 => 'California',
                    'fromDate'             => 2020,
                    'toDate'               => 2025,
                    'current'              => false,
                    'country'              => 'USA',
                    'educationDescription' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.',
                ],
                [
                    'institution'          => 'University of California',
                    'name'                 => 'Computer Science',
                    'degree'               => 'Bachelor',
                    'city'                 => 'California',
                    'fromDate'             => 2020,
                    'toDate'               => 2025,
                    'current'              => false,
                    'country'              => 'USA',
                    'educationDescription' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.',
                ],
                [
                    'institution'          => 'University of California',
                    'name'                 => 'Computer Science',
                    'degree'               => 'Bachelor',
                    'city'                 => 'California',
                    'fromDate'             => 2020,
                    'toDate'               => 2025,
                    'current'              => false,
                    'country'              => 'USA',
                    'educationDescription' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.',
                ],

            ],
        ],
        [
            'id'    => '7',
            'type'  => 'experience',
            'title' => 'Experience',
            'items' => [
                [
                    'name'                  => 'University of California',
                    'designation'           => 'Web Developer',
                    'present'               => false,
                    'fromExpDate'           => '2020/05',
                    'toExpDate'             => '2025/05',
                    'experienceDescription' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.',
                ],
                [
                    'name'                  => 'University of California',
                    'designation'           => 'Web Developer',
                    'present'               => false,
                    'fromExpDate'           => '2020/05',
                    'toExpDate'             => '2025/05',
                    'experienceDescription' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.',
                ],
                [
                    'name'                  => 'University of California',
                    'designation'           => 'Web Developer',
                    'present'               => false,
                    'fromExpDate'           => '2020/05',
                    'toExpDate'             => '2025/05',
                    'experienceDescription' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.',
                ],

            ],
        ],
        [
            'id'    => '8',
            'type'  => 'reference',
            'title' => 'Reference',
            'items' => [
                [
                    'name'        => 'John Doe',
                    'jobPosition' => 'CEO',
                    'company'     => 'Company Inc',
                    'phone'       => '1234567890',
                    'relation'    => 'Friend',
                ],

                [
                    'name'        => 'John Doe',
                    'jobPosition' => 'CEO',
                    'company'     => 'Company Inc',
                    'phone'       => '1234567890',
                    'relation'    => 'Friend',
                ],

            ],
        ],
        [
            'id'    => '9',
            'type'  => 'awards',
            'title' => 'Achievements & Awards',
            'items' => [
                ['name' => 'Top Finance Leader LATAM – Global Capital Solutions, 2022'],
                ['name' => 'Outstanding Account Manager – Banco Nacional, 2018'],
                ['name' => 'Reduced finance operating expenses by $250K annually'],
                ['name' => 'Successfully led post-merger finance integration project across 3 countries'],
            ],
        ],
        [
            'id'    => '10',
            'type'  => 'tools',
            'title' => 'Tools & Technologies',
            'items' => [
                ['name' => 'SAP, Oracle, QuickBooks, Xero'],
                ['name' => 'Microsoft Excel (Advanced), Power BI'],
                ['name' => 'Tableau, Zoho Finance Suite'],
                ['name' => 'CRM Tools: Salesforce, HubSpot'],
                ['name' => 'Banking platforms & compliance tools'],
            ],
        ],

    ] );

    $sectionItems = isset( $attributes['sectionItems16'] ) ? $attributes['sectionItems16'] : $default_value;

    $firstFiveSections = array_slice( $sectionItems, 0, $sectionCountSixteen );
    $remainingSections = array_slice( $sectionItems, $sectionCountSixteen );

    $dataByStyle = isset( $attributes['dataByStyle'] ) ? $attributes['dataByStyle'] : [];
    $currentData = isset( $dataByStyle[$style] ) ? $dataByStyle[$style] : [];
    if ( class_exists( 'BWDCV_Template_Defaults' ) ) {
        $defaultData = BWDCV_Template_Defaults::get_template_defaults( $style );
        $currentData = wp_parse_args( $currentData, $defaultData );
    }
    $firstName = isset( $currentData['firstName'] ) ? $currentData['firstName'] : '';
    $lastName = isset( $currentData['lastName'] ) ? $currentData['lastName'] : '';
    $designation = isset( $currentData['designation'] ) ? $currentData['designation'] : '';
    $email = isset( $currentData['email'] ) ? $currentData['email'] : '';
    $phoneNumber = isset( $currentData['phoneNumber'] ) ? $currentData['phoneNumber'] : '';
    $address = isset( $currentData['address'] ) ? $currentData['address'] : '';
    $city = isset( $currentData['city'] ) ? $currentData['city'] : '';
    $postalCode = isset( $currentData['postalCode'] ) ? $currentData['postalCode'] : '';
    $website = isset( $currentData['website'] ) ? $currentData['website'] : '';

    $waterMarkCanvas = '';
    for ( $i = 1; $i <= 28; $i++ ) {
        $option_nname = 'style' . $i;
        $optionName = 'cv_allow_style' . $i;

        if ( $style === $option_nname && get_option( $optionName ) === 'on' ) {
            $waterMarkCanvas = '';
        } else {
            $waterMarkCanvas = 'bwd-cv-wrap-watermark';
        }
    }

    ob_start();

    echo '<div class="' . esc_attr( $unique_id ) . ' wp-block-bwdcv-wp-cv-builder-sass">';

    $styles = ['style1', 'style2', 'style3', 'style4', 'style5', 'style6', 'style7', 'style8', 'style9', 'style10', 'style11', 'style12', 'style13', 'style14', 'style15', 'style16', 'style17', 'style18', 'style19', 'style20', 'style21', 'style22', 'style23', 'style24', 'style25'];
    if ( in_array( $style, $styles ) ) {

        echo '<div class="' . esc_attr( $style ) . ' bwdcvs-main-wrapper bwdcvs-cv-builder-common">';
        echo '<div class="cv-builder-information ' . $waterMarkCanvas . '">';
        if ( $showQRCode ) {
            bwdcv_output_qr_canvas( $linkedin_url );
        }
        echo '<div class="cv-header">';
        echo '<div class="profile-img">';
        if ( !empty( $profile_image ) ) {
            echo '<img src="' . esc_url( $profile_image ) . '" alt="Profile Image" />';
        } else {
            echo '<img src="' . esc_url( $placeholder_image_url ) . '" alt="Profile Image" />';
        }
        echo '</div>';
        echo '<div class="profile-info">';
        echo '<div class="bwdcv-name-wrap">';
        echo '<span class="first-name">' . $firstName . '</span>';
        echo '<span class="last-name">' . ' ' . $lastName . '</span>';
        echo '</div>';
        echo '<div class="designation">' . $designation . '</div>';
        $show_social_icon = apply_filters( 'bwdcv_show_social_icon', true );
if ( $show_social_icon ) {

    // SVG এর জন্য allowed tags define করো
    $allowed_svg = [
        'svg'     => [ 'width' => [], 'height' => [], 'viewbox' => [], 'viewBox' => [], 'xmlns' => [], 'fill' => [], 'class' => [] ],
        'path'    => [ 'd' => [], 'fill' => [], 'fill-rule' => [], 'clip-rule' => [] ],
        'g'       => [ 'fill' => [], 'class' => [] ],
        'circle'  => [ 'cx' => [], 'cy' => [], 'r' => [], 'fill' => [] ],
        'rect'    => [ 'x' => [], 'y' => [], 'width' => [], 'height' => [], 'fill' => [] ],
        'polygon' => [ 'points' => [], 'fill' => [] ],
        'defs'    => [],
    ];

    echo '<div class="social-icon">';
    foreach ( $social_icon as $icon ) {
        require_once plugin_dir_path( __FILE__ ) . '../../../../includes/blocks/icons.php';

        $icon_key = isset( $icon['icon'] ) ? sanitize_text_field( $icon['icon'] ) : '';
        $svg      = isset( $icons[ $icon_key ] ) ? $icons[ $icon_key ] : '';

        if ( ! empty( $icon['link'] ) ) {
            echo '<a href="' . esc_url( $icon['link'] ) . '"><span class="icon">' . wp_kses( $svg, $allowed_svg ) . '</span></a>';
        } else {
            echo '<span class="icon disabled">' . wp_kses( $svg, $allowed_svg ) . '</span>';
        }
    }
    echo '</div>';
}
        // Contact info
        $current_user = wp_get_current_user();
        $user_email = $current_user->user_email;
        do_action( 'bwdcv_show_user_contact_info', $phone_number, $user_email );
        echo '</div>';
        echo '</div>';
        echo '<div class="cv-body">';
        echo '<div class="bwdcv-main-wrapper">';

        echo '<div class="cv-left-content">';
        foreach ( $firstFiveSections as $index => $section ) {
            require_once plugin_dir_path( __FILE__ ) . '../../../../includes/blocks/section-icon.php';
            echo '<div class="section section-' . $section['type'] . '" id="section-' . $section['id'] . '">';
            echo '<div class="icon-title-wrap">';
            echo '<div class="bwdcv-svg-icon">' . ( !empty( $sectionIcons[$section['type']] ) ? $sectionIcons[$section['type']] : '' ) . '</div>';
            echo '<div class="section-title">' . esc_html( $section['title'] ) . '</div>';
            echo '</div>';
            if ( $section['type'] === 'about' ) {
                echo '<div class="cv-about">';
                echo '<div class="about-content-wrap">';
                echo '<div class="description">' . ( $section['description'] ? $section['description'] : '' ) . '</div>';
                if ( !empty( $section['dateOfBirth'] ) ) {
                    $date = DateTime::createFromFormat( 'Y-m-d', $section['dateOfBirth'] );
                    if ( !$date ) {
                        $date = DateTime::createFromFormat( 'd-m-Y', $section['dateOfBirth'] );
                    }
                    if ( $date ) {
                        $formatted_date = $date->format( 'd-m-Y' );
                        echo '<div class="birth-date-wrap"><strong>' . esc_html__( 'Date of Birth', 'cv-builder' ) . ':</strong> ' . esc_html( $formatted_date ) . '</div>';
                    }
                }
                if ( !empty( $section['nationality'] ) ) {
                    echo '<div class="nationality-wrap">';
                    echo '<strong>' . esc_html__( 'Nationality', 'cv-builder' ) . ':</strong>';
                    echo '<span class="nationality">' . esc_html( $section['nationality'] ) . '</span>';
                    echo '</div>';
                }
                echo '</div>';
                echo '</div>';
            }

            if ( $section['type'] === 'contact' ) {
                echo '<div class="cv-contact">';
                $show_email_phone = apply_filters( 'show_email_phone', true );
                if ( $show_email_phone ) {
                    echo isset( $section['showEmail'] ) && $section['showEmail'] ? '<div><strong>' . esc_html__( 'Email', 'cv-builder' ) . ':</strong> ' . ( $section['email'] ?? '' ) . '</div>' : '';
                    echo isset( $section['showPhoneNumber'] ) && $section['showPhoneNumber'] ? '<div><strong>' . esc_html__( 'Phone', 'cv-builder' ) . ':</strong> ' . esc_html( $section['phoneNumber'] ?? '' ) . '</div>' : '';
                }
                echo( isset( $section['showAddress'] ) && $section['showAddress'] && !empty( $section['address'] ) ) ? '<div><strong>' . esc_html__( 'Address', 'cv-builder' ) . ':</strong> ' . ( $section['address'] ) . '</div>' : '';
                echo( isset( $section['showWebsite'] ) && isset( $section['website'] ) && $section['showWebsite'] && !empty( $section['website'] ) ) ? '<div><strong>' . esc_html__( 'Website', 'cv-builder' ) . ':</strong> ' . $section['website'] . '</div>' : '';
                echo( isset( $section['showCity'] ) && $section['showCity'] && !empty( $section['city'] ) ) ? '<div><strong>' . esc_html__( 'City', 'cv-builder' ) . ':</strong> ' . $section['city'] . '</div>' : '';

                echo( isset( $section['showPostalCode'] ) && $section['showPostalCode'] && !empty( $section['postalCode'] ) ) ? '<div><strong>' . esc_html__( 'Postal Code', 'cv-builder' ) . ':</strong> ' . $section['postalCode'] . '</div>' : '';
                // Add social icons
                if ( isset( $section['socialIcon'] ) ) {
                    do_action( 'bwdcv_show_social_icon_two', $section['socialIcon'] );
                }

                echo '</div>';
            }

            echo '<div class="bwdcvs-content-wrapper ' . $section['type'] . '">';

            if ( isset( $section['items'] ) && is_array( $section['items'] ) ) {
                foreach ( $section['items'] as $itemIndex => $item ) {
                    echo '<div class="draggable-item">';

                    if ( $section['type'] === 'skills' ) {
                        echo '<div class="cv-skill">';
                        if ( !empty( $item['name'] || $item['percentage'] ) ) {
                            echo '<div class="bwdcv-pb-area">';
                            echo '<div class="bwdcv-pb-name">';
                            echo '<div class="bwdcv-pb-label"><span>' . $item['name'] . '</span></div>';
                            echo '<div class="bwdcv-progress-bar">';
                            echo '<span class="bwdcv-percentage-counter">0%</span>';
                            echo '<div class="bwdcv-per-val" data-pb-val="' . esc_attr( $item['percentage'] ) . '"></div>';
                            echo '</div>';
                            echo '</div>';
                            echo '</div>';
                        }
                        echo '</div>';
                    }
                    if ( $section['type'] === 'languages' ) {
                        echo '<div class="cv-language">';
                        if ( !empty( $item['name'] || $item['percentage'] ) ) {
                            echo '<div class="bwdcv-pb-area">';
                            echo '<div class="bwdcv-pb-name">';
                            echo '<div class="bwdcv-pb-label"><span>' . $item['name'] . '</span></div>';
                            echo '<div class="bwdcv-progress-bar">';
                            echo '<span class="bwdcv-percentage-counter">0%</span>';
                            echo '<div class="bwdcv-per-val" data-pb-val="' . esc_attr( $item['percentage'] ) . '"></div>';
                            echo '</div>';
                            echo '</div>';
                            echo '</div>';
                        }
                        echo '</div>';
                    }

                    if ( $section['type'] === 'hobbies' ) {
                        require_once plugin_dir_path( __FILE__ ) . '../../../../includes/blocks/icons.php';
                        echo '<div class="cv-hobby">';
                        if ( isset( $item['icon'] ) && isset( $icons[$item['icon']] ) ) {
                            echo '<span class="icon">' . $icons[$item['icon']] . '</span>';
                        }
                        echo '<span class="hobby-name">' . $item['name'] . '</span>';
                        echo '</div>';
                    }

                    if ( $section['type'] === 'education' ) {
                        echo '<div class="cv-education">';
                        if ( !empty( $item['name'] || $item['degree'] || $item['institution'] || $item['city'] || $item['country'] || $item['educationDescription'] || $item['fromDate'] || $item['toDate'] ) ) {
                            echo '<div class="education-content-wrap">';
                            echo '<span class="study-field">' . esc_html( $item['name'] ?? '' ) . '</span>';
                            echo '<span class="degree-name">' . ( $item['degree'] ? ' | ' : '' ) . $item['degree'] . '</span>';
                            echo '<div class="institution-wrapper">';
                            echo '<span class="institution">' . $item['institution'] . '</span>' . ( $item['institution'] ? ', ' : '' );
                            echo '<span class="city-country">' . esc_html( $item['city'] ) . ( $item['city'] ? ', ' : '' ) . esc_html( $item['country'] ) . '</span>';
                            echo '</div>';
                            echo '<div class="description">' . wp_kses_post( $item['educationDescription'] ) . '</div>';
                            // $fromYear = !empty( $item['fromDate'] ) ? date( 'Y', strtotime( $item['fromDate'] ) ) : '';
                            $fromYear = !empty( $item['fromDate'] ) ? date_i18n( 'Y', strtotime( $item['fromDate'] ) ) : '';
                            // $toYear = !empty( $item['toDate'] ) ? date( 'Y', strtotime( $item['toDate'] ) ) : '';
                            $toYear = !empty( $item['toDate'] ) ? date_i18n( 'Y', strtotime( $item['toDate'] ) ) : '';
                            // $current = !empty( $item['current'] ) ? 'Present' : $toYear;
                            $current = !empty( $item['current'] ) ? esc_html__( 'Present', 'cv-builder' ) : $toYear;
                            $dateDisplay = $fromYear;
                            if ( !empty( $fromYear ) && !empty( $current ) ) {
                                $dateDisplay .= ' - ' . $current;
                            } elseif ( empty( $fromYear ) && !empty( $current ) ) {
                                $dateDisplay = $current;
                            }
                            echo '<div class="duration">' . $dateDisplay . '</div>';
                            echo '</div>';
                        }
                        echo '</div>';
                    }

                    if ( $section['type'] === 'experience' ) {
                        if ( !empty( $item['name'] || $item['designation'] || $item['fromExpDate'] || $item['toExpDate'] || $item['experienceDescription'] ) ) {
                            echo '<div class="cv-experience">';
                            if ( !empty( $item['name'] ) ) {
                                echo '<span class="company-name">' . $item['name'] . '</span>';
                                if ( !empty( $item['designation'] ) ) {
                                    echo ' - ';
                                }
                            }
                            if ( !empty( $item['designation'] ) ) {
                                echo '<span class="designation">' . $item['designation'] . '</span>';
                            }
                            $fromDate = !empty( $item['fromExpDate'] ) ? formatDateDisplay( $item['fromExpDate'] ) : '';
                            // $toDate = !empty( $item['present'] ) ? 'Present' : ( !empty( $item['toExpDate'] ) ? formatDateDisplay( $item['toExpDate'] ) : '' );
                            $toDate = !empty( $item['present'] ) ? esc_html__( 'Present', 'cv-builder' ) : ( !empty( $item['toExpDate'] ) ? formatDateDisplay( $item['toExpDate'] ) : '' );
                            $dateRange = '';
                            if ( !empty( $fromDate ) ) {
                                $dateRange = $fromDate;
                                if ( !empty( $toDate ) ) {
                                    $dateRange .= ' - ' . $toDate;
                                }
                            } elseif ( !empty( $toDate ) ) {
                                $dateRange = $toDate;
                            }
                            echo '<div class="duration">' . $dateRange . '</div>';
                            echo '<div class="description">' . esc_html( $item['experienceDescription'] ) . '</div>';
                            echo '</div>';
                        }
                    }

                    if ( $section['type'] === 'reference' ) {
                        echo '<div class="cv-reference">';
                        echo '<div class="name">' . $item['name'] . '</div>';
                        echo '<span class="company">' . $item['company'] . '</span>';
                        if ( !empty( $item['jobPosition'] ) ) {
                            echo ', ';
                            echo '<span class="job-position">' . $item['jobPosition'] . '</span>';
                        }
                        if ( !empty( $item['phone'] ) ) {
                            echo '<div class="phone">Phone: ' . $item['phone'] . '</div>';
                        }
                        if ( !empty( $item['relation'] ) ) {
                            echo '<div class="relation">Relation: ' . $item['relation'] . '</div>';
                        }
                        echo '</div>';
                    }
                    if ( $section['type'] === 'awards' ) {
                        echo '<ul class="cv-awards">';
                        echo '<li class="award-item">' . $item['name'] . '</li>';
                        echo '</ul>';
                    }
                    if ( $section['type'] === 'tools' ) {
                        echo '<ul class="cv-tools">';
                        echo '<li class="tool-item">' . $item['name'] . '</li>';
                        echo '</ul>';
                    }
                    echo '</div>';
                }
            }
            echo '</div>';
            echo '</div>';
        }
        echo '</div>';
        echo '<div class="cv-right-content">';
        foreach ( $remainingSections as $index => $section ) {
            require_once plugin_dir_path( __FILE__ ) . '../../../../includes/blocks/section-icon.php';
            echo '<div class="section section-' . $section['type'] . '" id="section-' . $section['id'] . '">';
            echo '<div class="icon-title-wrap">';
            echo '<div class="bwdcv-svg-icon">' . ( !empty( $sectionIcons[$section['type']] ) ? $sectionIcons[$section['type']] : '' ) . '</div>';
            echo '<div class="section-title">' . esc_html( $section['title'] ) . '</div>';
            echo '</div>';
            if ( $section['type'] === 'about' ) {
                echo '<div class="cv-about">';
                echo '<div class="about-content-wrap">';
                echo '<div class="description">' . ( $section['description'] ? $section['description'] : '' ) . '</div>';
                if ( !empty( $section['dateOfBirth'] ) ) {
                    $date = DateTime::createFromFormat( 'Y-m-d', $section['dateOfBirth'] );
                    if ( !$date ) {
                        $date = DateTime::createFromFormat( 'd-m-Y', $section['dateOfBirth'] );
                    }
                    if ( $date ) {
                        $formatted_date = $date->format( 'd-m-Y' );
                        echo '<div class="birth-date-wrap"><strong>' . esc_html__( 'Date of Birth', 'cv-builder' ) . ':</strong> ' . esc_html( $formatted_date ) . '</div>';
                    }
                }
                if ( !empty( $section['nationality'] ) ) {
                    echo '<div class="nationality-wrap">';
                    echo '<strong>' . esc_html__( 'Nationality', 'cv-builder' ) . ':</strong>';
                    echo '<span class="nationality">' . esc_html( $section['nationality'] ) . '</span>';
                    echo '</div>';
                }
                echo '</div>';
                echo '</div>';
            }

            if ( $section['type'] === 'contact' ) {
                echo '<div class="cv-contact">';
                echo isset( $section['showEmail'] ) && $section['showEmail'] ? '<div><strong>' . esc_html__( 'Email', 'cv-builder' ) . ':</strong> ' . ( $section['email'] ?? '' ) . '</div>' : '';
                echo isset( $section['showPhoneNumber'] ) && $section['showPhoneNumber'] ? '<div><strong>' . esc_html__( 'Phone', 'cv-builder' ) . ':</strong> ' . esc_html( $section['phoneNumber'] ?? '' ) . '</div>' : '';
                echo isset( $section['showAddress'] ) && $section['showAddress'] ? '<div><strong>' . esc_html__( 'Address', 'cv-builder' ) . ':</strong> ' . ( $section['address'] ?? '' ) . '</div>' : '';
                echo isset( $section['showWebsite'] ) && $section['showWebsite'] ? '<div><strong>' . esc_html__( 'Website', 'cv-builder' ) . ':</strong> ' . ( $section['website'] ?? '' ) . '</div>' : '';
                echo isset( $section['showCity'] ) && $section['showCity'] ? '<div><strong>' . esc_html__( 'City', 'cv-builder' ) . ':</strong> ' . ( $section['city'] ?? '' ) . '</div>' : '';
                echo isset( $section['showPostalCode'] ) && $section['showPostalCode'] ? '<div><strong>' . esc_html__( 'Postal Code', 'cv-builder' ) . ':</strong> ' . ( $section['postalCode'] ?? '' ) . '</div>' : '';
                echo '</div>';
            }

            echo '<div class="bwdcvs-content-wrapper ' . $section['type'] . '">';

            if ( isset( $section['items'] ) && is_array( $section['items'] ) ) {
                foreach ( $section['items'] as $itemIndex => $item ) {
                    echo '<div class="draggable-item">';

                    if ( $section['type'] === 'skills' ) {
                        echo '<div class="cv-skill">';
                        if ( !empty( $item['name'] || $item['percentage'] ) ) {
                            echo '<div class="bwdcv-pb-area">';
                            echo '<div class="bwdcv-pb-name">';
                            echo '<div class="bwdcv-pb-label"><span>' . $item['name'] . '</span></div>';
                            echo '<div class="bwdcv-progress-bar">';
                            echo '<span class="bwdcv-percentage-counter">0%</span>';
                            echo '<div class="bwdcv-per-val" data-pb-val="' . esc_attr( $item['percentage'] ) . '"></div>';
                            echo '</div>';
                            echo '</div>';
                            echo '</div>';
                        }
                        echo '</div>';
                    }
                    if ( $section['type'] === 'languages' ) {
                        echo '<div class="cv-language">';
                        if ( !empty( $item['name'] || $item['percentage'] ) ) {
                            echo '<div class="bwdcv-pb-area">';
                            echo '<div class="bwdcv-pb-name">';
                            echo '<div class="bwdcv-pb-label"><span>' . $item['name'] . '</span></div>';
                            echo '<div class="bwdcv-progress-bar">';
                            echo '<span class="bwdcv-percentage-counter">0%</span>';
                            echo '<div class="bwdcv-per-val" data-pb-val="' . esc_attr( $item['percentage'] ) . '"></div>';
                            echo '</div>';
                            echo '</div>';
                            echo '</div>';
                        }
                        echo '</div>';
                    }

                    if ( $section['type'] === 'hobbies' ) {
                        require_once plugin_dir_path( __FILE__ ) . '../../../../includes/blocks/icons.php';
                        echo '<div class="cv-hobby">';
                        if ( isset( $item['icon'] ) && isset( $icons[$item['icon']] ) ) {
                            echo '<span class="icon">' . $icons[$item['icon']] . '</span>';
                        }
                        echo '<span class="hobby-name">' . $item['name'] . '</span>';
                        echo '</div>';
                    }

                    if ( $section['type'] === 'education' ) {
                        echo '<div class="cv-education">';
                        if ( !empty( $item['name'] || $item['degree'] || $item['institution'] || $item['city'] || $item['country'] || $item['educationDescription'] || $item['fromDate'] || $item['toDate'] ) ) {
                            echo '<div class="education-content-wrap">';
                            echo '<span class="study-field">' . esc_html( $item['name'] ?? '' ) . '</span>';
                            echo '<span class="degree-name">' . ( $item['degree'] ? ' | ' : '' ) . $item['degree'] . '</span>';
                            echo '<div class="institution-wrapper">';
                            echo '<span class="institution">' . $item['institution'] . '</span>' . ( $item['institution'] ? ', ' : '' );
                            echo '<span class="city-country">' . esc_html( $item['city'] ) . ( $item['city'] ? ', ' : '' ) . esc_html( $item['country'] ) . '</span>';
                            echo '</div>';
                            echo '<div class="description">' . wp_kses_post( $item['educationDescription'] ) . '</div>';
                            // $fromYear = !empty( $item['fromDate'] ) ? date( 'Y', strtotime( $item['fromDate'] ) ) : '';
                            $fromYear = !empty( $item['fromDate'] ) ? date_i18n( 'Y', strtotime( $item['fromDate'] ) ) : '';
                            // $toYear = !empty( $item['toDate'] ) ? date( 'Y', strtotime( $item['toDate'] ) ) : '';
                            $toYear = !empty( $item['toDate'] ) ? date_i18n( 'Y', strtotime( $item['toDate'] ) ) : '';
                            // $current = !empty( $item['current'] ) ? 'Present' : $toYear;
                            $current = !empty( $item['current'] ) ? esc_html__( 'Present', 'cv-builder' ) : $toYear;
                            $dateDisplay = $fromYear;
                            if ( !empty( $fromYear ) && !empty( $current ) ) {
                                $dateDisplay .= ' - ' . $current;
                            } elseif ( empty( $fromYear ) && !empty( $current ) ) {
                                $dateDisplay = $current;
                            }
                            echo '<div class="duration">' . $dateDisplay . '</div>';
                            echo '</div>';
                        }
                        echo '</div>';
                    }

                    if ( $section['type'] === 'experience' ) {
                        if ( !empty( $item['name'] || $item['designation'] || $item['fromExpDate'] || $item['toExpDate'] || $item['experienceDescription'] ) ) {
                            echo '<div class="cv-experience">';
                            if ( !empty( $item['name'] ) ) {
                                echo '<span class="company-name">' . $item['name'] . '</span>';
                                if ( !empty( $item['designation'] ) ) {
                                    echo ' - ';
                                }
                            }
                            if ( !empty( $item['designation'] ) ) {
                                echo '<span class="designation">' . $item['designation'] . '</span>';
                            }
                            $fromDate = !empty( $item['fromExpDate'] ) ? formatDateDisplay( $item['fromExpDate'] ) : '';
                            // $toDate = !empty( $item['present'] ) ? 'Present' : ( !empty( $item['toExpDate'] ) ? formatDateDisplay( $item['toExpDate'] ) : '' );
                            $toDate = !empty( $item['present'] ) ? esc_html__( 'Present', 'cv-builder' ) : ( !empty( $item['toExpDate'] ) ? formatDateDisplay( $item['toExpDate'] ) : '' );
                            $dateRange = '';
                            if ( !empty( $fromDate ) ) {
                                $dateRange = $fromDate;
                                if ( !empty( $toDate ) ) {
                                    $dateRange .= ' - ' . $toDate;
                                }
                            } elseif ( !empty( $toDate ) ) {
                                $dateRange = $toDate;
                            }
                            echo '<div class="duration">' . $dateRange . '</div>';
                            echo '<div class="description">' . esc_html( $item['experienceDescription'] ) . '</div>';
                            echo '</div>';
                        }
                    }

                    if ( $section['type'] === 'reference' ) {
                        echo '<div class="cv-reference">';
                        echo '<div class="name">' . $item['name'] . '</div>';
                        echo '<span class="company">' . $item['company'] . '</span>';
                        if ( !empty( $item['jobPosition'] ) ) {
                            echo ', ';
                            echo '<span class="job-position">' . $item['jobPosition'] . '</span>';
                        }
                        if ( !empty( $item['phone'] ) ) {
                            echo '<div class="phone">Phone: ' . $item['phone'] . '</div>';
                        }
                        if ( !empty( $item['relation'] ) ) {
                            echo '<div class="relation">Relation: ' . $item['relation'] . '</div>';
                        }
                        echo '</div>';
                    }
                    if ( $section['type'] === 'awards' ) {
                        echo '<ul class="cv-awards">';
                        echo '<li class="award-item">' . $item['name'] . '</li>';
                        echo '</ul>';
                    }
                    if ( $section['type'] === 'tools' ) {
                        echo '<ul class="cv-tools">';
                        echo '<li class="tool-item">' . $item['name'] . '</li>';
                        echo '</ul>';
                    }
                    echo '</div>';
                }
            }
            echo '</div>';
            echo '</div>';
        }
        echo '</div>';
        echo '</div>';
        echo '</div>';

        $show_footer = apply_filters( 'show_footer', true );
        if ( $show_footer && $isFooterVisible ) {
            echo '<div class="footer">';
            echo '<div class="footer-content">';
            echo '<a class="youtube-link" href="' . esc_url( $footer_link ) . '"><svg viewBox="0 0 1024 1024"><path d="M852.727563 392.447107C956.997809 458.473635 956.941389 565.559517 852.727563 631.55032L281.888889 993.019655C177.618644 1059.046186 93.090909 1016.054114 93.090909 897.137364L93.090909 126.860063C93.090909 7.879206 177.675064-35.013033 281.888889 30.977769L852.727563 392.447107 852.727563 392.447107Z"/></svg></a>';
            if ( !empty( $signature ) ) {
                echo '<img class="signature" src="' . esc_url( $signature['url'] ) . '" alt="Signature Image" />';
            } else {
                echo '<img class="signature" src="' . esc_url( $signature_image ) . '" alt="Signature Image" />';
            }
            echo '<a class="footer-btn" href="' . esc_url( $footer_btn_link ) . '">' . esc_html( $footer_btn_text ) . '</a>';
            echo '</div>';
            echo '</div>';
        }
        echo '</div>';
        echo '</div>';
    }

    echo '</div>';
    do_action( 'bwdcv_custom_download_button' );
    if ( !current_user_can( 'administrator' ) ) {
        // ffffff
        $current_user = wp_get_current_user();
        $user_id = esc_html( $current_user->ID );
        $cv_page_id = get_user_meta( $current_user->ID, 'cv_page_id', true );
        $edit_cv_url = '';
        if ( $cv_page_id ) {
            $edit_cv_url = add_query_arg( array(
                'post'   => $cv_page_id,
                'action' => 'edit',
            ), admin_url( 'post.php' ) );
        }
        $getEditLink = '<a href="' . esc_url( $edit_cv_url ) . '" class="wer dash-edit-cv bwdcv-view-edit-btn">' . esc_html( get_option( 'cv_edit_bwd', __( 'Edit CV', 'cv-builder' ) ) ) . '</a>';
        if ( is_user_logged_in() ) {
            $user_id = $current_user->ID;
            $orders = wc_get_orders( [
                'customer_id' => $user_id,
                'limit'       => -1,
                'status'      => ['completed', 'processing'],
            ] );
            if ( !empty( $orders ) ) {
                $show_download_info = apply_filters( 'bwdcv_show_download_info', true );
                if ( $show_download_info ) {
                    echo '<h1 class="bwdcv-download-info-title">' . get_option( 'cv_download_info_title_bwd', 'Download Information...' ) . '</h1>';
                    echo '<table class="wp-list-table widefat fixed striped striped-table" style="margin-top: 20px;">';

                    // For download button
                    $options = get_option( 'bwd_userfronted_options' );
                    if ( $options['subscription_page'] == 'It\'s Free' ) {
                        $get_permalink = '';
                        $get_class = 'bwd-download-text';
                    } elseif ( isset( $options['subscription_page'] ) && !empty( $options['subscription_page'] ) ) {
                        $get_permalink = get_permalink( $options['subscription_page'] );
                        $get_class = '';
                    }

                    // Table header
                    echo '<thead>
                        <tr>
                            <th>' . esc_html__( 'Plan Name', 'cv-builder' ) . '</th>
                            <th>' . esc_html__( 'Download Limit', 'cv-builder' ) . '</th>
                            <th>' . esc_html__( 'Billing Period', 'cv-builder' ) . '</th>
                            <th>' . esc_html__( 'Total Downloads', 'cv-builder' ) . '</th>
                            <th>' . esc_html__( 'Purchase Date', 'cv-builder' ) . '</th>
                            <th>' . esc_html__( 'Expire Date', 'cv-builder' ) . '</th>
                            <th>' . esc_html__( 'Action', 'cv-builder' ) . '</th>
                        </tr>
                    </thead>';
                    echo '<tbody>';

                    $total_downloads = 0;
                    foreach ( $orders as $order ) {
                        $order_id = $order->get_id();
                        $order_total = $order->get_total();

                        $purchase_date = $order->get_date_created();
                        $formatted_purchase_date = $purchase_date ?
                        $purchase_date->setTimezone( new \DateTimeZone( wp_timezone_string() ) )->format( 'Y-m-d' ) : esc_html__( 'N/A', 'cv-builder' );

                        $items = $order->get_items();
                        foreach ( $items as $item ) {
                            $product_id = $item->get_product_id();
                            $product_name = $item->get_name();
                            $plan_name = get_post_meta( $product_id, '_subscription_plan_name', true );

                            $cv_download = $order->get_meta( '_subscription_per_download', true );
                            if ( $cv_download === '' || $cv_download === null || $cv_download === false ) {
                                $cv_download = get_post_meta( $product_id, '_subscription_per_download', true );
                                $cv_download = is_numeric( $cv_download ) ? (int) $cv_download : 0;
                                $order->update_meta_data( '_subscription_per_download', $cv_download );
                                $order->save();
                            } else {
                                $cv_download = is_numeric( $cv_download ) ? (int) $cv_download : 0;
                            }

                            $order_total_downloads = (int) $order->get_meta( '_total_downloads', true );
                            $total_downloads += $order_total_downloads;

                            $subscription_billing_period = (int) $order->get_meta( '_subscription_billing_period', true );
                            if ( !$subscription_billing_period ) {
                                $subscription_billing_period = get_post_meta( $product_id, '_subscription_billing_period', true );
                                $order->update_meta_data( '_subscription_billing_period', $subscription_billing_period );
                                $order->save();
                            }
                            echo '<tr>';
                            if ( $plan_name ) {
                                echo '<td>' . esc_html( $plan_name ? $plan_name : esc_html__( 'N/A', 'cv-builder' ) ) . ' (' . wp_kses_post( wc_price( $order_total ) ) . ') </td>';
                                $subValid = empty( $subscription_billing_period ) ? $cv_download : esc_html__( 'Unlimited', 'cv-builder' );
                                echo '<td class="cv-download-cell">' . esc_html( $cv_download ? $subValid : esc_html__( 'N/A', 'cv-builder' ) ) . '</td>';
                                $dayValid = $subscription_billing_period >= 2 ? ' Days' : ' Day';
                                echo '<td>' . esc_html( $subscription_billing_period ? ucfirst( $subscription_billing_period ) : esc_html__( 'N/A', 'cv-builder' ) ) . $dayValid . '</td>';
                                echo '<td class="total-download-cell">' . esc_html( $order_total_downloads ) . '</td>';
                                echo '<td>' . esc_html( $formatted_purchase_date ) . '</td>';

                                $expire_date = '';
                                if ( $subscription_billing_period ) {
                                    $billing_days = 0;
                                    if ( $subscription_billing_period == '1' ) {
                                        $billing_days = 1;
                                    } elseif ( $subscription_billing_period == '30' ) {
                                        $billing_days = 30;
                                    } elseif ( $subscription_billing_period == '90' ) {
                                        $billing_days = 90;
                                    } elseif ( $subscription_billing_period == '183' ) {
                                        $billing_days = 183;
                                    } elseif ( $subscription_billing_period == '365' ) {
                                        $billing_days = 365;
                                    }
                                    if ( $purchase_date && $billing_days ) {
                                        $purchase_date_obj = new \DateTime( $formatted_purchase_date );
                                        $purchase_date_obj->modify( "+$billing_days days" );
                                        $newDate = $purchase_date_obj->format( 'Y-m-d' );
                                        $expire_date = $subscription_billing_period ? $newDate : '';
                                    }
                                } else {
                                    $expire_date = esc_html__( 'Unlimited', 'cv-builder' );
                                }
                                echo '<td>' . esc_html( $expire_date ) . '</td>';
                                echo '<td>';
                                $expireCheck = '';
                                if ( \DateTime::createFromFormat( 'Y-m-d', $expire_date ) !== false ) {
                                    $expireCheck = $expire_date;
                                }
                                $current_date = date( "Y-m-d" );
                                if ( $cv_download >= 1 || $current_date <= $expireCheck ) {
                                    echo '<button class="bwd-download-text" data-order-id="' . esc_attr( $order_id ) . '" data-cv-download="' . esc_attr( $cv_download ) . '" data-subscription-billing-period="' . $subscription_billing_period . '">' . esc_html( get_option( 'cv_download_bwd', __( 'Download', 'cv-builder' ) ) ) . '</button>';
                                    echo $getEditLink;
                                } else {
                                    $options = get_option( 'bwd_userfronted_options' );
                                    echo '<a class="bwd-expire-text" href="' . get_permalink( $options['subscription_page'] ) . '" target="_blank">' . esc_html( get_option( 'cv_anew_bwd', __( 'Renew', 'cv-builder' ) ) ) . '</a>';
                                }
                                echo '</td>';
                            } else {
                                echo '<div class="bwd-downl-btn">';
                                echo '<button class="bwd-download-text">' . esc_html( get_option( 'cv_download_bwd', __( 'Download', 'cv-builder' ) ) ) . '</button>';
                                echo $getEditLink;
                                echo '</div>';
                            }
                            echo '</tr>';
                        }
                    }

                    echo '</tbody>';
                    echo '</table>';
                    echo '<p><strong>' . esc_html__( 'Total Downloads:', 'cv-builder' ) . '</strong> ' . esc_html( $total_downloads ) . '</p>';
                }
            } else {
                // render_cv_download_button( $style, $getEditLink, $subscription_orders = [] );
                render_cv_download_button( $style, $getEditLink, isset($subscription_orders) ? $subscription_orders : [] );
            }
        }
        // Social share
        if ( get_option( 'cv_social_share' ) == 'on' ) {
            $current_url = urlencode( esc_url( get_cv_page_token_url() ) );
            $share_url = esc_url( get_cv_page_token_url() );
            ?>
            <h3 style="text-align: center"><?php esc_html_e( 'Share', 'cv-builder' ); ?></h3>
            <div class="social-share-buttons" style="text-align: center; margin: 20px 0; font-size: 24px;">
                <a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo $current_url; ?>" target="_blank" onclick="window.open(this.href, 'social-share', 'width=600,height=400,left=' + (window.innerWidth / 2 - 300) + ',top=' + (window.innerHeight / 2 - 200) + ''); return false;" style="text-decoration: none; margin: 0 10px; color: #4267B2;">
                    <i class="fa-brands fa-facebook"></i>
                </a>
                <a href="https://twitter.com/intent/tweet?url=<?php echo $current_url; ?>" target="_blank" onclick="window.open(this.href, 'social-share', 'width=600,height=400,left=' + (window.innerWidth / 2 - 300) + ',top=' + (window.innerHeight / 2 - 200) + ''); return false;" style="text-decoration: none; margin: 0 10px; color: #1DA1F2;">
                    <i class="fa-brands fa-twitter"></i>
                </a>
                <a href="https://www.linkedin.com/shareArticle?mini=true&url=<?php echo $current_url; ?>" target="_blank" onclick="window.open(this.href, 'social-share', 'width=600,height=400,left=' + (window.innerWidth / 2 - 300) + ',top=' + (window.innerHeight / 2 - 200) + ''); return false;" style="text-decoration: none; margin: 0 10px; color: #0077B5;">
                    <i class="fa-brands fa-linkedin-in"></i>
                </a>
                <a href="https://api.whatsapp.com/send?text=<?php echo $current_url; ?>" target="_blank" onclick="window.open(this.href, 'social-share', 'width=600,height=400,left=' + (window.innerWidth / 2 - 300) + ',top=' + (window.innerHeight / 2 - 200) + ''); return false;" style="text-decoration: none; margin: 0 10px; color: #25D366;">
                    <i class="fa-brands fa-whatsapp"></i>
                </a>
                <a href="mailto:?subject=Check this out&body=<?php echo $current_url; ?>" style="text-decoration: none; margin: 0 10px; color: #D44638;">
                    <i class="fa-regular fa-envelope"></i>
                </a>
                <a href="https://pinterest.com/pin/create/button/?url=<?php echo $current_url; ?>" target="_blank" onclick="window.open(this.href, 'social-share', 'width=600,height=400,left=' + (window.innerWidth / 2 - 300) + ',top=' + (window.innerHeight / 2 - 200) + ''); return false;" style="text-decoration: none; margin: 0 10px; color: #E60023;">
                    <i class="fa-brands fa-pinterest-p"></i>
                </a>
                <a href="https://reddit.com/submit?url=<?php echo $current_url; ?>" target="_blank" onclick="window.open(this.href, 'social-share', 'width=600,height=400,left=' + (window.innerWidth / 2 - 300) + ',top=' + (window.innerHeight / 2 - 200) + ''); return false;" style="text-decoration: none; margin: 0 10px; color: #FF4500;">
                    <i class="fa-brands fa-reddit-alien"></i>
                </a>
                <a href="https://telegram.me/share/url?url=<?php echo $current_url; ?>" target="_blank" onclick="window.open(this.href, 'social-share', 'width=600,height=400,left=' + (window.innerWidth / 2 - 300) + ',top=' + (window.innerHeight / 2 - 200) + ''); return false;" style="text-decoration: none; margin: 0 10px; color: #0088cc;">
                    <i class="fa-brands fa-telegram"></i>
                </a>
                <a href="https://www.tumblr.com/widgets/share/tool?canonicalUrl=<?php echo $current_url; ?>" target="_blank" onclick="window.open(this.href, 'social-share', 'width=600,height=400,left=' + (window.innerWidth / 2 - 300) + ',top=' + (window.innerHeight / 2 - 200) + ''); return false;" style="text-decoration: none; margin: 0 10px; color: #35465C;">
                    <i class="fa-brands fa-tumblr"></i>
                </a>
                <input type="text" id="hidden-url" value="<?php echo $share_url; ?>" style="position:absolute; left:-9999px;">

                <a href="#" onclick="fallbackCopy(); return false;" style="text-decoration: none; margin: 0 10px; color: #000;">
                    <i class="fa fa-link"></i>
                </a>
                <script>
                function fallbackCopy() {
                    var input = document.getElementById("hidden-url");
                    input.select();
                    document.execCommand("copy");
                    alert("Link copied to clipboard!");
                }
                </script>
            </div>
            <?php
}
        // ffffff
    }
    $output = ob_get_clean();
    return $output;
}