| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: SmartVideo |
| 4 |
* Description: SmartVideo makes building a beautiful, professional video experience for your site effortless. |
| 5 |
* Version: 2.3.3 |
| 6 |
* Requires at least: 6.6 |
| 7 |
* Requires PHP: 7.3 |
| 8 |
* Author: Swarmify |
| 9 |
* Author URI: https://swarmify.com/?smartvideo_wordpress_plugin |
| 10 |
* Developer: James Christensen |
| 11 |
* Developer URI: https://profiles.wordpress.org/chris10sen/ |
| 12 |
* Text Domain: swarmify |
| 13 |
* Domain Path: /languages |
| 14 |
* |
| 15 |
* License: AGPL-3.0-or-later |
| 16 |
* License URI: https://www.gnu.org/licenses/agpl-3.0.html |
| 17 |
* |
| 18 |
* @package SmartVideo |
| 19 |
*/ |
| 20 |
|
| 21 |
defined( 'ABSPATH' ) || exit; |
| 22 |
|
| 23 |
if ( ! defined( 'SMARTVIDEO_PLUGIN_FILE' ) ) { |
| 24 |
define( 'SMARTVIDEO_PLUGIN_FILE', __FILE__ ); |
| 25 |
} |
| 26 |
|
| 27 |
if ( ! defined( 'SWARMIFY_PLUGIN_VERSION' ) ) { |
| 28 |
define( 'SWARMIFY_PLUGIN_VERSION', '2.3.3' ); |
| 29 |
} |
| 30 |
|
| 31 |
require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; |
| 32 |
|
| 33 |
use Swarmify\Smartvideo; |
| 34 |
|
| 35 |
|
| 36 |
// phpcs:disable WordPress.Files.FileName |
| 37 |
|
| 38 |
|
| 39 |
if ( ! function_exists( 'activate_smartvideo' ) ) { |
| 40 |
/** |
| 41 |
* Activates SmartVideo. |
| 42 |
*/ |
| 43 |
function activate_smartvideo() { |
| 44 |
Smartvideo\Activator::activate(); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
register_activation_hook( __FILE__, 'activate_smartvideo' ); |
| 49 |
|
| 50 |
if ( ! function_exists( 'deactivate_smartvideo' ) ) { |
| 51 |
/** |
| 52 |
* Deactivates SmartVideo. |
| 53 |
*/ |
| 54 |
function deactivate_smartvideo() { |
| 55 |
delete_transient( 'smartvideo_activation_redirect_' . get_current_user_id() ); |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
register_deactivation_hook( __FILE__, 'deactivate_smartvideo' ); |
| 60 |
|
| 61 |
|
| 62 |
if ( ! class_exists( 'SmartVideo_Bootstrap' ) ) { |
| 63 |
/** |
| 64 |
* The SmartVideo_Bootstrap class. |
| 65 |
*/ |
| 66 |
class SmartVideo_Bootstrap { |
| 67 |
/** |
| 68 |
* This class instance. |
| 69 |
* |
| 70 |
* @var \SmartVideo_Bootstrap single instance of this class. |
| 71 |
*/ |
| 72 |
private static $instance; |
| 73 |
|
| 74 |
/** |
| 75 |
* Constructor. |
| 76 |
*/ |
| 77 |
public function __construct() { |
| 78 |
new Smartvideo\Swarmify( 'SmartVideo' ); |
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* Cloning is forbidden. |
| 83 |
*/ |
| 84 |
public function __clone() { |
| 85 |
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cloning is forbidden.', 'swarmify' ), esc_html( SWARMIFY_PLUGIN_VERSION ) ); |
| 86 |
} |
| 87 |
|
| 88 |
/** |
| 89 |
* Unserializing instances of this class is forbidden. |
| 90 |
*/ |
| 91 |
public function __wakeup() { |
| 92 |
_doing_it_wrong( __FUNCTION__, esc_html__( 'Unserializing instances of this class is forbidden.', 'swarmify' ), esc_html( SWARMIFY_PLUGIN_VERSION ) ); |
| 93 |
} |
| 94 |
|
| 95 |
/** |
| 96 |
* Gets the main instance. |
| 97 |
* |
| 98 |
* Ensures only one instance can be loaded. |
| 99 |
* |
| 100 |
* @return \SmartVideo_Bootstrap |
| 101 |
*/ |
| 102 |
public static function instance() { |
| 103 |
|
| 104 |
if ( null === self::$instance ) { |
| 105 |
self::$instance = new self(); |
| 106 |
} |
| 107 |
|
| 108 |
return self::$instance; |
| 109 |
} |
| 110 |
} |
| 111 |
} |
| 112 |
|
| 113 |
|
| 114 |
/** |
| 115 |
* Load page builder integrations. |
| 116 |
* |
| 117 |
* Each integration is lazy-loaded only when its host plugin is active, |
| 118 |
* so we don't parse files or register assets on every request for builders |
| 119 |
* the site doesn't use. |
| 120 |
*/ |
| 121 |
|
| 122 |
// Elementor — only load when Elementor has fired its init hook. |
| 123 |
if ( ! function_exists( 'smartvideo_load_elementor' ) ) { |
| 124 |
/** |
| 125 |
* Loads the Elementor SmartVideo widget when Elementor is active. |
| 126 |
*/ |
| 127 |
function smartvideo_load_elementor() { |
| 128 |
if ( did_action( 'elementor/loaded' ) ) { |
| 129 |
require_once plugin_dir_path( __FILE__ ) . 'includes/page-builders/elementor/class-elementor-swarmify.php'; |
| 130 |
} |
| 131 |
} |
| 132 |
add_action( 'init', 'smartvideo_load_elementor' ); |
| 133 |
} |
| 134 |
|
| 135 |
// Gutenberg — core since WP 5.0, but only load block assets when block editor is available. |
| 136 |
if ( ! function_exists( 'smartvideo_load_gutenberg' ) ) { |
| 137 |
/** |
| 138 |
* Loads Gutenberg integration assets when Gutenberg is active. |
| 139 |
*/ |
| 140 |
function smartvideo_load_gutenberg() { |
| 141 |
if ( function_exists( 'register_block_type' ) ) { |
| 142 |
require_once plugin_dir_path( __FILE__ ) . 'includes/page-builders/gutenberg/src/init.php'; |
| 143 |
} |
| 144 |
} |
| 145 |
add_action( 'init', 'smartvideo_load_gutenberg', 5 ); |
| 146 |
} |
| 147 |
|
| 148 |
// Beaver Builder — only load when FL Builder is active. |
| 149 |
if ( ! function_exists( 'smartvideo_load_beaver_builder' ) ) { |
| 150 |
/** |
| 151 |
* Loads the Beaver Builder SmartVideo module when Beaver Builder is active. |
| 152 |
*/ |
| 153 |
function smartvideo_load_beaver_builder() { |
| 154 |
if ( class_exists( 'FLBuilder' ) ) { |
| 155 |
require plugin_dir_path( __FILE__ ) . 'includes/page-builders/beaverbuilder/class-beaverbuilder-smartvideo.php'; |
| 156 |
} |
| 157 |
} |
| 158 |
add_action( 'init', 'smartvideo_load_beaver_builder' ); |
| 159 |
} |
| 160 |
|
| 161 |
// Divi 5 — register module via the D5 dependency tree (fires before divi_extensions_init). |
| 162 |
// The D4-era divi_extensions_init hook fires too late for D5's module registry, |
| 163 |
// so we hook directly into the dependency tree action and load our files there. |
| 164 |
if ( ! function_exists( 'smartvideo_load_divi5_builder' ) ) { |
| 165 |
/** |
| 166 |
* Loads the Divi 5 SmartVideo module. |
| 167 |
* |
| 168 |
* @param object $dependency_tree The dependency tree. |
| 169 |
*/ |
| 170 |
function smartvideo_load_divi5_builder( $dependency_tree ) { |
| 171 |
if ( ! function_exists( 'et_builder_d5_enabled' ) || ! et_builder_d5_enabled() ) { |
| 172 |
return; |
| 173 |
} |
| 174 |
require_once plugin_dir_path( __FILE__ ) . 'includes/page-builders/divi5-builder/divi5-smartvideo.php'; |
| 175 |
$dependency_tree->add_dependency( |
| 176 |
new \Swarmify\Divi5\Modules\SmartVideo\SmartVideo() |
| 177 |
); |
| 178 |
} |
| 179 |
add_action( 'divi_module_library_modules_dependency_tree', 'smartvideo_load_divi5_builder', 10 ); |
| 180 |
|
| 181 |
// Also load on divi_extensions_init for VB asset enqueuing (styles/scripts). |
| 182 |
add_action( |
| 183 |
'divi_extensions_init', |
| 184 |
function () { |
| 185 |
if ( function_exists( 'et_builder_d5_enabled' ) && et_builder_d5_enabled() ) { |
| 186 |
if ( ! defined( 'SMARTVIDEO_DIVI5_PATH' ) ) { |
| 187 |
require_once plugin_dir_path( __FILE__ ) . 'includes/page-builders/divi5-builder/divi5-smartvideo.php'; |
| 188 |
} |
| 189 |
} |
| 190 |
}, |
| 191 |
5 |
| 192 |
); |
| 193 |
} |
| 194 |
|
| 195 |
// Divi 4 — only load when Divi 5 is NOT enabled. |
| 196 |
if ( ! function_exists( 'smartvideo_load_divi_builder' ) ) { |
| 197 |
/** |
| 198 |
* Loads the Divi 4 SmartVideo builder integration when Divi 5 is not enabled. |
| 199 |
*/ |
| 200 |
function smartvideo_load_divi_builder() { |
| 201 |
if ( function_exists( 'et_builder_d5_enabled' ) && et_builder_d5_enabled() ) { |
| 202 |
return; // D5 module handles this. |
| 203 |
} |
| 204 |
require_once plugin_dir_path( __FILE__ ) . 'includes/page-builders/divi-builder/includes/DiviBuilder.php'; |
| 205 |
} |
| 206 |
add_action( 'divi_extensions_init', 'smartvideo_load_divi_builder' ); |
| 207 |
} |
| 208 |
|
| 209 |
// Bricks — only load when Bricks theme is active. |
| 210 |
if ( ! function_exists( 'smartvideo_load_bricks' ) ) { |
| 211 |
/** |
| 212 |
* Loads the Bricks SmartVideo element when Bricks is active. |
| 213 |
*/ |
| 214 |
function smartvideo_load_bricks() { |
| 215 |
if ( defined( 'BRICKS_VERSION' ) ) { |
| 216 |
require_once plugin_dir_path( __FILE__ ) . 'includes/page-builders/bricks/class-bricks-smartvideo.php'; |
| 217 |
} |
| 218 |
} |
| 219 |
add_action( 'init', 'smartvideo_load_bricks', 9 ); |
| 220 |
} |
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
/** |
| 225 |
* Initialize the plugin. |
| 226 |
* |
| 227 |
* @since 2.1.0 |
| 228 |
*/ |
| 229 |
function smart_video_init() { |
| 230 |
load_plugin_textdomain( 'swarmify', false, plugin_basename( __DIR__ ) . '/languages' ); |
| 231 |
|
| 232 |
SmartVideo_Bootstrap::instance(); |
| 233 |
} |
| 234 |
|
| 235 |
add_action( 'plugins_loaded', 'smart_video_init', 10 ); |
| 236 |
|