| 1 |
<?php |
| 2 |
|
| 3 |
defined( 'ABSPATH' ) || die(); |
| 4 |
|
| 5 |
use Sellkit_Elementor_Optin_Ajaxhandler as AjaxHandler; |
| 6 |
|
| 7 |
/** |
| 8 |
* An abstract class to register new optin action. |
| 9 |
* |
| 10 |
* @since 1.5.0 |
| 11 |
* @abstract |
| 12 |
*/ |
| 13 |
abstract class Sellkit_Elementor_Optin_Action_Base { |
| 14 |
|
| 15 |
/** |
| 16 |
* Initializes action base for Optin widget. |
| 17 |
* |
| 18 |
* @since 1.5.0 |
| 19 |
*/ |
| 20 |
public function __construct() { |
| 21 |
add_action( 'elementor/element/sellkit-optin/section_settings/after_section_end', [ $this, 'add_action_section_controls' ] ); |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Get name of this action. |
| 26 |
* |
| 27 |
* @since 1.5.0 |
| 28 |
* @access public |
| 29 |
* @abstract |
| 30 |
*/ |
| 31 |
abstract public function get_name(); |
| 32 |
|
| 33 |
/** |
| 34 |
* Get title of this action. |
| 35 |
* |
| 36 |
* @since 1.5.0 |
| 37 |
* @access public |
| 38 |
* @abstract |
| 39 |
*/ |
| 40 |
abstract public function get_title(); |
| 41 |
|
| 42 |
/** |
| 43 |
* Called by hook, and injects controls section relating to this action. |
| 44 |
* |
| 45 |
* @param object $widget widget instance passed by hook. |
| 46 |
* @since 1.5.0 |
| 47 |
* @access public |
| 48 |
*/ |
| 49 |
public function add_action_section_controls( $widget ) { |
| 50 |
$action = $this->get_name(); |
| 51 |
|
| 52 |
$widget->start_controls_section( "section_{$action}", |
| 53 |
[ |
| 54 |
'label' => $this->get_title(), |
| 55 |
'condition' => [ 'crm_actions' => $action ], |
| 56 |
] |
| 57 |
); |
| 58 |
|
| 59 |
$this->add_controls( $widget ); |
| 60 |
|
| 61 |
$widget->end_controls_section(); |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Add action controls. |
| 66 |
* |
| 67 |
* @param object $widget instance. |
| 68 |
* @return void |
| 69 |
* |
| 70 |
* @since 1.5.0 |
| 71 |
* @access public |
| 72 |
* @abstract |
| 73 |
*/ |
| 74 |
abstract public function add_controls( $widget ); |
| 75 |
|
| 76 |
/** |
| 77 |
* Run the main functionality of the action. |
| 78 |
* |
| 79 |
* @param AjaxHandler $ajax_handler Ajax handler instance. |
| 80 |
* |
| 81 |
* @since 1.5.0 |
| 82 |
* @access public |
| 83 |
* @abstract |
| 84 |
* @SuppressWarnings(PHPMD.UnusedFormalParameter) |
| 85 |
*/ |
| 86 |
public function run( AjaxHandler $ajax_handler ) {} |
| 87 |
} |
| 88 |
|