为 wordpress 后台添加“全部设置”选项

  • 时间:2020-05-16 19:39:54
  • 分类:网络文摘
  • 阅读:176 次

通过 wordpress 的“全部设置”选项可以对自定义字段值、插件设置、常规设置、主题设置等进行修改,相当于在数据库之外修改wp_options数据表。

这个“全部设置”选项默认是隐藏的,平时可以使用 http://yourdomain.com/wp-admin/options.php 链接打开。如果不想每次都输入链接,可以将此选项在后台开启,方便调用。

具体方法:

将下例代码添加到当前 wordpress主题的配置文件 functions.php 中,保存即可。

  1. // 显示全部设置选项
  2. function all_settings_link() {
  3.     add_options_page(__('All Settings'), __('All Settings'), 'administrator', 'options.php');
  4. }
  5. add_action('admin_menu', 'all_settings_link');

登陆后台就可以看到在“设置”菜单中多了一个“全部设置”的选项,如下图所示:

开启wordpress 全部设置

推荐阅读:
Facebook Onsite Interview Preparation Part 2: Coding Questions  The Process Killing Algorithms using Depth First Search or Bread  Breadth-First Search Algorithm to Solve Puzzle (Rotting Oranges)  Facebook Onsite Interview Preparation Part 1: Motivation/Bahavio  Celebrate WordPress’ 13th Birthday With These Interesting Facts  5 Ways to Use Your Smartphone to Build a Better Blog  The Most Expensive Domain Sales Ever  15 Ways Of How Not To Kill Your Leadership Authority  Study Shows Strong Growth of Tech Inventions to Fight Climate Ch  Interested in Bitcoins? Here are 10 Blogs You Need to Check Out 
评论列表
添加评论