PluginProbe
Ultimate Cursor – Interactive and Animated Custom Cursor and Background Effects Toolkit / 2.3.2
Ultimate Cursor – Interactive and Animated Custom Cursor and Background Effects Toolkit v2.3.2
2.4.1 2.4.0 2.3.3 2.3.2 2.3.1 2.3.0 2.2.3 2.2.2 2.2.1 trunk 1.0.0 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 All 56 releases
ultimate-cursor / ultimate-cursor.php

ultimate-cursor.php in Ultimate Cursor – Interactive and Animated Custom Cursor and Background Effects Toolkit 2.3.2, at ultimate-cursor.php

300 lines 8.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: Ultimate Cursor – Interactive and Animated Cursor and Background Effects Toolkit
5 * Plugin URI: https://wordpress.org/plugins/ultimate-cursor
6 * Description: Make Your Website Stand Out with Unique Cursor Effects and Smooth Animations!🚀
7 * Version: 2.3.2
8 * Author: WPXERO
9 * Author URI: https://wpxero.com/plugins/ultimate-cursor
10 * Requires at least: 6.0
11 * Requires PHP: 7.4
12 * License: GPL3
13 * License URI: http://www.gnu.org/licenses/gpl-3.0.html
14 * Text Domain: ultimate-cursor
15 * Domain Path: /languages
16 */
17
18
19 if ( ! defined( 'ABSPATH' ) ) {
20 exit;
21 }
22
23 if ( ! defined( 'UCA_VERSION' ) ) {
24 define( 'UCA_VERSION', '2.3.2' );
25 }
26
27
28
29 /**
30 * UltimateCursor Class
31 */
32 class UltimateCursor {
33 /**
34 * Freemius instance
35 *
36 * @var object
37 */
38 private $freemius;
39 /**
40 * The single class instance.
41 *
42 * @var $instance
43 */
44 private static $instance = null;
45 const VERSION = UCA_VERSION;
46 const MINIMUM_ELEMENTOR_VERSION = '3.0.0';
47 const MINIMUM_PHP_VERSION = '7.0';
48 /**
49 * Main Instance
50 * Ensures only one instance of this class exists in memory at any one time.
51 */
52 public static function instance() {
53 if ( is_null( self::$instance ) ) {
54 self::$instance = new self();
55 self::$instance->init();
56 }
57 return self::$instance;
58 }
59
60 /**
61 * Path to the plugin directory
62 *
63 * @var $plugin_path
64 */
65 public $plugin_path;
66
67 /**
68 * URL to the plugin directory
69 *
70 * @var $plugin_url
71 */
72 public $plugin_url;
73 public $minimum_elementor_version;
74 public $minimum_php_version;
75
76 /**
77 * Ultimate Cursor constructor.
78 */
79 public function __construct() {
80 /* We do nothing here! */
81 }
82
83 /**
84 * Init options
85 */
86 public function init() {
87 $this->plugin_path = plugin_dir_path( __FILE__ );
88 $this->plugin_url = plugin_dir_url( __FILE__ );
89 $this->minimum_elementor_version = self::MINIMUM_ELEMENTOR_VERSION;
90 $this->minimum_php_version = self::MINIMUM_PHP_VERSION;
91
92 // include helper files.
93 $this->include_dependencies();
94 $this->init_freemius();
95 }
96
97 /**
98 * Initialize Freemius SDK
99 */
100 private function init_freemius() {
101 if ( ! isset( $this->freemius ) ) {
102 // Skip Freemius init during plugin upgrade/install to prevent memory exhaustion.
103 if (
104 ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) ||
105 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only check of the core upgrader action to skip Freemius init, no data is processed.
106 ( isset( $_REQUEST['action'] ) && in_array( sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ), array( 'upload-plugin', 'update-plugin', 'delete-plugin' ), true ) )
107 ) {
108 return $this->freemius;
109 }
110
111 // Include Freemius SDK
112 if ( file_exists( __DIR__ . '/vendor/freemius/wordpress-sdk/start.php' ) ) {
113 require_once __DIR__ . '/vendor/freemius/wordpress-sdk/start.php';
114
115 try {
116 $this->freemius = fs_dynamic_init(
117 array(
118 'id' => '19720',
119 'slug' => 'ultimate-cursor',
120 'premium_slug' => 'ultimate-cursor-pro',
121 'type' => 'plugin',
122 'public_key' => 'pk_fb94765a4f619e83979c2825626c2',
123 'is_premium' => false,
124 'is_premium_only' => false,
125 'has_paid_plans' => true,
126 'is_live' => true,
127 'is_org_compliant' => true,
128 'parallel_activation' => array(
129 'enabled' => true,
130 'premium_version_basename' => 'ultimate-cursor-pro/ultimate-cursor-pro.php',
131 ),
132 'menu' => array(
133 'slug' => 'ultimate-cursor',
134 'first-path' => 'admin.php?page=ultimate-cursor',
135 'support' => false,
136 'contact' => false,
137 'pricing' => true,
138 ),
139 )
140 );
141
142 // Signal that Freemius SDK is initiated
143 do_action( 'ultimate_cursor_fs_loaded' );
144 } catch ( Exception $e ) {
145 // Log error but don't break the plugin
146 if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
147 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- Error logging gated behind WP_DEBUG for diagnostics only.
148 error_log( 'Ultimate Cursor Freemius Error: ' . $e->getMessage() );
149 }
150 }
151 }
152 }
153
154 return $this->freemius;
155 }
156
157
158 /**
159 * Get Freemius instance
160 *
161 * @return object|null
162 */
163 public function get_freemius() {
164 return $this->freemius;
165 }
166
167
168
169 /**
170 * Check if the user has a valid premium license.
171 *
172 * Delegates to Ultimate_Cursor_License_Gate — the single source of truth
173 * for premium feature gating. Kept for backward compatibility.
174 *
175 * @return bool True only if pro plugin is active AND license is valid.
176 */
177 public static function is_premium_active() {
178 return Ultimate_Cursor_License_Gate::is_premium_active();
179 }
180
181 /**
182 * List of cursor setting keys that are premium-only.
183 *
184 * Kept for backward compatibility; the registry lives in Ultimate_Cursor_License_Gate.
185 *
186 * @return array
187 */
188 public static function get_premium_setting_keys() {
189 return Ultimate_Cursor_License_Gate::get_premium_keys( 'cursor' );
190 }
191
192 /**
193 * List of cursor setting values that are premium-only.
194 *
195 * Kept for backward compatibility; the registry lives in Ultimate_Cursor_License_Gate.
196 *
197 * @return array
198 */
199 public static function get_premium_setting_values() {
200 $values = array();
201 foreach ( Ultimate_Cursor_License_Gate::get_premium_values( 'cursor' ) as $field => $rule ) {
202 $values[ $field ] = $rule['blocked'];
203 }
204 return $values;
205 }
206
207 /**
208 * Sanitize cursor settings by stripping premium-only fields if no valid license.
209 *
210 * Delegates to Ultimate_Cursor_License_Gate. Kept for backward compatibility.
211 *
212 * @param array $settings The settings array to sanitize.
213 * @return array Sanitized settings.
214 */
215 public static function sanitize_premium_settings( $settings ) {
216 return Ultimate_Cursor_License_Gate::sanitize( $settings, 'cursor' );
217 }
218
219 /**
220 * Include dependencies
221 */
222 private function include_dependencies() {
223 // License gate must load first — admin/assets/rest all depend on it.
224 require_once $this->plugin_path . 'classes/class-license-gate.php';
225 // Settings schema (REST write allowlist) depends on the license gate.
226 require_once $this->plugin_path . 'classes/class-settings-schema.php';
227 require_once $this->plugin_path . 'classes/class-admin.php';
228 require_once $this->plugin_path . 'classes/class-assets.php';
229 require_once $this->plugin_path . 'classes/class-rest.php';
230
231 // CRITICAL: Handles CDN CORS headers and prevents "Delay JS" from breaking the cursor
232 // Do not remove this unless you want to break compatibility with WP Rocket, LiteSpeed, etc.
233 require_once $this->plugin_path . 'classes/class-cache-compatibility.php';
234 if ( did_action( 'elementor/loaded' ) ) {
235 require_once $this->plugin_path . 'classes/class-elementor.php';
236 }
237
238 if ( ! class_exists( 'Ultimate_Cursor_Pro' ) ) {
239 require_once $this->plugin_path . 'classes/class-dashboard-widget.php';
240 }
241 }
242
243 /**
244 * Activation Hook
245 */
246 public function activation_hook() {
247 // Welcome Page Flag.
248 set_transient( '_ultimate_cursor_welcome_screen_activation_redirect', true, 30 );
249 }
250
251 /**
252 * Deactivation Hook
253 * Note: We only clean up temporary data here.
254 * Settings are preserved so users don't lose configuration when deactivating/reactivating.
255 */
256 public function deactivation_hook() {
257 delete_transient( '_ultimate_cursor_welcome_screen_activation_redirect' );
258 // Settings are intentionally NOT deleted here - they persist through deactivation
259 // Settings will only be deleted if user uninstalls (deletes) the plugin via uninstall.php
260 }
261 }
262
263 /**
264 * Function works with the Loader class instance
265 *
266 * @return object UltimateCursor
267 */
268 function ultimate_cursor() {
269 return UltimateCursor::instance();
270 }
271
272 add_action( 'plugins_loaded', 'ultimate_cursor' );
273
274 /**
275 * Get Freemius instance for free plugin
276 *
277 * @return object|null
278 */
279 function ultimate_cursor_fs() {
280 $plugin = ultimate_cursor();
281 return $plugin ? $plugin->get_freemius() : null;
282 }
283
284 /**
285 * Activation hook callback
286 */
287 function ultimate_cursor_activation_hook() {
288 ultimate_cursor()->activation_hook();
289 }
290
291 /**
292 * Deactivation hook callback
293 */
294 function ultimate_cursor_deactivation_hook() {
295 ultimate_cursor()->deactivation_hook();
296 }
297
298 register_activation_hook( __FILE__, 'ultimate_cursor_activation_hook' );
299 register_deactivation_hook( __FILE__, 'ultimate_cursor_deactivation_hook' );
300