WordPress Plugin Development - Part 16 - Dealing with Callbacks

Поделиться
HTML-код
  • Опубликовано: 3 дек 2024

Комментарии • 62

  • @dronesim
    @dronesim 6 лет назад +11

    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.

    • @alecaddd
      @alecaddd  6 лет назад +4

      Wow, thank you so much :D

    • @alecaddd
      @alecaddd  6 лет назад +2

      Were you able to fix your issues from video 10?

    • @dronesim
      @dronesim 6 лет назад +1

      Alessandro Castellani yes I’ve fixed it by removing the additional dot in ‘/vendor/autoload.php’

  • @Danielaviv
    @Danielaviv 6 лет назад +21

    Hey Alex,
    Just keep in mind you can avoid overridint the parent classes constructors by using parent::__construct(); inside the constructor :)

    • @alecaddd
      @alecaddd  6 лет назад +3

      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

    • @sevdamurat4455
      @sevdamurat4455 6 лет назад

      I was planning to ask same question, thanks

    • @yevheniirodkin751
      @yevheniirodkin751 4 года назад

      I'm too) Thx.

    • @nahraejin4770
      @nahraejin4770 4 года назад

      Same question from here, too. :)

    • @nahraejin4770
      @nahraejin4770 4 года назад

      But this is really great and useful tutorial!

  • @SpiritMeaning
    @SpiritMeaning 3 года назад

    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!!

  • @daniel_gsc
    @daniel_gsc 6 лет назад +2

    Can't thank you enough, super informative and understandable and you are incredibly knowledgeable, thanks Alessandro!

    • @alecaddd
      @alecaddd  6 лет назад

      Thanks for watching, I'm glad I was helpful.
      Cheers

  • @tolgaerdonmezorigamitutori1605
    @tolgaerdonmezorigamitutori1605 4 года назад +7

    Why didn't you use parent::__construct() for calling the BaseController constructor, it's much easier.

    • @MoneylessWorld
      @MoneylessWorld 3 года назад +1

      I agree but perhaps it makes more sense further on in the tutorial. Dunno, still have to see it.

  • @andrewlee7809
    @andrewlee7809 6 лет назад +2

    @Alessandro Castellani
    This course is legit. Thank you for taking the time and making this, it has been really helpful.

    • @alecaddd
      @alecaddd  6 лет назад

      You're very welcome :D

  • @bramjanssen8865
    @bramjanssen8865 5 лет назад

    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?

  • @gxgl
    @gxgl 7 лет назад +2

    This is very nice! :) I've learned a lot from this episode. Thank you, Alex! Thumb up!!! :)

    • @alecaddd
      @alecaddd  7 лет назад +1

      Awesome to hear, thanks for watching :D

  • @bdkoder
    @bdkoder 4 года назад

    Thank you for your awesome tutorial. :)

  • @djwave28
    @djwave28 4 года назад

    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?

  • @dipakjaiswal8966
    @dipakjaiswal8966 3 года назад

    Amazing
    Knowledge

  • @LearningSimplified
    @LearningSimplified 7 лет назад +1

    great topic to explain Alessandro. Good explanation.

  • @vroshabhisam5582
    @vroshabhisam5582 6 лет назад +2

    Thanks for Great, Flawless Tutorial ^^

    • @alecaddd
      @alecaddd  6 лет назад

      Thank you so much :D

  • @nobir98
    @nobir98 7 лет назад +1

    at last another WordPrass Plugin tutorial after 2 week V_V . I am really relief :D . ohw and thanks for the tutorial
    Cheers

    • @alecaddd
      @alecaddd  7 лет назад

      it wasn't 2 weeks...just 9 days :P

    • @nobir98
      @nobir98 7 лет назад

      but it feels like 1 year :/

  • @habibbellia2607
    @habibbellia2607 6 лет назад +1

    Mr Alex ,, My respect .

  • @MohammadAbdulHyeShaon
    @MohammadAbdulHyeShaon 7 лет назад +1

    Great..........................Alessandro Castellani

    • @alecaddd
      @alecaddd  7 лет назад

      Thanks..........................Mohammad Abdul Hye Shaon

  • @kevinmulholland4550
    @kevinmulholland4550 6 лет назад

    You can also use parent::__construct(); in your Admin construct, and you will have access to your vars the way we would expect.

    • @alecaddd
      @alecaddd  6 лет назад +1

      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

    • @matthieulormeau
      @matthieulormeau 6 лет назад

      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 ?

  • @maometus
    @maometus 6 лет назад +1

    Good, it's really MVC architecture !

    • @alecaddd
      @alecaddd  6 лет назад +1

      Yup, a good architecture for a solid plugin system :D

  • @sadekhossain9566
    @sadekhossain9566 5 лет назад

    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!

  • @mischl1
    @mischl1 6 лет назад

    You can still use __construct():
    public function __construct()
    {
    parent::__construct(); // initializes everything from the parent class
    // code here
    }

    • @alecaddd
      @alecaddd  6 лет назад

      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

  • @nefpiar5009
    @nefpiar5009 3 года назад

    hey alex my string in withSubPage doesn't work it won't change my menu_title into dashboard could you tel me why?

  • @notDacian
    @notDacian 7 лет назад

    I think you can use "parent::__construct();" in the current class to call the BaseController contructor.

    • @alecaddd
      @alecaddd  7 лет назад +1

      Sure, but I prefer not to in order to maintain code consistency and coherence.

    • @notDacian
      @notDacian 7 лет назад

      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

  • @kimcodemonkey
    @kimcodemonkey 6 лет назад +1

    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?

    • @alecaddd
      @alecaddd  6 лет назад +5

      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()

  • @technophile7024
    @technophile7024 5 лет назад

    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!

  • @Adnanlah
    @Adnanlah 6 лет назад

    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 ?

    • @alecaddd
      @alecaddd  6 лет назад

      Keep watching the series and you will reach the part where I create a Custom Post Type Manager section

  • @MrColins710
    @MrColins710 4 года назад

    top!

  • @webprogramming2707
    @webprogramming2707 5 лет назад +1

    Greeat :) thankssss

  • @techcanyon411
    @techcanyon411 5 лет назад

    Thanks for this wonderful course all beneficiaries should try and donate Alex Patreon acct in the above link.

  • @bitscoders
    @bitscoders 6 лет назад

    You don't need to remove the constructor method, just put below code in your constructor
    parent::__construct();

    • @alecaddd
      @alecaddd  6 лет назад

      Sure, you can do that, but I wanted to avoid an inconsistent structure between files and trigger everything via the register method

  • @monowarhossain7971
    @monowarhossain7971 4 года назад

    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

  • @carlosalbertobatistacruz
    @carlosalbertobatistacruz 6 лет назад

    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.

    • @alecaddd
      @alecaddd  6 лет назад

      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

  • @stpengineering
    @stpengineering 6 лет назад +1

    Tutto chiaro
    i.postimg.cc/2y821HcP/boom.gif
    Funziona!