Hello, a brand new year has arrived and today we want to begin making you aware of the changes we made in order to get the WordPress approval about our Divi Post Settings plugin submission (here the Series).
If you remember, in fact, when we went to submit our plugin a little problem was pointed out by the WordPress examinator. We quote below a part of the last Series post to resume the question:
The question in our case was the use of the ‘if exists’ function wrapping around our main function ‘et_single_settings_meta_box’ […] The use of this function, indeed, is not recommended by WordPress because it could conflict with other Themes or Plugins that have a function with the same name and that loading first could break your plugin at all […] we had an alternative way – as also suggested by the WordPress team itself – in order to avoid the use of the ‘if exists’ function and so we dive again into the code and modify it in order to do it ( […]essentially we had to remove the original theme metabox and rewrite a new custom metabox function, changing so the function names and avoiding so to redeclare the function in question).
Ok, so let’s get started showing in detail the changes we made to our code in order to get the plugin on the WordPress directory.
The solution is pretty simple; first of all we have to completely remove the original metabox that Divi add to our WordPress website.
So we open in our favorite editor the ‘class-divi-post-settings-admin.php’ file (located in the ‘admin’ folder) and just add this simple function:
We have also, of course, to add a line of code in our ‘class-divi-post-settins.php’ (located in ‘includes’) in order to hook the function on ‘admin_init’:
All done! Now if you try to create a new post (or also a page or project) no Divi metabox will be on the right.
You just have to remember that you need to remove the metabox by removing directly the action (see the ‘remove_action’ in the function above) and not by usinge the ‘remove_meta_boxes’ hook!
Ok, now is time to add our custom metabox just in place of the original Divi one; however, we don’t need to create a completely new one, we can simply create a function (this time we add the code directly in the main plugin file!) wrapping the same code we find in the Divi ‘functions.php’ file and just changing the third parameter (‘et_single_settings_meta_box’ in the original file) to ‘idivi_single_settings_meta_box’.
This will be the name of the following function in which all the metabox code will be (the same code we added in our third Series post).
All done, our code is now perfectly working without the need to redeclare the Divi function. WordPress is happy and we are too ’cause our code is even more well-written than before.
The approval is promptly arrived and our plugin happily in the WordPress directory.
See you next post!