I hope the following question is acceptable here.
I rely entirely on copy/paste for most WP functions, however I guess WP veterans don’t. Is it important to know by heart the common WP syntax, and if it is, do people actually make an effort to memorize them just like we memorize a piece of poetry or a quote?
Not everyone will follow convention, so you can be assured if you are copy-pasting then you are getting a mix-and-match approach from people who do it “right” and do it “wrong” and sometimes the difference between right and wrong is a matter of opinion, lets not forget.
Also this applies to NOT only Syntax Style but also Best Practice methods for using proper WP Core functions over less preferred hack-jobs or unconventional functions to perform certain tasks.
Here are two links that can help you understand what WordPress thinks is acceptable coding standards syntactically, most of which you will find is common practice elsewhere amongst PHP developers;
Work with anything long enough and you will begin to memorize good convention, you’ll also graduate from copy-pasting, more so to writing your own logic and with that you will adopt convention, standards and best practices because ultimately we want others to be able to read our
junkcode just the same as you’d expect from others.You donât have to remember very much. Any decent IDE will help you with auto-complete and an overview of the parsed PHPDoc.
Example from Eclipse:
After typing
add_
you get a list of matching function names and constants, a description and an explanation of the parameters ⦠if there is a useful PHPDoc block.And when you create a new object you get the public methods offered too.
See also this answer for a useful setup.
What you should learn is the order of the main actions:
muplugins_loaded
plugins_loaded
after_setup_theme
init
wp_loaded
But thatâs really easy. 🙂