Why WP Editor also strips the “placeholder” attribute of the input text element ?
Ofcourse, i am using the HTML mode.
Here is the input:
<input type="text" value="" name="s" style="width: 550px;" placeholder="Search this website..">
After updating the post (after strip):
<input type="text" value="" name="s" style="width: 550px;">
I do not want WP Editor to strip such attributes.
Any Help ?
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:
