Filter dependencies slug (WP 6.5)
M
Marc Bellêtre
Hi,
Wordpress 6.5 will add support for plugin dependencies (see https://make.wordpress.org/core/2024/03/05/introducing-plugin-dependencies-in-wordpress-6-5/)
The Pro version will have to use the new
wp_plugin_dependencies_slug
filter so the plugin requiring ACF can also work with ACF Pro.add_filter('wp_plugin_dependencies_slug', function ($slug) {
if ('advanced-custom-fields' === $slug) {
$slug = 'advanced-custom-fields-pro';
}
return $slug;
});
Iain Poulson
open
Iain Poulson
closed
Iain Poulson
Hey Marc Bellêtre ACF PRO actually contains the ACF codebase and runs independently of the free plugin. When you activate ACF PRO it actually deactivates the free plugin. Therefore we don't need to add this dependency code - but appreciate the heads up!
M
Marc Bellêtre
Hi Iain Poulson,
I'm sorry but I think you misunderstood the problem here.
Wordpress 6.5 is adding a new feature that enables plugins and themes to require other plugins. I built a plugin which provides a new field type to ACF so this new feature is great because I now can make ACF a requirement.
The problem is that ACF and ACF Pro have different slugs:
advanced-custom-fields
and advanced-custom-fields-pro
. But my plugin can work with one or the other. Currently if I require advanced-custom-fields
I get an alert if ACF Pro is activated and the other way around.Wordpress 6.5 provides a filter that enable plugins to change their slug for this new dependency feature. This way when a plugin or a theme requires
advanced-custom-fields
and ACF Pro is installed, it is detected as an alias of ACF.You can try it out by creating a simple plugin that requires
advanced-custom-fields
or with my plugin here: https://github.com/marcbelletre/acf-rrule/tree/plugin-dependenciesCheers
Iain Poulson
Marc Bellêtre Apologies for the misunderstanding and thank you for the extra context!