Broken with WP 5.0
-
Seems this plugin breaks when updating to WordPress 5.
Has a conflicting function that had already been defined by what looks like WP itself.
-
Seems that WordPress 5.0 with the new editor is using a function named “has_blocks” yes. Easy fix for this is to change the function name for the plugin.
Only one file needs to be updated. Open “plugins/multiple-content-blocks/assets/inc/template-tags.php”.
Use an editor to replace all occurrences of
has_blockwith for exampleaddon_has block. You might also want to changethe_blockwithaddon_the_block.You will also have to update the function name in your template files. Then it should work fine again.
This fix didn’t work for me I still get the same error
Fatal error: Cannot redeclare has_block() (previously declared in /home/nck/public_html/wp-includes/blocks.php:81)
Are you sure that you have updated the right place?
Line 62 intemplate-tags.phpshould look like this:function addon_has_block( $name, $args = array() ) {OK it does seem to be working now. I changed the file before updating to WP 5. Not sure if this made a difference or not.
Thanks for the fix though! I use this plugin a lot so very helpful.
Nope sorry my bad, does work!
-
This reply was modified 6 years, 11 months ago by
montey11.
This is Broken with WP 5.0, that fix did work for me.
Thanks, the fix worked for me!
Thanks @pmbs, that worked. I only applied the first change (has_block > addon_has_block) and it worked perfectly.
worked like a charm – thanks for the save! π
Hi there
Wiiii – Got it working π
Though .. when i edit my page is says : multiple-content-blocks (inactive)How can i active theese blocks?
Read something like : https://www.bleepingcomputer.com/forums/t/555074/plugin-multiple-content-blocks-not-appearing-on-wordpress-site/But i just donΒ΄t get it
Really hope you can help
Cheers
/Kimo1) I recommend using the prefix mcb_ (short for multiple content blocks), so the function names will be mcb_the_block(), mcb_has_block(), mcb_get_the_block(). The plugin already defines other functions with the same name so this prefix is logical.
2) I recommend changing your theme code that uses has_block() / the_block() using function_exists(). That way, the site wont display fatal errors / display a white screen.
-
This reply was modified 6 years, 9 months ago by
Ruben Vincenten.
Thanks so much @pmbs it worked for me!
-
This reply was modified 6 years, 11 months ago by
The topic ‘Broken with WP 5.0’ is closed to new replies.