PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / includes / admin / campaign-builder / fields / class-donation-options.php

class-donation-options.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at includes/admin/campaign-builder/fields/class-donation-options.php

199 lines 5.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class to add donation options to a campaign form in the builder.
4 *
5 * @package Charitable
6 * @author David Bisset
7 * @copyright Copyright (c) 2023, WP Charitable LLC
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 1.8.0
10 * @version 1.8.0
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 if ( ! class_exists( 'Charitable_Field_Donation_Options' ) ) :
18
19 /**
20 * Class to add campaign donation options field to a campaign form in the builder.
21 */
22 class Charitable_Field_Donation_Options extends Charitable_Builder_Field {
23
24 /**
25 * Primary class constructor.
26 *
27 * @since 1.8.0
28 */
29 public function init() {
30
31 // Define field type information.
32 $this->name = esc_html__( 'Donation Options', 'charitable' );
33 $this->type = 'donation-options';
34 $this->icon = 'fa-sliders';
35 $this->order = 30;
36
37 // Edit/Duplication information.
38 $this->can_be_edited = true;
39 $this->can_be_deleted = true;
40 $this->can_be_duplicated = true;
41 $this->edit_label = esc_html__( 'Edit Donation Options', 'charitable' );
42 $this->edit_type = 'donation-options'; // was settings
43 $this->edit_section = 'standard';
44
45 // Misc.
46 $this->tooltip = '';
47
48 // Define additional field properties.
49 add_action( 'charitable_frontend_js', [ $this, 'frontend_js' ] );
50 }
51
52 /**
53 * Donation Options options panel inside the builder.
54 *
55 * @since 1.8.0
56 *
57 * @param array $field Donation Options settings.
58 */
59 public function field_options( $field ) {
60 /*
61 * Basic field options.
62 */
63
64 // Options open markup.
65 }
66
67 /**
68 * Donation Options preview inside the builder.
69 *
70 * @since 1.8.0
71 * @version 1.8.8.5
72 *
73 * @param array $field_data Field data and settings.
74 * @param array $campaign_data Campaign data and settings.
75 * @param array $field_id Field ID.
76 * @param string $theme Template data.
77 */
78 public function field_preview( $field_data = false, $campaign_data = false, $field_id = false, $theme = '' ) {
79
80 // Define data.
81 $placeholder = ! empty( $field_data['placeholder'] ) ? $field_data['placeholder'] : '';
82 $default_value = ! empty( $field_data['default_value'] ) ? $field_data['default_value'] : '';
83
84 echo '<h4>' . esc_html( $this->name ) . '</h4>';
85
86 echo '<div class="charitable-field-preview-donation-options donation-options" data-field-type="' . esc_attr( $this->type ) . '"><div class="row">
87 <div class="column">
88 <span class="placeholder"></span>
89 <span class="placeholder"></span>
90 </div>
91 <div class="column">
92 <span class="placeholder"></span>
93 <span class="placeholder"></span>
94 </div>
95 <div class="column">
96 <span class="placeholder"></span>
97 <span class="placeholder"></span>
98 </div>
99 </div></div>';
100 }
101
102 /**
103 * Donation Options display on the form front-end.
104 *
105 * @since 1.8.0
106 *
107 * @param array $field Donation Options settings.
108 * @param array $deprecated Deprecated.
109 * @param array $form_data Form data and settings.
110 */
111 public function field_display( $field, $deprecated = false, $form_data = false ) {
112
113 echo '[Real Donation Options Here]';
114 }
115
116 /**
117 * The display on the form settings backend when the user clicks on the field/block.
118 *
119 * @since 1.8.0
120 *
121 * @param array $field Social Sharing settings.
122 * @param array $campaign_data Campaign data and settings.
123 */
124 public function settings_display( $field_id = false, $campaign_data = false ) {
125
126 $charitable_builder_form_fields = new Charitable_Builder_Form_Fields();
127
128 $settings = isset( $campaign_data['fields'][ $field_id ] ) ? $campaign_data['fields'][ $field_id ] : false;
129
130 ob_start();
131
132 ?>
133
134 <h4 class="charitable-panel-field" data-field-id="<?php echo intval( $field_id ); ?>"><?php echo esc_html( $this->name ); ?> (ID: <?php echo intval( $field_id ); ?>)</h4>
135
136 <?php
137
138 echo $charitable_builder_form_fields->generate_text( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
139 isset( $settings['css_class'] ) ? $settings['css_class'] : false,
140 esc_html__( 'CSS Class', 'charitable' ),
141 array(
142 'id' => 'field_' . esc_attr( $this->type ) . '_css_class' . '_' . intval( $field_id ),
143 'name' => array( '_fields', intval( $field_id ), 'css_class' ),
144 'field_id' => intval( $field_id ),
145 'tooltip' => esc_html__( 'Add CSS classes (seperated by a space) for this field to customize it\'s appearance in your theme.', 'charitable' ),
146 )
147 );
148
149 ?>
150
151 <div class="charitable-panel-field" data-field-id="<?php echo intval( $field_id ); ?>">
152 <p><button class="go-to-settings-button charitable-button" data-settings-section="donation-options">Go To Settings for Donation Options</button></p>
153 </div>
154
155 <?php
156
157 $html = ob_get_clean();
158
159 return $html;
160 }
161
162 /**
163 * Enqueue frontend limit option js.
164 *
165 * @since 1.8.0
166 *
167 * @param array $forms Forms on the current page.
168 */
169 public function frontend_js( $forms ) {
170 }
171
172 /**
173 * Format and sanitize field.
174 *
175 * @since 1.8.0
176 *
177 * @param int $field_id Donation Options ID.
178 * @param mixed $field_submit Donation Options value that was submitted.
179 * @param array $form_data Form data and settings.
180 */
181 public function format( $field_id, $field_submit, $form_data ) {
182 }
183
184 /**
185 * Validate field on form submit.
186 *
187 * @since 1.8.0
188 *
189 * @param int $field_id Donation Options ID.
190 * @param mixed $field_submit Donation Options value that was submitted.
191 * @param array $form_data Form data and settings.
192 */
193 public function validate( $field_id, $field_submit, $form_data ) {
194 }
195 }
196
197 new Charitable_Field_Donation_Options();
198
199 endif;