解析错误:语法错误,意外的metabox.php custon-sidebar

时间:2014-08-14 20:42:15

标签: php html wordpress plugins

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

<?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
}

1 个答案:

答案 0 :(得分:1)

我认为这个问题是因为它已经在全球范围内的全球宣言。您只在函数/方法中使用全局声明。

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

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