TwisterMc / pdfjs-viewer-shortcode

A Wordpress plugin for embedding PDFs using Mozilla's Excellent PDF.js
https://wordpress.org/plugins/pdfjs-viewer-shortcode/
Apache License 2.0
7 stars 5 forks source link

Uncaught Error: Call to un defined function register_block_type() #4

Closed Now-Italy-Demo closed 3 years ago

Now-Italy-Demo commented 4 years ago

Once updated to 1.5.1 on Wordpress 4.8.14 I get HTTP 500 due to Call to un defined function register_block_type() in pdfjs-viewer.php on line 158.

Fixed by changing line 158 to:

    if ( function_exists( 'register_block_type' ) )  {
            register_block_type('blocks/pdfjs-block', array(
                    'editor_script' => 'gutenberg-pdfjs',
                    'editor_style' => 'gutenberg-pdfjs-edit-style',
                    'style' => 'gutenberg-pdfjs'
            ));
    }
TwisterMc commented 3 years ago

Ok, I never tested in WordPress 4.x. I need to update the documentation to require 5.0 or make this work in WordPress 4.x.

Might I ask why you haven't updated to 5.x yet?

TwisterMc commented 3 years ago

I'll get this fix added to the next version.

Now-Italy-Demo commented 3 years ago

Unfortunately we have some customisations and will need to test the upgrade first..... basically didn't have the time yet :)

Now-Italy-Demo commented 3 years ago

Thanks for picking this up. I think it's no big deal to just fix the documentation. Just wanted to make you aware that on 4.x it has a problem. Cheers.

octoxan commented 3 years ago

We're running ClassicPress on a lot of our sites, so they don't have Gutenberg. Fixed this issue with https://github.com/TwisterMc/pdfjs-viewer-shortcode/pull/7 so it's compatible with both WP 4.x, 5.x, and all CP versions.

TwisterMc commented 3 years ago

Should be fixed and ready to go.