在Wordpress网站上引发ParseError

时间:2018-08-04 21:01:41

标签: php wordpress

使用Wordpress中的css / html内置编辑器,我已经在functions.php文件中添加了一些代码,但是发生了一些错误,每次我打开网站时都会出现以下错误:

$variable_firstname = filter_input (INPUT_POST, 'firstname', FILTER_UNSAFE_RAW);
if ( mb_strlen($variable_firstname , 'UTF-8')  <  3 )
{
   print '<input type="text" name="firstname" value="'.$variable_firstname.'">';
}

我使用文件管理器访问了主题的functions.php文件,并将其替换为主题的原始文件,并且代码中未显示任何错误,但是,在打开网站时仍然存在相同的错误。有什么事吗预先感谢。

编辑:这是functions.php文件内容的一部分。我添加的代码在最后,之后我删除了它,但错误仍然存​​在。

 ParseError thrown
 syntax error, unexpected '<', expecting end of file

1 个答案:

答案 0 :(得分:0)

我检查了您的代码有两个错误  没有定义第一个功能的右括号,如果条件在任何地方都没有结束。

 if ( ! function_exists( 'buzzstore_setup' ) ) :
 /**
  * Sets up theme defaults and registers support for various WordPress 
 features.
  *
  * Note that this function is hooked into the after_setup_theme hook, which
  * runs before the init hook. The init hook is too late for some features, 
 such
  * as indicating support for post thumbnails.
  */
 function buzzstore_setup() {
    /*
     * Make theme available for translation.
      * Translations can be filed in the /languages/ directory.
      * If you're building a theme based on Buzz Store, use a find and replace
     * to change 'buzzstore' to the name of your theme in all the template files.
      */
     load_theme_textdomain( 'buzzstore', get_template_directory() . '/languages' );

    // Add default posts and comments RSS feed links to head.
    add_theme_support( 'automatic-feed-links' );

    // WooCommerce Plugins Support
    add_theme_support( 'woocommerce' );

    // Set up the WordPress Gallery Lightbox
    add_theme_support('wc-product-gallery-lightbox');

    /*
     * Let WordPress manage the document title.
     * By adding theme support, we declare that this theme does not use a
      * hard-coded <title> tag in the document head, and expect WordPress to
      * provide it for us.
     */
    add_theme_support( 'title-tag' );

    /*
     * Enable support for custom logo.
        */
    add_theme_support( 'custom-logo', array(
        'width'       => 190,
        'height'      => 60,
        'flex-width'  => true,              
        'flex-height' => true,
        'header-text' => array( '.site-title', '.site-description' ),
    ) );

    /*
     * Enable support for Post Thumbnails on posts and pages.
     *
     * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
    */
    add_theme_support( 'post-thumbnails' );
    add_image_size('buzzstore-banner-image', 1350, 485, true); // banner
    add_image_size('buzzstore-news-image', 370, 285, true); // Home Blog
    add_image_size('buzzstore-news-details-image', 850, 385, true); // Details Blog
    add_image_size('buzzstore-cat-image', 275, 370, true);


    // This theme uses wp_nav_menu() in one location.
    register_nav_menus( array(
        'topmenu' => esc_html__( 'Top Menu', 'buzzstore' ),
        'primary' => esc_html__( 'Primary', 'buzzstore' ),
    ) );

    /*
     * Switch default core markup for search form, comment form, and comments
     * to output valid HTML5.
     */
    add_theme_support( 'html5', array(
        'search-form',
        'comment-form',
        'comment-list',
        'gallery',
        'caption',
    ) );

}
function buzzstore_customize_partial_blogname() {
    bloginfo( 'name' );
}
function buzzstore_customize_partial_blogdescription() {
    bloginfo( 'description' );
}
endif;