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/converters/bbPress1.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 *****************************************************/
     
    626631
    627632    /**
    628      * Translate the post status from bbPress 1's numeric's to WordPress's
     633     * Translate the post status from bbPress 1's numerics to WordPress's
    629634     * strings.
    630635     *
     
    651656
    652657    /**
    653      * Translate the forum type from bbPress 1.x numeric's to WordPress's strings.
     658     * Translate the forum type from bbPress 1.x numerics to WordPress's strings.
    654659     *
    655660     * @param int $status bbPress 1.x numeric forum type
     
    666671
    667672    /**
    668      * Translate the topic status from bbPress 1's numeric's to WordPress's
     673     * Translate the topic status from bbPress 1's numerics to WordPress's
    669674     * strings.
    670675     *
     
    687692
    688693    /**
    689      * Translate the topic sticky status type from bbPress 1.x numeric's to WordPress's strings.
     694     * Translate the topic sticky status type from bbPress 1.x numerics to WordPress's strings.
    690695     *
    691696     * @param int $status bbPress 1.x numeric forum type
     
    752757        return $field;
    753758    }
    754 
    755     /**
    756      * This callback:
    757      *
    758      * - turns off smiley parsing
    759      * - processes any custom parser.php attributes
    760      * - decodes necessary HTML entities
    761      */
    762     protected function callback_html( $field ) {
    763         require_once bbpress()->admin->admin_dir . 'parser.php';
    764         $bbcode = BBCode::getInstance();
    765         $bbcode->enable_smileys = false;
    766         $bbcode->smiley_regex   = false;
    767         return html_entity_decode( $bbcode->Parse( $field ) );
    768     }
    769759}
Note: See TracChangeset for help on using the changeset viewer.