Support » Plugin: PDF Embedder » Re: Pdf embedder not loading jsfiles

  • I came across this issue:

    Hi, i am trying use this plugin on my wordpress site, i structured my code with timber that is a template engine builded with twig.

    The problem with your plugin it’s because i need to have wp_head and wp_footer on my single.php and page.php. But i use twig template engine to separate files, create a better code structure, and i have that functions on separate files.

    Because i have wp_head and wp_footer on separate files, your .js files are not loading on the page.

    I had exactly the same issue as I use Twig templating and load scripts in the footer of the page.

    The suggested fix from Emma on the other thread would obviously not work as the scripts weren’t even loaded in the first place so haven’t modified the jQuery prototype.

    The problem is that insert_scripts() is called before pdfemb_wp_enqueue_scripts()
    I was able to fix the issue by inserting one line of code into the plugin.
    At line 26 of core_pdf_embedder.pdf in the insert_scripts() function:

    $this->pdfemb_wp_enqueue_scripts();

    This makes sure the scripts have been defined before they are enqueued.

    I’m not sure what PDF Embedder is doing differently but every other plugin manages to successfully embed scripts.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi, i think the plugin has changed. I added in line 26 your code and nothing happens. Can you take a look again please?

    Thread Starter IJMacD

    (@ijmacd)

    The important thing is that $this->pdfemb_wp_enqueue_scrips() is called before wp_enqueue_script( 'pdfemb_embed_pdf_js' )

    
    22	        protected function insert_scripts() {
    23	                if (!$this->inserted_scripts) {
    24	                        $this->inserted_scripts = true;
      24a + inserted line           $this->pdfemb_wp_enqueue_scrips(); // NEW LINE
    25	                        wp_enqueue_script( 'pdfemb_embed_pdf_js' );
    26	                       
    27	                        wp_enqueue_script( 'pdfemb_pdf_js' );
    28	                       
    29	                        wp_enqueue_style( 'pdfemb_embed_pdf_css', $this->my_plugin_url().'css/pdfemb-embed-pdf-'.$this->PLUGIN_VERSION.'.css', array(), $this->PLUGIN_VERSION );
    30	                }
    31	        }
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Re: Pdf embedder not loading jsfiles’ is closed to new replies.