Remove dashboard, use Pages tab as default

The best way is to re-direct user logins to your page and also remove the dashboard from the menu, this can be done with 2 filters. Redirect logins to your page edit screen example based on user roles, this example uses “author”: function dashboard_redirect($url) { global $current_user; // is there a user ? if(is_array($current_user->roles)) { … Read more

Export data as CSV in back end with proper HTTP headers

Do not point the URL to admin.php, use admin-post.php instead: ‘<a href=”‘ . admin_url( ‘admin-post.php?action=print.csv’ ) . ‘”>’ In your plugin register a callback for that action: add_action( ‘admin_post_print.csv’, ‘print_csv’ ); function print_csv() { if ( ! current_user_can( ‘manage_options’ ) ) return; header(‘Content-Type: application/csv’); header(‘Content-Disposition: attachment; filename=example.csv’); header(‘Pragma: no-cache’); // output the CSV data } … Read more

How set defaults on wpLink()

Also an small example for change the url in link-button to use the url from installed blog. Use print JS in footer, not an include from js file via wp_enqueue_script() – ist faster vor development, specially for this small requirement, but not so on standard and fine, how the example from the other answer. <?php … Read more

How to order by post meta name in wp admin?

I assume merchant name is another meta field and not the title for that post type? If so, here is a way to organize your admin edit.php area // Add a column in admin edit.php to display the Merchant post type data you want shown add_filter(‘manage_merchant_posts_columns’, ‘admin_merchant_columns’); function admin_merchant_columns( $posts_columns ) { $posts_columns = array( … Read more

Sort admin menu items

It can be done sorting the global $submenu. The sorting that’s applied resets the key number of the sub-array $submenu[‘options-general.php’], which is: array ‘options-general.php’ => array 10 => array 0 => string ‘General’ 1 => string ‘manage_options’ 2 => string ‘options-general.php’ 15 => array 0 => string ‘Writing’ 1 => string ‘manage_options’ 2 => string … Read more

wordpress wp-admin css not loading

I had the same issue a few months back I tried this and this works for me. define(‘FORCE_SSL_LOGIN’, false); define(‘FORCE_SSL_ADMIN’, false); define( ‘CONCATENATE_SCRIPTS’, false ); define( ‘SCRIPT_DEBUG’, true ); try to load wp-admin with SSL. After reloading it looks OK, maybe after re-login, set SCRIPT_DEBUG to false. hope this help

Taxonomy dropdown metabox in the back-end

Here is an example. I have also created a Gist with more generic code. add_action(‘add_meta_boxes’, ‘my_custom_metabox’); function my_custom_metabox() { add_meta_box(‘custom-taxonomy-dropdown’,’Brands’,’taxonomy_dropdowns_box’,’post’,’side’,’high’); } function taxonomy_dropdowns_box( $post ) { wp_nonce_field(‘custom-dropdown’, ‘dropdown-nonce’); $terms = get_terms( ‘brands’, ‘hide_empty=0’); $object_terms = wp_get_object_terms( $post->ID, ‘brands’, array(‘fields’=>’ids’)); // you can move the below java script to admin_head ?> <script type=”text/javascript”> jQuery(document).ready(function() { jQuery(‘#custombrandoptions’).change(function() … 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.