Last active
December 5, 2021 13:48
-
-
Save rocket-martue/e7b5e22a7ec2065ce6a6f644175852df to your computer and use it in GitHub Desktop.
必要なブロックのみ表示する(sample)※コメントアウトしたブロックは、表示されない
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 必要なブロックのみ表示 | |
*/ | |
add_filter( 'allowed_block_types', 'custom_allowed_block_types' ); | |
function custom_allowed_block_types( $allowed_block_types ) { | |
if ( !current_user_can('administrator') ) { //管理者ではない場合 | |
$allowed_block_types = array( | |
// テキスト | |
'core/paragraph' // 段落 | |
'core/heading' // 見出し | |
'core/list' // リスト | |
'core/quote' // 引用 | |
'core/code' // コード | |
// 'core/freeform' // クラシック | |
'core/preformatted' // 整形済み | |
'core/pullquote' // プルクオート | |
'core/table' // テーブル | |
'core/verse' // 詩 | |
// メディア | |
'core/image' // 画像 | |
'core/gallery' // ギャラリー | |
'core/audio' // 音声 | |
'core/cover' // カバー | |
'core/file' // ファイル | |
'core/media-text' // メディアとテキスト | |
'core/video' // 動画 | |
// デザイン | |
'core/buttons' // ボタン | |
'core/columns' // カラム | |
'core/group' // グループ | |
'core/more' // 続き | |
'core/nextpage' // ページ区切り | |
'core/separator' // 区切り | |
'core/spacer' // スペーサー | |
// 'core/site-logo' // サイトロゴ | |
// 'core/site-tagline' // サイトのキャッチフレーズ | |
// 'core/site-title' // サイトのタイトル | |
// 'core/query-title' // アーカイブタイトル | |
// 'core/post-terms' // 投稿カテゴリー, 投稿タグ | |
// ウィジェット | |
'core/shortcode' // ショートコード | |
'core/archives' // アーカイブ | |
'core/calendar' // カレンダー | |
'core/categories' // カテゴリー | |
'core/html' // カスタムHTML | |
'core/latest-comments' // 最新のコメント | |
'core/latest-posts' // 最新の投稿 | |
'core/page-list' // 固定ページリスト | |
'core/rss' // RSS | |
'core/social-links' // ソーシャルアイコン | |
'core/tag-cloud' // タグクラウド | |
'core/search' // 検索 | |
// テーマ | |
// 'core/query' // クエリーループ, 投稿一覧 | |
// 'core/post-title' // 投稿タイトル | |
// 'core/post-content' // 投稿コンテンツ | |
// 'core/post-date' // 投稿日 | |
// 'core/post-excerpt' // 投稿の抜粋 | |
// 'core/post-featured-image' // 投稿のアイキャッチ画像 | |
// 'core/loginout' // ログイン/ログアウト | |
// 埋め込み | |
'core/embed' | |
); | |
return $allowed_block_types; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment