<?php
// Silence is golden.

	$settings = $this->get_settings_for_display();
    $id = $this->get_id();

    if( class_exists('SFWD_LMS') ) :
        $elementor_editor = \Elementor\Plugin::instance()->editor->is_edit_mode();
        if( $elementor_editor ) {
            $course_id = learndash_post_arr()[0];
        } else {
            $course_id = learndash_get_course_id();
        }
        
        if( is_user_logged_in() ) {
            $user_id = get_current_user_id();
        } else {
            $user_id = 0;
        }

        $course_certficate_link  = learndash_get_course_certificate_link( $course_id, $user_id );
        if ( $course_certficate_link && ! empty( $course_certficate_link ) ): ?>
        <div class="ld-alert ld-alert-success ld-alert-certificate">
            <div class="ld-alert-content">
                <div class="ld-alert-icon ld-icon ld-icon-certificate">
                    <img src="<?php echo esc_url( WKP_URL .'inc/learndash/images/medal.png'); ?>" alt="">
                </div>
                <div class="ld-alert-messages"><?php esc_html_e('You\'ve earned a certificate!','widgetkit-pro'); ?></div>
            </div>
            <a class="ld-button" href="<?php echo esc_url( $course_certficate_link ); ?>" target="_new"><?php esc_html_e('Download Certificate','widgetkit-pro'); ?></a>
        </div>
        <?php
        endif;

    else :
    ?>
        <div class="plugin-active-massage">
            <h3><?php esc_html_e('Please activate LearnDash LMS plugin first', 'widgetkit-pro');?></h3>
        </div>
    <?php
    endif;