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

Why are my styles being applied to the admin area?

Why are my styles being applied to the admin area? Assuming that is all of the code, it is because you are enqueueing the styles globally. You need to hook that to wp_enqueue_scripts, which will only load on the front end. wp_register_style( ‘main-styles’, get_stylesheet_directory_uri() . ‘/css/styles.css’, false, ‘1.0.0’, ‘all’); function enqueue_script_front_wpse_84975() { wp_enqueue_style(‘main-styles’); } add_action(‘wp_enqueue_scripts’, … Read more

Remove default subpages from Custom Post Menu

You can manipulate the global variable $submenu and remove them. In normal circumstances, the index key values are 5 (All items) and 10 (New item). In this example, the post type is portfolio: add_action( ‘admin_init’, ‘remove_cpt_submenus_wpse_95797’ ); function remove_cpt_submenus_wpse_95797() { global $submenu; unset( $submenu[‘edit.php?post_type=portfolio’][5], $submenu[‘edit.php?post_type=portfolio’][10] ); }

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