How to change admin menu position of “Media”?

There’s a combination of two filters, menu_order does the job, but you also use custom_menu_order to enable menu_order. function wpse_233129_custom_menu_order() { return array( ‘index.php’, ‘upload.php’ ); } add_filter( ‘custom_menu_order’, ‘__return_true’ ); add_filter( ‘menu_order’, ‘wpse_233129_custom_menu_order’ ); This will put upload.php (the Media screen) just after the Dashboard and then the other top-level menu items will follow. … Read more

How to enable enqueue_script to work with a logged in user?

Additionally, apart from the “where” of your wp_enqueue_script() function (i.e. theme, plugin, etc.), the “when” is also important, in terms of WP’s Action Reference hooks, and the order in which they’re fired. There are 2 distinct script-related hooks, wp_enqueue_scripts and admin_enqueue_scripts, which allow for separation of scripts and styles depending on which view the user … Read more

Remove the whole menu in the admin

add_action(‘admin_head’, ‘t5_hide_menu’); function t5_hide_menu() { $GLOBALS[‘menu’] = array(); ?> <style>#adminmenuback,#adminmenuwrap{display:none !important} #wpcontent, #footer{margin-left:0 !important}</style> <?php } Now I want to know: why? 🙂

get user list in admin area

What you’ve done is incredibly bad practice, and should be undone immediatley. There is already a dedicated table for storing user details aka User Meta. Altering the user table could cause issues with other plugins and Core, prevent upgrades working, and bypasses all the caching and object stores WordPress puts in place. It also adds … Read more

$user_id vs. is_user_logged_in()

Well it wouldn’t always work unless you global $user_id. is_user_logged_in will however work without that extra line of code. The speed improvement is most likely so small it’s less than the speed improvement between single and double quotes and not even worth thinking about. Also $user_id variable may disappear in a new version and would … Read more

Protect custom php file with login

This is impossible to answer definitively without a better description, but I am assuming that app.php is a completely distinct piece of code. In which case, WordPress can’t really manage access to it. You will need to incorporate it into WordPress. While this is not the only way to do it I would advise: Create … Read more

wp.template() Not a function

Ah, I get it. When you enqueue your admin script, add ‘wp-util’ as a dependancy. wp_enqueue_script( ‘script_handle’, plugin_dir_url( __FILE__ ) . ‘script.js’, array( ‘jquery’, ‘wp-util’ ), ‘1.0’, true );

Disable WP Editor for specific page templates

Yes, try this : function remove_editor() { if (isset($_GET[‘post’])) { $id = $_GET[‘post’]; $template = get_post_meta($id, ‘_wp_page_template’, true); switch ($template) { case ‘template_01.php’: case ‘template_02.php’: case ‘template_03.php’: case ‘template_04.php’: // the below removes ‘editor’ support for ‘pages’ // if you want to remove for posts or custom post types as well // add this line … Read more