WordPress plugin development using OOP

后端 未结 4 1140
遇见更好的自我
遇见更好的自我 2021-02-05 13:19

I am new to plugin development. So please correct me, wherever I get it wrong.

I have a website which needs a players plugin with the following needs:-

  • An
4条回答
  •  生来不讨喜
    2021-02-05 13:55

    I'm not a guru, but I've been working with WordPress for several years now and have quite a few plugins behind my back. Your first mistake I can point out is

    along with database table creation

    This is wrong. You don't create tables when you work with WordPress, the default schema is flexible enough to fit anything you have in mind. Even complicated plugins such as WP-eCommerce is being rewritten (or already, don't know) to fit the standard WordPress schema. Especially since WordPress 3.0 is already out. This has been mentioned on WordCamp earlier this year.

    You can easily fit your players into the Users table. Their attributes could be stored in the Users Meta table, plus you could give them special roles and/or privileges.

    Now, if you're really into OOP, you should download some cool plugins out there and read through the code to see how other people do it. As an example I could mention one of my own plugins called Twitter Friendly Links - it's not the best OOP around, but it's definitely a start ;)

    You can kick it over to W3 Total Cache afterwards, where you'll see some very impressive stuff and code organization (thanks to Frederick Townes).

    Also, some parts of the Codex now show examples in OOP style - the Widget API for instance. I hope to see more soon and hurray for OOP in WordPress! It's a good thing that people ask such questions, it is what motivates the core developers :)

提交回复
热议问题