-7

我刚刚在我的 function.php 上添加了一个时事通讯 php 代码,但粘贴后我遇到了这个问题:

解析错误:语法错误,第 1 行 /home/a7888901/public_html/wp-content/themes/eleven40/functions.php 中的意外 T_REQUIRE_ONCE

这是我的function.php代码,请帮我修复它。

<?php
/** Start the engine */require_once( get_template_directory() . '/lib/init.php' );
/** Child theme (do not remove) */define( 'CHILD_THEME_NAME', 'eleven40 theme' );define( 'CHILD_THEME_URL', 'http://www.studiopress.com/themes/eleven40' );/** Add Viewport meta tag for mobile browsers */add_action( 'genesis_meta', 'eleven40_viewport_meta_tag' );function eleven40_viewport_meta_tag() {    echo '<meta name="viewport" content="width=device-width, initial-scale=1.0"/>';}
/** Add new image sizes */add_image_size( 'grid-thumbnail', 270, 100, TRUE );/** Create additional color style options */add_theme_support( 'genesis-style-selector', array(    'eleven40-blue'     => 'Blue',  'eleven40-green'    => 'Green', 'eleven40-red'      => 'Red') );
/** Add support for structural wraps */add_theme_support( 'genesis-structural-wraps', array(    'header',   'nav',  'subnav',   'inner',    'footer-widgets',   'footer') );/** Add the page title section */add_action( 'genesis_before_content_sidebar_wrap', 'eleven40_page_title' );function eleven40_page_title() {   genesis_widget_area( 'page-title', array(       'before' => '<div class="page-title widget-area">',   ) );}
/** Add the after post section */add_action( 'genesis_after_post_content', 'eleven40_after_post' );function eleven40_after_post() { if ( ! is_singular( 'post' ) )  return; genesis_widget_area( 'after-post', array(       'before' => '<div class="after-post widget-area">', ) );}
/** Add 3-column footer widgets */add_theme_support( 'genesis-footer-widgets', 3 );
/** Register widget areas */genesis_register_sidebar( array(    'id'                => 'page-title',    'name'          => __( 'Page Title', 'eleven40' ),  'description'   => __( 'This is the page title section.', 'eleven40' ),) );genesis_register_sidebar( array( 'id'                => 'after-post',    'name'          => __( 'After Post', 'eleven40' ),  'description'   => __( 'This is the after post section.', 'eleven40' ),) );}
/** Add newsletter section on single posts */add_action( 'genesis_after_post_content', 'include_newsletter' );function include_newsletter() {if ( is_singular( 'post' ) )require( CHILD_DIR.'/newsletter.php' );}
/** Customize the entire footer */remove_action( 'genesis_footer', 'genesis_do_footer' );add_action( 'genesis_footer', 'child_do_footer' );function child_do_footer() {    ?><p><center>Copyright &copy; 2013 <a href="http://www.nepaligajalsansar.com/">NepaliGajalSansar</a>.</center></p><?php}
4

1 回答 1

2

}在函数的第二次调用结束时有一个额外的genesis_register_sidebar。如果您逐行放置 1 条指令,您会很容易发现这一点。

编辑我没有重新缩进所有内容,只是在每个之后添加换行符{};通过正则表达式。语法错误位于下一行 37,在 2 之后/** Register widget areas */

<?php
/** Start the engine */
require_once( get_template_directory() . '/lib/init.php' );

/** Child theme (do not remove) */
define( 'CHILD_THEME_NAME', 'eleven40 theme' );
define( 'CHILD_THEME_URL', 'http://www.studiopress.com/themes/eleven40' );
/** Add Viewport meta tag for mobile browsers */add_action( 'genesis_meta', 'eleven40_viewport_meta_tag' );
function eleven40_viewport_meta_tag() {
    echo '<meta name="viewport" content="width=device-width, initial-scale=1.0"/>';
}

/** Add new image sizes */
add_image_size( 'grid-thumbnail', 270, 100, TRUE );
/** Create additional color style options */add_theme_support( 'genesis-style-selector', array( 'eleven40-blue'     => 'Blue',  'eleven40-green'    => 'Green', 'eleven40-red'      => 'Red') );

/** Add support for structural wraps */
add_theme_support( 'genesis-structural-wraps', array(   'header',   'nav',  'subnav',   'inner',    'footer-widgets',   'footer') );
/** Add the page title section */add_action( 'genesis_before_content_sidebar_wrap', 'eleven40_page_title' );
function eleven40_page_title() {
    genesis_widget_area( 'page-title', array(       'before' => '<div class="page-title widget-area">',   ) );
}

/** Add the after post section */
add_action( 'genesis_after_post_content', 'eleven40_after_post' );
function eleven40_after_post() {
    if ( ! is_singular( 'post' ) )  return;
    genesis_widget_area( 'after-post', array(       'before' => '<div class="after-post widget-area">', ) );
}

/** Add 3-column footer widgets */
add_theme_support( 'genesis-footer-widgets', 3 );

/** Register widget areas */
genesis_register_sidebar( array(    'id'                => 'page-title',    'name'      => __( 'Page Title', 'eleven40' ),  'description'   => __( 'This is the page title section.', 'eleven40' ),) );
genesis_register_sidebar( array(    'id'                => 'after-post',    'name'      => __( 'After Post', 'eleven40' ),  'description'   => __( 'This is the after post section.', 'eleven40' ),) );
}

/** Add newsletter section on single posts */
add_action( 'genesis_after_post_content', 'include_newsletter' );
function include_newsletter() {
    if ( is_singular( 'post' ) )require( CHILD_DIR.'/newsletter.php' );
}

/** Customize the entire footer */
remove_action( 'genesis_footer', 'genesis_do_footer' );
add_action( 'genesis_footer', 'child_do_footer' );
function child_do_footer() {
?><p><center>Copyright &copy;
2013 <a href="http://www.nepaligajalsansar.com/">NepaliGajalSansar</a>.</center></p><?php
}
于 2013-10-31T16:45:10.707 回答