Unit testing in the WordPress backend (is_admin() is true)

According to this test, you use set_current_screen() to navigate to one of these in the setUp method. Alas, none of this is apparent if you look at the tremendously-helpful reference page for get_current_screen()… Example: <?php class AxisSetupTest extends WP_UnitTestCase { /** * @covers AxisWP::__construct */ function test_constructor() { // Assert // Admin $this->assertInternalType(‘integer’, has_action( ‘admin_enqueue_scripts’, … Read more

Changing the ‘wp-admin’ URL to whatever I want

If you’re looking for a way to physically move the wp-admin folder to another location, that is indeed problematic. That’s why there is not an easy solution available. Not that it isn’t just easy, it is even the opposite. The directory name “wp-admin” is hardcoded deeply into wordpress. This is by design, so wordpress actively … Read more

How can I control the position in the admin menu of items added by plugins?

To change top level admin menu items order you’ll need two hooks, two filters, and one function. Put the following code in your current theme’s functions.php: function wpse_custom_menu_order( $menu_ord ) { if ( !$menu_ord ) return true; return array( ‘index.php’, // Dashboard ‘separator1’, // First separator ‘edit.php’, // Posts ‘upload.php’, // Media ‘link-manager.php’, // Links … Read more

do_shortcode() within Admin Page

Instead of calling do_shortcode() just call the function associated with the shortcode. Example There is a shortcode named [example] and a function registered as shortcode handler: function example_shortcode( $atts = array(), $content=”” ) { extract( shortcode_atts( array ( ‘before’ => ”, ‘after’ => ”, ), $atts ) ); return $before . $content . $after; } … Read more

Change page title in admin area

add_filter(‘admin_title’, ‘my_admin_title’, 10, 2); function my_admin_title($admin_title, $title) { return get_bloginfo(‘name’).’ &bull; ‘.$title; } You could also do a str_replace on $admin_title to remove “— WordPress” and change “‹”. Look at the top of the wp-admin/admin-header.php file to see what is going on by default.

How to disable the “Post Lock/Edit Lock”?

As an addition to @birgire answer… Findings register_post_type() allows to register a post type support, which can as well be done later on using add_post_type_support(). And that can get checked against even later using the all mighty post_type_supports( $cpt, $feat ). A general mini plugin that adds a new feature Now the following (mu-)plugin checks … Read more

When moving a WP site, why does wp-admin redirect to old site?

If this is a single WordPress install, there are a couple database entries with your old domain. Specifically, siteurl and home within wp_options. That said, if the dev URL is temporary, you can also set the following two constants in wp-config.php: define(‘WP_HOME’, ‘http://’ . $_SERVER[‘SERVER_NAME’]); define(‘WP_SITEURL’, WP_HOME . “https://wordpress.stackexchange.com/”); Provided that WordPress is installed in … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)