开发者 |
tombenner
robertpeake |
---|---|
更新时间 | 2019年11月14日 19:40 |
PHP版本: | 3.0 及以上 |
WordPress版本: | 5.3 |
wp-mvc
into the wp-content/plugins
directorywpmvc
:wp-content/plugins/wp-mvc/examples/events-calendar-example
) into the wp-content/plugins
directory (e.g. wp-content/plugins/events-calendar-example
)/events/
, /events/1/
, /venues/
, etc to see the public-facing views.
Creating a WP MVC-based plugin
It only takes four simple steps to create a basic WP MVC-based plugin:
You need to go to Settings > Permalinks and click "save". This flushes the WordPress rewrite rules. For performance reasons, the rewrite rules are only flushed either when the plugin is activated or when the Permalinks are saved. So, if you are developing with the plugin activated and adding controller routes as you go, you need to use this approach to flush the rewrite rules and use your new URL endpoints.
WP MVC is a full-fledged MVC framework, but behind the scenes it uses existing WordPress functionality to lessen its footprint and better interface with the parent WordPress application. The developer will not need to know about much of this, though, and may merely treat it as another MVC framework. It draws on concepts and workflows from other MVC frameworks; Rails and CakePHP are the biggest influences, and you may see some of their naming conventions being used.
If there's functionality that you'd like to use that isn't implemented in the example plugins or mentioned on wpmvc.org, it may not exist yet. However, if it's something that is widely useful, I'd certainly be willing to implement it myself or to accept any well-written code that implements it. Please feel free to either add a topic in the WordPress forum or contact me through GitHub for any such requests:
'layout' => 'whatever'