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

663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
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.