| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: MarqueeX – Smooth Marquee Slider, News Ticker & Post Marquee for Block Editor & Elementor |
| 5 |
* Description: The complete Marquee plugin for WordPress — build marquee sliders, news tickers, post marquees & infinite sliders for Elementor & Gutenberg. Fast, lightweight & SEO-optimized. |
| 6 |
* Requires at least: 6.0 |
| 7 |
* Requires PHP: 7.4 |
| 8 |
* Version: 0.6.0 |
| 9 |
* Author: WPXERO |
| 10 |
* Author URI: https://wpxero.com |
| 11 |
* License: GPL-2.0-or-later |
| 12 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 13 |
* Text Domain: marqueex |
| 14 |
* Domain Path: /languages |
| 15 |
*/ |
| 16 |
|
| 17 |
namespace Wpxero\Marqueex; |
| 18 |
|
| 19 |
use Wpxero\Marqueex\Traits\Singleton; |
| 20 |
use Wpxero\Marqueex\Utils; |
| 21 |
use Wpxero\Marqueex\Admin\Menu; |
| 22 |
use Wpxero\Marqueex\Admin\Enqueue; |
| 23 |
use Wpxero\Marqueex\Admin; |
| 24 |
use Wpxero\Marqueex\Core\Settings; |
| 25 |
use Wpxero\Marqueex\Integrations; |
| 26 |
|
| 27 |
if (!defined('ABSPATH')) { |
| 28 |
exit; // Exit if accessed directly. |
| 29 |
} |
| 30 |
|
| 31 |
// Check if vendor directory and autoload.php exist |
| 32 |
$marqueex_autoload_file = __DIR__ . '/vendor/autoload.php'; |
| 33 |
if (file_exists($marqueex_autoload_file)) { |
| 34 |
// Load autoloader (vendor/autoload.php). |
| 35 |
require_once $marqueex_autoload_file; |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Main MarqueeX Class |
| 40 |
* |
| 41 |
* @class MarqueeX |
| 42 |
* @since 0.1.0 |
| 43 |
*/ |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
class MarqueeX { |
| 48 |
use Singleton; |
| 49 |
|
| 50 |
/** |
| 51 |
* Freemius instance |
| 52 |
* @var object |
| 53 |
*/ |
| 54 |
private $freemius; |
| 55 |
|
| 56 |
/** |
| 57 |
* Path to the plugin directory |
| 58 |
* |
| 59 |
* @var $plugin_path |
| 60 |
*/ |
| 61 |
public $plugin_path; |
| 62 |
|
| 63 |
/** |
| 64 |
* URL to the plugin directory |
| 65 |
* |
| 66 |
* @var $plugin_url |
| 67 |
*/ |
| 68 |
public $plugin_url; |
| 69 |
|
| 70 |
/** |
| 71 |
* Plugin name |
| 72 |
* |
| 73 |
* @var $plugin_name |
| 74 |
*/ |
| 75 |
public $plugin_name; |
| 76 |
|
| 77 |
/** |
| 78 |
* Plugin version |
| 79 |
* |
| 80 |
* @var $plugin_version |
| 81 |
*/ |
| 82 |
public $plugin_version; |
| 83 |
|
| 84 |
/** |
| 85 |
* Plugin slug |
| 86 |
* |
| 87 |
* @var $plugin_slug |
| 88 |
*/ |
| 89 |
public $plugin_slug; |
| 90 |
|
| 91 |
/** |
| 92 |
* Plugin name sanitized |
| 93 |
* |
| 94 |
* @var $plugin_name_sanitized |
| 95 |
*/ |
| 96 |
public $plugin_name_sanitized; |
| 97 |
|
| 98 |
/** |
| 99 |
* MarqueeX constructor. |
| 100 |
*/ |
| 101 |
public function __construct() { |
| 102 |
/* We do nothing here! */ |
| 103 |
} |
| 104 |
|
| 105 |
public function init_hooks() { |
| 106 |
$this->define_constants(); |
| 107 |
$this->load_files(); |
| 108 |
} |
| 109 |
/** |
| 110 |
* Define Constants |
| 111 |
*/ |
| 112 |
public static function define_constants() { |
| 113 |
define('MARQUEEX_FILE', __FILE__); |
| 114 |
define('MARQUEEX_NAMESPACE', 'MARQUEEX'); |
| 115 |
define('MARQUEEX_SLUG', 'marqueex'); |
| 116 |
define('MARQUEEX_VERSION', '0.6.0'); |
| 117 |
define('MARQUEEX_DIR_PATH', plugin_dir_path(__FILE__)); |
| 118 |
define('MARQUEEX_ADMIN_URL', plugin_dir_url(__FILE__)); |
| 119 |
define('MARQUEEX_WP_VERSION', (float) get_bloginfo('version')); |
| 120 |
define('MARQUEEX_PHP_VERSION', (float) phpversion()); |
| 121 |
} |
| 122 |
|
| 123 |
public function load_files() { |
| 124 |
Settings::get_instance(); |
| 125 |
Menu::get_instance(); |
| 126 |
Enqueue::get_instance(); |
| 127 |
Admin\ReviewRequest::get_instance(); |
| 128 |
Utils\SeoImprovements::get_instance(); |
| 129 |
Utils\MetaDescription::get_instance(); |
| 130 |
|
| 131 |
// Load integrations |
| 132 |
$this->load_integrations(); |
| 133 |
$this->init_freemius(); |
| 134 |
} |
| 135 |
|
| 136 |
/** |
| 137 |
* Load builder integrations |
| 138 |
*/ |
| 139 |
private function load_integrations() { |
| 140 |
// Load Elementor integration |
| 141 |
if (class_exists('\Elementor\Plugin')) { |
| 142 |
Integrations\Elementor\ElementorIntegration::get_instance(); |
| 143 |
} |
| 144 |
|
| 145 |
// Load Shortcode integration |
| 146 |
Integrations\Shortcode\ShortcodeIntegration::get_instance(); |
| 147 |
|
| 148 |
// Load Gutenberg integration |
| 149 |
Integrations\Gutenberg\GutenbergIntegration::get_instance(); |
| 150 |
} |
| 151 |
|
| 152 |
|
| 153 |
/** |
| 154 |
* Initialize Freemius SDK |
| 155 |
*/ |
| 156 |
private function init_freemius() { |
| 157 |
if (!isset($this->freemius)) { |
| 158 |
// Skip Freemius init during plugin upgrade/install to prevent memory exhaustion. |
| 159 |
// Read-only context check (which WP screen we are on) — not form |
| 160 |
// processing, so no nonce is involved. |
| 161 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 162 |
if ( |
| 163 |
(defined('WP_INSTALLING') && WP_INSTALLING) || |
| 164 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 165 |
(isset($_REQUEST['action']) && in_array(sanitize_key(wp_unslash($_REQUEST['action'])), array('upload-plugin', 'update-plugin', 'delete-plugin'), true)) |
| 166 |
) { |
| 167 |
return $this->freemius; |
| 168 |
} |
| 169 |
|
| 170 |
// Include Freemius SDK |
| 171 |
if (file_exists(dirname(__FILE__) . '/vendor/freemius/wordpress-sdk/start.php')) { |
| 172 |
require_once dirname(__FILE__) . '/vendor/freemius/wordpress-sdk/start.php'; |
| 173 |
|
| 174 |
try { |
| 175 |
$this->freemius = fs_dynamic_init(array( |
| 176 |
'id' => '21024', |
| 177 |
'slug' => 'marqueex', |
| 178 |
'premium_slug' => 'marqueex-pro', |
| 179 |
'type' => 'plugin', |
| 180 |
'public_key' => 'pk_b8a19bfe3fffa97b497382eddcc3b', |
| 181 |
'is_premium' => false, |
| 182 |
'is_premium_only' => false, |
| 183 |
'has_paid_plans' => true, |
| 184 |
'is_live' => true, |
| 185 |
'is_org_compliant' => true, |
| 186 |
'parallel_activation' => array( |
| 187 |
'enabled' => true, |
| 188 |
'premium_version_basename' => 'marqueex-pro/marqueex-pro.php', |
| 189 |
), |
| 190 |
'menu' => array( |
| 191 |
'slug' => 'marqueex', |
| 192 |
'first-path' => 'admin.php?page=marqueex', |
| 193 |
'network' => true, |
| 194 |
'support' => false, |
| 195 |
'contact' => false, |
| 196 |
'pricing' => true, |
| 197 |
), |
| 198 |
)); |
| 199 |
|
| 200 |
// Signal that Freemius SDK is initiated |
| 201 |
do_action('marqueex_fs_loaded'); |
| 202 |
} catch (\Exception $e) { |
| 203 |
// Log error but don't break the plugin |
| 204 |
if (defined('WP_DEBUG') && WP_DEBUG) { |
| 205 |
error_log('MarqueeX Freemius Error: ' . $e->getMessage()); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log |
| 206 |
} |
| 207 |
} |
| 208 |
} |
| 209 |
} |
| 210 |
|
| 211 |
return $this->freemius; |
| 212 |
} |
| 213 |
|
| 214 |
/** |
| 215 |
* Get Freemius instance |
| 216 |
* |
| 217 |
* @return object|null |
| 218 |
*/ |
| 219 |
public function get_freemius() { |
| 220 |
return $this->freemius; |
| 221 |
} |
| 222 |
|
| 223 |
/** |
| 224 |
* Check if the user has a valid premium license. |
| 225 |
* |
| 226 |
* This is the SINGLE SOURCE OF TRUTH for premium feature gating. |
| 227 |
* It verifies BOTH conditions: |
| 228 |
* 1. The pro plugin class is loaded (plugin is active) |
| 229 |
* 2. Freemius reports a valid license or trial |
| 230 |
* |
| 231 |
* @return bool True only if pro plugin is active AND license is valid. |
| 232 |
*/ |
| 233 |
public static function is_premium_active() { |
| 234 |
// Cache the result to avoid repeated Freemius calls within a single request |
| 235 |
static $result = null; |
| 236 |
if ($result !== null) { |
| 237 |
return $result; |
| 238 |
} |
| 239 |
|
| 240 |
// Condition 1: Pro plugin must be active |
| 241 |
if (!class_exists('\Wpxero\MarqueexPro\MarqueeXPro')) { |
| 242 |
$result = false; |
| 243 |
return $result; |
| 244 |
} |
| 245 |
|
| 246 |
// Condition 2: Freemius must confirm a valid license |
| 247 |
try { |
| 248 |
$fs = null; |
| 249 |
|
| 250 |
// Try getting Freemius from the pro plugin first |
| 251 |
if (function_exists('\Wpxero\MarqueexPro\marqueex_pro_fs')) { |
| 252 |
$fs = \Wpxero\MarqueexPro\marqueex_pro_fs(); |
| 253 |
} |
| 254 |
|
| 255 |
// Fallback to free plugin's Freemius instance |
| 256 |
if (!$fs) { |
| 257 |
$instance = self::get_instance(); |
| 258 |
$fs = $instance->get_freemius(); |
| 259 |
} |
| 260 |
|
| 261 |
if (!$fs) { |
| 262 |
$result = false; |
| 263 |
return $result; |
| 264 |
} |
| 265 |
|
| 266 |
// can_use_premium_code() covers both paid licenses and trials |
| 267 |
$result = $fs->can_use_premium_code(); |
| 268 |
} catch (\Exception $e) { |
| 269 |
if (defined('WP_DEBUG') && WP_DEBUG) { |
| 270 |
error_log('MarqueeX: Premium validation error - ' . $e->getMessage()); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log |
| 271 |
} |
| 272 |
$result = false; |
| 273 |
} |
| 274 |
|
| 275 |
return $result; |
| 276 |
} |
| 277 |
|
| 278 |
/** |
| 279 |
* Activation Hook |
| 280 |
*/ |
| 281 |
public function activation_hook() { |
| 282 |
// Welcome Page Flag. |
| 283 |
set_transient('_marqueex_welcome_screen_activation_redirect', true, 30); |
| 284 |
} |
| 285 |
|
| 286 |
/** |
| 287 |
* Deactivation Hook |
| 288 |
*/ |
| 289 |
public function deactivation_hook() { |
| 290 |
} |
| 291 |
} |
| 292 |
|
| 293 |
|
| 294 |
// Initialize the plugin |
| 295 |
add_action('plugins_loaded', function () { |
| 296 |
$instance = \Wpxero\Marqueex\MarqueeX::get_instance(); |
| 297 |
$instance->init_hooks(); |
| 298 |
}); |
| 299 |
|
| 300 |
/** |
| 301 |
* Get Freemius instance for free plugin |
| 302 |
* |
| 303 |
* @return object|null |
| 304 |
*/ |
| 305 |
function marqueex_fs() { |
| 306 |
$plugin = MarqueeX::get_instance(); |
| 307 |
return $plugin ? $plugin->get_freemius() : null; |
| 308 |
} |
| 309 |
|
| 310 |
register_activation_hook(__FILE__, [\Wpxero\Marqueex\MarqueeX::get_instance(), 'activation_hook']); |
| 311 |
register_deactivation_hook(__FILE__, [\Wpxero\Marqueex\MarqueeX::get_instance(), 'deactivation_hook']); |
| 312 |
|