Skip to:
Content

bbPress.org


Ignore:
Timestamp:
08/27/2017 11:24:00 PM (8 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/classes/class-bbp-converter-base.php

    r6669 r6670  
    9191    public $clean = false;
    9292
     93    /**
     94     * @var array Custom BBCode class properties in a key => value format
     95     */
     96    public $bbcode_parser_properties = array();
     97
    9398    /** Methods ***************************************************************/
    9499
     
    98103    public function __construct() {
    99104        $this->init();
     105        $this->setup_globals();
    100106    }
    101107
     
    106112     */
    107113    private function init() {
     114
     115        /** BBCode Parse Properties *******************************************/
     116
     117        // Setup smiley URL & path
     118        $this->bbcode_parser_properties = array(
     119            'smiley_url' => includes_url( 'images/smilies' ),
     120            'smiley_dir' => '/' . WPINC . '/images/smilies'
     121        );
    108122
    109123        /** Sanitize Options **************************************************/
     
    250264        );
    251265    }
     266
     267    /**
     268     * Setup global values
     269     */
     270    public function setup_globals() {}
    252271
    253272    /**
     
    11281147        $bbcode = BBCode::getInstance();
    11291148
    1130         // Setup smiley URL & path
    1131         $bbcode->smiley_url = includes_url( 'images/smilies' );
    1132         $bbcode->smiley_dir = '/' . WPINC . '/images/smilies';
     1149        // Pass BBCode properties to the parser
     1150        foreach ( $this->bbcode_parser_properties as $prop => $value ) {
     1151            $bbcode->{$prop} = $value;
     1152        }
    11331153
    11341154        return html_entity_decode( $bbcode->Parse( $field ) );
Note: See TracChangeset for help on using the changeset viewer.