duanmei1694 2012-05-06 12:11
浏览 31
已采纳

Wordpress插件错误PHP

When trying to activate my plugin, wordpress comes up with this error:

Plugin could not be activated because it triggered a fatal error. Parse error: syntax error, unexpected T_FUNCTION on line 79

The line 79 is the first line of the snippet below, from looking into this I think it is because of a PHP version error, since I have no control over updating php, how would I make it compatible with earlier versions?

add_action('admin_menu', function(){
        Plugin_Options::add_menu_page();
    });
  • 写回答

2条回答 默认 最新

  • dongzhan1948 2012-05-06 12:13
    关注

    Most likely, your PHP version is < 5.3. Anonymous functions were added to PHP in 5.3. In order to make use of this, you can pass the function as a callback string like:

    function add_menu_callback() {
      Plugin_Options::add_menu_page();
    }
    
    add_action('admin_menu', 'add_menu_callback');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失
  • ¥15 springboot+vue 集成keycloak sso到阿里云
  • ¥15 win7系统进入桌面过一秒后突然黑屏
  • ¥30 backtrader对于期货交易的现金和资产计算的问题
  • ¥15 求C# .net4.8小报表工具
  • ¥15 安装虚拟机时出现问题
  • ¥15 Selenium+docker Chrome不能运行
  • ¥15 mac电脑,安装charles后无法正常抓包
  • ¥18 visio打开文件一直显示文件未找到