Wp主题错误PHP

Wp主题错误PHP,php,wordpress,templates,themes,Php,Wordpress,Templates,Themes,大家好,我得到了新的可湿性粉剂主题,我不能安装我得到这个网站上的错误 分析错误:语法错误,意外“}”,应为中的文件结尾 /storage/h3/665/790665/public_html/wp content/themes/gameaddict/post_templates.php 在线1 假设主题是这一个,并且它是从themeforest购买的,那么它应该是开箱即用的。再次尝试下载,确保检查您正在下载的zip文件中是否没有压缩文件,以确保您正在上载正确的文件,有时您下载的zip文件中有很多

大家好,我得到了新的可湿性粉剂主题,我不能安装我得到这个网站上的错误

分析错误:语法错误,意外“}”,应为中的文件结尾 /storage/h3/665/790665/public_html/wp content/themes/gameaddict/post_templates.php 在线1



假设主题是这一个,并且它是从themeforest购买的,那么它应该是开箱即用的。再次尝试下载,确保检查您正在下载的zip文件中是否没有压缩文件,以确保您正在上载正确的文件,有时您下载的zip文件中有很多文件,如文档和演示,但实际的主题文件是另一个zip文件。

如果上面没有任何帮助,请写信给他们的客户支持。

假设主题是这一个,并且它是从他们之前购买的,那么它应该可以开箱即用。再次尝试下载,确保检查您正在下载的zip文件中是否没有压缩文件,以确保您正在上载正确的文件,有时您下载的zip文件中有很多文件,如文档和演示,但实际的主题文件是另一个zip文件。

如果上面没有任何帮助,请写信给他们的客户支持。

基本上,它是在抱怨
wp content/themes/gameaddict/post_templates.php
在第1行有一个
}
,而php则希望文件结束。您包含的代码似乎很好。问题很可能是开发人员在代码的某个地方关闭了一个括号而没有打开它。看起来您使用的是一个预先制作的主题,在这种情况下,与开发人员联系是最好的选择。

基本上,它抱怨
wp-content/themes/gameaddict/post_-templates.php
在第1行有一个
}
,而php则希望文件结束。您包含的代码似乎很好。问题很可能是开发人员在代码的某个地方关闭了一个括号而没有打开它。似乎您正在使用一个预先制作的主题,在这种情况下,联系开发人员是最好的选择。

