Skip to:
Content

BuddyPress.org

Ticket #7325: 7325-group-extension-class-anonymous-functions.diff

File 7325-group-extension-class-anonymous-functions.diff, 1.8 KB (added by tw2113, 8 years ago)
  • src/bp-groups/classes/class-bp-group-extension.php

    diff --git src/bp-groups/classes/class-bp-group-extension.php src/bp-groups/classes/class-bp-group-extension.php
    index 208e2ff..c51b9ed 100644
    class BP_Group_Extension { (this hunk was shorter than expected) 
    752752
    753753                        // When we are viewing the extension display page, set the title and options title.
    754754                        if ( bp_is_current_action( $this->slug ) ) {
     755                                $name = $this->name;
    755756                                add_filter( 'bp_group_user_has_access',   array( $this, 'group_access_protection' ), 10, 2 );
    756                                 add_action( 'bp_template_content_header', create_function( '', 'echo "' . esc_attr( $this->name ) . '";' ) );
    757                                 add_action( 'bp_template_title',          create_function( '', 'echo "' . esc_attr( $this->name ) . '";' ) );
     757                                add_action( 'bp_template_content_header', function() use ( $name ) { echo esc_attr( $name ); } );
     758                                add_action( 'bp_template_title',          function() use ( $name ) { echo esc_attr( $name ); } );
    758759                        }
    759760                }
    class BP_Group_Extension { 
    11841189        public function _meta_box_display_callback() {
    11851190                $group_id = isset( $_GET['gid'] ) ? (int) $_GET['gid'] : 0;
    11861191                $screen   = $this->screens['admin'];
    1187 
     1192                $slug     = $this->slug;
    11881193                add_meta_box(
    11891194                        $screen['slug'],
    11901195                        $screen['name'],
    1191                         create_function( '', 'do_action( "bp_groups_admin_meta_box_content_' . $this->slug . '", ' . $group_id . ' );' ),
     1196                        function() use ( $slug, $group_id ) {
     1197
     1198                                /**
     1199                                 * Fires as part of the add_meta_box callback.
     1200                                 *
     1201                                 * Note this is a dynamic action that relies on the current extension slug.
     1202                                 *
     1203                                 * @since 1.7.0
     1204                                 *
     1205                                 * @param int $group_id Current group ID.
     1206                                 */
     1207                                do_action( 'bp_groups_admin_meta_box_content_{$slug}', $group_id );
     1208                        },
    11921209                        get_current_screen()->id,
    11931210                        $screen['metabox_context'],
    11941211                        $screen['metabox_priority']