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.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 / elementor / class-charitable-elementor.php

class-charitable-elementor.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at includes/elementor/class-charitable-elementor.php

172 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Charitable Elementor Integration
4 *
5 * @package Charitable
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.6
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Charitable Elementor Integration
19 *
20 * @since 1.8.6
21 */
22 class Charitable_Elementor {
23
24 /**
25 * Single instance of this class.
26 *
27 * @since 1.8.6
28 *
29 * @var Charitable_Elementor
30 */
31 private static $instance = null;
32
33 /**
34 * Create class instance.
35 *
36 * @since 1.8.6
37 */
38 private function __construct() {
39
40 // if the CHARITABLE_DISABLE_ELEMENTOR_INTEGRATION constant is defined, don't load the elementor integration
41 if ( defined( 'CHARITABLE_DISABLE_ELEMENTOR_INTEGRATION' ) && CHARITABLE_DISABLE_ELEMENTOR_INTEGRATION ) {
42 return;
43 }
44
45 $this->load_dependencies();
46 $this->setup_hooks();
47 }
48
49 /**
50 * Initialize the class.
51 *
52 * @since 1.8.6
53 */
54 public static function init() {
55 if ( ! did_action( 'elementor/loaded' ) ) {
56 return;
57 }
58
59 self::get_instance();
60 }
61
62 /**
63 * Include necessary files.
64 *
65 * @since 1.8.6
66 *
67 * @return void
68 */
69 private function load_dependencies() {
70 require_once charitable()->get_path( 'includes' ) . 'elementor/widgets/class-charitable-elementor-campaign-widget.php';
71 require_once charitable()->get_path( 'includes' ) . 'elementor/widgets/class-charitable-elementor-button-widget.php';
72 require_once charitable()->get_path( 'includes' ) . 'elementor/widgets/class-charitable-elementor-donation-form-widget.php';
73 require_once charitable()->get_path( 'includes' ) . 'elementor/widgets/class-charitable-elementor-campaigns-widget.php';
74 }
75
76 /**
77 * Set up hook and filter callback functions.
78 *
79 * @since 1.8.6
80 *
81 * @return void
82 */
83 private function setup_hooks() {
84 add_action( 'elementor/widgets/register', array( $this, 'register_widgets' ) );
85 add_action( 'elementor/elements/categories_registered', array( $this, 'add_elementor_charitable_category' ) );
86 add_action( 'elementor/frontend/after_register_scripts', array( $this, 'register_scripts' ) );
87 add_action( 'elementor/frontend/after_register_styles', array( $this, 'register_styles' ) );
88 }
89
90 /**
91 * Register Charitable widgets.
92 *
93 * @param \Elementor\Widgets_Manager $widgets_manager Elementor widgets manager.
94 * @since 1.8.6
95 */
96 public function register_widgets( $widgets_manager ) {
97 $widgets_manager->register( new \Charitable_Elementor_Campaign_Widget() );
98 $widgets_manager->register( new \Charitable_Elementor_Button_Widget() );
99 $widgets_manager->register( new \Charitable_Elementor_Donation_Form_Widget() );
100 $widgets_manager->register( new \Charitable_Elementor_Campaigns_Widget() );
101 }
102
103 /**
104 * Add Charitable category to Elementor.
105 *
106 * @param \Elementor\Elements_Manager $elements_manager Elementor elements manager.
107 * @since 1.8.6
108 */
109 public function add_elementor_charitable_category( $elements_manager ) {
110 $elements_manager->add_category(
111 'wpcharitable',
112 [
113 'title' => esc_html__( 'Charitable', 'charitable' ),
114 'icon' => 'fa fa-plug',
115 ]
116 );
117 }
118
119 /**
120 * Register scripts.
121 *
122 * @since 1.8.6
123 */
124 public function register_scripts() {
125 wp_enqueue_script(
126 'charitable-elementor-preview',
127 charitable()->get_path( 'assets', false ) . 'js/elementor/charitable-elementor-preview.js',
128 array( 'jquery' ),
129 charitable()->get_version(),
130 true
131 );
132
133 wp_localize_script(
134 'charitable-elementor-preview',
135 'charitableElementor',
136 array(
137 'ajaxurl' => admin_url( 'admin-ajax.php' ),
138 'nonce' => wp_create_nonce( 'charitable_elementor_preview' ),
139 'debug' => true,
140 )
141 );
142 }
143
144 /**
145 * Register styles.
146 *
147 * @since 1.8.6
148 */
149 public function register_styles() {
150 wp_enqueue_style(
151 'charitable-elementor-editor',
152 charitable()->get_path( 'assets', false ) . 'css/elementor/charitable-elementor-editor.css',
153 array(),
154 charitable()->get_version()
155 );
156 }
157
158 /**
159 * Returns the original instance of this class.
160 *
161 * @since 1.8.6
162 *
163 * @return Charitable_Elementor
164 */
165 public static function get_instance() {
166 if ( is_null( self::$instance ) ) {
167 self::$instance = new self();
168 }
169 return self::$instance;
170 }
171
172 }