Submind YouTube summaries
Thumbnail for Stop Fatal Errors and Plugin conflicts!! New WordPress 6.5 “Requires Plugins” Header

Stop Fatal Errors and Plugin conflicts!! New WordPress 6.5 “Requires Plugins” Header

Watch on YouTube

Video summary

WordPress 6.5 introduces a powerful new feature designed specifically for plugin developers known as "Requires Plugins," which addresses the critical issue of fatal errors caused by missing dependencies. In previous versions, if a custom-built plugin relied on other specific plugins to function correctly and those required components were deactivated or uninstalled by an administrator who lacked technical knowledge, the site would often break completely or display fatal error messages. This new capability allows developers to declare their necessary prerequisites directly within the plugin header file using the "Requires Plugins" field, ensuring that WordPress is aware of these external requirements before activation can even occur. By implementing this feature in code, a developer can instruct the core system to prevent the installation or activation of their plugin unless all specified dependencies are already active on the site. For instance, if a custom menu builder relies on both Elementor and Elementor Pro, adding them as required plugins means that attempting to activate the custom tool while either dependency is missing will result in an error message rather than silent failure. Furthermore, this mechanism creates a protective lock where administrators cannot deactivate or delete these essential supporting plugins without first deactivating the plugin that depends on them, effectively preventing accidental site breakage caused by uninformed management actions. The practical impact of this update extends beyond simple activation checks to maintaining overall site stability and integrity across various hosting environments. It solves a common scenario where non-technical managers might deactivate what they perceive as unused plugins without realizing that other critical functionality relies on them, thereby avoiding the need for complex custom coding workarounds or manual database edits to enforce dependencies. This built-in solution provides a robust safety net that ensures sites remain functional even when user permissions allow anyone to manage plugin states, significantly reducing support tickets and downtime associated with dependency conflicts in WordPress ecosystems.
Read the full video transcript
as a plug-in developer what would you do if you have a custom built plugin that's dependent on one two or three or whatever other number of plugins that it requires for it to function properly if someone deactivated those particular plugins and you're viewing your website it's actually going to break or even worst case scenario you have a fatal error if this is a problem that you want to solve then this video is for you you welcome back to the channel in today's video I'm going to show you one of the most powerful tools that I think WordPress has added to the core since version 6.5 and it helps developers actually level up on my screen you can see that I have three different plugins installed I have elementa elementa Pro and I also have this little plugin that I developed for Elemental widgets and eventually it allows you to add a menu like this that you can can actually edit using elementa and you can see right here I can actually go and change things like the background colors and change this to something that is a little bit Bluer and if I preview my changes you'll see that now I have this different blue background for my menu there's only one challenge this plugin that I have developed actually depends on elementa Pro and elementa and and if I choose to deactivate both of these plugins if we go back to our front end to preview this you'll see that this is actually broken and I can no longer edit this with elementa in any given time of day you can actually say that this is missing from my page now this is a huge problem because depending on who is managing your site you never know who is going to come and deactivate any given plugin now so what does WordPress 6.5 offer us to help us avoid this kind of issue it has what we call plug-in dependencies that allow this plugin that you're developing talk to the call and say please do not deactivate please do not uninstall do not delete this Plugin or I need this plugin before I can actually be activated so let's see how that looks like in code terms so I'm going to open up my my local server and I'm using local WP right here I'm going to open up my local WP and I'm going to open up this particular folder and when I drag and drop that folder you'll see that my editor opens up and I have all this new code that I can edit so in here I'm going to add one little simple rule inside my plugin header to speak to Wordpress and tell it hey I need this plugin I'm going to add requires plugins and that is in plural and right here I'm going to add the slug of the plugin that I'm telling WordPress that this is required for my plugin that I'm devoloping to actually work I'm going to go back to my browser and inside here I'm going to reload this page and you'll see that this is now screaming and saying this plugin is active but may not function because it requires or some required plugins are missing and you'll see right here it says it requires Elemental website builder more than just a builder which we have right here so this is actually telling me I need to activate it and if you look closely here this is grade out I can actually not delete elementa because elementa is required by my custom plugin so if I deactivate this you will see that I still need to activate to have this running so I cannot activate this because this is not active but the moment I activate it this is also active and I can activate it that's the beauty of this if I want to deactivate elementa this is not possible because this plugin actually requires it now I'm going to just go back into my code and I'm going to add one other dependency let's add elementa Pro if I open up my browser again I'm just going to deactivate all of these and on reload of our page you'll see that this plugin now cannot be activated until I have both element and element Pro actually active so if I activate one you'll still see that this is not activatable but if I activate the pro version of elementa as well now we have this option to activate this plugin and I cannot deactivate elementa no Pro until I actually deactivate this this is a powerful feature that's going to help stop the breakage of so many sites where you have a manager of a site who probably didn't participate in the building of it and does not know which particular plugins are actually required so to me this is the biggest feature that we could have had and it's taken a number of years to actually learn in Co but I'm happy that it is actually here and I don't have to do any crazy coding to actually get this done what do you think about this feature please let me know in the comments whether you'll be using it or if you have some other system that you use remember don't forget to like this video and share it with very many others who might benefit from it otherwise enjoy whatever you're coding