Timeline for Applying OO patterns and principles to plugin development
Current License: CC BY-SA 3.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 28, 2011 at 18:03 | comment | added | EarnestoDev | -1 ME :: I abide by PHP coding standards. WordPress coding standards is just... buzz-words. WordPress is not a programming language as many falsely believe. It just has best practices, not standards. Methods/Functions are case insensitive in PHP AFAIK and I like pretty names as I'm vain ;) I always use Construct for statics as __construct is for instantiables. Same name, easy to understand, one's declared static and has no leading __ so you can't mistake it for a magic method. Oh... it's so funny in here. Mildly entertaining. | |
Oct 28, 2011 at 17:46 | comment | added | Tom Auger |
+1 @scribu. Use __construct() or create a static function like initialize() . Also, FWIW, lower-case your class methods. Since this is a WordPress specific SE, check out the WordPress Coding Standards in the Codex: codex.wordpress.org/WordPress_Coding_Standards.
|
|
Oct 28, 2011 at 16:29 | comment | added | scribu | As for his question, the kernel of it was "I have one or two non-class scripts, mostly for forms, that I don't quite know how to neatly fit into classes", but I'll let the OP comment on that. | |
Oct 28, 2011 at 16:28 | comment | added | scribu | Hold on. I'm all for static methods. I was just saying that 'Construct' is a bad name for that method, since it resembles '__construct()'. | |
Oct 28, 2011 at 15:52 | comment | added | EarnestoDev | And I do think I answered the question. Read his question. He instantiates in constructor. Really bad. Static methods should be used to ensure single addition of actions/filters. He also want to add external functions to a class. Static is also the way to go... | |
Oct 28, 2011 at 15:49 | comment | added | EarnestoDev | @scribu Why that? Why would you create the plugin structure as a non-static class. Why would you want users to randomly instantiate your object and keep adding layers of actions/filters... Eu evit clasele pt. pluginuri de obicei, dar in afara de Widget-uri, sunt statice! | |
Oct 28, 2011 at 15:42 | comment | added | scribu | It's confusing to call a static method 'Construct'. Also, it doesn't really answer the OP's question. | |
Oct 28, 2011 at 15:40 | history | answered | EarnestoDev | CC BY-SA 3.0 |