PluginProbe
MarqueeAll – Elementor Marquee for Image, Text, Post Grid, Testimonial, Cryptocurrency, Faqs & News Ticker 🌀 / 1.1.9
MarqueeAll – Elementor Marquee for Image, Text, Post Grid, Testimonial, Cryptocurrency, Faqs & News Ticker 🌀 v1.1.9
1.2.3 1.2.2 trunk 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1
marqueeall / includes / plugin.php

plugin.php in MarqueeAll – Elementor Marquee for Image, Text, Post Grid, Testimonial, Cryptocurrency, Faqs & News Ticker 🌀 1.1.9, at includes/plugin.php

290 lines 8.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Main Plugin Class
4 *
5 * @package MarqueeAll
6 */
7
8 namespace MASSCIE;
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit; // Exit if accessed directly.
12 }
13
14 final class Plugin {
15
16 /**
17 * Instance
18 *
19 * @var Plugin|null
20 */
21 private static $instance = null;
22
23 /**
24 * Singleton instance.
25 *
26 * @return Plugin
27 */
28 public static function instance() {
29 if ( null === self::$instance ) {
30 self::$instance = new self();
31 }
32 return self::$instance;
33 }
34
35 /**
36 * Constructor.
37 */
38 private function __construct() {
39 add_action( 'plugins_loaded', [ $this, 'on_plugins_loaded' ] );
40 add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_assets' ] );
41 add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'enqueue_elementor_editor_assets' ] );
42
43 if ( is_admin() ) {
44 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_assets' ] );
45 add_action( 'admin_footer-plugins.php', [ $this, 'render_deactivation_modal' ] );
46 add_action( 'wp_ajax_masscie_deactivation_feedback', [ $this, 'handle_deactivation_feedback' ] );
47 }
48 }
49
50 /**
51 * Plugins loaded.
52 */
53 public function on_plugins_loaded() {
54 // Ensure Elementor is active.
55 if ( ! did_action( 'elementor/loaded' ) ) {
56 add_action(
57 'admin_notices',
58 function () {
59 printf(
60 '<div class="notice notice-error"><p>%s</p></div>',
61 esc_html__( 'MarqueeAll requires Elementor to be installed and activated.', 'marqueeall' )
62 );
63 }
64 );
65 return;
66 }
67
68 // Register Elementor category.
69 add_action(
70 'elementor/elements/categories_registered',
71 function ( $manager ) {
72 $manager->add_category(
73 'masscie-widgets',
74 [
75 'title' => __( 'MarqueeAll Widgets', 'marqueeall' ),
76 'icon' => 'fa fa-arrows-h',
77 ]
78 );
79 }
80 );
81
82 // Register widgets.
83 add_action( 'elementor/widgets/register', [ $this, 'register_widgets' ] );
84 }
85
86 /**
87 * Enqueue assets.
88 */
89 public function enqueue_assets() {
90 wp_register_style(
91 'masscie-style',
92 MASSCIE_URL . 'assets/css/masscie.css',
93 [],
94 MASSCIE_VERSION
95 );
96
97 wp_register_style(
98 'masscie-crypto-style',
99 MASSCIE_URL . 'assets/css/masscie-crypto.css',
100 [],
101 MASSCIE_VERSION
102 );
103
104 wp_register_script(
105 'masscie-marquee',
106 MASSCIE_URL . 'assets/js/masscie-marquee.js',
107 [ 'jquery' ],
108 MASSCIE_VERSION,
109 true
110 );
111 }
112
113 /**
114 * Register widgets.
115 *
116 * @param \Elementor\Widgets_Manager $widgets_manager Elementor widgets manager.
117 */
118 public function register_widgets( $widgets_manager ) {
119 // Include widget files
120 require_once MASSCIE_PATH . 'includes/widgets/class-text-marquee.php';
121 require_once MASSCIE_PATH . 'includes/widgets/class-image-marquee.php';
122 require_once MASSCIE_PATH . 'includes/widgets/class-testimonial-marquee.php';
123 require_once MASSCIE_PATH . 'includes/widgets/class-news-ticker.php';
124 require_once MASSCIE_PATH . 'includes/widgets/class-post-grid-marquee.php';
125 require_once MASSCIE_PATH . 'includes/widgets/class-team-members-marquee.php';
126 require_once MASSCIE_PATH . 'includes/widgets/class-text-scramble.php';
127 require_once MASSCIE_PATH . 'includes/widgets/class-crypto-marquee.php';
128
129 // Register them with Elementor
130 $widgets_manager->register( new \MASSCIE\Widgets\Text_Marquee() );
131 $widgets_manager->register( new \MASSCIE\Widgets\Image_Marquee() );
132 $widgets_manager->register( new \MASSCIE\Widgets\Testimonial_Marquee() );
133 $widgets_manager->register( new \MASSCIE\Widgets\News_Ticker() );
134 $widgets_manager->register( new \MASSCIE\Widgets\Post_Grid_Marquee() );
135 $widgets_manager->register( new \MASSCIE\Widgets\Team_Members_Marquee() );
136 $widgets_manager->register( new \MASSCIE\Widgets\Text_Scramble() );
137 $widgets_manager->register( new \MASSCIE\Widgets\Crypto_Marquee() );
138 }
139
140 public function enqueue_admin_assets( $hook_suffix ) {
141 if ( 'plugins.php' !== $hook_suffix ) {
142 return;
143 }
144
145 wp_enqueue_style(
146 'masscie-admin-feedback',
147 MASSCIE_URL . 'assets/css/masscie-admin-feedback.css',
148 [],
149 MASSCIE_VERSION
150 );
151
152 wp_enqueue_script(
153 'masscie-admin-feedback',
154 MASSCIE_URL . 'assets/js/masscie-admin-feedback.js',
155 [ 'jquery' ],
156 MASSCIE_VERSION,
157 true
158 );
159
160 wp_localize_script(
161 'masscie-admin-feedback',
162 'MASSCIE_FEEDBACK',
163 [
164 'ajax_url' => admin_url( 'admin-ajax.php' ),
165 'nonce' => wp_create_nonce( 'masscie_deactivation_feedback' ),
166 'plugin_slug' => 'marqueeall', // folder name
167 'deactivateText'=> __( 'Deactivate', 'marqueeall' ),
168 ]
169 );
170 }
171 /**
172 * Enqueue Elementor editor assets.
173 */
174 public function enqueue_elementor_editor_assets() {
175 // Enqueue editor styles
176 wp_enqueue_style(
177 'marqueeall-elementor-editor',
178 MASSCIE_URL . 'assets/css/elementor-editor.css',
179 [],
180 MASSCIE_VERSION
181 );
182
183 // Enqueue crypto editor script
184 wp_enqueue_script(
185 'masscie-crypto-editor',
186 MASSCIE_URL . '/assets/js/crypto-editor.js',
187 [ 'jquery', 'select2' ],
188 MASSCIE_VERSION,
189 true
190 );
191
192 // Localize script with necessary data
193 wp_localize_script(
194 'masscie-crypto-editor',
195 'masscieCryptoEditor',
196 [
197 'ajax_url' => admin_url( 'admin-ajax.php' ),
198 'nonce' => wp_create_nonce( 'masscie_crypto_nonce' ),
199 'i18n' => [
200 'fetching' => __( 'Fetching...', 'marqueeall' ),
201 'error' => __( 'Error fetching data. Please try again.', 'marqueeall' ),
202 'no_cryptos' => __( 'No cryptocurrencies found.', 'marqueeall' ),
203 ],
204 ]
205 );
206
207 // Enqueue Select2 if not already loaded by Elementor
208 if ( ! wp_script_is( 'select2', 'enqueued' ) ) {
209 wp_enqueue_script( 'select2' );
210 wp_enqueue_style( 'select2' );
211 }
212 }
213
214 public function render_deactivation_modal() {
215 ?>
216 <div id="masscie-feedback-modal" style="display:none;">
217 <div class="masscie-feedback-backdrop"></div>
218 <div class="masscie-feedback-dialog">
219 <h2><?php esc_html_e( 'Quick Feedback', 'marqueeall' ); ?></h2>
220 <p><?php esc_html_e( 'If you have a moment, please let us know why you are deactivating:', 'marqueeall' ); ?></p>
221
222 <form id="masscie-feedback-form">
223 <label><input type="radio" name="reason" value="not_what_i_was_looking_for"> <?php esc_html_e( "It's not what I was looking for", 'marqueeall' ); ?></label>
224 <label><input type="radio" name="reason" value="not_working"> <?php esc_html_e( 'The plugin is not working', 'marqueeall' ); ?></label>
225 <label><input type="radio" name="reason" value="found_better"> <?php esc_html_e( 'I found a better plugin', 'marqueeall' ); ?></label>
226 <label><input type="radio" name="reason" value="didnt_work_as_expected"> <?php esc_html_e( "The plugin didn't work as expected", 'marqueeall' ); ?></label>
227 <label><input type="radio" name="reason" value="couldnt_understand"> <?php esc_html_e( "I couldn't understand how to make it work", 'marqueeall' ); ?></label>
228 <label><input type="radio" name="reason" value="missing_feature"> <?php esc_html_e( "The plugin is great, but I need specific feature that you don't support", 'marqueeall' ); ?></label>
229 <label><input type="radio" name="reason" value="temporary"> <?php esc_html_e( "It's a temporary deactivation - I'm troubleshooting an issue", 'marqueeall' ); ?></label>
230 <label>
231 <input type="radio" name="reason" value="other">
232 <?php esc_html_e( 'Other', 'marqueeall' ); ?>
233 </label>
234 <textarea name="details" placeholder="<?php esc_attr_e( 'Please share more details (optional)', 'marqueeall' ); ?>"></textarea>
235
236 <div class="masscie-feedback-buttons">
237 <button type="button" class="button button-secondary" id="masscie-feedback-skip">
238 <?php esc_html_e( 'Skip & Deactivate', 'marqueeall' ); ?>
239 </button>
240 <button type="submit" class="button button-primary" id="masscie-feedback-submit">
241 <?php esc_html_e( 'Submit & Deactivate', 'marqueeall' ); ?>
242 </button>
243 <button type="button" class="button" id="masscie-feedback-cancel">
244 <?php esc_html_e( 'Cancel', 'marqueeall' ); ?>
245 </button>
246 </div>
247
248 <input type="hidden" name="deactivate_url" id="masscie-deactivate-url" value="">
249 </form>
250 </div>
251 </div>
252 <?php
253 }
254
255 public function handle_deactivation_feedback() {
256 check_ajax_referer( 'masscie_deactivation_feedback', 'nonce' );
257
258 if ( ! current_user_can( 'activate_plugins' ) ) {
259 wp_send_json_error( [ 'message' => __( 'Permission denied', 'marqueeall' ) ] );
260 }
261
262 $reason = isset( $_POST['reason'] ) ? sanitize_text_field( wp_unslash( $_POST['reason'] ) ) : '';
263 $details = isset( $_POST['details'] ) ? wp_kses_post( wp_unslash( $_POST['details'] ) ) : '';
264 $deactivate_url= isset( $_POST['deactivate_url'] ) ? esc_url_raw( wp_unslash( $_POST['deactivate_url'] ) ) : '';
265
266 $site_url = home_url();
267
268 $subject = sprintf( 'MarqueeAll Deactivation Feedback from %s', $site_url );
269
270 $body = "Plugin: MarqueeAll\n";
271 $body .= "Site: $site_url\n";
272 $body .= "Reason: $reason\n\n";
273 $body .= "Details:\n$details\n";
274
275 wp_mail(
276 'amandeepsingh@webspero.com',
277 $subject,
278 $body
279 );
280
281 wp_send_json_success(
282 [
283 'deactivate_url' => $deactivate_url,
284 ]
285 );
286 }
287 }
288
289 Plugin::instance();
290