SMF::callback_html( $field )

This callback processes any custom parser.php attributes and custom code with preg_replace

Description

Source

File: bp-forums/admin/converters/SMF.php

	protected function callback_html( $field ) {

		// Strips SMF custom HTML first from $field before parsing $field to parser.php
		$SMF_markup = $field;
		$SMF_markup = html_entity_decode( $SMF_markup );

		// Replace '[quote]' with '<blockquote>'
		$SMF_markup = preg_replace( '/\[quote\]/',        '<blockquote>',  $SMF_markup );
		// Replace '[quote ($1)]' with '<blockquote>"
		$SMF_markup = preg_replace( '/\[quote (.*?)\]/' , '<blockquote>',  $SMF_markup );
		// Replace '[/quote]' with '</blockquote>'
		$SMF_markup = preg_replace( '/\[\/quote\]/',      '</blockquote>', $SMF_markup );

		// Replace '[glow]' with ''
		$SMF_markup = preg_replace( '/\[glow\]/',   '',       $SMF_markup );
		// Replace '[glow]' with ''
		$SMF_markup = preg_replace( '/\[glow=(.*?)\]/',   '', $SMF_markup );
		// Replace '[/glow]' with ''
		$SMF_markup = preg_replace( '/\[\/glow\]/', '',       $SMF_markup );

		// Replace '[shadow]' with ''
		$SMF_markup = preg_replace( '/\[shadow\]/',   '',       $SMF_markup );
		// Replace '[shadow]' with ''
		$SMF_markup = preg_replace( '/\[shadow=(.*?)\]/',   '', $SMF_markup );
		// Replace '[/shadow]' with ''
		$SMF_markup = preg_replace( '/\[\/shadow\]/', '',       $SMF_markup );

		// Replace '[move]' with ''
		$SMF_markup = preg_replace( '/\[move\]/',   '', $SMF_markup );
		// Replace '[/move]' with ''
		$SMF_markup = preg_replace( '/\[\/move\]/', '', $SMF_markup );

		// Replace '[table]' with '<table>'
		$SMF_markup = preg_replace( '/\[table\]/',   '<table>',  $SMF_markup );
		// Replace '[/table]' with '</table>'
		$SMF_markup = preg_replace( '/\[\/table\]/', '</table>', $SMF_markup );
		// Replace '[tr]' with '<tr>'
		$SMF_markup = preg_replace( '/\[tr\]/',   '<tr>',  $SMF_markup );
		// Replace '[/tr]' with '</tr>'
		$SMF_markup = preg_replace( '/\[\/tr\]/', '</tr>', $SMF_markup );
		// Replace '[td]' with '<td>'
		$SMF_markup = preg_replace( '/\[td\]/',   '<td>',  $SMF_markup );
		// Replace '[/td]' with '</td>'
		$SMF_markup = preg_replace( '/\[\/td\]/', '</td>', $SMF_markup );

		// Replace '[list]' with '<ul>'
		$phpbb_uid = preg_replace( '/\[list\]/',     '<ul>',          $phpbb_uid );
		// Replace '[liist type=decimal]' with '<ol type="a">'
		$phpbb_uid = preg_replace( '/\[list\ type=decimal\]/',   '<ol type="a">', $phpbb_uid );
		// Replace '[li]' with '<li>'
		$SMF_markup = preg_replace( '/\[li\]/',   '<li>',  $SMF_markup );
		// Replace '[/li]' with '</li>'
		$SMF_markup = preg_replace( '/\[\/li\]/', '</li>', $SMF_markup );

		// Replace '[tt]' with '<tt>'
		$SMF_markup = preg_replace( '/\[tt\]/',   '<tt>',  $SMF_markup );
		// Replace '[/tt]' with '</tt>'
		$SMF_markup = preg_replace( '/\[\/tt\]/', '</tt>', $SMF_markup );

		// Replace '<br />' with '<br>'
		$SMF_markup = preg_replace( '/\<br \/\>/',   '<br>',  $SMF_markup );

		// Replace '[size=$1]' with '<span style="font-size:$1%;">$3</span>'
		$SMF_markup = preg_replace( '/\[size=(.*?)\]/', '<span style="font-size:$1">', $SMF_markup );
		// Replace '[/size]' with '</span>'
		$SMF_markup = preg_replace( '/\[\/size\]/',     '</span>',                     $SMF_markup );

		// Replace non-break space '&nbsp;' with space ' '
		$SMF_markup = preg_replace ( '/&nbsp;/', ' ', $SMF_markup );

		// Now that SMF custom HTML has been stripped put the cleaned HTML back in $field
		$field = $SMF_markup;

		// Parse out any bbCodes in $field with the BBCode 'parser.php'
		require_once( bbpress()->admin->admin_dir . 'parser.php' );
		$bbcode = BBCode::getInstance();
		$bbcode->enable_smileys = false;
		$bbcode->smiley_regex   = false;
		return html_entity_decode( $bbcode->Parse( $field ) );
	}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.