简体   繁体   English

如何修复主题主题的Wordpress Blog中的语法错误

[英]How to Fix Syntax error in Wordpress Blog for a theme

I am new to programming and while trying to remove a footer message from the site, some coding went wrong and I am getting this error message in my site. 我是编程新手,尝试从网站中删除页脚消息时,某些编码出现错误,并且我在网站中收到此错误消息。

Parse error: syntax error, unexpected T_CLASS in G:\Inetpub\vhosts\socialwebarena.com\httpdocs\wp-content\themes\spacious\inc\functions.php on line 440


/**************************************************************************************/

add_action( 'spacious_footer_copyright', 'spacious_footer_copyright', 10 );
/**
 * function to show the footer info, copyright information
 */
if ( ! function_exists( 'spacious_footer_copyright' ) ) :
function spacious_footer_copyright() {
    $site_link = '<a href="' . esc_url( home_url( '/' ) ) . '" title="' . esc_attr( get_bloginfo( 'name', 'display' ) ) . '" ><span>' . get_bloginfo( 'name', 'display' ) . '</span></a>';

    //$wp_link = '<a href="'.esc_url( 'http://wordpress.org' ).'" target="_blank" title="' . esc_attr__( 'WordPress', 'spacious' ) . '"><span>' . __( 'WordPress', 'spacious' ) . '</span></a>';

    //$tg_link =  '<a href="'.esc_url( 'http://themegrill.com/themes/spacious' ).'" target="_blank" title="'.esc_attr__( 'ThemeGrill', 'spacious' ).'" rel="designer"><span>'.__( 'ThemeGrill', 'spacious') .'</span></a>';

    //$default_footer_value = sprintf( __( 'Copyright &copy; %1$s %2$s.', 'spacious' ), date( 'Y' ), $site_link ).' '.sprintf( __( 'Powered by %s.', 'spacious' ), $wp_link ).' '.sprintf( __( 'Theme: %1$s by %2$s.', 'spacious' ), 'Spacious', $tg_link );

$default_footer_value = sprintf( __( 'Copyright &copy; %1$s %2$s.', 'spacious' ), date( 'Y' ), $site_link ).' '.sprintf( __( 'Powered by %s.', 'spacious' ), $wp_link ).', $tg_link );

    $spacious_footer_copyright = '<div class="copyright">'.$default_footer_value.'</div>';
    echo $spacious_footer_copyright;
}
endif;

/*

This is the section and the closing braces just before endif; 这是endif之前的部分和右括号; is line no 440. Can anyone help me to fix this. 是第440行。任何人都可以帮助我解决此问题。 I asked the host service, but they mentioned that something has gone wrong in the coding. 我询问了主机服务,但他们提到在编码中出现了问题。

Can someone help me in this 有人可以帮我吗

Your add action is incorrect, Please check below sample for use of add_action in word-press.You need to apply hook name in first argument instead of your custom function. 您的添加操作不正确,请检查以下示例以在word-press中使用add_action。您需要在第一个参数中应用钩子名称,而不是自定义函数。

<?php add_action( $hook, $function_to_add, $priority, $accepted_args ); ?>

$hook (string) (required) $ hook (字符串)(必需)

The name of the action to which $function_to_add is hooked. $ function_to_add挂接到的动作的名称。 (See Plugin API/Action Reference for a list of action hooks). (有关动作挂钩的列表,请参见插件API /动作参考)。 Can also be the name of an action inside a theme or plugin file, or the special tag "all", in which case the function will be called for all hooks. 也可以是主题或插件文件中动作的名称,或特殊标记“ all”,在这种情况下,将为所有挂钩调用该函数。

$function_to_add (callback) (required) $ function_to_add (回调)(必需)

The name of the function you wish to be hooked. 您希望挂接的函数的名称。

Default: None 默认值:无

$priority (int) (optional) $ priority (int)(可选)

Used to specify the order in which the functions associated with a particular action are executed. 用于指定执行与特定操作关联的功能的顺序。 Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action. 较小的数字表示较早的执行,并且具有相同优先级的功能按照将它们添加到操作中的顺序执行。

$accepted_args (int) (optional) $ accepted_args (int)(可选)

The number of arguments the hooked function accepts. 挂钩函数接受的参数数量。 In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run. 在WordPress 1.5.1+中,钩子函数可以接受在运行匹配的do_action()或apply_filters()调用时设置的其他参数。 For example, the action comment_id_not_found will pass any functions that hook onto it the ID of the requested comment. 例如,操作comment_id_not_found将传递任何与请求的注释ID挂钩的函数。

Default: 1 默认值:1

For more info. 有关更多信息。 about add_action you can visit this 关于add_action,您可以访问

Change 更改

sprintf( __( 'Powered by %s.', 'spacious' ), $wp_link ).', $tg_link );

to

sprintf( __( 'Powered by %s.', 'spacious' ), $wp_link );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM