php - functions.php 代码打印在屏幕 wordpress 上
问题描述
我正在尝试制作一个子主题,一切看起来都很好,直到我将 php 版本从 5.6 更改为 7.2.1,发生的情况是 functions.php 代码在屏幕上打印(回显),如果我检查图像没有意义。
这是我的 functions.php,它只是 wordpress 中的一个示例,向您展示正在发生的事情:
<?function wporg_shortcode($atts = [], $content = null, $tag = '')
{
// normalize attribute keys, lowercase
$atts = array_change_key_case((array)$atts, CASE_LOWER);
// override default attributes with user attributes
$wporg_atts = shortcode_atts([
"title" => "WordPress.org",
], $atts, $tag);
// start output
$o = '';
// start box
$o .= '<div class="wporg-box">';
// title
$o .= '<h2>' . esc_html__($wporg_atts['title'], 'wporg') . '</h2>';
// enclosing tags
if (!is_null($content)) {
// secure output by executing the_content filter hook on $content
$o .= apply_filters('the_content', $content);
// run shortcode parser recursively
$o .= do_shortcode($content);
}
// end box
$o .= '</div>';
// return output
return $o;
}
function wporg_shortcodes_init()
{
add_shortcode('wporg', 'wporg_shortcode');
}
add_action('init', 'wporg_shortcodes_init');
解决方案
开始文件<?php
不是从<?
推荐阅读
- java - 使用 ArrayAdapter (Java Android) 返回 ListView 时获取 IndexOutOfBoundsException: Index: 1, Size: 0
- javascript - JavaScript onclick 函数只工作一次(非常简单的代码)
- php - 从 laravel 的数据库中打印刀片指令
- mysql - spring boot 在应用程序属性中使用占位符
- ruby-on-rails - Ruby 正则表达式允许使用字母数字和 & 符号
- python - 在 Python 中将字符串转换为字典
- java - 如何编写忽略数据库活动的 JUnit 测试用例
- jquery - 如果长度大于 2,则使用 jquery 添加价格
- kubernetes - Helm(或 Kubernetes)是否缓存图表?
- javascript - NEXT.js 同构-unfetch 出错了