| 1 |
<?php |
| 2 |
/** |
| 3 |
* Bricks element: Campaign Donate Button. |
| 4 |
* |
| 5 |
* @package SureDonation |
| 6 |
* @since 1.2.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace SureDonation\Inc\Page_Builders\Bricks\Elements; |
| 10 |
|
| 11 |
use SureDonation\Inc\Page_Builders\Bricks\Base_Element; |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; // Exit if accessed directly. |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* Campaign_Donate_Button class. |
| 19 |
* |
| 20 |
* @since 1.2.0 |
| 21 |
*/ |
| 22 |
class Campaign_Donate_Button extends Base_Element { |
| 23 |
/** |
| 24 |
* Element name. |
| 25 |
* |
| 26 |
* @since 1.2.0 |
| 27 |
* @var string |
| 28 |
*/ |
| 29 |
public $name = 'suredonation-campaign-donate-button'; |
| 30 |
|
| 31 |
/** |
| 32 |
* Element icon. |
| 33 |
* |
| 34 |
* @since 1.2.0 |
| 35 |
* @var string |
| 36 |
*/ |
| 37 |
public $icon = 'ti-money'; |
| 38 |
|
| 39 |
/** |
| 40 |
* Element label shown in the builder panel. |
| 41 |
* |
| 42 |
* @since 1.2.0 |
| 43 |
* @return string |
| 44 |
*/ |
| 45 |
public function get_label() { |
| 46 |
return esc_html__( 'Campaign Donate Button', 'suredonation' ); |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* {@inheritDoc} |
| 51 |
*/ |
| 52 |
public function get_keywords() { |
| 53 |
return array_merge( parent::get_keywords(), [ 'button', 'donate' ] ); |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Register the element controls. |
| 58 |
* |
| 59 |
* @since 1.2.0 |
| 60 |
* @return void |
| 61 |
*/ |
| 62 |
public function set_controls() { |
| 63 |
$this->add_campaign_control(); |
| 64 |
|
| 65 |
$this->controls['buttonText'] = [ |
| 66 |
'tab' => 'content', |
| 67 |
'label' => esc_html__( 'Button text', 'suredonation' ), |
| 68 |
'type' => 'text', |
| 69 |
'default' => esc_html__( 'Donate', 'suredonation' ), |
| 70 |
]; |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* {@inheritDoc} |
| 75 |
*/ |
| 76 |
protected function block_name() { |
| 77 |
return 'suredonation/campaign-donate-button'; |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* Map the element settings to the block attributes. |
| 82 |
* |
| 83 |
* @since 1.2.0 |
| 84 |
* @param array<string, mixed> $settings Element settings. |
| 85 |
* @return array<string, mixed> |
| 86 |
*/ |
| 87 |
protected function get_block_attrs( $settings ) { |
| 88 |
return [ |
| 89 |
'buttonText' => $this->setting_string( $settings, 'buttonText', __( 'Donate', 'suredonation' ) ), |
| 90 |
]; |
| 91 |
} |
| 92 |
} |
| 93 |
|