Skip to content

Instantly share code, notes, and snippets.

@mypacecreator
Last active December 21, 2015 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mypacecreator/6262990 to your computer and use it in GitHub Desktop.
Save mypacecreator/6262990 to your computer and use it in GitHub Desktop.
特権管理者じゃなくても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
Copy link
Author

プラグイン化してみた。
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