Тёмный

Create a WordPress Plugin from Scratch - Part 3 - Basic PHP OOP 

Alessandro Castellani
Подписаться 99 тыс.
Просмотров 194 тыс.
50% 1

Опубликовано:

 

29 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 217   
@martinkaspar5095
@martinkaspar5095 2 года назад
Well dear Allesandro - this is very helpful - many thanks for the awesome rundown ... We look forward to the next video. Keep up the great work
@muhammadalirashed7330
@muhammadalirashed7330 5 лет назад
bless the way you pronounce UNINSTALL. Love all your vids.
@jephmat
@jephmat 4 года назад
I will probably start pronouncing it that way as well! :)
@manishzinzuwadiya7208
@manishzinzuwadiya7208 7 лет назад
very useful. waiting for next tutorial
@alecaddd
@alecaddd 7 лет назад
Thanks for watching
@post-nj8kc
@post-nj8kc 7 лет назад
when will the new video be online ? using this for my work , great tutorial
@alecaddd
@alecaddd 7 лет назад
New video coming in a couple of days. Happy to be helpful :D
@MichHusker
@MichHusker 4 года назад
Any reason the register_activation_hook and register_deactivation_hook aren't put in __construct method?
@JuanDanielOrnella
@JuanDanielOrnella 5 лет назад
Thanks for the tutorial!
@jcnation5393
@jcnation5393 Год назад
I created a plugin , but it doesn't have edit button like this, can you please help?
@yasirtahirkheli74
@yasirtahirkheli74 6 лет назад
super easy...too good.
@alecaddd
@alecaddd 6 лет назад
Thanks :D
@baodianco
@baodianco Год назад
I thought it's un-install, not uni-stall ?
@raj080288
@raj080288 6 лет назад
I'm getting the error below when I activate the plugin: Plugin could not be activated because it triggered a fatal error.
@alecaddd
@alecaddd 6 лет назад
Check my source code on Github to see if you have any typos or mistakes. Cheers
@slaklad4321
@slaklad4321 6 лет назад
why you cant access the activate method like this: alecadddPlugin->activate() ???
@alecaddd
@alecaddd 6 лет назад
It's a limitation of the WordPress hooks. If your method is inside a class, you need to pass an array with the instance of that class as a first parameter. Otherwise, WordPress expects a string that will use to call the `call_user_func` method of PHP.
@markgitau6647
@markgitau6647 5 лет назад
Goal of the video (OOP)0:20 Review of previous video 0:28 Start of lesson 1:13 How to define/declare a class 1:15 _class ClassName_ _{_ _//methods_ _}_ How to create a class instance (the object) 3:20 _className= new ClassName();_ Before you create a class instance it is important to check if the class exists 4:35 _if (class_exists('ClassName')) {_ _$className= new ClassName();_ _}_ Explain the purpose of a constructor 5:45 Syntax of creating a php constructor 7:45 _function __construct(){_ _}_ 10:20 WordPress has inbuilt methods that are triggered during different parts of the lifecycle of a plugin ie : On activation On deactivation On uninstall 11:38 We will create our own user defined functions that will be called when the above methods are triggered _function activate(){_ _}_ _function deactivate(){_ _}_ _function uninstall(){_ _}_ 12:43 We will then link each of our user defined methods to the respective inbuilt method using the syntax shown below _register_activation_hook(filename, array($class_instance_name,’activation_function_name’));_ _register_deactivation_hook(filename, array($class_instance_name,’deactivation_function_name’));_ For the filename argument, we will use __FILE__ Magic Constant _register_activation_hook(__FILE__, array($class_instance_name,’activation_function_name’));_ _register_deactivation_hook(__FILE__, array($class_instance_name,’ ’deactivation_function_name’));_
@satyamsahay238
@satyamsahay238 3 года назад
Your voice resembles to "Hickup" from the movie how to train your dragon...
@aminulgaffar6786
@aminulgaffar6786 4 года назад
The plugin generated 24 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.
@ahmedchouihi
@ahmedchouihi 2 года назад
I have same problem , how did you dealt with it?
@klaasdeeindbaas
@klaasdeeindbaas 4 года назад
At 15:55 I don't completely understand why the echo you put there will and actually does create the error. Since when would echoing from a php file not be possible? You seem to say it has something to do with (at which moment) the file header is ... read/sent? (if sent, then sent to where?) and the moment at which the activate function is called upon. That would seem to me like the function is called upon *before* the file is read by the wp system, but if that's the case then why the hell would wp call upon the function without first having read what is written inside the it?! And why don't the CPT creation and rewrite flush that you code in the following lesson generate errors? They're called upon in the same timespan (which is *within the activate function* ) as the echo here is ... ?:-/ Most likely my understanding is completely wrong, but please help me understand the order of things and the cause of the error correctly then. From what you tell about it in this vid I get no clue :'-(( Apart from that, I love this tutorial! I can code a bit but am used to coding at the back-end. I learn a lot from this channel :))
@Hmouhtar
@Hmouhtar 5 лет назад
I think that the way you're covering PHP is amazing! It is obviously necessary to understand the basics. Thanks!
@alecaddd
@alecaddd 5 лет назад
Thank you so much :D
@MrDevil0910
@MrDevil0910 Год назад
Hi Ale! What's going on ? Sorry, I really didn't understand what are the activation and deactivation hook and how they can be usefull for the building of my plugin! Can you kindly answer me ? PS Vedo adesso che sei italiano. Magari se rispondi in inglese, credo che qualcun altro possa beneficiarne. Grazie mille :)
@DanielTriesLife
@DanielTriesLife 4 года назад
hi, if you make the variable $alecadddPlugin inside the "if" statement above the register_activation_hook, how are you accessing it, shouldnt it only exist inside the if statement?
@justanotheryoutuber739
@justanotheryoutuber739 5 лет назад
marvellous work! I really enjoy your style of teaching (and the sublime text theme too ^^)
@lekhnathpandey860
@lekhnathpandey860 5 лет назад
Recoverable fatal error: Object of class PluginName could not be converted to string in C:\xampp\htdocs\wordpress-plugin\wp-includes\functions.php on line 1909 in register_activation_hook(__FILE__, array($plugin_name, 'activate'));
@ShivaniSingh-ed1ib
@ShivaniSingh-ed1ib 6 лет назад
Sir you are really doing a great job.thanks for the lessons they are really helpful.plz keep it up sir
@alecaddd
@alecaddd 6 лет назад
Thanks for watching :D
@sidehustlediscovery2285
@sidehustlediscovery2285 2 года назад
*ALL your content in FIRE* - *_BRILLIANT!!_* I see this was years and years ago... what are you up to these days?! I can imagine you probably work for _Elon,_ _Mark...,_ _Bill..._ *_all three?!_* - Adam M.
@bhan
@bhan 2 года назад
Good-Tutorials for the beginner who wants to start development in WordPress.
@stichtingmagnitude
@stichtingmagnitude 4 года назад
Great tutorial. All of this is very new to me, so I am glad with what you teach. (Just one very minor, totally unimportant thing..... You talk about "uni-stall"m but it is actual "un-install". :-) )
@VinceAggrippino
@VinceAggrippino 5 лет назад
All examples in the codex show opening curly braces inline. Never on a line by itself. -- make.wordpress.org/core/handbook/best-practices/coding-standards/php/#brace-style
@vishalchavda5766
@vishalchavda5766 7 лет назад
There is any up-coming tutorial series for PHP beginners or OOP for Beginners??
@alecaddd
@alecaddd 7 лет назад
I'm using the Plugin series to explain some OOP along the way. If more users will request it, I will do a series only on PHP after this one.
@vishalchavda5766
@vishalchavda5766 7 лет назад
Master Alessandro Castellani Yes I want to learn:D
@djin01
@djin01 6 лет назад
Please, do OOP!
@FrancisSuarez
@FrancisSuarez 6 лет назад
Maybe better to wrap your class within a negate class_exist condition checking other plugins haven't initialized or declared similar name within scope? if(!class_exists('AlecadddPlugin')){ class AlecadddPlugin{
@alecaddd
@alecaddd 6 лет назад
Sure, that's a good approach
@RADIOSCATRACHASUTAN
@RADIOSCATRACHASUTAN 6 лет назад
I didnt see u this reply before, noted same issue..
@kramer26
@kramer26 6 лет назад
I thought that too. Thanks for the clarification
@EvertvanIngen
@EvertvanIngen 3 года назад
"Uni Stall" *Un install ;)
@ashiqrahman4858
@ashiqrahman4858 6 лет назад
Its amazing to watch. I have just started this series but you know you are special. Mostly describing the OOP, just loving it. Thanks man
@alecaddd
@alecaddd 6 лет назад
Thank you so much :D
@reemosman2207
@reemosman2207 5 лет назад
you are amazing ما شاء الله good luck man
@alecaddd
@alecaddd 5 лет назад
Cheers
@hamdanibrahim9712
@hamdanibrahim9712 5 лет назад
Hi! Thank you for your series . I am working in PHP for the last 1 year . From today i have started learning wordpress from your series of wordpress .Hopefully it will be helpful .
@alecaddd
@alecaddd 5 лет назад
Thank you for watching and Happy Coding :D
@sangtuah
@sangtuah 5 лет назад
//How about this class SomePlugin { public function __construct() { register_activation_hook(__FILE__, array($this, 'activate')) ; // some others stuff ie: // Add Javascript and CSS for front-end display add_action('wp_enqueue_scripts', array($this, 'enqueue')); } public function enqueue() { wp_enqueue_script('js-name', plugins_url('js/somefile.js', __FILE__), array('jquery'), '1.0', true); wp_enqueue_style('style-name', plugins_url('css/somefile.css', __FILE__), null, '1.0'); } public function activate(){ } } //outside class you can instantiate this //you can also declare as global $skeleton whatever suit your need $skeleton = new SomePlugin();
@alecaddd
@alecaddd 5 лет назад
Sure, you can do that. Keep watching the series as we will learn many more cool approaches to OOP
@haiwang7645
@haiwang7645 7 лет назад
hey,Alessand.you are so amazing ,so nice and patient to share the knowledge of WP.I was previous a c and c++programmer for 3years .But now I am loving web dev and started WordPress two month ago ,from building up wp website to child theme and theme and plugins.Logical and structured programming is ok for me but lacking so basic ideas of the wp.i have created several plugins which can functional perform well but I think they don't fit well with wp rules .your beginner's course is so helpful for me.if you don't mind ,I can get contact with you of some questions.Anyway please continue to do more.
@alecaddd
@alecaddd 7 лет назад
Hi, thanks for watching. I'm glad my videos are helpful also for other developers that already know how to code these stuff :D If you want, you can come to the forum and write your questions there: forum.alecaddd.com Cheers
@peterkoutsoukalis2910
@peterkoutsoukalis2910 5 лет назад
Very clear and concise information very happy I found your videos. Definitely going to be watching more videos of yours after this tutorial!
@donte_henley
@donte_henley 3 года назад
This is probably the best quick explanation of procedural vs OOP I've seen!
@gricchastain6506
@gricchastain6506 2 года назад
Wow so long ago. And i been looking to only make a custom right click menu
@trisnakurniawan7813
@trisnakurniawan7813 5 лет назад
can you make tutorial how to create plugin to get external API to show the content from external API?
@billbob4456
@billbob4456 5 лет назад
I see people complaining about AC talking about php in these videos. If you do not know basic php then these videos are not for you. AC pretty much states this in his introduction video as well as the beginning of this video that you will have a hard time following the series if you do not understand php. From the WP developer site "A WordPress Plugin is a program or a set of one or more functions written in the PHP scripting language." These videos are extremely helpful to us who know php and want a fast track to build WP plugins. Thank you for these videos.
@alecaddd
@alecaddd 5 лет назад
Thank you so much :D
@prateekbhardwaj9943
@prateekbhardwaj9943 3 года назад
watch in 1.75 x for better experience
@alecaddd
@alecaddd 3 года назад
Bu then my voice will sound like a chipmunk
@rominaaliotta5180
@rominaaliotta5180 6 лет назад
Hello Ale ! great tutorial as ALWAYS!!! i have simple question : when you use register_activation_hook(__FILE__, array($alecadddPLugin, 'activate')); and you call the methos in the class using the array, could be doing using the PHP : register_activation_hook(__FILE__, $alecadddPlugin->activate()) ? thanks so much romy
@alecaddd
@alecaddd 6 лет назад
Mh, I'm not sure it'll work. The second parameter needs to be a function name written as a string, or a class passed as an array. That's the way WordPress recognizes what you need to trigger. In your example, you're trying to pass the method from within the class, but not as a string. I don't think WordPress will be able to handle that.
@rejowanahmed6819
@rejowanahmed6819 2 года назад
Can you share the name of the theme and font for your visual studio code?
@crazyidea9143
@crazyidea9143 4 года назад
how to disable wordpress undefined function in vscode intelepense?
@stpengineering
@stpengineering 5 лет назад
oh wow ... quindi posso creare in contemporanea con l'attivazione/disattivazione del plugin ulteriori elementi (pagine, cpt, ecc) questo è fantastico ...
@alecaddd
@alecaddd 5 лет назад
Yup, puoi fare tutto quello che ti pare l'esatto momento il plugin si attiva. Magic :P
@yashpatel-lu5bm
@yashpatel-lu5bm 4 года назад
plzz provide elementor plugin development video from backend
@swiftninjapro
@swiftninjapro 5 лет назад
Nice tutorial, very well explained :D I have some experience with java in android studio, and so far, php seems quite similar to java. following this tutorial I ran into an error, and spent probably double the length of the video trying to troubleshoot it, then when I read the error message for the 10th time, and looked closer at my code, I relized I forgot one of the most important rules of code: Don't Forget The Semicolon; the error was wordpress didn't recognize }, because I forgot to put a ";" after the command "echo $string" once I fixed it to "echo $string;" it worked as expected :D
@alecaddd
@alecaddd 5 лет назад
Yup, damn semicolon :P
@xcaliburrz7524
@xcaliburrz7524 6 лет назад
Im just a beginner and wonderign what software you're using to code? It would really help me a lot with the software you using since it has autocomplete feature.
@alecaddd
@alecaddd 6 лет назад
Sublime Text 3, here's a video about my setup: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-oHmPrjSzmwU.html
@ToskersCorner
@ToskersCorner 5 лет назад
I wish this covered more about plugins and not PHP. If people don't know basic PHP or object oriented concepts, they should go to a PHP tutorial first. A video on WordPress plugins should be only about WordPress plugins. I understand some off-the-cuff things, but there is too much irrelevant information. Either way, good video. Just find it a tad frustrating. I am specifically referring to the explanation of things such as code-convention such as the talking of camel case, and passing arguments, etc.
@alecaddd
@alecaddd 5 лет назад
Yeah, I see your point. I'm sorry for the frustration, but I decided to add this portion to the initial videos because lots of users asked for it and were confused by the OOP structure. You can watch the videos at 2x speed and quickly reach the part where we start coding the real plugin. Happy Coding
@ToskersCorner
@ToskersCorner 5 лет назад
@@alecaddd I understand. You can't please everyone. I am actually watching your WordPress theme tutorial, and that one is PERFECT.
@pyrotechnick420
@pyrotechnick420 5 лет назад
So I already have a PHP script that I want to turn into a Wordpress Plugin. I didn't use OOP when I wrote the code for my script so it would be nice to see how you set up the activate(), deactivate(), and uninstall() in a procedural way. Thanks for making these videos. EDIT: It turns out since I'm using AJAX in my script I have learn a lot more about how wordpress handles ajax requests
@silviupavel6966
@silviupavel6966 6 месяцев назад
great tutorial bro! it is still good in 2024 💯
@balanceit2207
@balanceit2207 7 лет назад
What use is the` if ( class_exists...` part? It's defined just above so it definitely does exist, no? It would make more sense to only create an instance if the class DOESN'T already exist, wouldn't it?
@mihajloilic5836
@mihajloilic5836 2 года назад
This is cool man, can't wait to see more examples. :)
@alecaddd
@alecaddd 2 года назад
Be sure to subscribe to not miss any video. Also, check the playlist where this video belongs to and you'll find 50 more related tutorials :D
@danldg9052
@danldg9052 6 лет назад
Again, in this video you are teaching PHP. You should put that in your title too. Seriously, no offence. Take it as a tip
@OliverWieland1981
@OliverWieland1981 6 лет назад
This is awesome. I'm curious though. There is a boilerplate plugin generator by Devin Vinson and Tom McFarlin (wppb.me and wppb.io for boilerplate)... these guys do not use OOP for activate/deactivate by the looks of it. Those guys are pretty heavyweight so I was curious what your thoughts are on their way of doing things. Ta.
@alecaddd
@alecaddd 6 лет назад
wpbb uses OOP for activate, the method is static. I went through all the different options and possibilities you can use in future videos. Personally, I think you can go the way you feel comfortable and how you think the code looks cleaner and easier to read. Happy Coding
@OliverWieland1981
@OliverWieland1981 6 лет назад
haha! that makes sense. I'm on part 10 now and saw your bit on static methods. makes sense. thanks for the awesome tutorials. i watched your premium wp theme one quite a while ago and it was also brilliant. for me you are teaching at the perfect level of detail.
@md.abulkalamazad4965
@md.abulkalamazad4965 6 лет назад
I think oop is a very describable things....
@tinkersro592
@tinkersro592 4 года назад
did you meant 'you install' or 'uninstall'?
@pixel1872
@pixel1872 7 месяцев назад
Thank you soo much for this lesson
@nobir98
@nobir98 7 лет назад
wow nice Alex brother :D
@alecaddd
@alecaddd 7 лет назад
Thank you so much :D
@raihanhaquexyz
@raihanhaquexyz 6 лет назад
hey, awesome video. it help me to know lot of thing about wordpress plugin
@alecaddd
@alecaddd 6 лет назад
Great to hear that :D
@shabee_k
@shabee_k 6 лет назад
Superb... Tnx for making this video.
@alecaddd
@alecaddd 6 лет назад
Thanks for watching :D
@sidneysousa3520
@sidneysousa3520 7 лет назад
Hi Alec, I just tried the code but I cannot see the post type name showing in the dashboard menu. I click on activate but the Books does not show in the dashboard.
@alecaddd
@alecaddd 7 лет назад
Did you check my source code on Github?
@sidneysousa3520
@sidneysousa3520 7 лет назад
Never mind sorry. I found the issue. I had put a boolean (true) inside single quotes. Happy coding
@SGDCTVDUBAI
@SGDCTVDUBAI 4 года назад
I did enjoy! Awesome stuff with a cup of coffee otherwise I normally get sleepy watching boring tone tutorials!
@dipakdhakal3008
@dipakdhakal3008 7 лет назад
You are awesome forever .... :P
@alecaddd
@alecaddd 7 лет назад
Well, some days I'm not that great, but I always try to keep my level of awesomeness above average :P
@rubenlopez302
@rubenlopez302 2 года назад
It will be easier to follow starting with the definition of a business need, then developing the corresponding in the plugin.
@cjfranca2004
@cjfranca2004 Год назад
construct is depreciate in 2023 rrsrsrsrsrsrs how to work now?
@cjfranca2004
@cjfranca2004 Год назад
function __construct($string){ echo $string; } this ok , not problem,
@avijitsarkar4516
@avijitsarkar4516 6 лет назад
dear what to do if i want to create multiple plugin in same wp site with the seed ( wp plugin repo ) you provided .
@alecaddd
@alecaddd 6 лет назад
You have to change the unique name of the folder, as well as the file, name of the plugin, and if you have some unique functions with a specific prefix name, also those.
@avijitsarkar4516
@avijitsarkar4516 6 лет назад
but want about composer namespace ? Do I need to change composer ( Inc ) to any other name . Bkz I have created a customised plugin seed and your seed is in the same site but when I activate my plugin it just repeats your seed 2 times . Have a look . Create another plying with same directory structure in your root plugin dir and active booth see what happens . If you want I can create a short video regarding to this issue and post you on fb or some other social site
@MrForund
@MrForund 7 лет назад
I get 'headers already sent' when outputting echo message when initalizing a new object
@alecaddd
@alecaddd 7 лет назад
Check my source code on Github, you probably have some blank space left in your PHP
@ForceDan
@ForceDan 5 лет назад
@@alecaddd I having the same problem. Can you send the link for your github project?
@kevin_neugebauer
@kevin_neugebauer 2 года назад
thanks! cool video!
@MrVictor2777
@MrVictor2777 6 лет назад
function activate() called BEFORE we send the headers with WP redirecting by clicking the Activate button in the Console, not AFTER the header was sent, man. If the function with 'echo' was called AFTER so there would be no mistake at all. For example: echo "Something"; // echo was called before header(); // the mistake in this line!
@alecaddd
@alecaddd 6 лет назад
Uh, yeah, that's what I meant. Did I say it wrong? :D Sorry for the confusion if I did, and thanks for pointing that out.
@g_chariton
@g_chariton 5 лет назад
Could you please tell us which autocomplete tool do you use? Thanks!
@rajeeshhit1947
@rajeeshhit1947 5 лет назад
what editor do you use
@VinceAggrippino
@VinceAggrippino 5 лет назад
The actual recommendation of the codex: "Class names should use capitalized words separated by underscores. Any acronyms should be all upper case." -- make.wordpress.org/core/handbook/best-practices/coding-standards/php/#naming-conventions
@alecaddd
@alecaddd 5 лет назад
I'm using the PHP PSR2 code convention, not the wordpress codex convention.
@nurakhtar8332
@nurakhtar8332 3 года назад
Your explanation is really helpful to learn. Getting interested!!
@MattKnowsTech
@MattKnowsTech 7 лет назад
You can also wrap the PHP class in an if statement like so: if(!class_exists('MyClass')) { class MyClass {} }
@alecaddd
@alecaddd 7 лет назад
Sure, you can do that. I personally don't like it because it forces me to rap the entire class around a condition, just a simple styling preference :D
@hamidhos8101
@hamidhos8101 4 года назад
Hi. master, where can i download source code of this course? which do you use editor? which plugin for autocomplete params function? thanks master.
@alecaddd
@alecaddd 4 года назад
Source code is on my GitHub repository, link in the description. I use VSCode with WordPress autocomplete extension.
@muhammadhassan6158
@muhammadhassan6158 4 года назад
Thank you soo much
@vahidmohagheghi
@vahidmohagheghi 7 лет назад
Hi Alex! It's a thrill to see your new tutorial series! I'm sorry to catch up so late! ANYWAY! Would you plz, tell us how to develop a plug-in to organize Wordpress uploads into different folders, based on file extension, size, etc. ?
@alecaddd
@alecaddd 7 лет назад
Hi, thanks for watching. I wouldn't recommend trying to achieve something like that. WordPress organises the files in year/month based folders, and you shouldn't hack the default folder structure or you risk to break your installation.
@slimaidar2272
@slimaidar2272 7 лет назад
another legendary tuto
@alecaddd
@alecaddd 7 лет назад
Thank you so much :D
@trevordllewellyn
@trevordllewellyn 6 лет назад
What editor are you using? Love the videos!
@alecaddd
@alecaddd 6 лет назад
VSCode
@RADIOSCATRACHASUTAN
@RADIOSCATRACHASUTAN 6 лет назад
I am at the biginning of tut, I see two issues, you should wrap the class definition and instatiate the class inside the if class_exists otherwise there is risk of collition with other pluging, and you dont pass undefined $vars to the $hooks.. I love this tuts.
@alecaddd
@alecaddd 6 лет назад
The first 10 videos of this series are just an intro to PHP and OOP, it won't be the actual plugin structure. Things will change drastically :D
@danishiqbal9826
@danishiqbal9826 4 года назад
nice work .where this code we coud find??
@alecaddd
@alecaddd 4 года назад
GitHub repository link is in the description of the video.
@bitsinmyblood
@bitsinmyblood 4 года назад
groundhog day
@cristianbytes2621
@cristianbytes2621 5 лет назад
I dont understand the error about headers were already sent before bla bla
@akhilauguestine9922
@akhilauguestine9922 5 лет назад
great video this video helped me a lot to customize my plugin
@ananyamahapatra6597
@ananyamahapatra6597 4 года назад
Thanks for the clear picture buddy😊
@slaklad4321
@slaklad4321 6 лет назад
Good tutorial, but not because of oop the the functions scopes are private... even in procedural functions scope is always private.
@alecaddd
@alecaddd 6 лет назад
Sure, thanks for pointing that out.
@elkhanhamet2561
@elkhanhamet2561 3 года назад
Amazing, amazing, amazing !!! Thanks again Alessandro!!!
@weiwei5260
@weiwei5260 4 года назад
youinstall
@onemandream1
@onemandream1 5 лет назад
What kinna plugin we are creating? whats the objective? where we are? what is next? what's the goal ?!
@alecaddd
@alecaddd 5 лет назад
Lol, keep watching the videos :D
@Omeostatica
@Omeostatica 6 лет назад
Why can't you simply use $alecadddPlugin->activate()?
@alecaddd
@alecaddd 6 лет назад
The WordPress hooks and actions don't like calling OOP classes directly as an attribute, but it requires an array with the class and method as separated parameters. Not sure if it was changed recently.
@dyanbonke
@dyanbonke 5 лет назад
Nice one, Happy coding
@alecaddd
@alecaddd 5 лет назад
Cheers
@sandro6691
@sandro6691 5 лет назад
Part 3: Basic PHP object oriented programming - creating and initializing classes and passing parameters with construct method - built in wordpress functions and hooks - activation, deactivation.
@alecaddd
@alecaddd 5 лет назад
Thanks for the topic recap :D
@sandro6691
@sandro6691 5 лет назад
@@alecaddd Thank you for the tutorial! I've been following along and enjoying it. Great job!
@sudhakarsudha9655
@sudhakarsudha9655 7 лет назад
Excellent giving nice explanation of oops
@alecaddd
@alecaddd 7 лет назад
Thanks, hopefully, is not too overwhelming and it'll remain easy to understand
@sudhakarsudha9655
@sudhakarsudha9655 7 лет назад
explain more brief you know
@websepantadevelopers7781
@websepantadevelopers7781 6 лет назад
fantastic learning ...
@alecaddd
@alecaddd 6 лет назад
Thanks :D
@CJ-pd7xg
@CJ-pd7xg 6 лет назад
I am enjoying the tutorial very much but just as a tip, it would have been much more useful if you didn't show us 3 ways of doing something that will cause an error first before just showing us what the correct way is. You do a very good job IMO of explaining OOP overall however.
@alecaddd
@alecaddd 6 лет назад
That's kinda my way of teaching. I like to show the most common mistakes an inexperienced developer could make and the issues he could stumble upon. Personally, I find it very insightful and useful, I'm sorry if it doesn't resonate with you or makes the tutorial a bit boring :D Thanks for watching anyway, and always Happy Coding
@CJ-pd7xg
@CJ-pd7xg 6 лет назад
I love the tutorial man, and I appreciate the information. That was my only nit picky critic is all. Thank you and keep up the great work.
@juliandarley
@juliandarley 4 года назад
​@@alecaddd although i understand Carl's point, i really appreciate your way of teaching, alessandro, because such a huge proportion of coding is trying to figure out what the heck you have done wrong and why things won't work. the more things you know in advance about why things fail, the better and faster one can code.
@jaimesastre1046
@jaimesastre1046 5 лет назад
Hello, Why does >if (class_exists('myClass'){ not work when I have a namespace??
@SSiEAX
@SSiEAX 5 лет назад
because it's no longer in the global NS. if( class_exists(\myCustomNS\ClassName) )
@jaimesastre1046
@jaimesastre1046 5 лет назад
oh thank you! didn't hear about this! very useful!
@marlo3898
@marlo3898 5 лет назад
Dude it's called UN INSTALL not UNI STALL
@alecaddd
@alecaddd 5 лет назад
Nope, it's called UNNNNIIHHHHZZXXXTTSTSTSTSAAAAHHHAAALLLL
@Kunuut84
@Kunuut84 5 лет назад
@@alecaddd I've searched in the comment just for this remark, and I've found it. Great tut by the way
@acuteclub7381
@acuteclub7381 6 лет назад
Great tutorial
@alecaddd
@alecaddd 6 лет назад
Thanks
@mithoomiyaan2534
@mithoomiyaan2534 6 лет назад
Hello. I am finding an error. ! please help me Uncaught Error: Call to undefined function register_activtion_hook
@mithoomiyaan2534
@mithoomiyaan2534 6 лет назад
Uncaught Error: Call to undefined function register_activtion_hook() in C:\xampp\htdocs\plugin\wp-content\plugins\alecaddd-plugin\alecaddd-plugin.php:44 Stack trace: #0 C:\xampp\htdocs\plugin\wp-settings.php(305): include_once() #1 C:\xampp\htdocs\plugin\wp-config.php(89): require_once('C:\\xampp\\htdocs...') #2 C:\xampp\htdocs\plugin\wp-load.php(37): require_once('C:\\xampp\\htdocs...') #3 C:\xampp\htdocs\plugin\wp-admin\admin.php(31): require_once('C:\\xampp\\htdocs...') #4 C:\xampp\htdocs\plugin\wp-admin\index.php(10): require_once('C:\\xampp\\htdocs...') #5 {main} thrown in C:\xampp\htdocs\plugin\wp-content\plugins\alecaddd-plugin\alecaddd-plugin.php on line 44
@alecaddd
@alecaddd 6 лет назад
Check my source code on GitHub to see if you have any typos.
@ahiadh
@ahiadh 5 лет назад
@@mithoomiyaan2534 the problem is that you have a typo, it's "register_activation_hook" and not "register_activtion_hook" you're missing the letter a in activation
@kayodeolaniyi3566
@kayodeolaniyi3566 5 лет назад
I want to commend you on your work. Thank you but I wish this covered more on the plugins than PHP
@alecaddd
@alecaddd 5 лет назад
The series has 50+ videos, a little introduction on PHP was absolutely necessary.
@kayodeolaniyi3566
@kayodeolaniyi3566 5 лет назад
@@alecaddd thank you for your work though. Well done. You did a good job
@raj080288
@raj080288 7 лет назад
if you install a plugin on multiple sites and we release an update for the plugin, how would multiple websites get an update in the wordpress admin to update the plugin?
@alecaddd
@alecaddd 7 лет назад
If the plugin it's installed via the official plugin repository of WP, you just need to update the version number and the user will get the notification. If the plugin it's private and not released in the WP repository, you can handle this problem in a couple of ways. Code a built-in trigger to check once a week the version of the plugin against a remote repository, or add a button in the admin area to "Check for Updates"
@raj080288
@raj080288 6 лет назад
Perfect, that makes sense. thank you very much. If I add it to the wp repo, does that mean everyone can access and download the plugin?
Далее
Should You Learn Object Oriented PHP?
13:48
Просмотров 11 тыс.
荧光棒的最佳玩法UP+#short #angel #clown
00:18
How principled coders outperform the competition
11:11
5 JavaScript Concepts You HAVE TO KNOW
9:38
Просмотров 1,4 млн
Being Competent With Coding Is More Fun
11:13
Просмотров 82 тыс.
Create a WordPress Plugin from Scratch - Part 1
12:22
Просмотров 400 тыс.
荧光棒的最佳玩法UP+#short #angel #clown
00:18