Tindakan Ajax WordPress

function foo() {
    echo 'bar';
}
add_action('wp_ajax_foo', 'foo' ); // executed when logged in
add_action('wp_ajax_nopriv_foo', 'foo' ); // executed when logged out
Yousef Qaoud