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/friends/ajax.php

    r11899 r11903  
    99defined( 'ABSPATH' ) || exit;
    1010
    11 /**
    12  * Registers friends AJAX actions.
    13  */
    14 bp_nouveau_register_ajax_actions(
    15     array(
     11add_action( 'admin_init', function() {
     12    $ajax_actions = array(
    1613        array(
    1714            'friends_remove_friend' => array(
     
    4441            ),
    4542        ),
    46     )
    47 );
     43    );
     44
     45    foreach ( $ajax_actions as $ajax_action ) {
     46        $action = key( $ajax_action );
     47
     48        add_action( 'wp_ajax_' . $action, $ajax_action[ $action ]['function'] );
     49
     50        if ( ! empty( $ajax_action[ $action ]['nopriv'] ) ) {
     51            add_action( 'wp_ajax_nopriv_' . $action, $ajax_action[ $action ]['function'] );
     52        }
     53    }
     54}, 12 );
    4855
    4956/**
Note: See TracChangeset for help on using the changeset viewer.