开发者 | convissor |
---|---|
更新时间 | 2016年8月14日 00:46 |
捐献地址: | 去捐款 |
PHP版本: | 3.3 及以上 |
WordPress版本: | 4.4 |
http://wordpress.org/extend/plugins/oop-plugin-template-solution/
/wp-content/plugins/
directory
1. Activate the plugin using WordPress' admin interface:
* Regular sites: Plugins
* Sites using multisite networks: My Sites | Network Admin | Plugins
Removal
This plugin is coded to be installed in either a regular, single WordPress
installation or as a network plugin for multisite installations. So, by
default, multisite networks can only activate this plugin via the Network Admin
panel.
If you want your plugin to be configurable for each site in a multisite
network, follow the instructions in the docblock at the top of admin.php
.
We add some abstraction around WordPress'
Settings API. All you need to do
is add some elements to two arrays and maybe create a section header if you
want. This is way better than having to write out add_settings_field()
calls and creating display and validation callbacks for each and every field.
admin.php
in your favorite text editorThis framework uses PHPUnit, so standard PHPUnit file, class, and method naming practices apply. Our framework requires that your test files and classes:
require_once
call for TestCase.php
at the top of the script.
That obtains the PHPUnit and other items needed. It's the only file you
need to include.TestCase
setUpBeforeClass()
method, it must
call parent::setUpBeforeClass()
setUp()
method, it must call parent::setUp()
tearDown()
method, it must call parent::tearDown()
tearDownAfterClass()
method, it must
call parent::tearDownAfterClass()
TestLogin.php
script for examples of how to handle
calls to wp_mail()
(and translations of mail messages) and wp_redirect()
,
the use of database savepoints, and manipulating user metadata.
Please note that the tests make extensive use of database transactions.
Many tests will be skipped if your wp_options
and wp_usermeta
tables
are not using the InnoDB
storage engine.
To execute the tests, install and activate the plugin, then use a shell
to cd
into this plugin's directory and call phpunit tests
While it is possible to test plugins using WordPress' Automated
Testing PHPUnit framework, it
is a complex system, is another dependency, and runs in its own environment.
The benefit of using my plugin's PHPUnit is that it ships with the plugin
and executes in the users actual WordPress installation. This means any end
user can easily test how the plugin interacts with their site.
To produce the machine readable translations used by WordPress' gettext
implementation, use the scripts I made for generating all of
the .pot
, .po
and .mo
files:
cd languages
./makepot.sh
.pot
file as desired.touch <plugin-id>-<lc>_<CC>.mo
Substitutions:
plugin-id: the plugin's identifier ($new_id from above)
lc: language code
CC: country code./updatepos.sh
.po
files../makemos.sh
wp_logout()
and wp_redirect()
calls from direct calls in the
test method to a method in the tested class instead.