| 1 |
<?php |
| 2 |
|
| 3 |
namespace HTML_Forms\Actions; |
| 4 |
|
| 5 |
use HTML_Forms\Form; |
| 6 |
use HTML_Forms\Submission; |
| 7 |
|
| 8 |
abstract class Action { |
| 9 |
|
| 10 |
public $type = ''; |
| 11 |
public $label = ''; |
| 12 |
|
| 13 |
public function hook() { |
| 14 |
add_filter( 'hf_available_form_actions', array( $this, 'register' ) ); |
| 15 |
add_action( 'hf_render_form_action_' . $this->type . '_settings', array( $this, 'page_settings' ) ); |
| 16 |
add_action( 'hf_process_form_action_' . $this->type, array( $this, 'process' ), 10, 3 ); |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Renders the settings for this action. |
| 21 |
* |
| 22 |
* @param array $settings |
| 23 |
*/ |
| 24 |
abstract function page_settings( $settings ); |
| 25 |
|
| 26 |
abstract function process( array $settings, Submission $submission, Form $form ); |
| 27 |
|
| 28 |
/** |
| 29 |
* @param array $actions |
| 30 |
* @return array |
| 31 |
*/ |
| 32 |
public function register( array $actions ) { |
| 33 |
$actions[$this->type] = $this->label; |
| 34 |
return $actions; |
| 35 |
} |
| 36 |
} |
| 37 |
|