Missing a character

I don’t know any PHP, but I’m trying to edit a function in a wordpress theme, and messed up with one of the edits without saving a backup. I think I just deleted an extra character or messed up some syntax while making edits. Can someone please look at this code and tell me where the error is?

[php]
function art_sidebar($index = 1)

{

if (!function_exists('dynamic_sidebar')) return false;

ob_start();

$success = dynamic_sidebar($index);

$content = ob_get_clean();

if (!$success) return false;

$content = art_normalize_widget_style_tokens($content);

$replaces = array(

	'<!--- BEGIN Widget --->' => "<div class=\"art-Block\">\r\n    <div class=\"art-Block-body\">\r\n",

	'<!--- BEGIN WidgetTitle --->' => "<div class=\"art-BlockHeader\">\r\n   

	'<!--- END WidgetTitle --->' => "</div>\r\n",

	'<!--- BEGIN WidgetContent --->' => "<div class=\"art-BlockContent\">\r\n    <div class=\"art-BlockContent-body\">\r\n",

	'<!--- END WidgetContent --->' => "\r\n		<div class=\"cleared\"></div>\r\n    </div>\r\n</div>\r\n",

	'<!--- END Widget --->' => "\r\n		<div class=\"cleared\"></div>\r\n    </div>\r\n</div>\r\n"

);

$bwt = '<!--- BEGIN WidgetTitle --->';

$ewt = '<!--- END WidgetTitle --->';

if ('' == $replaces[$bwt] && '' == $replaces[$ewt]) {

	$startTitle = 0;

	$endTitle = 0;

	$result = '';

	while (true) {

		$startTitle = strpos($content, $bwt, $endTitle);

		if (false == $startTitle) {

			$result .= substr($content, $endTitle);

			break;

		}

		$result .= substr($content, $endTitle, $startTitle - $endTitle);

		$endTitle = strpos($content, $ewt, $startTitle);

		if (false == $endTitle) {

			$result .= substr($content, $startTitle);

			break;

		}

		$endTitle += strlen($ewt);

	}

	$content = $result;

}

$content = str_replace(array_keys($replaces), array_values($replaces), $content);

echo $content;

return true;

}

[/php]

You’re missing ", at the end of this line:

[php]’<!— BEGIN WidgetTitle —>’ => "<div class=“art-BlockHeader”>\r\n[/php]

There is also a problem with this line:

[php]’<!— BEGIN WidgetContent —>’ => “

\r\n <div class=“art-BlockContent-body”>\r\n”,[/php]

it needs the first double quotes around art-BlockContent escaping with a .

and also:

[php]“

rn”,[/php]

I think you want to have:

[php]"\r\n",[/php]

So it would become:

[php]
function art_sidebar($index = 1)

{

if (!function_exists('dynamic_sidebar')) return false;

ob_start();

$success = dynamic_sidebar($index);

$content = ob_get_clean();

if (!$success) return false;

$content = art_normalize_widget_style_tokens($content);

$replaces = array(

	'<!--- BEGIN Widget --->' => "<div class=\"art-Block\">\r\n    <div class=\"art-Block-body\">\r\n",

	'<!--- BEGIN WidgetTitle --->' => "<div class=\"art-BlockHeader\">\r\n",

	'<!--- END WidgetTitle --->' => "</div>\r\n",

	'<!--- BEGIN WidgetContent --->' => "<div class=\"art-BlockContent\">\r\n    <div class=\"art-BlockContent-body\">\r\n",

	'<!--- END WidgetContent --->' => "\r\n		<div class=\"cleared\"></div>\r\n    </div>\r\n</div>\r\n",

	'<!--- END Widget --->' => "\r\n		<div class=\"cleared\"></div>\r\n    </div>\r\n</div>\r\n"

);

$bwt = '<!--- BEGIN WidgetTitle --->';

$ewt = '<!--- END WidgetTitle --->';

if ('' == $replaces[$bwt] && '' == $replaces[$ewt]) {

	$startTitle = 0;

	$endTitle = 0;

	$result = '';

	while (true) {

		$startTitle = strpos($content, $bwt, $endTitle);

		if (false == $startTitle) {

			$result .= substr($content, $endTitle);

			break;

		}

		$result .= substr($content, $endTitle, $startTitle - $endTitle);

		$endTitle = strpos($content, $ewt, $startTitle);

		if (false == $endTitle) {

			$result .= substr($content, $startTitle);

			break;

		}

		$endTitle += strlen($ewt);

	}

	$content = $result;

}

$content = str_replace(array_keys($replaces), array_values($replaces), $content);

echo $content;

return true;

}
[/php]

Awesome. Thanks a lot.

Sponsor our Newsletter | Privacy Policy | Terms of Service