Skip to:
Content

bbPress.org


Ignore:
Timestamp:
08/27/2017 11:24:00 PM (7 years ago)
Author:
johnjamesjacoby
Message:

Converter: more OOP, specifically for the BBCode parser.

This change introduces a bbcode_parser_properties array to the base converter, allowing custom BBCode parser properties to be passed into the parent method via the child, minimizing the amount of code in each individual forum converter.

Trunk, for 2.6.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/converters/SimplePress5.php

    r6573 r6670  
    2121     *
    2222     */
    23     function __construct() {
     23    public function __construct() {
    2424        parent::__construct();
    25         $this->setup_globals();
    2625    }
    2726
     
    3029     */
    3130    public function setup_globals() {
     31
     32        // Setup smiley URL & path
     33        $this->bbcode_parser_properties = array(
     34            'smiley_url' => false,
     35            'smiley_dir' => false
     36        );
    3237
    3338        /** Forum Section *****************************************************/
     
    522527
    523528    /**
    524      * Translate the post status from Simple:Press v5.x numeric's to WordPress's strings.
     529     * Translate the post status from Simple:Press v5.x numerics to WordPress's strings.
    525530     *
    526531     * @param int $status Simple:Press numeric status
     
    542547
    543548    /**
    544      * Translate the topic sticky status type from Simple:Press v5.x numeric's to WordPress's strings.
     549     * Translate the topic sticky status type from Simple:Press v5.x numerics to WordPress's strings.
    545550     *
    546551     * @param int $status Simple:Press v5.x numeric forum type
     
    598603
    599604        // Replace '<strong>username said </strong>' with '@username said:'
    600         $simplepress_markup = preg_replace ( '/\<strong\>(.*?)\ said\ \<\/strong\>/',     '@$1 said:',        $simplepress_markup );
     605        $simplepress_markup = preg_replace( '/\<strong\>(.*?)\ said\ \<\/strong\>/',     '@$1 said:',        $simplepress_markup );
    601606
    602607        // Replace '<p>&nbsp;</p>' with '<p>&nbsp;</p>'
    603         $simplepress_markup = preg_replace ( '/\n(&nbsp;|[\s\p{Z}\xA0\x{00A0}]+)\r/', '<br>', $simplepress_markup );
     608        $simplepress_markup = preg_replace( '/\n(&nbsp;|[\s\p{Z}\xA0\x{00A0}]+)\r/', '<br>', $simplepress_markup );
    604609
    605610        // Now that SimplePress' custom HTML codes have been stripped put the cleaned HTML back in $field
    606611        $field = $simplepress_markup;
    607612
    608         // Parse out any bbCodes with the BBCode 'parser.php'
    609         require_once bbpress()->admin->admin_dir . 'parser.php';
    610         $bbcode = BBCode::getInstance();
    611         $bbcode->enable_smileys = false;
    612         $bbcode->smiley_regex   = false;
    613         return html_entity_decode( $bbcode->Parse( $field ) );
     613        // Parse out any bbCodes in $field with the BBCode 'parser.php'
     614        return parent::callback_html( $field );
    614615    }
    615616}
Note: See TracChangeset for help on using the changeset viewer.