How to use the static keyword with WordPress


This site has a lot of object-oriented programming articles. Most of them focus on solving WordPress problems using object-oriented programming. This is great when you’re comfortable with object-oriented programming. But most WordPress developers aren’t that comfortable with it. (You’d think there’d be a book on that or something.) It’s one thing to read about basic concepts like encapsulation and inheritance. It’s another to put them in practice. There are a lot of obstacles that you have to overcome.
One of these obstacles is the proper use of the static keyword. Static methods are a great object-oriented tool to use. But, like all good things, we can also abuse it if we’re not careful.
This happens a lot more in the WordPress development world than anywhere else. And there are good reasons for that. We’ll look at why that is and what you can do about it.
The static keyword is a something that you only use with object-oriented programming. You use it when declaring class methods and properties. This allows you to access them without needing to instantiate the class.
123456789101112131415161718192021
class A_WP_Class{/** * Actions that
Source: https://managewp.org/articles/14116/how-to-use-the-static-keyword-with-wordpress




source https://williechiu40.wordpress.com/2017/01/03/how-to-use-the-static-keyword-with-wordpress/