説明
パラメータ
- $cssstyle属性値を指定。
- $deprecated使用不可(省略時は'')。
返り値
ルールに適合しない内容を取り除いたstyle属性値を返す。
注意
有効なスタイルのプロパティ名はバージョンによって異なる(適宜追加されてきている)。
プロパティ名 | 5.3.0 | 5.2.0 | 5.1.0 |
---|---|---|---|
'background' | 〇 | 〇 | 〇 |
'background-color' | 〇 | 〇 | 〇 |
'background-image' | 〇 | 〇 | 〇 |
'background-position' | 〇 | 〇 | |
'background-size' | 〇 | ||
'background-attachment' | 〇 | ||
'background-blend-mode' | 〇 | ||
'border' | 〇 | 〇 | 〇 |
'border-radius' | 〇 | ||
'border-width' | 〇 | 〇 | 〇 |
'border-color' | 〇 | 〇 | 〇 |
'border-style' | 〇 | 〇 | 〇 |
'border-right' | 〇 | 〇 | 〇 |
'border-right-color' | 〇 | 〇 | 〇 |
'border-right-style' | 〇 | 〇 | 〇 |
'border-right-width' | 〇 | 〇 | 〇 |
'border-bottom' | 〇 | 〇 | 〇 |
'border-bottom-color' | 〇 | 〇 | 〇 |
'border-bottom-style' | 〇 | 〇 | 〇 |
'border-bottom-width' | 〇 | 〇 | 〇 |
'border-left' | 〇 | 〇 | 〇 |
'border-left-color' | 〇 | 〇 | 〇 |
'border-left-style' | 〇 | 〇 | 〇 |
'border-left-width' | 〇 | 〇 | 〇 |
'border-top' | 〇 | 〇 | 〇 |
'border-top-color' | 〇 | 〇 | 〇 |
'border-top-style' | 〇 | 〇 | 〇 |
'border-top-width' | 〇 | 〇 | 〇 |
'border-spacing' | 〇 | 〇 | 〇 |
'border-collapse' | 〇 | 〇 | 〇 |
'caption-side' | 〇 | 〇 | 〇 |
'columns' | 〇 | ||
'column-count' | 〇 | ||
'column-fill' | 〇 | ||
'column-gap' | 〇 | ||
'column-rule' | 〇 | ||
'column-span' | 〇 | ||
'column-width' | 〇 | ||
'color' | 〇 | 〇 | 〇 |
'font' | 〇 | 〇 | 〇 |
'font-family' | 〇 | 〇 | 〇 |
'font-size' | 〇 | 〇 | 〇 |
'font-style' | 〇 | 〇 | 〇 |
'font-variant' | 〇 | 〇 | 〇 |
'font-weight' | 〇 | 〇 | 〇 |
'letter-spacing' | 〇 | 〇 | 〇 |
'line-height' | 〇 | 〇 | 〇 |
'text-align' | 〇 | 〇 | 〇 |
'text-decoration' | 〇 | 〇 | 〇 |
'text-indent' | 〇 | 〇 | 〇 |
'text-transform' | 〇 | 〇 | 〇 |
'height' | 〇 | 〇 | 〇 |
'min-height' | 〇 | 〇 | 〇 |
'max-height' | 〇 | 〇 | 〇 |
'width' | 〇 | 〇 | 〇 |
'min-width' | 〇 | 〇 | 〇 |
'max-width' | 〇 | 〇 | 〇 |
'margin' | 〇 | 〇 | 〇 |
'margin-right' | 〇 | 〇 | 〇 |
'margin-bottom' | 〇 | 〇 | 〇 |
'margin-left' | 〇 | 〇 | 〇 |
'margin-top' | 〇 | 〇 | 〇 |
'padding' | 〇 | 〇 | 〇 |
'padding-right' | 〇 | 〇 | 〇 |
'padding-bottom' | 〇 | 〇 | 〇 |
'padding-left' | 〇 | 〇 | 〇 |
'padding-top' | 〇 | 〇 | 〇 |
'flex' | 〇 | ||
'flex-basis' | 〇 | ||
'flex-direction' | 〇 | ||
'flex-flow' | 〇 | ||
'flex-grow' | 〇 | ||
'flex-shrink' | 〇 | ||
'grid-template-columns' | 〇 | 〇 | |
'grid-auto-columns' | 〇 | ||
'grid-column-start' | 〇 | ||
'grid-column-end' | 〇 | ||
'grid-column-gap' | 〇 | ||
'grid-template-rows' | 〇 | ||
'grid-auto-rows' | 〇 | ||
'grid-row-start' | 〇 | ||
'grid-row-end' | 〇 | ||
'grid-row-gap' | 〇 | ||
'grid-gap' | 〇 | ||
'justify-content' | 〇 | ||
'justify-items' | 〇 | ||
'justify-self' | 〇 | ||
'align-content' | 〇 | ||
'align-items' | 〇 | ||
'align-self' | 〇 | ||
'clear' | 〇 | 〇 | 〇 |
'cursor' | 〇 | 〇 | 〇 |
'direction' | 〇 | 〇 | 〇 |
'float' | 〇 | 〇 | 〇 |
'overflow' | 〇 | 〇 | 〇 |
'vertical-align' | 〇 | 〇 | 〇 |
'list-style-type' | 〇 | 〇 | 〇 |
'safe_style_css'フィルターにて得られる内容が空の場合、パラメータ$cssはそのまま返り値となる。
使用例
- インラインスタイルをサニタイズする。
<?php $inline_style = safecss_filter_attr( $inline_style ); ?>
フィルター
[2.8.1]'safe_style_css'フィルターを呼び出す。パラメータ$attrには有効なスタイルのプロパティ名を列挙した配列が格納されている。$allowed_attr = apply_filters( 'safe_style_css', $attr );
アクション
直接実行するアクションはありません。ソースファイル
/wp-includes/kses.php最終更新 : 2019年11月21日 11:06
お勧め
ダッシュボードの「クイックドラフト」を「CodeMirror」に変更してみた(2019年11月5日 更新)
管理ページの「テーマエディター」では4.9以降「CodeMirror」が利用されている。今回はこの「CodeMirror」をプラグインで活用できないか調べた話である。
headタグのmeta(generator)タグを取り除く(2018年5月27日 更新)
標準的なWordPressのテーマで出力されるHTMLには、headタグ内に次のようなmetaタグが出力されている。<meta name="generator" content="WordPress 3.0.5" />
Blacklist keys manager:プラグイン作ってみました(2015年5月22日 更新)
少し前から明らかにスパムと思われるコメントが投稿され、そのモデレーションメールを受け取る回数が増えてきた。あまりにもあからさまなコメントばかりなので、何らかの対策ができないか考えてみました。
5.5の機能強化:テーマ変更時に要求バージョンを確認(2020年8月12日 更新)
WordPress 5.5 RC 2が公開され、来週には正式版がリリース。変更箇所が多い「WordPress 5.5 RC 2(以降RC 2)」のソースコードを眺めていると、テーマの切り替え前にWordPressとPHPのバージョンを確認するようになっていた。
投稿内容に応じてwpautopを制御する(2013年8月13日 更新)
投稿内容を表示する the_content関数では、 wpautop関数がフィルターの1つとして呼び出され、改行をbrタグに変換したり、pタグで調整したりする。この機能自体は便利なのだが、きちんとデザインされたHTMLソースを流し込んだ場合はこの機能は好ましくない。そんなわけで、記事内容に応じてwpautop関数を制御できないか考えてみた。