Skip to:
Content

BuddyPress.org

Changeset 11366


Ignore:
Timestamp:
01/02/2017 08:13:14 PM (10 years ago)
Author:
tw2113
Message:

Removes usage of create_function across various BuddyPress components.

See #7325.

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-actions.php

    r11102 r11366  
    833833        // Add "new_post_type_comment" to the whitelisted activity types, so that the activity's Akismet history is generated
    834834        $post_type_comment_action = $activity_comment_object->action_id;
    835         $comment_akismet_history = create_function( '$t', '$t[] = $post_type_comment_action; return $t;' );
     835        $comment_akismet_history = function ( $activity_types ) use ( $post_type_comment_action ) {
     836                $activity_types[] = $post_type_comment_action;
     837
     838                return $activity_types;
     839        };
    836840        add_filter( 'bp_akismet_get_activity_types', $comment_akismet_history );
    837841
  • trunk/src/bp-activity/bp-activity-functions.php

    r11356 r11366  
    37513751        buddypress()->activity->read_more_id = $activity->id;
    37523752
    3753         add_filter( 'embed_post_id',         create_function( '', 'return buddypress()->activity->read_more_id;' ) );
     3753        add_filter( 'embed_post_id',         function() { return buddypress()->activity->read_more_id; } );
    37543754        add_filter( 'bp_embed_get_cache',    'bp_embed_activity_cache',      10, 3 );
    37553755        add_action( 'bp_embed_update_cache', 'bp_embed_activity_save_cache', 10, 3 );
  • trunk/src/bp-activity/classes/class-bp-activity-list-table.php

    r11351 r11366  
    172172
    173173                        // Sort the array by the activity object's date_recorded value.
    174                         usort( $activities['activities'], create_function( '$a, $b', 'return $a->date_recorded > $b->date_recorded;' ) );
     174                        usort( $activities['activities'], function( $a, $b ) { return $a->date_recorded > $b->date_recorded; } );
    175175                }
    176176
  • trunk/src/bp-blogs/bp-blogs-widgets.php

    r11360 r11366  
    1818
    1919        if ( bp_is_active( 'activity' ) && bp_is_root_blog( $wpdb->blogid ) ) {
    20                 add_action( 'widgets_init', create_function( '', 'return register_widget("BP_Blogs_Recent_Posts_Widget");' ) );
     20                add_action( 'widgets_init', function() { register_widget( 'BP_Blogs_Recent_Posts_Widget' ); } );
    2121        }
    2222}
  • trunk/src/bp-core/admin/bp-core-admin-tools.php

    r11014 r11366  
    358358        $message = '<div id="message" class="' . esc_attr( $class ) . '">' . $message . '</div>';
    359359        $message = str_replace( "'", "\'", $message );
    360         $lambda  = create_function( '', "echo '$message';" );
     360        $lambda  = function() use ( $message ) { echo $message; };
    361361
    362362        add_action( bp_core_do_network_admin() ? 'network_admin_notices' : 'admin_notices', $lambda );
  • trunk/src/bp-core/bp-core-widgets.php

    r11360 r11366  
    1717 */
    1818function bp_core_register_widgets() {
    19         add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Login_Widget");') );
     19        add_action( 'widgets_init', function() { register_widget( 'BP_Core_Login_Widget' ); } );
    2020}
    2121add_action( 'bp_register_widgets', 'bp_core_register_widgets' );
  • trunk/src/bp-forums/bp-forums-bbpress-sa.php

    r11363 r11366  
    150150         * @since 1.1.0
    151151         */
    152         register_shutdown_function( create_function( '', 'do_action("bb_shutdown");' ) );
     152        register_shutdown_function( function() { do_action( 'bb_shutdown' ); } );
    153153}
    154154add_action( 'bbpress_init', 'bp_forums_load_bbpress' );
  • trunk/src/bp-friends/bp-friends-widgets.php

    r11360 r11366  
    2828        }
    2929
    30         add_action( 'widgets_init', create_function( '', 'return register_widget("BP_Core_Friends_Widget");' ) );
     30        add_action( 'widgets_init', function() { register_widget( 'BP_Core_Friends_Widget' ); } );
    3131}
    3232add_action( 'bp_register_widgets', 'bp_friends_register_widgets' );
  • trunk/src/bp-friends/classes/class-bp-friends-friendship.php

    r11242 r11366  
    645645
    646646                // Sort and structure as expected in legacy function.
    647                 usort( $last_activities, create_function( '$a, $b', '
    648                         if ( $a["date_recorded"] == $b["date_recorded"] ) {
     647                usort( $last_activities, function( $a, $b ) {
     648                        if ( $a['date_recorded'] == $b['date_recorded'] ) {
    649649                                return 0;
    650650                        }
    651651
    652                         return ( strtotime( $a["date_recorded"] ) < strtotime( $b["date_recorded"] ) ) ? 1 : -1;
    653                 ' ) );
     652                        return ( strtotime( $a['date_recorded'] ) < strtotime( $b['date_recorded'] ) ) ? 1 : -1;
     653                } );
    654654
    655655                $retval = array();
  • trunk/src/bp-groups/bp-groups-widgets.php

    r11360 r11366  
    1717 */
    1818function groups_register_widgets() {
    19         add_action('widgets_init', create_function('', 'return register_widget("BP_Groups_Widget");') );
     19        add_action( 'widgets_init', function() { register_widget( 'BP_Groups_Widget' ); } );
    2020}
    2121add_action( 'bp_register_widgets', 'groups_register_widgets' );
  • trunk/src/bp-groups/classes/class-bp-group-extension.php

    r11091 r11366  
    975975                                $this->edit_screen_template = '/groups/single/home';
    976976                        } else {
    977                                 add_action( 'bp_template_content_header', create_function( '', 'echo "<ul class=\"content-header-nav\">"; bp_group_admin_tabs(); echo "</ul>";' ) );
     977                                add_action( 'bp_template_content_header', function() {
     978                                        echo '<ul class="content-header-nav">';
     979                                        bp_group_admin_tabs();
     980                                        echo '</ul>';
     981                                } );
    978982                                add_action( 'bp_template_content', array( &$this, 'call_edit_screen' ) );
    979983                                $this->edit_screen_template = '/groups/single/plugins';
    … …  
    16911695        // Register the group extension on the bp_init action so we have access
    16921696        // to all plugins.
    1693         add_action( 'bp_init', create_function( '', '
    1694                 $extension = new ' . $group_extension_class . ';
    1695                 add_action( "bp_actions", array( &$extension, "_register" ), 8 );
    1696                 add_action( "admin_init", array( &$extension, "_register" ) );
    1697         ' ), 11 );
     1697        add_action( 'bp_init', function() use ( $group_extension_class ) {
     1698                $extension = new $group_extension_class;
     1699                add_action( 'bp_actions', array( &$extension, '_register' ), 8 );
     1700                add_action( 'admin_init', array( &$extension, '_register' ) );
     1701        }, 11 );
    16981702}
  • trunk/src/bp-members/bp-members-widgets.php

    r11360 r11366  
    1919 */
    2020function bp_members_register_widgets() {
    21         add_action( 'widgets_init', create_function( '', 'return register_widget("BP_Core_Members_Widget");'         ) );
    22         add_action( 'widgets_init', create_function( '', 'return register_widget("BP_Core_Whos_Online_Widget");'     ) );
    23         add_action( 'widgets_init', create_function( '', 'return register_widget("BP_Core_Recently_Active_Widget");' ) );
     21        add_action( 'widgets_init', function() { return register_widget( 'BP_Core_Members_Widget' );         } );
     22        add_action( 'widgets_init', function() { return register_widget( 'BP_Core_Whos_Online_Widget' );     } );
     23        add_action( 'widgets_init', function() { return register_widget( 'BP_Core_Recently_Active_Widget' ); } );
    2424}
    2525add_action( 'bp_register_widgets', 'bp_members_register_widgets' );
  • trunk/src/bp-messages/bp-messages-widgets.php

    r11360 r11366  
    1717 */
    1818function bp_messages_register_widgets() {
    19         add_action( 'widgets_init', create_function('', 'return register_widget( "BP_Messages_Sitewide_Notices_Widget" );') );
     19        add_action( 'widgets_init', function() { register_widget( 'BP_Messages_Sitewide_Notices_Widget' ); } );
    2020}
    2121add_action( 'bp_register_widgets', 'bp_messages_register_widgets' );
  • trunk/src/bp-xprofile/bp-xprofile-admin.php

    r11360 r11366  
    701701
    702702                // Sort these fields types alphabetically.
    703                 uasort( $fields, create_function( '$a, $b', 'return strnatcmp( $a[1]->name, $b[1]->name );' ) );
     703                uasort( $fields, function( $a, $b ) { return strnatcmp( $a[1]->name, $b[1]->name ); } );
    704704
    705705                foreach ( $fields as $field_type_obj ) {
  • trunk/tests/phpunit/testcases/core/class-bp-user-query.php

    r11067 r11366  
    176176                ) );
    177177
    178                 add_filter( 'bp_user_query_online_interval', create_function( '', 'return 5;' ) );
     178                add_filter( 'bp_user_query_online_interval', function() { return 5; } );
    179179
    180180                $q = new BP_User_Query( array(
Note: See TracChangeset for help on using the changeset viewer.