PluginProbe
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management / 1.5.1
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management v1.5.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 / elementor / widgets / campaign-donations-widget.php

campaign-donations-widget.php in SureDonation – Donation Forms, Fundraising Campaigns & Donor Management 1.5.1, at inc/page-builders/elementor/widgets/campaign-donations-widget.php

126 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Elementor widget: Campaign Donations.
4 *
5 * @package SureDonation
6 * @since 1.2.0
7 */
8
9 namespace SureDonation\Inc\Page_Builders\Elementor\Widgets;
10
11 use Elementor\Controls_Manager;
12 use SureDonation\Inc\Page_Builders\Elementor\Base_Widget;
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit; // Exit if accessed directly.
16 }
17
18 /**
19 * Campaign_Donations_Widget class.
20 *
21 * @since 1.2.0
22 */
23 class Campaign_Donations_Widget extends Base_Widget {
24 /**
25 * {@inheritDoc}
26 */
27 public function get_name() {
28 return 'suredonation-campaign-donations';
29 }
30
31 /**
32 * {@inheritDoc}
33 */
34 public function get_title() {
35 return esc_html__( 'Campaign Donations', 'suredonation' );
36 }
37
38 /**
39 * {@inheritDoc}
40 */
41 public function get_icon() {
42 return 'eicon-post-list';
43 }
44
45 /**
46 * {@inheritDoc}
47 */
48 protected function block_name() {
49 return 'suredonation/campaign-donations';
50 }
51
52 /**
53 * Register the widget controls.
54 *
55 * @since 1.2.0
56 * @return void
57 */
58 protected function register_controls() {
59 $this->start_controls_section(
60 'content',
61 [ 'label' => esc_html__( 'Campaign Donations', 'suredonation' ) ]
62 );
63
64 $this->add_campaign_control();
65
66 $this->add_control(
67 'donations_to_show',
68 [
69 'label' => esc_html__( 'Number of donations', 'suredonation' ),
70 'type' => Controls_Manager::NUMBER,
71 'default' => 5,
72 'min' => 1,
73 'max' => 50,
74 ]
75 );
76
77 $this->add_control(
78 'show_anonymous',
79 [
80 'label' => esc_html__( 'Show anonymous donations', 'suredonation' ),
81 'type' => Controls_Manager::SWITCHER,
82 'return_value' => 'yes',
83 'default' => 'yes',
84 ]
85 );
86
87 $this->add_control(
88 'show_button',
89 [
90 'label' => esc_html__( 'Show button', 'suredonation' ),
91 'type' => Controls_Manager::SWITCHER,
92 'return_value' => 'yes',
93 'default' => '',
94 ]
95 );
96
97 $this->add_control(
98 'button_text',
99 [
100 'label' => esc_html__( 'Button text', 'suredonation' ),
101 'type' => Controls_Manager::TEXT,
102 'default' => esc_html__( 'Donate', 'suredonation' ),
103 'condition' => [ 'show_button' => 'yes' ],
104 ]
105 );
106
107 $this->end_controls_section();
108 }
109
110 /**
111 * Map the widget settings to the block attributes.
112 *
113 * @since 1.2.0
114 * @param array<string, mixed> $settings Widget settings.
115 * @return array<string, mixed>
116 */
117 protected function get_block_attrs( $settings ) {
118 return [
119 'donationsToShow' => $this->setting_int( $settings, 'donations_to_show', 5 ),
120 'showAnonymous' => $this->setting_bool( $settings, 'show_anonymous', true ),
121 'showButton' => $this->setting_bool( $settings, 'show_button', false ),
122 'buttonText' => $this->setting_string( $settings, 'button_text', __( 'Donate', 'suredonation' ) ),
123 ];
124 }
125 }
126