Sure, that's also another approach. I continued the series by only relying on the register method in all the controllers and leaving the construct only in the BaseController. Cheers
Best , THE BEST tutorials on RUclips. Sincerity and Concern for all. Thanks for such a beautiful set of tutorials. Anyone with a burning desire to learn, cannot miss these tutorials. Amazing!!
Hi Alex, my php errors are not easily readable like yours. For example at 2:43 you have the table with the orange heading and the stack trace, how can I enable this error output for myself?
Hi. Part from making you a chair next to the gods as a well earned compliment, I also have a question. @11:23 there is a call to array($this->callbacks,'adminDasboard'). I thought I could do $this->callbacks->adminDasboard(), but the page structure changes with admin.php being attached to the body tag. It baffles me. Do you have any insight on why that behavior is different from using an array call?
Sure, but I didn't want to make the behavior inconsistent. I prefer to have all the controllers to behave equally and as expected, so moving everything into a register() method makes more sense for me. Cheers
Hi Alex, First of all thanks a lot for this awesome plugin development series. why using parent:__construct makes the code consistent ? what could be future problems ? is using parent: __construct totally equivalent or are there some drawbacks ?
Hi Alex, how can I get the source code of it? Is there any starter plugin things so that we can use it as a starting point? Your structure looks brilliant!
Yes, true, but I didn't want to do that in order to keep the structure and behavior of my plugin consistent, all the controllers triggering their own register method. Cheers
Alessandro Castellani i understand, i like your course, can you maybe share where you get your resources for the course? I want to implement a contact button widget... thank you
Hello Alex. I'm not good with OOP so a question comes in my mind. We've created so many classes for our plugin so, Is it possible that we could have conflict classes with other plugins when use our plugin on real WordPress site?
That's one of the many pros of using OOP. Everything is based on the initial class, and with composer autoload, you just need to update the first unique name of your base class and everything will work. Classes won't interfere with other plugins because are located in different directories and not used via require() or include()
Dear Sir, Excellent WordPress tutorials over the internet! I have a question for this tutorials if I use the following code for callback, so is it correct? public function __construct() {
/** Just I use the parent constructor */ parent::__construct(); $this->settings = new SettingsApi(); $this->pages = array( array( 'page_title' => 'Alecaddd Plugin', 'menu_title' => 'Alecaddd', 'capability' => 'manage_options', 'menu_slug' => 'alecaddd_plugin', 'callback' => function() { return require_once wp_sprintf( '%s/templates/Admin.php',$this->plugin_path ); }, 'icon_url' => 'dashicons-store', 'position' => 110 ) );
} Finally, Everything is working properly. Waiting for your swift response!
Hello Alessandro, Im trying to ass custom post type in the plugin in to the structure you setup here, but non of your video shows how we do add custom post type here in plugin and make a hook in constructor, any tips ?
You are very inteligent man. I am not so ex[ert in php OOP. That's why I cant solve a problem. According to this video tutorial I follow it but I found this error Warning: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in D:\xampp\htdocs\learn\wp-includes\class-wp-hook.php on line 287 . Please reply it to solve my problem
developing this way only works locally, when going to an online server nothing works nor even composer.php. You should make a video showing how to install on the server.
My website and all the WordPress websites I built in the past 4 years are based on composer and use this method. Don't simply assume that an approach doesn't work only because it doesn't work for you, you don't want to misguide other users. The development should happen locally. When the software is ready, you should publish it on a live server and upload the vendor folder, without the necessity of running composer on a live server, which is not recommended because it's heavy and resource demanding. I'll make a video explaining this concept thoroughly. Thanks for watching
I swear to god, this is the best wp tutorial series I've ever seen in my life. Thank you very much for all your time and hard work on that.
Wow, thank you so much :D
Were you able to fix your issues from video 10?
Alessandro Castellani yes I’ve fixed it by removing the additional dot in ‘/vendor/autoload.php’
Hey Alex,
Just keep in mind you can avoid overridint the parent classes constructors by using parent::__construct(); inside the constructor :)
Sure, that's also another approach. I continued the series by only relying on the register method in all the controllers and leaving the construct only in the BaseController. Cheers
I was planning to ask same question, thanks
I'm too) Thx.
Same question from here, too. :)
But this is really great and useful tutorial!
Best , THE BEST tutorials on RUclips. Sincerity and Concern for all. Thanks for such a beautiful set of tutorials. Anyone with a burning desire to learn, cannot miss these tutorials. Amazing!!
Can't thank you enough, super informative and understandable and you are incredibly knowledgeable, thanks Alessandro!
Thanks for watching, I'm glad I was helpful.
Cheers
Why didn't you use parent::__construct() for calling the BaseController constructor, it's much easier.
I agree but perhaps it makes more sense further on in the tutorial. Dunno, still have to see it.
@Alessandro Castellani
This course is legit. Thank you for taking the time and making this, it has been really helpful.
You're very welcome :D
Hi Alex, my php errors are not easily readable like yours. For example at 2:43 you have the table with the orange heading and the stack trace, how can I enable this error output for myself?
This is very nice! :) I've learned a lot from this episode. Thank you, Alex! Thumb up!!! :)
Awesome to hear, thanks for watching :D
Thank you for your awesome tutorial. :)
Hi. Part from making you a chair next to the gods as a well earned compliment, I also have a question. @11:23 there is a call to array($this->callbacks,'adminDasboard'). I thought I could do $this->callbacks->adminDasboard(), but the page structure changes with admin.php being attached to the body tag. It baffles me. Do you have any insight on why that behavior is different from using an array call?
Amazing
Knowledge
great topic to explain Alessandro. Good explanation.
Thanks for watching
np problem, you are welcome sir!!!
Thanks for Great, Flawless Tutorial ^^
Thank you so much :D
at last another WordPrass Plugin tutorial after 2 week V_V . I am really relief :D . ohw and thanks for the tutorial
Cheers
it wasn't 2 weeks...just 9 days :P
but it feels like 1 year :/
Mr Alex ,, My respect .
Cheers
Great..........................Alessandro Castellani
Thanks..........................Mohammad Abdul Hye Shaon
You can also use parent::__construct(); in your Admin construct, and you will have access to your vars the way we would expect.
Sure, but I didn't want to make the behavior inconsistent. I prefer to have all the controllers to behave equally and as expected, so moving everything into a register() method makes more sense for me.
Cheers
Hi Alex,
First of all thanks a lot for this awesome plugin development series.
why using parent:__construct makes the code consistent ? what could be future problems ? is using parent: __construct totally equivalent or are there some drawbacks ?
Good, it's really MVC architecture !
Yup, a good architecture for a solid plugin system :D
Hi Alex, how can I get the source code of it? Is there any starter plugin things so that we can use it as a starting point? Your structure looks brilliant!
You can still use __construct():
public function __construct()
{
parent::__construct(); // initializes everything from the parent class
// code here
}
Yes, true, but I didn't want to do that in order to keep the structure and behavior of my plugin consistent, all the controllers triggering their own register method.
Cheers
hey alex my string in withSubPage doesn't work it won't change my menu_title into dashboard could you tel me why?
I think you can use "parent::__construct();" in the current class to call the BaseController contructor.
Sure, but I prefer not to in order to maintain code consistency and coherence.
Alessandro Castellani i understand, i like your course, can you maybe share where you get your resources for the course? I want to implement a contact button widget... thank you
Hello Alex. I'm not good with OOP so a question comes in my mind. We've created so many classes for our plugin so, Is it possible that we could have conflict classes with other plugins when use our plugin on real WordPress site?
That's one of the many pros of using OOP. Everything is based on the initial class, and with composer autoload, you just need to update the first unique name of your base class and everything will work.
Classes won't interfere with other plugins because are located in different directories and not used via require() or include()
Dear Sir, Excellent WordPress tutorials over the internet!
I have a question for this tutorials if I use the following code for callback, so is it correct?
public function __construct()
{
/** Just I use the parent constructor */
parent::__construct();
$this->settings = new SettingsApi();
$this->pages = array(
array(
'page_title' => 'Alecaddd Plugin',
'menu_title' => 'Alecaddd',
'capability' => 'manage_options',
'menu_slug' => 'alecaddd_plugin',
'callback' => function() {
return require_once wp_sprintf( '%s/templates/Admin.php',$this->plugin_path );
},
'icon_url' => 'dashicons-store',
'position' => 110
)
);
}
Finally, Everything is working properly. Waiting for your swift response!
Hello Alessandro, Im trying to ass custom post type in the plugin in to the structure you setup here, but non of your video shows how we do add custom post type here in plugin and make a hook in constructor, any tips ?
Keep watching the series and you will reach the part where I create a Custom Post Type Manager section
top!
Greeat :) thankssss
Cheers
Thanks for this wonderful course all beneficiaries should try and donate Alex Patreon acct in the above link.
You don't need to remove the constructor method, just put below code in your constructor
parent::__construct();
Sure, you can do that, but I wanted to avoid an inconsistent structure between files and trigger everything via the register method
You are very inteligent man. I am not so ex[ert in php OOP. That's why I cant solve a problem. According to this video tutorial I follow it but I found this error Warning: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in D:\xampp\htdocs\learn\wp-includes\class-wp-hook.php on line 287 . Please reply it to solve my problem
developing this way only works locally, when going to an online server nothing works nor even composer.php. You should make a video showing how to install on the server.
My website and all the WordPress websites I built in the past 4 years are based on composer and use this method.
Don't simply assume that an approach doesn't work only because it doesn't work for you, you don't want to misguide other users.
The development should happen locally.
When the software is ready, you should publish it on a live server and upload the vendor folder, without the necessity of running composer on a live server, which is not recommended because it's heavy and resource demanding.
I'll make a video explaining this concept thoroughly.
Thanks for watching
Tutto chiaro
i.postimg.cc/2y821HcP/boom.gif
Funziona!