Wsparcie » Używanie i konfiguracja WordPressa » Syntax error -functions.php

  • Rozwiązano martunia.waluk

    (@martuniawaluk)


    Witam serdecznie,

    zwracam się z pytaniem do osób mądrzejszych ode mnie.
    Otóż chciałam zmodyfikować mój custom header na plik swf i wszystko zepsułam.
    Wystąpił błąd:
    Parse error: syntax error, unexpected '<’ in /home/kontafor/domains/konta-forex.pl/public_html/wp-content/themes/zeemagazine/functions.php on line 47

    Kod w tym miejscu wygląda następująco:

    // Add Custom Header
    	add_theme_support('custom-header', array(
    		'default-image' => get_template_directory_uri() . '/images/default_header.jpg',
    		'header-text' => false,
    		'width'	=> 980,
    		'height' => 344,
    		'flex-height' => true,
    		'wp-head-callback' => 'themezee_header_style'));

    Wolałabym uniknąć załadowania na nowo całego folderu includes, gdyż po pierwsze mój backup jest stosunkowo stary i plik „theme-functions” wydaje się być inny, może to dlatego, że nie uaktualniłam ostatniej wersji, a może to w ogóle nie ten, którego szukam.

    Pracuję na Zee Magazine, jeśli to ma znaczenie.

    Proszę o pomoc.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Cóż, powyższy kawałek kodu kompletnie nic nie mówi …a raczej mówi, ze problem jest gdzieś indziej.
    Może plik zapisany z nieprawidłowym kodowaniem? powinno być utf-8 bez BOM

    Thread Starter martunia.waluk

    (@martuniawaluk)

    Dzięki za odpowiedź. Zapisałam plik functions.php z odpowiednim kodowaniem, załadowałam na stronę przez ftp, ale strona dalej nie działa. Sęk w tym, że był to jedyny fragment pliku w którym próbowałam coś zmieniać. Mogłam jednak przez przypadek coś wykasować, ciężko znaleźć błąd, jeśli nie zna się języka programowania.

    Poniżej przedstwiam cały, przekopiowany plik functions.php, może uda Ci się znaleźć tam błąd:

    <?php
    
    // Set Content Width
    if ( ! isset( $content_width ) )
    	$content_width = 580;
    
    /*==================================== THEME SETUP ====================================*/
    
    // Load default style.css and Javascripts
    add_action('wp_enqueue_scripts', 'themezee_enqueue_scripts');
    
    if ( ! function_exists( 'themezee_enqueue_scripts' ) ):
    function themezee_enqueue_scripts() { 
    
    	// Register and Enqueue Stylesheet
    	wp_register_style('zee_stylesheet', get_stylesheet_directory_uri() . '/style.css');
    	wp_enqueue_style('zee_stylesheet');
    
    	// Enqueue jQuery Framework
    	wp_enqueue_script('jquery');
    
    	// Register and enqueue the Malsup Cycle Plugin
    	wp_register_script('zee_jquery-cycle', get_template_directory_uri() .'/includes/js/jquery.cycle.all.min.js', array('jquery'));
    	wp_enqueue_script('zee_jquery-cycle');
    }
    endif;
    
    // Setup Function: Registers support for various WordPress features
    add_action( 'after_setup_theme', 'themezee_setup' );
    
    if ( ! function_exists( 'themezee_setup' ) ):
    function themezee_setup() { 
    
    	// init Localization
    	load_theme_textdomain('themezee_lang', get_template_directory() . '/includes/lang' );
    
    	// Add Theme Support
    	add_theme_support('post-thumbnails');
    	add_theme_support('automatic-feed-links');
    	add_editor_style();
    
    	// Add Custom Background
    	add_theme_support('custom-background', array('default-color' => 'ddd'));
    
    	// Add Custom Header
    <object width="980" height="270">
    <param name="movie" value="somefilename.swf">
    <embed src="http://www.konta-forex.pl/wp-content/uploads/2012/11/oferty-domow-maklerskich.swf" width="980" height="270">
    </embed>
    </object>
    	add_theme_support('custom-header', array(
    		'default-image' => get_template_directory_uri() . '/images/default_header.jpg',
    		'header-text' => false,
    		'width'	=> 980,
    		'height' => 270,
    		'flex-height' => true,
    		'wp-head-callback' => 'themezee_header_style'));
    
    	// Register Navigation Menus
    	register_nav_menu( 'top_navi', 'Top Navigation' );
    	register_nav_menu( 'main_navi', 'Main Navigation' );
    }
    endif;
    
    // Defines extra CSS for Custom Header
    function themezee_header_style() {
        ?><style type="text/css">
            #custom_header img {
    			margin-bottom: -3px;
                            width: 980px;
                            height: 270;
                            align: center;
            }
        </style><?php
    }
    
    // Register Sidebars
    add_action( 'widgets_init', 'themezee_register_sidebars' );
    
    if ( ! function_exists( 'themezee_register_sidebars' ) ):
    function themezee_register_sidebars() { 
    
    	// Register Sidebars
    	register_sidebar(array('name' => 'Sidebar Blog','id' => 'sidebar-blog'));
    	register_sidebar(array('name' => 'Sidebar Pages','id' => 'sidebar-pages'));
    
    	// Register Footer Bars
    	register_sidebar(array('name' => 'Footer','id' => 'sidebar-footer'));
    }
    endif;
    
    /*==================================== INCLUDE FILES ====================================*/
    
    // Includes all files needed for theme options, custom JS/CSS and Widgets
    add_action( 'after_setup_theme', 'themezee_include_files' );
    
    if ( ! function_exists( 'themezee_include_files' ) ):
    function themezee_include_files() { 
    
    	// include Admin Files
    	locate_template('/includes/admin/theme-functions.php', true);
    	locate_template('/includes/admin/theme-admin.php', true);
    
    	// include custom Javascript and custom CSS Handler files
    	locate_template('/includes/js/jscript.php', true);
    	locate_template('/includes/css/csshandler.php', true);
    
    	// include Widget Files
    	locate_template('/includes/widgets/theme-widget-ads.php', true);
    	locate_template('/includes/widgets/theme-widget-socialmedia.php', true);
    }
    endif;
    
    /*==================================== THEME FUNCTIONS ====================================*/
    
    // Add Default Menu Fallback Function
    function themezee_default_menu() {
    	echo '<ul id="nav" class="menu">'. wp_list_pages('title_li=&echo=0') .'</ul>';
    }
    
    // Display Credit Link Function
    function themezee_credit_link() { ?>
    	<a href="http://themezee.com/"><?php _e('Wordpress Theme by ThemeZee', 'themezee_lang'); ?></a>
    <?php
    }
    
    // Change Excerpt Length
    add_filter('excerpt_length', 'themezee_excerpt_length');
    function themezee_excerpt_length($length) {
        return 30;
    }
    
    // Change Excerpt More
    add_filter('excerpt_more', 'themezee_excerpt_more');
    function themezee_excerpt_more($more) {
        return '';
    }
    
    // Add Postmeta Data
    add_action( 'themezee_display_postmeta_index', 'themezee_postmeta_content' );
    add_action( 'themezee_display_postmeta_single', 'themezee_postmeta_content' ); 
    
    function themezee_postmeta_content() { ?>
    	<span class="date"><a href="<?php the_permalink() ?>"><?php the_time(get_option('date_format')); ?></a> </span>
    	<span class="author"><?php the_author_posts_link(); ?> </span>
    	<span class="folder"><?php the_category(', ') ?> </span>
    <?php
    }
    
    // Add Postinfo Data
    add_action( 'themezee_display_postinfo_index', 'themezee_postinfo_content' );
    add_action( 'themezee_display_postinfo_single', 'themezee_postinfo_content' );
    
    function themezee_postinfo_content() { ?>
    	<span class="comment"><?php comments_popup_link( __('No comments', 'themezee_lang'),__('One comment','themezee_lang'),__('% comments','themezee_lang') ); ?></span>
    <?php if (get_the_tags()) : ?>
    	<span class="tag"><?php the_tags('', ', '); ?> </span>
    <?php
    	endif;
    	edit_post_link(__( 'Edit', 'themezee_lang' ), ' | ');
    }
    
    ?>

    Na drugi raz, wklejając duży kod skorzystaj z serwisu pastebin.com

    Tu masz wersję, w której poprawiłem błędy php:

    http://pastebin.com/cW6yShte

    dodałem linie: 46 i 52.

    Uwaga: wcale nie znaczy, że to będzie działać dobrze, teraz to tylko jest działający plik php, ponieważ ta okolica linie 45-55 wygląda jakby była w tymi miejscu od czapy!

    Thread Starter martunia.waluk

    (@martuniawaluk)

    Oczywiście że jest zupełnie w złym miejscu. Ja się niestety jeszcze uczę i nie wiem gdzie pewne rzeczy wklejać.

    Spróbuję ten baner wstawić w innym miejscu.

    Dziękuję za pomoc, strona rzeczywiście działa.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Temat ‘Syntax error -functions.php’ jest zamknięty na nowe odpowiedzi.