Skip to:
Content

bbPress.org

Changeset 3438


Ignore:
Timestamp:
08/23/2011 01:39:45 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Add admin_dir var to $bbp->admin global, and use it in BBP_Admin class. Add filter to importer path to allow override. Fixes #1598. Props GautamGupta for original patch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-admin/bbp-admin.php

    r3436 r3438  
    2121class BBP_Admin {
    2222
     23    /** Directory *************************************************************/
     24
     25    /**
     26     * @var string Path to the bbPress admin directory
     27     */
     28    public $admin_dir = '';
     29
    2330    /** URLs ******************************************************************/
    2431
    2532    /**
     33     * @var string URL to the bbPress admin directory
     34     */
     35    public $admin_url = '';
     36
     37    /**
    2638     * @var string URL to the bbPress images directory
    2739     */
     
    3345    public $styles_url = '';
    3446
    35     /** URLs ******************************************************************/
     47    /** Recounts **************************************************************/
    3648
    3749    /**
     
    7082        /** General Actions ***************************************************/
    7183
    72         // Attach the bbPress admin init action to the WordPress admin init action.
    73         add_action( 'admin_init',    array( $this, 'init'                    ) );
     84        // Attach the bbPress admin_init action to the WordPress admin_init action.
     85        add_action( 'admin_init',         array( $this, 'admin_init'                 ) );
    7486
    7587        // Add some general styling to the admin area
    76         add_action( 'admin_head',    array( $this, 'admin_head'              ) );
     88        add_action( 'admin_head',         array( $this, 'admin_head'                 ) );
    7789
    7890        // Add menu item to settings menu
    79         add_action( 'admin_menu',    array( $this, 'admin_menus'             ) );
     91        add_action( 'admin_menu',         array( $this, 'admin_menus'                ) );
    8092
    8193        // Add notice if not using a bbPress theme
    82         add_action( 'admin_notices', array( $this, 'activation_notice'       ) );
    83 
    84         // Register bbPress admin style
    85         add_action( 'bbp_admin_init',     array( $this, 'register_admin_style'    ) );
    86 
    87         // Add the importers
    88         add_action( 'bbp_admin_init',     array( $this, 'register_importers'      ) );
    89 
    90         // Add the settings
    91         add_action( 'bbp_admin_init',     array( $this, 'register_admin_settings' ) );
     94        add_action( 'admin_notices',      array( $this, 'activation_notice'          ) );
     95
     96        // Add importers
     97        add_action( 'bbp_admin_init',     array( $this, 'register_importers'         ) );
     98
     99        // Add green admin style
     100        add_action( 'bbp_admin_init',     array( $this, 'register_admin_style'       ) );
     101
     102        // Add settings
     103        add_action( 'bbp_admin_init',     array( $this, 'register_admin_settings'    ) );
    92104
    93105        // Forums 'Right now' Dashboard widget
     
    110122     */
    111123    private function includes() {
    112         global $bbp;
    113 
    114         // Files to include
    115         $files = array( 'tools', 'settings', 'functions', 'metaboxes', 'forums', 'topics', 'replies' );
    116 
    117         // Buzz buzz
    118         //if ( get_option( '_bbp_first_run' ) ) $files[] = 'first-run';
    119124
    120125        // Include the files
    121         foreach ( $files as $file )
    122             require( $bbp->plugin_dir . 'bbp-admin/bbp-' . $file . '.php' );
     126        require( $this->admin_dir . 'bbp-tools.php'     );
     127        require( $this->admin_dir . 'bbp-settings.php'  );
     128        require( $this->admin_dir . 'bbp-functions.php' );
     129        require( $this->admin_dir . 'bbp-metaboxes.php' );
     130        require( $this->admin_dir . 'bbp-forums.php'    );
     131        require( $this->admin_dir . 'bbp-topics.php'    );
     132        require( $this->admin_dir . 'bbp-replies.php'   );
    123133    }
    124134
     
    131141    private function setup_globals() {
    132142        global $bbp;
     143
     144        // Admin url
     145        $this->admin_dir  = trailingslashit( $bbp->plugin_dir . 'bbp-admin' );
    133146
    134147        // Admin url
     
    291304     *
    292305     * @uses do_action() Calls 'bbp_register_importers'
     306     * @uses apply_filters() Calls 'bbp_importer_path' filter to allow plugins
     307     *                        to customize the importer script locations.
    293308     */
    294309    public function register_importers() {
     
    298313            return;
    299314
    300         global $bbp;
    301 
    302315        // Load Importer API
    303316        require_once( ABSPATH . 'wp-admin/includes/import.php' );
     
    309322        foreach ( $importers as $importer ) {
    310323
     324            // Allow custom importer directory
     325            $import_dir  = apply_filters( 'bbp_importer_path', $this->admin_dir . 'importers', $importer );
     326
    311327            // Compile the importer path
    312             $import_file = $bbp->plugin_dir . 'bbp-admin/importers/' . $importer . '.php';
     328            $import_file = trailingslashit( $import_dir ) . $importer . '.php';
    313329
    314330            // If the file exists, include it
     
    382398     * @uses do_action() Calls 'bbp_admin_init'
    383399     */
    384     public function init() {
     400    public function admin_init() {
    385401        do_action( 'bbp_admin_init' );
    386402    }
Note: See TracChangeset for help on using the changeset viewer.