解析错误:语法错误、意外的元框.php侧边栏


Parse error: syntax error, unexpected metabox.php custon-sidebar

我执行了将生产服务器的批准迁移到wordpress的操作,最终在一个名为"custom-sidebar"的插件中给出了以下消息: 解析错误:语法错误,/home/storage/c/ff/92/sindpfpr/public_html/wp-content/plugins/custom-sidebars/views/metabox.php中的意外T_GLOBAL 在第 2 行遵循指向错误的代码,我非常感谢那些帮助我解决这个问题的人, 谢谢

<?php
/**
 * Metabox inside posts/pages where user can define custom sidebars for an
 * individual post.
 */
global $wp_registered_sidebars;
$available = $wp_registered_sidebars;
$sidebars = CustomSidebars::get_options( 'modifiable' );
?>
<p>
    <?php _e(
        'Here you can replace the default sidebars. Simply select what ' .
        'sidebar you want to show for this post!', CSB_LANG
    ); ?>
</p>
<?php if ( ! empty( $sidebars ) ) { ?>
    <?php foreach ( $sidebars as $s ) { ?>
        <?php $sb_name = $available[ $s ]['name']; ?>
        <p>
            <b><?php echo esc_html( $sb_name ); ?></b>:
            <select name="cs_replacement_<?php echo esc_attr( $s ); ?>">
                <option value=""></option>
                <?php foreach ( $available as $a ) : ?>
                <option value="<?php echo esc_attr( $a['id'] ); ?>" <?php selected( $selected[ $s ], $a['id'] ); ?>>
                    <?php echo esc_html( $a['name'] ); ?>
                </option>
                <?php endforeach; ?>
            </select>
        </p>
    <?php
    }
} else {
    ?>
    <p id="message" class="updated">
        <?php _e(
            'All sidebars have been locked, you cannot replace them. ' .
            'Go to <a href="widgets.php">the widgets page</a> to unlock a ' .
            'sidebar', CSB_LANG
        ); ?>
    </p>
    <?php
}
我相信

这个问题是因为全球声明已经处于全球范围内。 只能在函数/方法中使用全局声明。

http://php.net/manual/en/language.variables.scope.php

但是,在函数中使用全局变量是一种不好的做法,我不建议这样做。