protected function registerHooks()
    {
        // Our callbacks are registered only on the admin side even for guest and frontend callbacks
        if (is_admin())
        {
            switch ($this->accessType)
            {
                case 'guest':
                    Hooks::action('wp_ajax_nopriv_' . static::$ACTION, $this, 'doAjax');
                    break;

                case 'logged':
                    Hooks::action('wp_ajax_' . static::$ACTION, $this, 'doAjax');
                    break;

                case 'any':
                    Hooks::action('wp_ajax_nopriv_' . static::$ACTION, $this, 'doAjax');
                    Hooks::action('wp_ajax_' . static::$ACTION, $this, 'doAjax');
                    break;

                default:
                    throw new \InvalidArgumentException("Invalid value for the Ajax access type parameter: "
                        . $this->accessType);
            }
        }

        // If we have global variables
        Hooks::filter('baobab/ajax/global_data', $this, 'addGlobalVariables');
    }
protected function registerHooks()
    {
        // Our callbacks are registered only on the admin side even for guest and frontend callbacks
        if (is_admin())
        {
            switch ($this->accessType)
            {
                case 'guest':
                    Hooks::action('wp_ajax_nopriv_' . static::$ACTION, $this, 'doAjax');
                    break;

                case 'logged':
                    Hooks::action('wp_ajax_' . static::$ACTION, $this, 'doAjax');
                    break;

                case 'any':
                    Hooks::action('wp_ajax_nopriv_' . static::$ACTION, $this, 'doAjax');
                    Hooks::action('wp_ajax_' . static::$ACTION, $this, 'doAjax');
                    break;

                default:
                    throw new \InvalidArgumentException("Invalid value for the Ajax access type parameter: "
                        . $this->accessType);
            }
        }

        // If we have global variables
        Hooks::filter('baobab/ajax/global_data', $this, 'addGlobalVariables');
    }
protected function registerHooks ( ) { // Our callbacks are registered only on the admin side even for guest and frontend callbacks if ( is_admin ( ) ) { switch ( $ this -> accessType ) { case 'guest' : Hooks :: action ( 'wp_ajax_nopriv_' . static :: $ ACTION , $ this , 'doAjax' ) ; break ; case 'logged' : Hooks :: action ( 'wp_ajax_' . static :: $ ACTION , $ this , 'doAjax' ) ; break ; case 'any' : Hooks :: action ( 'wp_ajax_nopriv_' . static :: $ ACTION , $ this , 'doAjax' ) ; Hooks :: action ( 'wp_ajax_' . static :: $ ACTION , $ this , 'doAjax' ) ; break ; default : throw new \ InvalidArgumentException ( "Invalid value for the Ajax access type parameter: " . $ this -> accessType ) ; } } // If we have global variables Hooks :: filter ( 'baobab/ajax/global_data' , $ this , 'addGlobalVariables' ) ; }
Hook into WordPress to execute our ajax callback
Hook into WordPress to execute our ajax callback