Base class for an action.
Description
Source
File: src/modules/actions/action.php
abstract class Action extends Submodule implements Meta_Submodule_Interface, Settings_Submodule_Interface { use Meta_Submodule_Trait, Settings_Submodule_Trait { Meta_Submodule_Trait::get_meta_fields as protected _get_meta_fields; } /** * Checks whether the action is enabled for a specific form. * * @since 1.0.0 * * @param Form $form Form object to check. * @return bool True if the action is enabled, false otherwise. */ public function enabled( $form ) { return $this->get_form_option( $form->id, 'enabled', false ); } /** * Handles the action for a specific form submission. * * @since 1.0.0 * * @param Submission $submission Submission to handle by the action. * @param Form $form Form the submission applies to. * @return bool|WP_Error True on success, error object on failure. */ public abstract function handle( $submission, $form ); /** * Returns the available meta fields for the submodule. * * @since 1.0.0 * * @return array Associative array of `$field_slug => $field_args` pairs. */ public function get_meta_fields() { $meta_fields = $this->_get_meta_fields(); $meta_fields['enabled'] = array( 'type' => 'checkbox', 'label' => _x( 'Enable?', 'action', 'torro-forms' ), 'visual_label' => _x( 'Status', 'action', 'torro-forms' ), ); return $meta_fields; } }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |
Methods
- bootstrap — Bootstraps the submodule by setting properties.
- enabled — Checks whether the access control is enabled for a specific form.
- enqueue_form_builder_assets — Enqueues scripts and stylesheets on the form editing screen.
- get_dynamic_template_tags — Gets all the dynamic template tags for a form, consisting of the form's element value tags.
- get_meta_fields — Returns the available meta fields for the submodule.
- handle — Handles the action for a specific form submission.
- override_content_type — Gets the email content type.
- override_from_email — Gets the email from email.
- override_from_name — Gets the email from name.
- register_assets — Registers all assets the submodule provides.
- register_template_tag_handlers — Registers the template tag handler for email notifications.
- store_phpmailer_error — Stores an error object as the internal PHPMailer error.
- wrap_message — Wraps the message in valid presentational HTML markup.