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.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 1.7.0.9 All 211 releases
charitable / includes / admin / class-charitable-user-onboarding.php

class-charitable-user-onboarding.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.11.3, at includes/admin/class-charitable-user-onboarding.php

120 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Main class for setting up the server side onboarding.
4 *
5 * @package Charitable/Classes/Charitable_User_Onboarding
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.0.0
10 * @version 1.8.4
11 */
12
13 /* Exit if accessed directly */
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 if ( ! class_exists( 'Charitable_User_Onboarding' ) ) :
19
20 /**
21 * Charitable_User_Onboarding
22 *
23 * @since 1.0.0
24 */
25 class Charitable_User_Onboarding {
26
27 /**
28 * The single instance of this class.
29 *
30 * @var Charitable_User_Onboarding|null
31 */
32 private static $instance = null;
33
34 /**
35 * Stores whether the current request is in the user onboarding.
36 *
37 * @since 1.6.42
38 *
39 * @var boolean
40 */
41 private $on_user_onboarding_page;
42
43 /**
44 * Returns and/or create the single instance of this class.
45 *
46 * @since 1.2.0
47 *
48 * @return Charitable_User_Onboarding
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 * Create class instance.
60 *
61 * @since 1.0.0
62 */
63 private function __construct() {
64 add_filter( 'body_class', array( $this, 'add_body_class' ) );
65 add_action( 'template_include', array( $this, 'load_user_onboarding_template' ) );
66
67 do_action( 'charitable_user_onboarding_start', $this );
68 }
69
70 /**
71 * Loads the user onboarding template.
72 *
73 * @since 1.0.0
74 *
75 * @param string $template The template to use for the user onboarding.
76 * @return string
77 */
78 public function load_user_onboarding_template( $template ) {
79 /**
80 * The user onboarding template is not loaded by default; this has to be enabled.
81 */
82 if ( false === apply_filters( 'charitable_force_user_onboarding_template', false ) ) {
83 return $template;
84 }
85
86 /**
87 * The current object isn't in the nav, so return the template.
88 */
89 if ( ! get_query_var( 'page' ) || 'wpchar_lite' !== get_query_var( 'page' ) ) {
90 return $template;
91 }
92
93 do_action( 'charitable_is_user_onboarding' );
94
95 $new_template = apply_filters( 'charitable_user_onboarding_template', 'user-onboarding.php' );
96 $template = charitable_get_template_path( $new_template, $template );
97
98 return $template;
99 }
100
101 /**
102 * Add the user-onboarding class to the body if we're looking at it.
103 *
104 * @since 1.0.0
105 *
106 * @param array $classes Body classes.
107 * @return array
108 */
109 public function add_body_class( $classes ) {
110 // check the query var first.
111 if ( isset( $_GET['wpchar_lite'] ) && 'welcome' === $_GET['wpchar_lite'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
112 $classes .= ' wpchar-user-onboarding';
113 }
114
115 return $classes;
116 }
117 }
118
119 endif;
120