PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.11.3
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.11.3
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 / panels / class-settings.php

class-settings.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.11.3, at includes/admin/campaign-builder/panels/class-settings.php

244 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Settings class management panel.
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_Builder_Panel_Settings' ) ) :
18
19 /**
20 * Design management panel.
21 *
22 * @since 1.8.0
23 */
24 class Charitable_Builder_Panel_Settings extends Charitable_Builder_Panel {
25
26 /**
27 * Form data and settings.
28 *
29 * @since 1.4.4.1
30 *
31 * @var array
32 */
33 public $campaign_data;
34
35 /**
36 * Panels for the submenu campaign builder.
37 *
38 * @since 1.8.0
39 *
40 * @var array
41 */
42 public $submenu_panels;
43
44 /**
45 * All systems go.
46 *
47 * @since 1.8.0
48 */
49 public function init() {
50
51 // Define panel information.
52 $this->name = esc_html__( 'Settings', 'charitable' );
53 $this->slug = 'settings';
54 $this->icon = 'panel_settings.svg';
55 $this->order = 30;
56 $this->sidebar = true;
57
58 // This should never be called unless we are on the campaign builder page.
59 if ( campaign_is_campaign_builder_admin_page() ) {
60 $this->load_submenu_panels();
61 }
62 }
63
64 /**
65 * Enqueue assets for the Design panel.
66 *
67 * @since 1.8.0
68 */
69 public function enqueues() {
70 }
71
72 /**
73 * Load panels.
74 *
75 * @since 1.8.0
76 */
77 public function load_submenu_panels() {
78
79 $this->submenu_panels = apply_filters(
80 'charitable_builder_panels_settings_',
81 array(
82 'general',
83 'donation-options',
84 'addons',
85 )
86 );
87
88 foreach ( $this->submenu_panels as $panel ) {
89 $panel = sanitize_file_name( $panel );
90 $file = require_once charitable()->get_path( 'includes' ) . "admin/campaign-builder/panels/settings/class-settings-{$panel}.php";
91
92 if ( file_exists( $file ) ) {
93 require_once $file;
94 }
95 }
96 }
97
98
99 /**
100 * Output the Field panel sidebar.
101 *
102 * @since 1.8.0
103 */
104 public function panel_sidebar() {
105
106 // This should never be called unless we are on the campaign builder page.
107 if ( ! campaign_is_campaign_builder_admin_page() ) {
108 return;
109 }
110
111 do_action( 'charitable_campaign_builder_settings_sidebar', $this->campaign_data );
112 }
113
114 /**
115 * Process settings for campaigns, mostly via the builder.
116 *
117 * @since 1.8.0
118 *
119 * @param string $field Field.
120 * @param string $section Settings section.
121 * @param string $top_level Level.
122 * @param string $meta_key Alt legacy location to try to pull settings.
123 *
124 * @return string
125 */
126 public function campaign_data_settings( $field = 'title', $section = 'general', $top_level = 'settings', $meta_key = false ) {
127
128 if ( false === $top_level ) {
129
130 $value = isset( $this->campaign_data[ $field ] ) ? $this->campaign_data[ $field ] : false;
131
132 } elseif ( $section === 'campaign-summary' ) {
133
134 $value_array = isset( $this->campaign_data[ $top_level ][ $section ] ) ? $this->campaign_data[ $top_level ][ $section ] : false;
135
136 return $value_array;
137
138 } elseif ( $field === 'categories' ) {
139
140 $value_array = isset( $this->campaign_data[ $top_level ][ $section ] ) ? $this->campaign_data[ $top_level ][ $section ] : false;
141 $result = [];
142
143 if ( ! empty( $value_array ) ) {
144
145 foreach ( $value_array as $key => $value ) {
146
147 $exp_key = explode( '-', $key );
148
149 if ( $exp_key[0] === 'categories' ) {
150 $result[] = $value;
151 }
152
153 }
154
155 }
156
157 return $result;
158
159 } else {
160
161 $value = isset( $this->campaign_data[ $top_level ][ $section ][ $field ] ) ? $this->campaign_data[ $top_level ][ $section ][ $field ] : false;
162
163 }
164
165 // If there is no value, attempt to see if this could be a postmeta from an addon.
166 if ( false === $value && false !== $meta_key && isset( $this->campaign_data['id'] ) ) {
167
168 $value = get_post_meta( intval( $this->campaign_data['id'] ), esc_attr( $meta_key ), true );
169
170 }
171
172 // todo: clean up, santitize.
173
174 return apply_filters( 'charitable_builder_data_setting', $value, $field, $section, $top_level, $this->campaign_data );
175 }
176
177 /**
178 * Output the Field panel primary content.
179 *
180 * @since 1.8.0
181 */
182 public function panel_content() {
183
184 // This should never be called unless we are on the campaign builder page.
185 if ( ! campaign_is_campaign_builder_admin_page() ) {
186 return;
187 }
188
189 do_action( 'charitable_campaign_builder_settings_panels', $this->campaign_data );
190 }
191
192
193 /**
194 * Output the Field panel primary content.
195 *
196 * @since 1.8.0
197 */
198 public function preview() {
199
200 ob_start();
201
202 ?>
203
204 <div class="charitable-campaign-preview container">
205
206 </div>
207
208 <?php
209
210 $preview = ob_get_clean();
211
212 echo $preview; // phpcs:ignore
213 }
214
215
216
217 /**
218 * Builder field buttons.
219 *
220 * @since 1.8.0
221 */
222 public function fields() {
223 }
224
225 /**
226 * Sort Add Field buttons by order provided.
227 *
228 * @since 1.8.0
229 *
230 * @param array $a First item.
231 * @param array $b Second item.
232 *
233 * @return array
234 */
235 public function field_order( $a, $b ) {
236
237 return $a['order'] - $b['order'];
238 }
239 }
240
241 endif;
242
243 new Charitable_Builder_Panel_Settings();
244