• Resolved juaalton

    (@juaalton)


    The shortcode e.g., [pdfev_embed_viewer id=”99530″] seems to provide empty view and inspecting the html shows that the data-pdfev-url is empty string even though the id is in place and is correct.

    In functions.php:

    176	        public static function shortcode_view($post_id){
    177 $link = \PDFEV_Functions::get_pdf_link();
    178 $flipbook = get_option('pdfev_flipbook_status');

    $post_id is passed but discarded, and get_pdf_link() uses get_the_ID() instead.

    “However, this function only works correctly within The Loop or when global $post is properly set”. I tested by modifying the code so that $post_id is used (and not get_the_ID()), and the PDF was shown correctly.

    Has anyone else noticed problems with this shortcode?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Shahadat Hossain

    (@raselsha)

    Hi @juaalton,

    Thank you for your ticket. I’ll check and debug if this is a bug. But no one noticed yet.

    Thread Starter juaalton

    (@juaalton)

    Thanks.

    It might be that this is related to my configuration only (intranet development site; Kadence child theme).

    I fixed the problem in my child theme’s functions.php:

    function pdfev_fixed_shortcode($atts) {
    $atts = shortcode_atts(
    array(
    'id' => '',
    ),
    $atts,
    'pdfev_fixed_viewer'
    );

    $post_id = intval($atts['id']);
    if ($post_id <= 0) {
    return '';
    }

    ob_start();

    // Set global $post so get_the_ID() works
    global $post;
    $original_post = $post;
    $post = get_post($post_id);
    setup_postdata($post);

    // Call original rendering logic
    if (class_exists('PDFEV_Functions')) {
    PDFEV_Functions::shortcode_view($post_id);
    }

    // Restore global $post
    $post = $original_post;
    wp_reset_postdata();

    return ob_get_clean();
    }
    add_shortcode('pdfev_fixed_viewer', 'pdfev_fixed_shortcode');

    osjewel

    (@osjewel)

    I am having the same issue, standard short code does not work. Post created from plugin does work.

    I need the shortcode

    Plugin Author Shahadat Hossain

    (@raselsha)

    Hi @osjewel ,
    We appreciate your reply for this bug. Please kindly download from our git-hub latest released version 1.3.9 if you not get updated notice in your dashboard. I hope your issue will be solved.

    https://github.com/raselsha/pdf-embed-viewer/releases

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.