您编写了主题吗?如果没有,请询问作者您确定这是正确的文件吗?第1行没有
}
。当我在ftp中上载所有文件,然后尝试在网站上激活时,我总是收到此错误。您是否编写主题?如果没有,请询问作者您确定这是正确的文件吗?第1行没有
}
。当我在ftp中上载所有文件,然后尝试在网站上激活时,我总是会遇到此错误。请告诉我您上载到网站的zip包含哪些内容?截图将显示dogame-addict.zip此文件夹im上载您是否尝试通过ftp上载?是的,还有一件事,即使我删除了该post_模板上的一半代码,也会产生相同的错误。您能告诉我您上载到该网站的zip中包含哪些内容吗?屏幕截图将显示dogame-addict.zip此文件夹im uploading您是否尝试通过ftp上传它?是的,还有一件事,即使我删除了该post_模板上的一半代码,也会出现相同的错误
<?php
class Single_Post_Template_Plugin {
    function __construct() {
        add_action( 'admin_menu', array( $this, 'add_metabox' ) );
        add_action( 'save_post', array( $this, 'metabox_save' ), 1, 2 );
        add_filter( 'single_template', array( $this, 'get_post_template' ) );
    }
    function get_post_template( $template ) {
        global $post;
        $custom_field = get_post_meta( $post->ID, '_wp_post_template', true );
        if( !$custom_field )
            return $template;
        /** Prevent directory traversal */
        $custom_field = str_replace( '..', '', $custom_field );
        if( file_exists( get_stylesheet_directory() . "/{$custom_field}" ) )
            $template = get_stylesheet_directory() . "/{$custom_field}";
        elseif( file_exists( get_template_directory() . "/{$custom_field}" ) )
            $template = get_template_directory() . "/{$custom_field}";
        return $template;
    }
    function get_post_templates() {
        $templates = wp_get_theme()->get_files( 'php', 1 );
        $post_templates = array();
        $base = array( trailingslashit( get_template_directory()), trailingslashit( get_stylesheet_directory()) );
        foreach ( (array) $templates as $file => $full_path ) {
            if( $full_path ==  get_theme_root().'/gameaddict/post_templates.php'){continue;}else{
            if ( !preg_match( '|Single Post Template:(.*)$|mi', file_get_contents( $full_path ), $header ))
                continue;
            $post_templates[ $file ] = _cleanup_header_comment( $header[1] );
        }}
        return $post_templates;
    }
    function post_templates_dropdown() {
        global $post;
        $post_templates = $this->get_post_templates();
        /** Loop through templates, make them options */
        foreach ( (array) $post_templates as $template_file => $template_name ) {
            $selected = ( $template_file == get_post_meta( $post->ID, '_wp_post_template', true ) ) ? ' selected="selected"' : '';
            $opt = '<option value="' . esc_attr( $template_file ) . '"' . $selected . '>' . esc_html( $template_name ) . '</option>';
            echo $opt;
        }
    }
    function add_metabox() {

         $screens = array( 'post', 'portfolio' );

    foreach ( $screens as $screen ) {

        add_meta_box(
            'pt_post_templates',
            __( 'Sidebar position', 'addict' ),
            array( $this, 'metabox' ),
            $screen,'normal', 'high'

        );
    }


    }
    function metabox( $post ) {
        ?>
        <input type="hidden" name="pt_noncename" id="pt_noncename" value="<?php echo wp_create_nonce( plugin_basename( __FILE__ ) ); ?>" />
        <label class="hidden" for="post_template"><?php  _e( 'Post Template', 'addict' ); ?></label><br />
        <select name="_wp_post_template" id="post_template" class="dropdown">
            <?php $this->post_templates_dropdown(); ?>
        </select>
        <?php
    }
    function metabox_save( $post_id, $post ) {
        /*
         * Verify this came from the our screen and with proper authorization,
         * because save_post can be triggered at other times
         */
        if(isset($_POST['pt_noncename'])){
        if ( !wp_verify_nonce( $_POST['pt_noncename'], plugin_basename( __FILE__ ) ) )
            return $post->ID;
         }
        /** Is the user allowed to edit the post or page? */
        if(isset($_POST['post_type'])){
        if ( 'page' == $_POST['post_type'] )
            if ( !current_user_can( 'edit_page', $post->ID ) )
                return $post->ID;
        else
            if ( !current_user_can( 'edit_post', $post->ID ) )
                return $post->ID;
        }
        /** OK, we're authenticated: we need to find and save the data */
        /** Put the data into an array to make it easier to loop though and save */
        if(isset($_POST['_wp_post_template'])){
        $mydata['_wp_post_template'] = $_POST['_wp_post_template'];
        }
        /** Add values of $mydata as custom fields */
        if(isset($mydata)){
        foreach ( $mydata as $key => $value ) {
            /** Don't store custom data twice */
            if( 'revision' == $post->post_type )
                return;
            /** If $value is an array, make it a CSV (unlikely) */
            $value = implode( ',', (array) $value );
            /** Update the data if it exists, or add it if it doesn't */
            if( get_post_meta( $post->ID, $key, false ) )
                update_post_meta( $post->ID, $key, $value );
            else
                add_post_meta( $post->ID, $key, $value );
            /** Delete if blank */
            if( !$value )
                delete_post_meta( $post->ID, $key );
        }}
    }
}
add_action( 'init', 'post_templates_plugin_init' );
/**
 * Instantiate the class after theme has been set up.
 */
function post_templates_plugin_init() {
    new Single_Post_Template_Plugin;
}