Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/19/2018 05:20:23 PM (8 years ago)
Author:
djpaul
Message:

Templates, Nouveau: move AJAX registration handlers to function hooks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-nouveau/includes/blogs/ajax.php

    r11899 r11903  
    99defined( 'ABSPATH' ) || exit;
    1010
    11 /**
    12  * Registers friends AJAX actions.
    13  *
    14  * @todo this funciton CANNOT be run when the file is included (like it is now). Move to a function and hook to something.
    15  */
    16 bp_nouveau_register_ajax_actions(
    17     array(
     11add_action( 'admin_init', function() {
     12    $ajax_actions = array(
    1813        array(
    1914            'blogs_filter' => array(
     
    2217            ),
    2318        ),
    24     )
    25 );
     19    );
     20
     21    foreach ( $ajax_actions as $ajax_action ) {
     22        $action = key( $ajax_action );
     23
     24        add_action( 'wp_ajax_' . $action, $ajax_action[ $action ]['function'] );
     25
     26        if ( ! empty( $ajax_action[ $action ]['nopriv'] ) ) {
     27            add_action( 'wp_ajax_nopriv_' . $action, $ajax_action[ $action ]['function'] );
     28        }
     29    }
     30}, 12 );
Note: See TracChangeset for help on using the changeset viewer.