Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
特権管理者じゃなくてもdlとかのclassを消されたり、WordPress Importerで投稿をインポートした時記事内にiframeとかobjectとかあっても消されたりしないようにする
<?php
//HTMLの自動整形を解除
function set_allowedposttags($content){
global $allowedposttags;
$allowedposttags['dl'] = array(
'class' => array(),
'id' => array()
);
$allowedposttags['dt'] = array(
'class' => array(),
'id' => array()
);
$allowedposttags['dd'] = array(
'class' => array(),
'id' => array()
);
$allowedposttags['iframe'] = array(
'class' => array(),
'src' => array(),
'width' => array(),
'height' => array() ,
'frameborder' => array(),
'scrolling' => array(),
'marginheight' => array(),
'marginwidth' => array()
);
$allowedposttags['object'] = array(
'class' => array(),
'data' => array(),
'width' => array(),
'height' => array(),
'type' => array()
);
$allowedposttags['param'] = array(
'class' => array(),
'name' => array(),
'value' => array()
);
return $content;
}
add_filter('content_save_pre', 'set_allowedposttags', 8);
@mypacecreator

This comment has been minimized.

Copy link
Owner Author

@mypacecreator mypacecreator commented Mar 24, 2014

プラグイン化してみた。
https://github.com/mypacecreator/my_allowedposttags

マルチサイトの場合はAutomattic謹製のプラグインがある。ちょっと古いけど。
http://wordpress.org/plugins/unfiltered-mu/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment