简体   繁体   中英

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; is line no 440. Can anyone help me to fix this. 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.

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

$hook (string) (required)

The name of the action to which $function_to_add is hooked. (See Plugin API/Action Reference for a list of action hooks). 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.

$function_to_add (callback) (required)

The name of the function you wish to be hooked.

Default: None

$priority (int) (optional)

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)

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. For example, the action comment_id_not_found will pass any functions that hook onto it the ID of the requested comment.

Default: 1

For more info. about add_action you can visit this

Change

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

to

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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