WordPress开发教程:如何移除后台仪表盘上的小工具区块

前端之家收集整理的这篇文章主要介绍了WordPress开发教程:如何移除后台仪表盘上的小工具区块前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我们在使用的过程中,很多时候需要修改网站后台的显示和布局。第一步就是修改仪表盘上的小工具。在前面的教程里我们已经向大家讲解了。在这篇教程里,我们将重点向大家讲解一下移除后台仪表盘上小工具区块的方法,移除的小工具区块见下图。

dashboard

切换到主题目录,打开functions.PHP文件,加入以下代码

Crayon-5c891d1c9df06349759259" class="Crayon-Syntax Crayon-theme-classic Crayon-font-monaco Crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouSEOver" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
Crayon-toolbar" data-settings=" mouSEOver overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-title">functions.PHP
Crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-mixed-highlight" title="Contains Mixed Languages">
Crayon-button Crayon-nums-button" title="Toggle Line Numbers">
Crayon-button-icon">
Crayon-button Crayon-plain-button" title="Toggle Plain Code">
Crayon-button-icon">
Crayon-button Crayon-wrap-button" title="Toggle Line Wrap">
Crayon-button-icon">
Crayon-button Crayon-expand-button" title="Expand Code">
Crayon-button-icon">
Crayon-button Crayon-copy-button" title="Copy">
Crayon-button-icon">
Crayon-button Crayon-popup-button" title="Open Code In New Window">
Crayon-button-icon">
Crayon-language">PHP
Crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
Crayon-plain-wrap">
Crayon-main" style="">Crayon-table">Crayon-row">
Crayon-nums " data-settings="show">
Crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
Crayon-num" data-line="Crayon-5c891d1c9df06349759259-1">1
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1c9df06349759259-2">2
Crayon-num" data-line="Crayon-5c891d1c9df06349759259-3">3
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1c9df06349759259-4">4
Crayon-num" data-line="Crayon-5c891d1c9df06349759259-5">5
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1c9df06349759259-6">6
Crayon-num" data-line="Crayon-5c891d1c9df06349759259-7">7
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1c9df06349759259-8">8
Crayon-num" data-line="Crayon-5c891d1c9df06349759259-9">9
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1c9df06349759259-10">10
Crayon-num" data-line="Crayon-5c891d1c9df06349759259-11">11
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1c9df06349759259-12">12
Crayon-num" data-line="Crayon-5c891d1c9df06349759259-13">13
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1c9df06349759259-14">14
Crayon-num" data-line="Crayon-5c891d1c9df06349759259-15">15
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1c9df06349759259-16">16
Crayon-num" data-line="Crayon-5c891d1c9df06349759259-17">17
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1c9df06349759259-18">18
Crayon-num" data-line="Crayon-5c891d1c9df06349759259-19">19
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1c9df06349759259-20">20
Crayon-num" data-line="Crayon-5c891d1c9df06349759259-21">21
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1c9df06349759259-22">22
Crayon-num" data-line="Crayon-5c891d1c9df06349759259-23">23
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1c9df06349759259-24">24
Crayon-code">
Crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
Crayon-line" id="Crayon-5c891d1c9df06349759259-1">Crayon-ta">PHP
Crayon-line Crayon-striped-line" id="Crayon-5c891d1c9df06349759259-2">Crayon-h"> Crayon-t">functionCrayon-h"> Crayon-e">remove_dashboard_widgetsCrayon-sy">(Crayon-sy">)Crayon-h"> Crayon-sy">{
Crayon-line" id="Crayon-5c891d1c9df06349759259-3">Crayon-h"> Crayon-m">globalCrayon-h"> Crayon-v">$wp_Meta_BoxesCrayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891d1c9df06349759259-4">Crayon-h"> Crayon-c">//Right Now - Comments,Pages at a glance
Crayon-line" id="Crayon-5c891d1c9df06349759259-5">Crayon-h"> Crayon-k ">unsetCrayon-sy">(Crayon-v">$wp_Meta_BoxesCrayon-sy">[Crayon-s">'dashboard'Crayon-sy">]Crayon-sy">[Crayon-s">'normal'Crayon-sy">]Crayon-sy">[Crayon-s">'core'Crayon-sy">]Crayon-sy">[Crayon-s">'dashboard_right_now'Crayon-sy">]Crayon-sy">)Crayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891d1c9df06349759259-6">Crayon-h"> Crayon-c">//Recent Comments
Crayon-line" id="Crayon-5c891d1c9df06349759259-7">Crayon-h"> Crayon-k ">unsetCrayon-sy">(Crayon-v">$wp_Meta_BoxesCrayon-sy">[Crayon-s">'dashboard'Crayon-sy">]Crayon-sy">[Crayon-s">'normal'Crayon-sy">]Crayon-sy">[Crayon-s">'core'Crayon-sy">]Crayon-sy">[Crayon-s">'dashboard_recent_comments'Crayon-sy">]Crayon-sy">)Crayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891d1c9df06349759259-8">Crayon-h"> Crayon-c">//Incoming Links
Crayon-line" id="Crayon-5c891d1c9df06349759259-9">Crayon-h"> Crayon-k ">unsetCrayon-sy">(Crayon-v">$wp_Meta_BoxesCrayon-sy">[Crayon-s">'dashboard'Crayon-sy">]Crayon-sy">[Crayon-s">'normal'Crayon-sy">]Crayon-sy">[Crayon-s">'core'Crayon-sy">]Crayon-sy">[Crayon-s">'dashboard_incoming_links'Crayon-sy">]Crayon-sy">)Crayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891d1c9df06349759259-10">Crayon-h"> Crayon-c">//Plugins - Popular,New and Recently updated wordpress Plugins
Crayon-line" id="Crayon-5c891d1c9df06349759259-11">Crayon-h"> Crayon-k ">unsetCrayon-sy">(Crayon-v">$wp_Meta_BoxesCrayon-sy">[Crayon-s">'dashboard'Crayon-sy">]Crayon-sy">[Crayon-s">'normal'Crayon-sy">]Crayon-sy">[Crayon-s">'core'Crayon-sy">]Crayon-sy">[Crayon-s">'dashboard_plugins'Crayon-sy">]Crayon-sy">)Crayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891d1c9df06349759259-12">Crayon-h"> Crayon-c">//wordpress Development Blog Feed
Crayon-line" id="Crayon-5c891d1c9df06349759259-13">Crayon-h"> Crayon-k ">unsetCrayon-sy">(Crayon-v">$wp_Meta_BoxesCrayon-sy">[Crayon-s">'dashboard'Crayon-sy">]Crayon-sy">[Crayon-s">'side'Crayon-sy">]Crayon-sy">[Crayon-s">'core'Crayon-sy">]Crayon-sy">[Crayon-s">'dashboard_primary'Crayon-sy">]Crayon-sy">)Crayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891d1c9df06349759259-14">Crayon-h"> Crayon-c">//Other wordpress News Feed
Crayon-line" id="Crayon-5c891d1c9df06349759259-15">Crayon-h"> Crayon-k ">unsetCrayon-sy">(Crayon-v">$wp_Meta_BoxesCrayon-sy">[Crayon-s">'dashboard'Crayon-sy">]Crayon-sy">[Crayon-s">'side'Crayon-sy">]Crayon-sy">[Crayon-s">'core'Crayon-sy">]Crayon-sy">[Crayon-s">'dashboard_secondary'Crayon-sy">]Crayon-sy">)Crayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891d1c9df06349759259-16">Crayon-h"> Crayon-c">//Quick Press Form
Crayon-line" id="Crayon-5c891d1c9df06349759259-17">Crayon-h"> Crayon-k ">unsetCrayon-sy">(Crayon-v">$wp_Meta_BoxesCrayon-sy">[Crayon-s">'dashboard'Crayon-sy">]Crayon-sy">[Crayon-s">'side'Crayon-sy">]Crayon-sy">[Crayon-s">'core'Crayon-sy">]Crayon-sy">[Crayon-s">'dashboard_quick_press'Crayon-sy">]Crayon-sy">)Crayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891d1c9df06349759259-18">Crayon-h"> Crayon-c">//Recent Drafts List
Crayon-line" id="Crayon-5c891d1c9df06349759259-19">Crayon-h"> Crayon-k ">unsetCrayon-sy">(Crayon-v">$wp_Meta_BoxesCrayon-sy">[Crayon-s">'dashboard'Crayon-sy">]Crayon-sy">[Crayon-s">'side'Crayon-sy">]Crayon-sy">[Crayon-s">'core'Crayon-sy">]Crayon-sy">[Crayon-s">'dashboard_recent_drafts'Crayon-sy">]Crayon-sy">)Crayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891d1c9df06349759259-20">Crayon-h"> Crayon-c">//activity
Crayon-line" id="Crayon-5c891d1c9df06349759259-21">Crayon-h"> Crayon-k ">unsetCrayon-sy">(Crayon-v">$wp_Meta_BoxesCrayon-sy">[Crayon-s">'dashboard'Crayon-sy">]Crayon-sy">[Crayon-s">'normal'Crayon-sy">]Crayon-sy">[Crayon-s">'core'Crayon-sy">]Crayon-sy">[Crayon-s">'dashboard_activity'Crayon-sy">]Crayon-sy">)Crayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891d1c9df06349759259-22">Crayon-h"> Crayon-sy">}
Crayon-line" id="Crayon-5c891d1c9df06349759259-23">Crayon-h"> Crayon-e">add_actionCrayon-sy">(Crayon-s">'wp_dashboard_setup'Crayon-sy">,Crayon-h"> Crayon-s">'remove_dashboard_widgets'Crayon-sy">)Crayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891d1c9df06349759259-24">

上面的代码会把后台仪表盘上的所有默认小工具区块都删除,如果您想保留哪一个小工具区块,可以注释掉对应的代码

如果我们只希望管理员角色可以看到这些小工具区块信息,其他用户角色(编辑、作者、投稿者、订阅者)看不到这些小工具区块信息,可以修改上面的代码为:

Crayon-5c891d1c9df11543151266" class="Crayon-Syntax Crayon-theme-classic Crayon-font-monaco Crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouSEOver" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
Crayon-toolbar" data-settings=" mouSEOver overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-title">functions.PHP
Crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-mixed-highlight" title="Contains Mixed Languages">
Crayon-button Crayon-nums-button" title="Toggle Line Numbers">
Crayon-button-icon">
Crayon-button Crayon-plain-button" title="Toggle Plain Code">
Crayon-button-icon">
Crayon-button Crayon-wrap-button" title="Toggle Line Wrap">
Crayon-button-icon">
Crayon-button Crayon-expand-button" title="Expand Code">
Crayon-button-icon">
Crayon-button Crayon-copy-button" title="Copy">
Crayon-button-icon">
Crayon-button Crayon-popup-button" title="Open Code In New Window">
Crayon-button-icon">
Crayon-language">PHP
Crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
Crayon-plain-wrap">
Crayon-main" style="">Crayon-table">Crayon-row">
Crayon-nums " data-settings="show">
Crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
Crayon-num" data-line="Crayon-5c891d1c9df11543151266-1">1
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1c9df11543151266-2">2
Crayon-num" data-line="Crayon-5c891d1c9df11543151266-3">3
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1c9df11543151266-4">4
Crayon-num" data-line="Crayon-5c891d1c9df11543151266-5">5
Crayon-code">
Crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
Crayon-line" id="Crayon-5c891d1c9df11543151266-1">Crayon-ta">PHP
Crayon-line Crayon-striped-line" id="Crayon-5c891d1c9df11543151266-2">Crayon-st">ifCrayon-h"> Crayon-sy">(Crayon-o">!Crayon-e">current_user_canCrayon-sy">(Crayon-s">'manage_options'Crayon-sy">)Crayon-sy">)Crayon-h"> Crayon-sy">{
Crayon-line" id="Crayon-5c891d1c9df11543151266-3">Crayon-h"> Crayon-e">add_actionCrayon-sy">(Crayon-s">'wp_dashboard_setup'Crayon-sy">,Crayon-h"> Crayon-s">'remove_dashboard_widgets'Crayon-h"> Crayon-sy">)Crayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891d1c9df11543151266-4">Crayon-sy">}
Crayon-line" id="Crayon-5c891d1c9df11543151266-5">

原文链接:https://www.f2er.com/wordpress/238460.html

猜你在找的wordpress相关文章