# 七星主题修复的问题

- Link: https://www.ixiqin.com/2018/01/13/seven-star-theme-repair-the-problem/
- Published: 2018-01-13T13:46:41+08:00
- Author: 白宦成

文章目录

 [Toggle](https://www.ixiqin.com/2018/01/13/seven-star-theme-repair-the-problem/#)

 * [建议给has_cap传入一个参数！用户级别已被废弃，请改用能力。](https://www.ixiqin.com/2018/01/13/seven-star-theme-repair-the-problem/#%e5%bb%ba%e8%ae%ae%e7%bb%99has_cap%e4%bc%a0%e5%85%a5%e4%b8%80%e4%b8%aa%e5%8f%82%e6%95%b0%ef%bc%81%e7%94%a8%e6%88%b7%e7%ba%a7%e5%88%ab%e5%b7%b2%e8%a2%ab%e5%ba%9f%e5%bc%83%ef%bc%8c%e8%af%b7%e6%94%b9%e7%94%a8%e8%83%bd%e5%8a%9b%e3%80%82)
 * [无法加载后台设置项目](https://www.ixiqin.com/2018/01/13/seven-star-theme-repair-the-problem/#%e6%97%a0%e6%b3%95%e5%8a%a0%e8%bd%bd%e5%90%8e%e5%8f%b0%e8%ae%be%e7%bd%ae%e9%a1%b9%e7%9b%ae)
 * [使用类名作为构造函数](https://www.ixiqin.com/2018/01/13/seven-star-theme-repair-the-problem/#%e4%bd%bf%e7%94%a8%e7%b1%bb%e5%90%8d%e4%bd%9c%e4%b8%ba%e6%9e%84%e9%80%a0%e5%87%bd%e6%95%b0)

前段时间承接了 李长太老师的博客，由于我惯用 PHP 7 ，所以李老师的博客也被我放在了
PHP 7 的站点上，但是由于使用的主题是第三方仿的，在使用中出现了非常多的问题。
 比如：
无法正常加载主题设置项、开启 Debug 后显示非常多的报错。在这里记录一下，以备后用。

# 建议给has_cap传入一个参数！用户级别已被废弃，请改用能力。

这是因为使用的函数调用的是传统的 1，2，3来表示权限，但是用户等级早已弃用，将其中
的用户等级修改为权限名即可。

    ```language-
    add_menu_page("主题设置", "主题设置", '10', 'sevenstar_theme', array(&$this,'sevenStar_Theme_Options_Form'),'dashicons-carrot','777');
    // 改为
    add_menu_page("主题设置", "主题设置", 'manage_options', 'sevenstar_theme', array(&$this,'sevenStar_Theme_Options_Form'),'dashicons-carrot','777');
    ```

# 无法加载后台设置项目

这一块主要是渲染表单出了问题，所以这里就只需要将对应的用法改为 php7 的即可。

    ```language-
    $this->$option['type']( $option )
    // 改为
    {$option['type']}( $option );
    ```

# 使用类名作为构造函数

这个更为简单，只需将类名对应的构造函数改为 `__construct`即可
