wp-admin remove part of the url

I’ve searched in the admin templates. It seems the placeholders rely on the functions wp_get_referer() and wp_get_raw_referer() which use $_SERVER[“REQUEST_URI”], $_SERVER[‘HTTP_REFERER’] and a wp custom variable passed in the request : $_REQUEST[‘_wp_http_referer’]. So WordPress builds some URLs (apparently not all) on REQUEST_URI, that is /wp-admin/whatever (in the backend). The logs show that wp-admin/admin-ajax.php comes through … Read more

How can I replace content in the WP Admin area before an admin page is rendered?

There’s no filter for filtering all of the HTML output in the admin. The closest thing is the gettext filter: function wpse_275812_filter_text( $translated_text, $text, $domain ) { $translate_text = str_ireplace( ‘foo’, ‘bar’, $translated_text ); return $translated_text; } add_filter( ‘gettext’, ‘wpse_275812_filter_text’ ); This filters any text output by the internationalization functions (__(), _e(), etc.). So it … Read more

Enque script based on url paramater

There are a couple of ways to do this. The easiest way is to use $_GET: if ( ( $hook == ‘post-new.php’ || $hook == ‘post.php’ ) && $_GET[‘action’] == ‘edit’ ) { // Enqueue your scripts here } You can also use the get_current_screen(); function instead of using a global variable.

Admin Filter – Add Post Type Description on Post Type Page

The filter views_{$this->screen->id} is fired just after the title of post edit screen has been print to screen, so it’s a safe place to just echo what you want. So you can simply do: function post_type_desc( $views ){ $screen = get_current_screen(); $post_type = get_post_type_object($screen->post_type); if ($post_type->description) { printf(‘<h4>%s</h4>’, esc_html($post_type->description)); // echo } return $views; // … Read more