Apply custom css for user role

To enqueue CSS in WordPress you can use: wp_enqueue_scripts action for the frontend login_scripts action for the login page admin_scriptsaction for the admin side, as you already know To check user’s roles you should get the user object and check the roles property. current_user_can() is function intended to check capabilities, not roles. So, to add … Read more

Enqueue a file that’s not js or css

You could also look to create a special CSS file that you setup an htaccess rewrite rule for. For example wp-content/yourtheme/custom.css And then add a rule in your htaccess: RewriteEngine On RewriteRule ^/wp-content/yourtheme/custom.css$ /wp-content/yourtheme/styles.php [L] You can then call wp-load inside this styles.php file, do any sort of logic required, before outputting your custom css … Read more

Override Admin menu icon

One way is to use the admin_menu hook to insert CSS with your selection of menu icons (which use the DashIcons). The googles show this recent result: https://swapnil.blog/2018/06/25/how-to-change-wordpress-admin-icons/ . Here’s some code from there; you’ll just need to figure out the CSS for each menu item – use your Developer inspection tools (F12, usually) to … Read more

Is it possible to load the css just on my plugin admin page?

To answer the question, from the codex, listed above in the comments. function load_custom_wp_admin_style($hook) { // Load only on ?page=mypluginname if($hook != ‘toplevel_page_mypluginname’) { return; } wp_enqueue_style( ‘custom_wp_admin_css’, plugins_url(‘admin-style.css’, __FILE__) ); } add_action( ‘admin_enqueue_scripts’, ‘load_custom_wp_admin_style’ ); Note: If you are unsure what your $hook name is .. use this to determine your hookname. Put the … Read more

Change the color of the Password Protected Post titles

To change the color of password protected post titles in the admin In your theme or child theme, enqueue a stylesheet to load in the admin, then add some simple CSS to change the color using the class that is given to password protected posts. In your theme’s functions.php… function wpse_admin_styles(){ wp_enqueue_style( ‘admin_css’, get_stylesheet_directory_uri() . … Read more

Gutenberg – Remove add block button

You can register a template for your CPT and lock that template so users cannot add, move, or delete blocks. There are several ways to set up the template, but since your CPT is already registered, the easiest might be: <?php add_action( ‘init’, ‘wpse_360075_register_block_template’ ); function wpse_360075_register_block_template() { // Make sure to change “yourcptslug” to … Read more

Notice-Updated div moving around unprompted

Searching for .notice on WP source code I found the culprit at wp-admin/js/common.js: $( ‘div.updated, div.error, div.notice’ ).not( ‘.inline, .below-h2’ ).insertAfter( $headerEnd ); Adding an inline class to my code solves the issue: <div class=”notice updated inline”>Form sent</div>

hide elements of admin with css file

It’s always better to encapsulate your styles in a separate file, so your first example is closer. That said, the documentation for admin_print_styles says quite clearly: admin_print_styles should not be used to enqueue styles or scripts on the admin pages. Use admin_enqueue_scripts instead.

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