Skip to:
Content

bbPress.org

Changeset 2515


Ignore:
Timestamp:
07/27/2010 02:44:24 AM (16 years ago)
Author:
johnjamesjacoby
Message:

Use classes the right way, at least until php 5 support comes around

Location:
branches/plugin
Files:
2 edited

Legend:

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

    r2495 r2515  
    11<?php
    22
    3 // Attach the bbPress admin init action to the WordPress admin init action.
    4 add_action( 'admin_init',                                           array( 'BBP_Admin', 'init' ) );
    5 
    6 // User profile edit/display actions
    7 add_action( 'edit_user_profile',                                    array( 'BBP_Admin', 'user_profile_forums' ) );
    8 add_action( 'show_user_profile',                                    array( 'BBP_Admin', 'user_profile_forums' ) );
    9 
    10 // User profile save actions
    11 add_action( 'personal_options_update',                              array( 'BBP_Admin', 'user_profile_update' ) );
    12 add_action( 'edit_user_profile_update',                             array( 'BBP_Admin', 'user_profile_update' ) );
    13 
    14 // Add some general styling to the admin area
    15 add_action( 'admin_head',                                           array( 'BBP_Admin', 'admin_head' ) );
    16 
    17 // Forum column headers.
    18 add_filter( 'manage_' . BBP_FORUM_POST_TYPE_ID . '_posts_columns',  array( 'BBP_Admin', 'forums_column_headers' ) );
    19 
    20 // Forum columns (in page row)
    21 add_action( 'manage_pages_custom_column',                           array( 'BBP_Admin', 'forums_column_data' ), 10, 2 );
    22 add_filter( 'page_row_actions',                                     array( 'BBP_Admin', 'forums_post_row_actions' ), 10, 2 );
    23 
    24 // Topic column headers.
    25 add_filter( 'manage_' . BBP_TOPIC_POST_TYPE_ID . '_posts_columns',  array( 'BBP_Admin', 'topics_column_headers' ) );
    26 
    27 // Topic columns (in post row)
    28 add_action( 'manage_posts_custom_column',                           array( 'BBP_Admin', 'topics_column_data' ), 10, 2 );
    29 add_filter( 'post_row_actions',                                     array( 'BBP_Admin', 'post_row_actions' ), 10, 2 );
    30 
    31 // Topic metabox actions
    32 add_action( 'admin_menu',                                           array( 'BBP_Admin', 'topic_parent_metabox' ) );
    33 add_action( 'save_post',                                            array( 'BBP_Admin', 'topic_parent_metabox_save' ) );
    34 
    35 // Topic reply metabox actions
    36 add_action( 'admin_menu',                                           array( 'BBP_Admin', 'topic_reply_parent_metabox' ) );
    37 add_action( 'save_post',                                            array( 'BBP_Admin', 'topic_reply_parent_metabox_save' ) );
    38 
     3if ( !class_exists( 'BBP_Admin' ) ) :
    394/**
    405 * BBP_Admin
    … …  
    4712 */
    4813class BBP_Admin {
     14
     15        function bbp_admin () {
     16                // Attach the bbPress admin init action to the WordPress admin init action.
     17                add_action( 'admin_init',                                           array( $this, 'init' ) );
     18
     19                // User profile edit/display actions
     20                add_action( 'edit_user_profile',                                    array( $this, 'user_profile_forums' ) );
     21                add_action( 'show_user_profile',                                    array( $this, 'user_profile_forums' ) );
     22
     23                // User profile save actions
     24                add_action( 'personal_options_update',                              array( $this, 'user_profile_update' ) );
     25                add_action( 'edit_user_profile_update',                             array( $this, 'user_profile_update' ) );
     26
     27                // Add some general styling to the admin area
     28                add_action( 'admin_head',                                           array( $this, 'admin_head' ) );
     29
     30                // Forum column headers.
     31                add_filter( 'manage_' . BBP_FORUM_POST_TYPE_ID . '_posts_columns',  array( $this, 'forums_column_headers' ) );
     32
     33                // Forum columns (in page row)
     34                add_action( 'manage_pages_custom_column',                           array( $this, 'forums_column_data' ), 10, 2 );
     35                add_filter( 'page_row_actions',                                     array( $this, 'forums_post_row_actions' ), 10, 2 );
     36
     37                // Topic column headers.
     38                add_filter( 'manage_' . BBP_TOPIC_POST_TYPE_ID . '_posts_columns',  array( $this, 'topics_column_headers' ) );
     39
     40                // Topic columns (in post row)
     41                add_action( 'manage_posts_custom_column',                           array( $this, 'topics_column_data' ), 10, 2 );
     42                add_filter( 'post_row_actions',                                     array( $this, 'post_row_actions' ), 10, 2 );
     43
     44                // Topic metabox actions
     45                add_action( 'admin_menu',                                           array( $this, 'topic_parent_metabox' ) );
     46                add_action( 'save_post',                                            array( $this, 'topic_parent_metabox_save' ) );
     47
     48                // Topic reply metabox actions
     49                add_action( 'admin_menu',                                           array( $this, 'topic_reply_parent_metabox' ) );
     50                add_action( 'save_post',                                            array( $this, 'topic_reply_parent_metabox_save' ) );
     51        }
    4952
    5053        /**
    … …  
    382385        }
    383386}
     387endif; // class_exists check
    384388
    385389/**
    … …  
    520524}
    521525
     526// Setup bbPress Admin
     527$bbp_admin = new BBP_Admin();
     528
    522529?>
  • branches/plugin/bbp-loader.php

    r2509 r2515  
    1717
    1818/** And now for something so unbelievable it's.... UNBELIEVABLE! */
    19 
    20 // Attach the bbp_loaded action to the WordPress plugins_loaded action.
    21 add_action( 'plugins_loaded',  array ( 'BBP_Loader', 'loaded' ) );
    22 
    23 // Attach the bbp_init to the WordPress init action.
    24 add_action( 'init',            array ( 'BBP_Loader', 'init' ) );
    25 
    26 // Attach constants to bbp_loaded.
    27 add_action( 'bbp_loaded',      array ( 'BBP_Loader', 'constants' ) );
    28 
    29 // Attach includes to bbp_loaded.
    30 add_action( 'bbp_loaded',      array ( 'BBP_Loader', 'includes' ) );
    31 
    32 // Attach theme directory bbp_loaded.
    33 add_action( 'bbp_loaded',      array ( 'BBP_Loader', 'register_theme_directory' ) );
    34 
    35 // Attach textdomain to bbp_init.
    36 add_action( 'bbp_init',        array ( 'BBP_Loader', 'textdomain' ) );
    37 
    38 // Attach post type registration to bbp_init.
    39 add_action( 'bbp_init',        array ( 'BBP_Loader', 'register_post_types' ) );
    40 
    41 // Attach topic tag registration bbp_init.
    42 add_action( 'bbp_init',        array ( 'BBP_Loader', 'register_taxonomies' ) );
    43 
    44 /**
    45  * Register bbPress activation sequence
    46  */
    47 register_activation_hook( __FILE__, array( 'BBP_Loader', 'activation' ) );
    48 
    49 /**
    50  * Register bbPress deactivation sequence
    51  */
    52 register_deactivation_hook( __FILE__, array( 'BBP_Loader', 'deactivation' ) );
    53 
    54 /** The main bbPress loader class *********************************************/
    5519
    5620if ( !class_exists( 'BBP_Loader' ) ) :
    … …  
    6630 */
    6731class BBP_Loader {
     32
     33        /**
     34         * The main bbPress loader
     35         */
     36        function bbp_loader () {
     37                // Attach the bbp_loaded action to the WordPress plugins_loaded action.
     38                add_action( 'plugins_loaded',  array ( $this, 'loaded' ) );
     39
     40                // Attach the bbp_init to the WordPress init action.
     41                add_action( 'init',            array ( $this, 'init' ) );
     42
     43                // Attach constants to bbp_loaded.
     44                add_action( 'bbp_loaded',      array ( $this, 'constants' ) );
     45
     46                // Attach includes to bbp_loaded.
     47                add_action( 'bbp_loaded',      array ( $this, 'includes' ) );
     48
     49                // Attach theme directory bbp_loaded.
     50                add_action( 'bbp_loaded',      array ( $this, 'register_theme_directory' ) );
     51
     52                // Attach textdomain to bbp_init.
     53                add_action( 'bbp_init',        array ( $this, 'textdomain' ) );
     54
     55                // Attach post type registration to bbp_init.
     56                add_action( 'bbp_init',        array ( $this, 'register_post_types' ) );
     57
     58                // Attach topic tag registration bbp_init.
     59                add_action( 'bbp_init',        array ( $this, 'register_taxonomies' ) );
     60
     61                // Register bbPress activation sequence
     62                register_activation_hook( __FILE__, array( $this, 'activation' ) );
     63
     64                // Register bbPress deactivation sequence
     65                register_deactivation_hook( __FILE__, array( $this, 'deactivation' ) );
     66        }
    6867
    6968        /**
    … …  
    451450         */
    452451        function activation () {
    453                 register_uninstall_hook( __FILE__, array( 'BBP_Loader', 'uninstall' ) );
     452                register_uninstall_hook( __FILE__, array( $this, 'uninstall' ) );
    454453                /**
    455454                 * bbPress has been activated
    … …  
    489488endif; // class_exists check
    490489
     490$bbp_loader = new BBP_Loader();
     491
    491492?>
Note: See TracChangeset for help on using the changeset viewer.