How can I remove css rules apply on dashboard in wordpress? - css

How can I remove css rules apply on dashboard in wordpress?
I make a theme and the css rules are applied inside the dashboard.
In functions.php is write this code :
wp_register_style('styles',get_bloginfo('template_url')."/css/styles.css");
wp_register_style('bootstrap',get_bloginfo('template_url')."/css/bootstrap.css");
wp_register_style('bootstrap-responsive',get_bloginfo('template_url')."/css/bootstrap-responsive.css");
wp_enqueue_style('bootstrap');
wp_enqueue_style('bootstrap-responsive');
wp_enqueue_style('styles');

It's spilling in the admin area because you need to wrap all that in the appropriate hook:
add_action( 'wp_enqueue_scripts', 'my_enqueue' );
function my_enqueue()
{
// Register and enqueue CSS and JS here
}
See: Action_Reference/wp_enqueue_scripts

Related

Deregister only Classic Editor styles (but leave Guten css)

I'd like to keep the Guten styles, what do I do to only remove classic editor tinymce styles?
Using function
wp_deregister_style('wp-reset-editor-styles');
to disable default WP css on TinyMCE to style it with a skin, but it's also destroying Guten builder.
To remove your editor style, simply find where it's enqueued in your theme (probably using add_editor_style) and then you can add it back in for the block editor, using the action below.
add_action( 'enqueue_block_editor_assets', 'my_enqueue_block_editor_assets', 102);
function my_enqueue_block_editor_assets () {
wp_register_style( 'wp-reset-editor-styles', get_stylesheet_directory_uri() . '/stylesheets/my-custom-stylesheet.css', false, '1.0', 'all' );
}

How to remove menu item from WordPress admin bar menu?

i want to remove an menu item from admin bar , tried the following code
add_action( 'admin_menu', 'remove_admin_menu_items', 999 );
function remove_admin_menu_items() {
remove_menu_page('admin.php?page=litespeed&LSCWP_CTRL=purge&LSCWP_NONCE=ccd23d492e&litespeed_type=purge_all_lscache' );
}
unfortunately it doesn't work ! I have attached a screenshot of menu I want to remove
I like to hide the menu using the child theme function.php code.
Plugin author posts the following:
The best way to hide our menu is by CSS. For top icon in adminbar, use
.litespeed-top-toolbar {display:none}. It can be done by using 3rd party plugin like https://wordpress.org/plugins/add-admin-css/ or
add_action('admin_head', 'hide_litespeed_icon');
function hide_litespeed_icon() {
echo '<style>.litespeed-top-toolbar {display:none}</style>';
}
into your theme’s functions.php
Alternatively, try adding the following code to functions.php:
function remove_lscwp_admin_menu($wp_admin_bar) {
$wp_admin_bar->remove_node('litespeed-menu');
}
add_action('admin_bar_menu', 'remove_lscwp_admin_menu', 999);

Including bootstrap in the admin page only

I have added this line on my plugin
wp_enqueue_style( 'dazzling-bootstrap', get_template_directory_uri() . '/inc/css/bootstrap.min.css' );
and it seems that the whole admin backend was affected of that bootstrap. Any ideas on how to be only on that plugin?
That's because you're not specifying anywhere that the file should be included only for your plugin page, and not for the whole admin backend. Try to add a conditional check and then enqueue the stylesheet.
global $post;
if ( 'enter_plugin_page_slug_here' == $post->name ) {
// enqueue stylesheet here
}

Custom title attribute for WordPress stylesheet

How can I add title attribute for my own custom stylesheet in wordpress within functions.php file? I find something like that
`
global $wp_styles;
$wp_styles->add('example-alt', '/themes/example/example-alt.css');
$wp_styles->add_data('example-alt', 'title', 'Example Alternate Stylesheet');
$wp_styles->add_data('example-alt', 'alt', TRUE);
$wp_styles->enqueue(array('example-alt'));
`
but I don't know how can i use it within functions.php file or anywhere else?
I'm not sure if I have understood your question. You want to add a CSS Stylesheet to your blog or an attribute to the title?
If you want to add a CSS Stylesheet within functions.php, you have to enqueue it like this:
If your CSS stylesheet is named "my-style.css", place it on a folderl called "css" withing the folder of your theme, and then write that on functions.php:
function your_theme_name_scripts() {
// For Styles:
wp_enqueue_style( 'my-style', get_template_directory_uri(), '/css/my-style.css' );
// For Scripts:
wp_enqueue_script( 'my-script', get_template_directory_uri(), '/js/my-script.js' );
}
add_action( 'wp_enqueue_scripts', 'your_theme_name_scripts' );
Your find more info about enqueueing styles here: http://codex.wordpress.org/Function_Reference/wp_enqueue_script
If you want to add any attribute to the title, you have two options: creating a filter on functions.php, or directly modifying the wp_title() function on header.php. The second options is the best one.
You find more info about the title here: http://codex.wordpress.org/Function_Reference/wp_title

How do I disable the_content support for a certain page template?

I have a very simple page template, simple-template.php for which I don't use the_content(). How to I remove that textarea in the backend?
Ok so let's do this:
Add a theme option css file for the admin area. Add this to your functions.php file or in a sub functions file:
add_action('admin_enqueue_scripts', 'my_admin_scripts');
function my_admin_scripts() {
wp_enqueue_style( 'theme-options', get_template_directory_uri() . '/your-theme-css-folder/theme-options.css' );
}
Then create your theme-options.css file and place it in your theme css folder and add this:
.edit-form-section{
display:none;
}
This will hide textarea in the backend.

Resources