| 1 |
<?php |
| 2 |
/** |
| 3 |
* Charitable About admin page class. |
| 4 |
* |
| 5 |
* @package Charitable/Classes/Charitable_About |
| 6 |
* @author David Bisset |
| 7 |
* @copyright Copyright (c) 2024, WP Charitable LLC |
| 8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 |
* @since 1.8.7.6 |
| 10 |
*/ |
| 11 |
|
| 12 |
// Exit if accessed directly. |
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
if ( ! class_exists( 'Charitable_About' ) ) : |
| 18 |
|
| 19 |
/** |
| 20 |
* Charitable_About |
| 21 |
* |
| 22 |
* @since 1.8.7.6 |
| 23 |
*/ |
| 24 |
class Charitable_About { |
| 25 |
|
| 26 |
/** |
| 27 |
* Admin menu page slug. |
| 28 |
* |
| 29 |
* @since 1.8.7.6 |
| 30 |
* |
| 31 |
* @var string |
| 32 |
*/ |
| 33 |
const SLUG = 'charitable-about'; |
| 34 |
|
| 35 |
/** |
| 36 |
* Default view for a page. |
| 37 |
* |
| 38 |
* @since 1.8.7.6 |
| 39 |
* |
| 40 |
* @var string |
| 41 |
*/ |
| 42 |
const DEFAULT_TAB = 'about'; |
| 43 |
|
| 44 |
/** |
| 45 |
* The current active tab. |
| 46 |
* |
| 47 |
* @since 1.8.7.6 |
| 48 |
* |
| 49 |
* @var string |
| 50 |
*/ |
| 51 |
public $view; |
| 52 |
|
| 53 |
/** |
| 54 |
* Primary class constructor. |
| 55 |
* |
| 56 |
* @since 1.8.7.6 |
| 57 |
*/ |
| 58 |
public function __construct() { |
| 59 |
$this->hooks(); |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Register hooks. |
| 64 |
* |
| 65 |
* @since 1.8.7.6 |
| 66 |
*/ |
| 67 |
private function hooks() { |
| 68 |
// Maybe load about page. |
| 69 |
add_action( 'admin_init', [ $this, 'init' ] ); |
| 70 |
// Enqueue assets. |
| 71 |
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] ); |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Determining if the user is viewing our page, if so, party on. |
| 76 |
* |
| 77 |
* @since 1.8.7.6 |
| 78 |
*/ |
| 79 |
public function init() { |
| 80 |
// Check what page we are on. |
| 81 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 82 |
$page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; |
| 83 |
|
| 84 |
// Only load if we are actually on the about page. |
| 85 |
if ( $page !== self::SLUG ) { |
| 86 |
return; |
| 87 |
} |
| 88 |
|
| 89 |
// Determine the current active tab. |
| 90 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 91 |
$this->view = ! empty( $_GET['view'] ) ? sanitize_text_field( wp_unslash( $_GET['view'] ) ) : self::DEFAULT_TAB; |
| 92 |
|
| 93 |
// If the user tries to load an invalid view - redirect to About Us. |
| 94 |
$valid_views = [ 'about', 'lite-vs-pro' ]; |
| 95 |
if ( ! in_array( $this->view, $valid_views, true ) ) { |
| 96 |
wp_safe_redirect( admin_url( 'admin.php?page=charitable-about&view=about' ) ); |
| 97 |
exit; |
| 98 |
} |
| 99 |
|
| 100 |
add_action( 'charitable_admin_page', [ $this, 'output' ] ); |
| 101 |
|
| 102 |
// Hook for addons. |
| 103 |
do_action( 'charitable_admin_about_init' ); |
| 104 |
} |
| 105 |
|
| 106 |
/** |
| 107 |
* Output the basic page structure. |
| 108 |
* |
| 109 |
* @since 1.8.7.6 |
| 110 |
*/ |
| 111 |
public function output() { |
| 112 |
charitable_admin_view( 'about/about' ); |
| 113 |
} |
| 114 |
|
| 115 |
/** |
| 116 |
* Enqueue assets for the About page. |
| 117 |
* |
| 118 |
* @since 1.8.7.6 |
| 119 |
*/ |
| 120 |
public function enqueue_assets() { |
| 121 |
// Check if we're on the about page |
| 122 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 123 |
$page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; |
| 124 |
|
| 125 |
if ( $page !== self::SLUG ) { |
| 126 |
return; |
| 127 |
} |
| 128 |
|
| 129 |
// Enqueue CSS |
| 130 |
wp_enqueue_style( |
| 131 |
'charitable-admin-about', |
| 132 |
charitable()->get_path( 'assets', false ) . 'css/admin/about-us.css', |
| 133 |
[], |
| 134 |
charitable()->get_version() |
| 135 |
); |
| 136 |
|
| 137 |
// Enqueue JavaScript |
| 138 |
wp_enqueue_script( |
| 139 |
'charitable-admin-about', |
| 140 |
charitable()->get_path( 'assets', false ) . 'js/admin/about-us.js', |
| 141 |
[ 'jquery' ], |
| 142 |
charitable()->get_version(), |
| 143 |
true |
| 144 |
); |
| 145 |
|
| 146 |
// Enqueue addons JavaScript |
| 147 |
wp_enqueue_script( |
| 148 |
'charitable-admin-addons', |
| 149 |
charitable()->get_path( 'assets', false ) . 'js/admin/charitable-admin-addons.js', |
| 150 |
[ 'jquery' ], |
| 151 |
charitable()->get_version(), |
| 152 |
true |
| 153 |
); |
| 154 |
|
| 155 |
// Localize addons script |
| 156 |
wp_localize_script( |
| 157 |
'charitable-admin-addons', |
| 158 |
'charitable_admin_addons', |
| 159 |
array( |
| 160 |
'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 161 |
'nonce' => wp_create_nonce( 'charitable_admin_addons' ), |
| 162 |
) |
| 163 |
); |
| 164 |
} |
| 165 |
|
| 166 |
/** |
| 167 |
* Get the current view. |
| 168 |
* |
| 169 |
* @since 1.8.7.6 |
| 170 |
* |
| 171 |
* @return string |
| 172 |
*/ |
| 173 |
public function get_view() { |
| 174 |
return $this->view; |
| 175 |
} |
| 176 |
|
| 177 |
/** |
| 178 |
* Get license data for a specific feature and license level. |
| 179 |
* |
| 180 |
* @since 1.8.7.6 |
| 181 |
* |
| 182 |
* @param string $feature The feature slug. |
| 183 |
* @param string $license The license level. |
| 184 |
* @return array|false |
| 185 |
*/ |
| 186 |
public function get_license_data( $feature, $license ) { |
| 187 |
$data = $this->get_licenses_data(); |
| 188 |
|
| 189 |
if ( ! isset( $data[ $feature ][ $license ] ) ) { |
| 190 |
return false; |
| 191 |
} |
| 192 |
|
| 193 |
return $data[ $feature ][ $license ]; |
| 194 |
} |
| 195 |
|
| 196 |
/** |
| 197 |
* Get all licenses data. |
| 198 |
* |
| 199 |
* @since 1.8.7.6 |
| 200 |
* |
| 201 |
* @return array |
| 202 |
*/ |
| 203 |
private function get_licenses_data() { |
| 204 |
return array( |
| 205 |
'campaigns' => array( |
| 206 |
'lite' => array( |
| 207 |
'status' => 'full', |
| 208 |
'text' => array( |
| 209 |
'<strong>' . esc_html__( 'Unlimited Campaigns', 'charitable' ) . '</strong>', |
| 210 |
), |
| 211 |
), |
| 212 |
'pro' => array( |
| 213 |
'status' => 'full', |
| 214 |
'text' => array( |
| 215 |
'<strong>' . esc_html__( 'Unlimited Campaigns', 'charitable' ) . '</strong>', |
| 216 |
), |
| 217 |
), |
| 218 |
), |
| 219 |
'payment_gateways' => array( |
| 220 |
'lite' => array( |
| 221 |
'status' => 'full', |
| 222 |
'text' => array( |
| 223 |
'<strong>' . esc_html__( 'Stripe, Square, PayPal Standard and Offline Donations', 'charitable' ) . '</strong>', |
| 224 |
), |
| 225 |
), |
| 226 |
'pro' => array( |
| 227 |
'status' => 'full', |
| 228 |
'text' => array( |
| 229 |
'<strong>' . esc_html__( 'Authorize.Net, Windcave, Mollie, Braintree, PayFast, GoCardless, Payrexx, and more', 'charitable' ) . '</strong>', |
| 230 |
), |
| 231 |
), |
| 232 |
), |
| 233 |
'recurring_donations' => array( |
| 234 |
'lite' => array( |
| 235 |
'status' => 'none', |
| 236 |
'text' => array( |
| 237 |
'<strong>' . esc_html__( 'Not Available', 'charitable' ) . '</strong>', |
| 238 |
), |
| 239 |
), |
| 240 |
'pro' => array( |
| 241 |
'status' => 'full', |
| 242 |
'text' => array( |
| 243 |
'<strong>' . esc_html__( 'Accept weekly, monthly, quarterly, semiannual, or annual donations', 'charitable' ) . '</strong>', |
| 244 |
), |
| 245 |
), |
| 246 |
), |
| 247 |
'suggested_amounts' => array( |
| 248 |
'lite' => array( |
| 249 |
'status' => 'full', |
| 250 |
'text' => array( |
| 251 |
'<strong>' . esc_html__( 'Available', 'charitable' ) . '</strong>', |
| 252 |
), |
| 253 |
), |
| 254 |
'pro' => array( |
| 255 |
'status' => 'full', |
| 256 |
'text' => array( |
| 257 |
'<strong>' . esc_html__( 'Advanced customization & recurring options', 'charitable' ) . '</strong>', |
| 258 |
), |
| 259 |
), |
| 260 |
), |
| 261 |
'fundraising_goals' => array( |
| 262 |
'lite' => array( |
| 263 |
'status' => 'partial', |
| 264 |
'text' => array( |
| 265 |
'<strong>' . esc_html__( 'Basic goal display', 'charitable' ) . '</strong>', |
| 266 |
), |
| 267 |
), |
| 268 |
'pro' => array( |
| 269 |
'status' => 'full', |
| 270 |
'text' => array( |
| 271 |
'<strong>' . esc_html__( 'Advanced goal tracking with flexible styles & progress bars', 'charitable' ) . '</strong>', |
| 272 |
), |
| 273 |
), |
| 274 |
), |
| 275 |
'peer_to_peer' => array( |
| 276 |
'lite' => array( |
| 277 |
'status' => 'none', |
| 278 |
'text' => array( |
| 279 |
'<strong>' . esc_html__( 'Not Available', 'charitable' ) . '</strong>', |
| 280 |
), |
| 281 |
), |
| 282 |
'pro' => array( |
| 283 |
'status' => 'full', |
| 284 |
'text' => array( |
| 285 |
'<strong>' . esc_html__( 'Let supporters create their own fundraising pages & track their progress', 'charitable' ) . '</strong>', |
| 286 |
), |
| 287 |
), |
| 288 |
), |
| 289 |
'ambassadors' => array( |
| 290 |
'lite' => array( |
| 291 |
'status' => 'none', |
| 292 |
'text' => array( |
| 293 |
'<strong>' . esc_html__( 'Not Available', 'charitable' ) . '</strong>', |
| 294 |
), |
| 295 |
), |
| 296 |
'pro' => array( |
| 297 |
'status' => 'full', |
| 298 |
'text' => array( |
| 299 |
'<strong>' . esc_html__( 'Recruit ambassadors & teams to raise funds on your behalf', 'charitable' ) . '</strong>', |
| 300 |
), |
| 301 |
), |
| 302 |
), |
| 303 |
'donation_data' => array( |
| 304 |
'lite' => array( |
| 305 |
'status' => 'full', |
| 306 |
'text' => array( |
| 307 |
'<strong>' . esc_html__( 'Full donation record management', 'charitable' ) . '</strong>', |
| 308 |
), |
| 309 |
), |
| 310 |
'pro' => array( |
| 311 |
'status' => 'full', |
| 312 |
'text' => array( |
| 313 |
'<strong>' . esc_html__( 'Full donation and donor records', 'charitable' ) . '</strong>', |
| 314 |
), |
| 315 |
), |
| 316 |
), |
| 317 |
'donor_comments' => array( |
| 318 |
'lite' => array( |
| 319 |
'status' => 'none', |
| 320 |
'text' => array( |
| 321 |
'<strong>' . esc_html__( 'Not Available', 'charitable' ) . '</strong>', |
| 322 |
), |
| 323 |
), |
| 324 |
'pro' => array( |
| 325 |
'status' => 'full', |
| 326 |
'text' => array( |
| 327 |
'<strong>' . esc_html__( 'Allow donors to leave public or private comments', 'charitable' ) . '</strong>', |
| 328 |
), |
| 329 |
), |
| 330 |
), |
| 331 |
'donor_dashboard' => array( |
| 332 |
'lite' => array( |
| 333 |
'status' => 'none', |
| 334 |
'text' => array( |
| 335 |
'<strong>' . esc_html__( 'Not Available', 'charitable' ) . '</strong>', |
| 336 |
), |
| 337 |
), |
| 338 |
'pro' => array( |
| 339 |
'status' => 'full', |
| 340 |
'text' => array( |
| 341 |
'<strong>' . esc_html__( 'Donors manage their giving, receipts, and payment methods', 'charitable' ) . '</strong>', |
| 342 |
), |
| 343 |
), |
| 344 |
), |
| 345 |
'pdf_receipts' => array( |
| 346 |
'lite' => array( |
| 347 |
'status' => 'none', |
| 348 |
'text' => array( |
| 349 |
'<strong>' . esc_html__( 'Not Available', 'charitable' ) . '</strong>', |
| 350 |
), |
| 351 |
), |
| 352 |
'pro' => array( |
| 353 |
'status' => 'full', |
| 354 |
'text' => array( |
| 355 |
'<strong>' . esc_html__( 'Automatically generate & send professional receipts', 'charitable' ) . '</strong>', |
| 356 |
), |
| 357 |
), |
| 358 |
), |
| 359 |
'fee_relief' => array( |
| 360 |
'lite' => array( |
| 361 |
'status' => 'none', |
| 362 |
'text' => array( |
| 363 |
'<strong>' . esc_html__( 'Not Available', 'charitable' ) . '</strong>', |
| 364 |
), |
| 365 |
), |
| 366 |
'pro' => array( |
| 367 |
'status' => 'full', |
| 368 |
'text' => array( |
| 369 |
'<strong>' . esc_html__( 'Let donors cover processing fees', 'charitable' ) . '</strong>', |
| 370 |
), |
| 371 |
), |
| 372 |
), |
| 373 |
'marketing' => array( |
| 374 |
'lite' => array( |
| 375 |
'status' => 'none', |
| 376 |
'text' => array( |
| 377 |
'<strong>' . esc_html__( 'Not Available', 'charitable' ) . '</strong>', |
| 378 |
), |
| 379 |
), |
| 380 |
'pro' => array( |
| 381 |
'status' => 'full', |
| 382 |
'text' => array( |
| 383 |
'<strong>' . esc_html__( 'Mailchimp, MailerLite, Campaign Monitor, and more', 'charitable' ) . '</strong>', |
| 384 |
), |
| 385 |
), |
| 386 |
), |
| 387 |
'reporting' => array( |
| 388 |
'lite' => array( |
| 389 |
'status' => 'partial', |
| 390 |
'text' => array( |
| 391 |
'<strong>' . esc_html__( 'Basic reports', 'charitable' ) . '</strong>', |
| 392 |
), |
| 393 |
), |
| 394 |
'pro' => array( |
| 395 |
'status' => 'full', |
| 396 |
'text' => array( |
| 397 |
'<strong>' . esc_html__( 'Advancing reports (including LYBUNT, SYBUNT, and detailed donor reports) & insights', 'charitable' ) . '</strong>', |
| 398 |
), |
| 399 |
), |
| 400 |
), |
| 401 |
'extensions' => array( |
| 402 |
'lite' => array( |
| 403 |
'status' => 'none', |
| 404 |
'text' => array( |
| 405 |
'<strong>' . esc_html__( 'None', 'charitable' ) . '</strong>', |
| 406 |
), |
| 407 |
), |
| 408 |
'pro' => array( |
| 409 |
'status' => 'full', |
| 410 |
'text' => array( |
| 411 |
'<strong>' . esc_html__( 'All Pro Extensions included', 'charitable' ) . '</strong>', |
| 412 |
), |
| 413 |
), |
| 414 |
), |
| 415 |
'support' => array( |
| 416 |
'lite' => array( |
| 417 |
'status' => 'partial', |
| 418 |
'text' => array( |
| 419 |
'<strong>' . esc_html__( 'Community Support Only', 'charitable' ) . '</strong>', |
| 420 |
), |
| 421 |
), |
| 422 |
'pro' => array( |
| 423 |
'status' => 'full', |
| 424 |
'text' => array( |
| 425 |
'<strong>' . esc_html__( 'Priority Email Support', 'charitable' ) . '</strong>', |
| 426 |
), |
| 427 |
), |
| 428 |
), |
| 429 |
); |
| 430 |
|
| 431 |
return $data; |
| 432 |
} |
| 433 |
} |
| 434 |
|
| 435 |
endif; |
| 436 |
|