Post Admin – Filter by posts without tags

The first part is to add a dropdown using restrict_manage_posts filter, and the second one is to actually get posts without tags using pre_get_posts filter: function wpse147471_add_no_tags_filter() { if ( ‘post’ !== get_current_screen()->post_type ) { return; } $selected = ( isset( $_GET[‘tag-filter’] ) && ‘no-tags’ === $_GET[‘tag-filter’] ); ?> <select name=”tag-filter”> <option value=””>&mdash; Select &mdash;</option> … Read more

Ban certain widgets from certain sidebars

You are overthinking it. The concept of widgets is designed to be transferable between widget area (AKA sidebars). If a widget is not tranferable it is just not a true wordpress widget. Now creating your own framework of widgets sound like a non pleasant idea. In addition to fighting the wordpress core code, you will … Read more

How to retain HTML5 Attributes on Markup

It is enough to add unfiltered_html capability to Editor role. Add the following code into your current theme’s functions.php: function wpse_change_capability() { $role = get_role( ‘editor’ ); if ( ! $role->has_cap( ‘unfiltered_html’ ) ) $role->add_cap( ‘unfiltered_html’ ); } add_action( ‘init’, ‘wpse_change_capability’, 10 ); Login as the user with Editor role. Test it by editing any … Read more

Handling error states with admin_post

You can use set_transient with the user_id if you are relying on users being logged in, otherwise, cookie would probably be better. For logged in users, you can have the user_id get set within the name of the transient. An example here: function form_post() { $user_info = wp_get_current_user(); $user_id = $user_info->exists() && !empty($user_info->ID) ? $user_info->ID … Read more

WordPress prompt checklist before publish?

Create new plugin and add this as your the content: <?php /* Plugin Name: [CR]TestDropIn Plugin URI: http://bayu.freelancer.web.id/ Description: A barebone plugin to test whatever wordpress API you want to test Author: Arief Bayu Purwanto Version: 0.0.1 Author URI: http://bayu.freelancer.web.id */ add_action(‘admin_head’, ‘xxx_admin_hook’); function xxx_admin_hook(){ ?> <script language=”javascript” type=”text/javascript”> jQuery(document).ready(function() { jQuery(‘#post’).submit(function() { //alert(‘Handler for … Read more

custom tabs in media uploader

found it. in the automattic SVN for media.php i found the media_upload_header() function, and the only thing left to do is to echo it in the last function: function media_upload_ell_gmap_form() { echo media_upload_header(); ?> <h2>HTML Form</h2> <?php } that’s it.

Add extra field when admin create user

With no hooks on that page (User > Add new page) other then user_new_form_tag its not possible to add new fields unless you hack the core file wp-admin/user-new.php . You could try adding that extra field by adding in in JQuery and processing it when the $_post[‘action’] == ‘adduser’ but that wont be very good … Read more

Customize the upload screen

You will need to hook into attachment_fields_to_edit and unset them for a role. You can use current_user_can(‘author’) http://codex.wordpress.org/Function_Reference/current_user_can Example to remove image alt field function remove_caption($form_fields) { if (current_user_can(‘author’)){ $form_fields[‘image_alt’][‘input’] = ‘hidden’; return $form_fields; }} add_filter(‘attachment_fields_to_edit’,’remove_caption’, 15, 2); My initial post used unset but I tried it and it did not work, from the example … Read more