How do I add an admin notice within javascript in the admin interface for posts?

Look at F:\sites\wp-git\wp-admin\js\common.js: $(‘div.updated, div.error’).not(‘.below-h2, .inline’).insertAfter( $(‘div.wrap h2:first’) ); If your notice has the class updated or error, it will be set after the first h2 automatically. When you create custom messages, make sure you are using one of these classes. Then you can just append them to body, and WordPress will move them to … Read more

Hide admin login without plugin

There is an action hook called login_init. It’s also called on the registration page. You can simply attach wp_die() to it. You might want to disable the entire backend as well, which can be done by hooking into admin_init. add_action( ‘login_init’ , ‘wp_die’ ); add_action( ‘admin_init’ , ‘wp_die’ ); WordPress will exit with an empty … Read more

How to set admin login page as home page

This plugin will do exactly that: Members Only. Don’t worry about the warning at the top about not being updated in over 2 years, I use the plugin all the time, there are no issues with it and no security flaws that I have run into. After you install the plugin, there is a small … Read more

Super slow admin panel

Set the install to default, all plugins inactive and the default theme. After this step will not reduce the load, analyze the install, like with the plugin “Debug Objects”, view the queries tab, there will give you information about slow DB Queries.

Add custom list menu on Posts page in admin panel

You can use the views_{$this->screen->id} filter in WP_List_Table::views(), where screen ID in this case is edit-post: function wpse_177655_views( $views ) { $custom = sprintf( ‘<a href=”https://wordpress.stackexchange.com/questions/177655/%s”‘, esc_url( ‘edit.php?post_type=post&custom=foobar’ ) ); if ( ! empty( $_GET[‘custom’] ) && $_GET[‘custom’] == ‘foobar’ ) $custom .= ‘ class=”current”‘; $custom .= ‘>Custom</a>’; $views[‘custom’] = $custom; return $views; } add_filter( … Read more

Clicking On View Post In Draft Opens New Tab

You can hack by adding below lines in your theme’s functions.php file. function remove_preview_target() { // below JS code will set Preview button’s **target** attribute to **_self**, it means same tab/window. echo “<script> jQuery(document).ready(function(){ jQuery(‘#post-preview’).attr(‘target’, ‘_self’); }) </script>”; } // this action performs in admit footer add_action(‘admin_footer’, ‘remove_preview_target’); Or add below lines in your JS … Read more