Warum entfernt der WP Editor auch das "Platzhalter" -Attribut des eingegebenen Textelements? Natürlich benutze ich den HTML-Modus. Hier ist die Eingabe:
<input type="text" value="" name="s" style="width: 550px;" placeholder="Search this website..">
Nach dem Update des Posts (nach dem Strip):
<input type="text" value="" name="s" style="width: 550px;">
Ich möchte nicht, dass WP Editor solche Attribute entfernt.
Irgendeine Hilfe ?
Die Liste der zulässigen Elemente und Attribute wird in der globalen Variablen $allowedposttags
gespeichert, die in wp-includes/kses.php
festgelegt ist.
Um es zu überschreiben, erstelle ein einfaches mu Plugin mit folgendem Inhalt:
<?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 );
}
Dieser Beitrag mit dem Inhalt <input placeholder="pass" required />
wurde mit einem Autorenkonto erstellt:
Sie könnten einen Shortcode verwenden! ;)
<?php
// desired output: <input type="text" value="" name="s" style="width: 550px;" placeholder="Search this website..">
// sc: [text_input name="s" style="width: 550px;" placeholder="Search this website.."]
add_shortcode('text_input','text_input_sc');
function text_input_sc($atts) {
// modify defaults as you wish
$defaults = array(
'id' => null,
'class' => null,
'value' => null,
'name' => null,
'size' => null,
'style' => null,
'placeholder' => null
);
$args = shortcode_atts($defaults, $atts);
$out = array();
foreach ($args as $attr => $value) {
if ( null !== $value )
$out[] = $attr.'="'.$value.'"';
}
$out = trim(implode(' ', $out));
if( !empty($out) )
$out = ' '.$out;
return vsprintf('<input type="text"%s>', $out);
}
Ungetestet, sollte aber auf jeden Fall funktionieren!