how to set context in WordPress for unit testing

If you have phpUnit configured for testing a WP plugin, you can use a test case like this: In your plugin-directory/tests/Some_Test_Case.php: class Plugin_Test extends WP_UnitTestCase { /** * @dataProvider post_IDs_and_expected_results */ public function test_something( $post_id, $expected_result ) { global $post; $post = get_post( $post_id ); $plugin_content = call_plugin_function(); // Your function name here $this->assertEquals( $expected_result, … Read more

Is it possible to modify the media library admin screen?

That area of all admin screens is where admin notices are displayed, so you could generate an admin notice. Here’s a suitable function and hook: function wpse_233031_admin_notice() { ?> <div class=”notice notice-info”> <p>Your message here!</p> </div> <?php } function wpse_233031_hook_admin_notice() { add_action( ‘admin_notices’, ‘wpse_233031_admin_notice’ ); } add_action( ‘load-upload.php’, ‘wpse_233031_hook_admin_notice’ ); /* Edited out anonymous function … Read more