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

class-charitable-advanced-settings.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.7.0.6, at includes/admin/settings/class-charitable-advanced-settings.php

186 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Charitable Advanced Settings UI.
4 *
5 * @package Charitable/Classes/Charitable_Advanced_Settings
6 * @author David Bisset
7 * @copyright Copyright (c) 2022, WP Charitable LLC
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 1.0.0
10 * @version 1.2.0
11 */
12
13 // Exit if accessed directly.
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 if ( ! class_exists( 'Charitable_Advanced_Settings' ) ) :
19
20 /**
21 * Charitable_Advanced_Settings
22 *
23 * @final
24 * @since 1.0.0
25 */
26 final class Charitable_Advanced_Settings {
27
28 /**
29 * The single instance of this class.
30 *
31 * @var Charitable_Advanced_Settings|null
32 */
33 private static $instance = null;
34
35 /**
36 * Create object instance.
37 *
38 * @since 1.0.0
39 */
40 private function __construct() {
41 }
42
43 /**
44 * Returns and/or create the single instance of this class.
45 *
46 * @since 1.2.0
47 *
48 * @return Charitable_Advanced_Settings
49 */
50 public static function get_instance() {
51 if ( is_null( self::$instance ) ) {
52 self::$instance = new self();
53 }
54
55 return self::$instance;
56 }
57
58 /**
59 * Add the advanced tab settings fields.
60 *
61 * @since 1.0.0
62 *
63 * @return array<string,array>
64 */
65 public function add_advanced_fields() {
66 if ( ! charitable_is_settings_view( 'advanced' ) ) {
67 return array();
68 }
69
70 return array(
71 'section' => array(
72 'title' => '',
73 'type' => 'hidden',
74 'priority' => 10000,
75 'value' => 'advanced',
76 ),
77 'section_dangerous' => array(
78 'title' => __( 'Dangerous Settings', 'charitable' ),
79 'type' => 'heading',
80 'class' => 'section-heading dangerous-settings',
81 'priority' => 100,
82 ),
83 'delete_data_on_uninstall' => array(
84 'label_for' => __( 'Reset Data', 'charitable' ),
85 'type' => 'checkbox',
86 'help' => __( 'DELETE ALL DATA when uninstalling the plugin.', 'charitable' ),
87 'priority' => 105,
88 ),
89 'section' => array(
90 'title' => '',
91 'type' => 'hidden',
92 'priority' => 10000,
93 'value' => 'licenses',
94 'save' => false,
95 ),
96 'section_licenses' => array(
97 'title' => __( 'Legacy Licenses', 'charitable' ),
98 'type' => 'heading',
99 'class' => 'section-heading',
100 'priority' => 202,
101 ),
102 'licenses' => array(
103 'title' => false,
104 'callback' => array( $this, 'render_licenses_table' ),
105 'priority' => 204,
106 ),
107 );
108
109 foreach ( charitable_get_helper( 'licenses' )->get_products() as $key => $product ) {
110 $fields[ $key ] = array(
111 'type' => 'text',
112 'render' => false,
113 'priority' => 206,
114 );
115 }
116
117 }
118
119 /**
120 * Add the licenses group.
121 *
122 * @since 1.0.0
123 *
124 * @param string[] $groups Settings groups.
125 * @return string[]
126 */
127 public function add_licenses_group( $groups ) {
128 $groups['licenses'] = array();
129 return $groups;
130 }
131
132 /**
133 * Render the licenses table.
134 *
135 * @since 1.0.0
136 *
137 * @return void
138 */
139 public function render_licenses_table() {
140 charitable_admin_view( 'settings/licenses' );
141 }
142
143 /**
144 * Checks for updated license and invalidates status field if not set.
145 *
146 * @since 1.0.0
147 *
148 * @param mixed[] $values The parsed values combining old values & new values.
149 * @param mixed[] $new_values The newly submitted values.
150 * @return mixed[]
151 */
152 public function save_license( $values, $new_values ) {
153 /* If we didn't just submit licenses, stop here. */
154 if ( ! isset( $new_values['licenses'] ) ) {
155 return $values;
156 }
157
158 $re_check = array_key_exists( 'recheck', $_POST );
159 $licenses = $new_values['licenses'];
160
161 foreach ( $licenses as $product_key => $license ) {
162 $license = trim( $license );
163
164 if ( empty( $license ) ) {
165 $values['licenses'][ $product_key ] = '';
166 continue;
167 }
168
169 $license_data = charitable_get_helper( 'licenses' )->verify_license( $product_key, $license, $re_check );
170
171 if ( empty( $license_data ) ) {
172 continue;
173 }
174
175 $values['licenses'][ $product_key ] = $license_data;
176 }
177
178 return $values;
179 }
180
181
182
183 }
184
185 endif;
186