PluginProbe
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management / 1.6.1
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management v1.6.1
1.6.1 1.6.0 1.5.1 1.5.0 1.4.0 1.3.0 trunk 0.0.1 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0
suredonation / inc / page-builders / bricks / elements / campaign-donors.php

campaign-donors.php in SureDonation – Donation Forms, Fundraising Campaigns & Donor Management 1.6.1, at inc/page-builders/bricks/elements/campaign-donors.php

111 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Bricks element: Campaign Donors.
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_Donors class.
19 *
20 * @since 1.2.0
21 */
22 class Campaign_Donors extends Base_Element {
23 /**
24 * Element name.
25 *
26 * @since 1.2.0
27 * @var string
28 */
29 public $name = 'suredonation-campaign-donors';
30
31 /**
32 * Element icon.
33 *
34 * @since 1.2.0
35 * @var string
36 */
37 public $icon = 'ti-user';
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 Donors', 'suredonation' );
47 }
48
49 /**
50 * {@inheritDoc}
51 */
52 public function get_keywords() {
53 return array_merge( parent::get_keywords(), [ 'donors', 'supporters' ] );
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['donorsToShow'] = [
66 'tab' => 'content',
67 'label' => esc_html__( 'Number of donors', 'suredonation' ),
68 'type' => 'number',
69 'default' => 5,
70 'min' => 1,
71 'max' => 50,
72 ];
73
74 $this->controls['showButton'] = [
75 'tab' => 'content',
76 'label' => esc_html__( 'Show button', 'suredonation' ),
77 'type' => 'checkbox',
78 ];
79
80 $this->controls['buttonText'] = [
81 'tab' => 'content',
82 'label' => esc_html__( 'Button text', 'suredonation' ),
83 'type' => 'text',
84 'default' => esc_html__( 'Join the list', 'suredonation' ),
85 'required' => [ 'showButton', '=', true ],
86 ];
87 }
88
89 /**
90 * {@inheritDoc}
91 */
92 protected function block_name() {
93 return 'suredonation/campaign-donors';
94 }
95
96 /**
97 * Map the element settings to the block attributes.
98 *
99 * @since 1.2.0
100 * @param array<string, mixed> $settings Element settings.
101 * @return array<string, mixed>
102 */
103 protected function get_block_attrs( $settings ) {
104 return [
105 'donorsToShow' => max( 1, min( 50, $this->setting_int( $settings, 'donorsToShow', 5 ) ) ),
106 'showButton' => $this->setting_bool( $settings, 'showButton' ),
107 'buttonText' => $this->setting_string( $settings, 'buttonText', __( 'Join the list', 'suredonation' ) ),
108 ];
109 }
110 }
111