LoginSignup
5
8

More than 3 years have passed since last update.

[Wordpress]管理側の諸々の非表示まとめ

Last updated at Posted at 2016-07-25

都度追記していきます。

ログイン中のユーザーID

ユーザーで表示を切り分ける場合など用で。

functions.php
$user = wp_get_current_user();
//ex
if ( in_array($user->ID, [1]) ) return;

ダッシュボード-ウィジェット

functions.php
add_action('wp_dashboard_setup', function() {
    $tmp = [
            'wp_welcome_panel',//WordPressへようこそ!
            'dashboard_activity',//アクティビティ
            'dashboard_recent_comments',//最近のコメント
            'dashboard_incoming_links',//被リンク
            'dashboard_plugins',//プラグイン
            'dashboard_quick_press',//クイック投稿
            'dashboard_recent_drafts',//最近の下書き
            'dashboard_primary',//WordPressブログ
            'dashboard_secondary',//WordPressフォーラム
            'dashboard_site_health',//サイトヘルスステータス
    ];
    foreach ($tmp as $v) {
        if ( $v == 'wp_welcome_panel' ) {
            remove_action('welcome_panel', 'wp_welcome_panel');
        } else {
            global $wp_meta_boxes;
            unset($wp_meta_boxes['dashboard']['normal']['core'][$v]);
            unset($wp_meta_boxes['dashboard']['side']['core'][$v]);
        }
    }
});

左メニュー

functions.php
add_action('admin_menu', function() {
    remove_menu_page('index.php');//ダッシュボード
    remove_menu_page('edit.php');//投稿
    remove_menu_page('upload.php');//メディア
    remove_menu_page('edit.php?post_type=page');//固定ページ
    remove_menu_page('edit-comments.php');//コメント
    remove_menu_page('themes.php');//外観
    remove_menu_page('plugins.php');//プラグイン
    remove_menu_page('users.php');//ユーザー
    remove_menu_page('tools.php');//ツール
    remove_submenu_page('tools.php', 'site-health.php');//サイトヘルス
    remove_menu_page('options-general.php');//設定
    remove_submenu_page('options-general.php','options-writing.php');//設定-投稿設定
    remove_submenu_page('options-general.php','options-reading.php');//設定-表示設定
    remove_submenu_page('options-general.php','options-discussion.php');//設定-ディスカッション設定
    remove_submenu_page('options-general.php','options-media.php');//設定-メディア設定
    remove_submenu_page('options-general.php','options-permalink.php');//設定-パーマリンク設定
    remove_menu_page('cptui_main_menu');//Custom Post Type UI
});

add_action('admin_init', function() {
    remove_menu_page('edit.php?post_type=acf');//Advanced Custom Fields
});

投稿ウィジェット

functions.php
add_action('admin_menu', function() {
    $post_type = ['post'];//対象投稿タイプ追加
    remove_meta_box('postcustom', $post_type, 'normal');//カスタムフィールド
    remove_meta_box('postexcerpt', $post_type, 'normal');//抜粋
    remove_meta_box('commentstatusdiv', $post_type, 'normal');//ディスカッション
    remove_meta_box('commentsdiv', $post_type, 'normal');//コメント設定
    remove_meta_box('trackbacksdiv', $post_type, 'normal');//トラックバック設定
    remove_meta_box('revisionsdiv', $post_type, 'normal');//リビジョン表示
    remove_meta_box('formatdiv', $post_type, 'normal');//フォーマット設定
    remove_meta_box('slugdiv', $post_type, 'normal');//スラッグ設定
    remove_meta_box('authordiv', $post_type, 'normal');//投稿者
    remove_meta_box('categorydiv', $post_type, 'normal');//カテゴリー
    remove_meta_box('tagsdiv-post_tag', $post_type, 'normal');//タグ
    remove_meta_box('dashboard_activity', $post_type, 'normal');//アクティビティー
});

投稿一覧

functions.php
add_filter("post_row_actions", function($actions, $post) {
    unset($actions['inline hide-if-no-js']);//クイック編集
    return $actions;
}, 0, 2);

投稿編集

functions.php
add_action('admin_head', function() {
    echo <<<EOT
<style>
a.edit-post-status { display: none !important; }/* ステータス */
</style>
EOT;
}, 11);
5
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
8