How do I load a CSS style into WordPress admin area only?

Just hook your callback into admin_print_styles, i.e.: add_action( ‘admin_print_styles’, ‘mytheme_add_init’ ); Alternately, you could add an is_admin() conditional wrapper inside your callback, and hook into wp_enqueue_scripts: function mytheme_add_init() { if ( is_admin() ) { $file_dir=get_bloginfo(‘template_directory’); wp_enqueue_style(“functions”, $file_dir.”/scripts/custom.css”, false, “1.0”, “all”); wp_enqueue_script(“rm_script”, $file_dir.”/scripts/custom.js”, false, “1.0”); } } add_action( ‘wp_enqueue_scripts’, ‘mytheme_add_init’ ); But the absolute best approach … Read more

Disable Media Uploads to non Admin Users

Here are 2 methods: Method 1: Remove the upload_files capability from the respective roles. e.g. removing it from author: $role = get_role( ‘author’ ); $role->remove_cap( ‘upload_files’ ); This is saved to the database so it should only happen once, not on every page load. Removing it from the editor role should be the same albeit … Read more

Settings API – adding setting fields dynamically?

It sounds like you would need a way to get those dynamic fields into the my_options function each time it’s called. You could try creating your own filter to use: function my_options() { $myarray = apply_filters( ‘my_get_options_dynamically’, array() ); $count = 0; foreach($myarray as $something) { $count++; $options[] = array( ‘id’ => ‘something’. $count, ‘title’ … Read more

How to save dismissable notice state in WP 4.2?

There’s no need for a library, it’s fairly straightforward to accomplish. If you are coding your own plugin (which it appears you are), then you can do this in a fairly lightweight way: A slightly modified version of the notice, which checks if it’s been dismissed before displaying, and stores the “type” of notice in … Read more

Securing Admin Accounts – Username Discovery

If you have pretty permalinks enabled WordPress will redirect all calls to /?author=1 to the author archive with the user name, eg.: /author/bob/. And then the visitor will know the author name. Use Login Lockdown, that plugin does not reset accounts, it will block IP addresses.

Is it possible to create a WordPress tour? V3.3.1

If you look at this plugin I wrote as a demonstration on using pointers, you will see how to create them and have them close correctly: https://github.com/Tarendai/WP-Pointer-Pointers This plugin creates ‘pointer pointers’:

This CSS Stuffing Works, But Is This A Good Practice?

You can use wp_add_inline_style() to add to a stylesheet that you’ve already defined, such as in your plugin. This way an options screen or other user settings can affect the final style output. That could become very tedious, however, depending on how many changes you are giving the user the power over. However, it is … Read more

WordPress admin stylesheet

Take a look here at the CODEX for an example on how to do this very thing. Example: Load CSS File on All Admin Pages function load_custom_wp_admin_style(){ wp_register_style( ‘custom_wp_admin_css’, get_bloginfo(‘stylesheet_directory’) . ‘/admin-style.css’, false, ‘1.0.0’ ); wp_enqueue_style( ‘custom_wp_admin_css’ ); } add_action(‘admin_enqueue_scripts’, ‘load_custom_wp_admin_style’); Example: Target a Specific Admin Page function my_enqueue($hook) { if( ‘edit.php’ != $hook ) … Read more

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