library/Helper/Ajax.php
public function hook($functionName, $private = true)
    {
        if(! method_exists($this, $functionName) || is_bool($private) == false) {
            return false;
        }

        switch ($private) {

            case false:
                add_action( 'wp_ajax_nopriv_'.$functionName, array($this,$functionName) );
            break;

            default:
                add_action( 'wp_ajax_'.$functionName, array($this,$functionName) );
            break;
        }

        add_action( 'wp_ajax_'.$functionName, array($this,$functionName) );

        return true;
    }
public function hook($functionName, $private = true)
    {
        if(! method_exists($this, $functionName) || is_bool($private) == false) {
            return false;
        }

        switch ($private) {

            case false:
                add_action( 'wp_ajax_nopriv_'.$functionName, array($this,$functionName) );
            break;

            default:
                add_action( 'wp_ajax_'.$functionName, array($this,$functionName) );
            break;
        }

        add_action( 'wp_ajax_'.$functionName, array($this,$functionName) );

        return true;
    }
public function hook ( $ functionName , $ private = true ) { if ( ! method_exists ( $ this , $ functionName ) || is_bool ( $ private ) == false ) { return false ; } switch ( $ private ) { case false : add_action ( 'wp_ajax_nopriv_' . $ functionName , array ( $ this , $ functionName ) ) ; break ; default : add_action ( 'wp_ajax_' . $ functionName , array ( $ this , $ functionName ) ) ; break ; } add_action ( 'wp_ajax_' . $ functionName , array ( $ this , $ functionName ) ) ; return true ; }
Hook - Hook function to WP ajax
@param  string $functionName - Name of existing function within the class
@param  boolean $private - Hook fires only for logged-in users, set to false for to fire for everyone
@return boolean
Hook - Hook function to WP ajax