WP Editor strips input placeholder attribute

The list of allowed elements and attributes is stored in the global variable $allowedposttags which is set in wp-includes/kses.php.

To override it create a simple mu plugin with the following content:

<?php # -*- coding: utf-8 -*-
/**
 * Plugin Name: Enable placeholder attribute for input elements in post tags.
 * Version: 2012.07.18
 */

add_action( 'init', 'wpse_54829_register_placeholder' );


function wpse_54829_register_placeholder()
{
    global $allowedposttags;

    $default = empty ( $allowedposttags['input'] ) ? array () : $allowedposttags['input'];
    $custom  = array (
        'placeholder' => TRUE,
        'name'        => TRUE,
        'value'       => TRUE,
        'size'        => TRUE,
        'maxlength'   => TRUE,
        'type'        => TRUE,
        'required'    => TRUE
    );

    $allowedposttags['input'] = array_merge( $default, $custom );
}

This post with the content <input placeholder="pass" required /> was created with an author account:

enter image description here

Leave a Comment