Support » Plugin: PDF Flipbook, 3D Flipbook WordPress - DearFlip » Problem: Shortcode parser only loaded on frontend

  • JS

    (@joaosaraiva)


    Hello.
    While analyzing why the dflip shortcode exhibited problems when used in conjunction with our plugin (Paperview Publisher), I noticed that the shortcode parser is only loaded when the request is in a frontend context; when in a backend context, the parser is not loaded. This, in turn, makes “apply_filters(‘the_content’, <content to filter>)” not return the content with the shortcode replaced by the corresponding HTML when it is invoked in the backend (in this specific case, in a plugin that runs in wp-admin, when there is new post content).

    The problematic snippet is in 3d-flipbook-dflip-lite.php, line 554:

    // Load admin only components.
     if ( is_admin() && !wp_doing_ajax() ) {
       $this->init_admin();
     } else { // Load frontend only components.
       $this->init_front();
     }

    My suggestion is to include the unconditional loading of the shortcode parser, like this:

    //include the shortcode parser
     include_once dirname( __FILE__ ) . "/inc/shortcode.php";
    
     // Load admin only components.
     if ( is_admin() && !wp_doing_ajax() ) {
       $this->init_admin();
     } else { // Load frontend only components.
       $this->init_front();
     }

    (The include_once is extracted from init_front. It can be removed from the function afterward, or just left there, as the code won’t be loaded again anyway.)

    I understand that you try to load only the necessary components, and that is fine. However, IMHO, loading the shortcode parser is not a particularly cumbersome or heavy operation (especially if PHP has a caching mechanism configured), but not loading it may lead to the ‘the_content’ filter not returning the expected results when run in the wp-admin context.

    Thank you for your time.

    Best regards,
    João Saraiva (Paperview Systems)

  • You must be logged in to reply to this topic.