easier; - Activation; - Deactivation; - Css and Js embed; YOU DON’T NEED TO GOOGLE NOR OPEN THAT OLD PLUGIN TO REMEMBER HOW TO DO IT!!! - Organised and Easy to follow; Wednesday, 4 July 12
the WordPress codebase you'd like to test. Add a backslash in the end. */ define( 'ABSPATH', '/path/to/your/site' ); define( 'DB_NAME', 'wordpress_tests' ); define( 'DB_USER', 'your_username' ); define( 'DB_PASSWORD', 'your_password' ); define( 'DB_HOST', 'localhost' ); define( 'DB_CHARSET', 'utf8' ); define( 'DB_COLLATE', '' ); define( 'WPLANG', '' ); define( 'WP_DEBUG', true ); define( 'WP_DEBUG_DISPLAY', true ); /* Cron tries to make an HTTP request to the blog, which always fails, because tests are run in CLI mode only */ define( 'DISABLE_WP_CRON', true ); $table_prefix = 'wp_'; Wednesday, 4 July 12
Tests */ class MyPluginTest extends WP_UnitTestCase { public $plugin_slug = 'my_plugin'; public function setUp() { parent::setUp(); $this->my_plugin = $GLOBALS['my_plugin']; } public function testPostTitle() { $this->go_to('http://mysite.com/?p=1'); global $wp_query; $post = $wp_query->get_queried_object(); $this->assertEquals('Hello world!', $post->post_title ); } } Wednesday, 4 July 12
of a page or process lifecycle that WordPress fires. - In your constructor, you have to define when your code should act; - add_action( 'publish_post', array( $this, 'send_email' ) ); Wednesday, 4 July 12
which WordPress modifies data before saving it or sending it to the browser. - add_filter( 'the_title', array( $this, 'add_italic' ) ); Wednesday, 4 July 12