| @@ -1,0 +1,18 @@ | ||
| 1 | +<?php | |
| 2 | +namespace ABlocks\Classes; | |
| 3 | + | |
| 4 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 5 | + exit; | |
| 6 | +} | |
| 7 | + | |
| 8 | +abstract class AbstractAjaxHandler extends AbstractRequestHandler { | |
| 9 | + | |
| 10 | + final public function dispatch_actions() { | |
| 11 | + foreach ( $this->actions as $action => $details ) { | |
| 12 | + add_action( 'wp_ajax_' . $this->namespace . '/' . $action, [ $this, 'handle_request' ] ); | |
| 13 | + if ( isset( $details['allow_visitor_action'] ) && true === $details['allow_visitor_action'] ) { | |
| 14 | + add_action( 'wp_ajax_nopriv_' . $this->namespace . '/' . $action, [ $this, 'handle_request' ] ); | |
| 15 | + } | |
| 16 | + } | |
| 17 | + } | |
| 18 | +} | |