| 1 |
<?php |
| 2 |
/** |
| 3 |
* A carousel plugin for WordPress. |
| 4 |
* |
| 5 |
* @link https://shapedplugin.com/ |
| 6 |
* @since 2.0.0 |
| 7 |
* @package WP_Carousel_Free |
| 8 |
* |
| 9 |
* Plugin Name: WP Carousel |
| 10 |
* Plugin URI: https://wpcarousel.io/ |
| 11 |
* Description: Create beautiful image carousels, sliders, video sliders, video galleries, and photo galleries with built-in Lightbox. Easily showcase images, videos, posts, and WooCommerce products with responsive layouts, grids, and fast performance—no code required. |
| 12 |
* Version: 2.7.9 |
| 13 |
* Author: ShapedPlugin LLC |
| 14 |
* Author URI: https://shapedplugin.com/ |
| 15 |
* License: GPL-2.0+ |
| 16 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 17 |
* Text Domain: wp-carousel-free |
| 18 |
* Domain Path: /languages |
| 19 |
* Requires PHP: 7.0.0 |
| 20 |
* WC requires at least: 6.4 |
| 21 |
* WC tested up to: 10.3.5 |
| 22 |
*/ |
| 23 |
|
| 24 |
// If this file is called directly, abort. |
| 25 |
if ( ! defined( 'WPINC' ) ) { |
| 26 |
die; |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Main class of the plugin |
| 31 |
* |
| 32 |
* @package WP_Carousel_Free |
| 33 |
* @author Shamim Mia <shamhagh@gmail.com> |
| 34 |
*/ |
| 35 |
class SP_WP_Carousel_Free { |
| 36 |
|
| 37 |
|
| 38 |
/** |
| 39 |
* The loader that's responsible for maintaining and registering all hooks that power |
| 40 |
* the plugin. |
| 41 |
* |
| 42 |
* @since 2.0.0 |
| 43 |
* @access protected |
| 44 |
* @var WP_Carousel_Free_Loader $loader Maintains and registers all hooks for the plugin. |
| 45 |
*/ |
| 46 |
public $loader; |
| 47 |
|
| 48 |
/** |
| 49 |
* The unique identifier of this plugin. |
| 50 |
* |
| 51 |
* @since 2.0.0 |
| 52 |
* @access protected |
| 53 |
* @var string $plugin_name The string used to uniquely identify this plugin. |
| 54 |
*/ |
| 55 |
protected $plugin_name; |
| 56 |
|
| 57 |
/** |
| 58 |
* The current version of the plugin. |
| 59 |
* |
| 60 |
* @since 2.0.0 |
| 61 |
* @access protected |
| 62 |
* @var string $version The current version of the plugin. |
| 63 |
*/ |
| 64 |
protected $version; |
| 65 |
|
| 66 |
/** |
| 67 |
* Plugin textdomain. |
| 68 |
* |
| 69 |
* @since 2.0.0 |
| 70 |
* |
| 71 |
* @var string |
| 72 |
*/ |
| 73 |
public $domain = 'wp-carousel-free'; |
| 74 |
|
| 75 |
/** |
| 76 |
* Minimum PHP version required |
| 77 |
* |
| 78 |
* @since 2.0.0 |
| 79 |
* @var string |
| 80 |
*/ |
| 81 |
private $min_php = '7.0.0'; |
| 82 |
|
| 83 |
/** |
| 84 |
* Plugin file. |
| 85 |
* |
| 86 |
* @var string |
| 87 |
*/ |
| 88 |
private $file = __FILE__; |
| 89 |
|
| 90 |
/** |
| 91 |
* Holds class object |
| 92 |
* |
| 93 |
* @var object |
| 94 |
* @since 2.0.0 |
| 95 |
*/ |
| 96 |
private static $instance; |
| 97 |
|
| 98 |
/** |
| 99 |
* Initialize the SP_WP_Carousel_Free() class |
| 100 |
* |
| 101 |
* @since 2.0.0 |
| 102 |
* @return object |
| 103 |
*/ |
| 104 |
public static function init() { |
| 105 |
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof SP_WP_Carousel_Free ) ) { |
| 106 |
self::$instance = new SP_WP_Carousel_Free(); |
| 107 |
self::$instance->setup(); |
| 108 |
} |
| 109 |
return self::$instance; |
| 110 |
} |
| 111 |
|
| 112 |
/** |
| 113 |
* Define the core functionality of the plugin. |
| 114 |
* |
| 115 |
* Set the plugin name and the plugin version that can be used throughout the plugin. |
| 116 |
* Load the dependencies, define the locale, and set the hooks for the admin area and |
| 117 |
* the public-facing side of the site. |
| 118 |
* |
| 119 |
* @since 2.0.0 |
| 120 |
*/ |
| 121 |
public function setup() { |
| 122 |
$this->plugin_name = 'wp-carousel-free'; |
| 123 |
$this->version = '2.7.9'; |
| 124 |
$this->define_constants(); |
| 125 |
$this->includes(); |
| 126 |
$this->load_dependencies(); |
| 127 |
$this->define_common_hooks(); |
| 128 |
$this->define_admin_hooks(); |
| 129 |
$this->define_public_hooks(); |
| 130 |
} |
| 131 |
|
| 132 |
/** |
| 133 |
* Define plugin constants. |
| 134 |
* |
| 135 |
* @since 2.0.0 |
| 136 |
* @return void |
| 137 |
*/ |
| 138 |
private function define_constants() { |
| 139 |
define( 'WPCAROUSELF_BASENAME', plugin_basename( __FILE__ ) ); |
| 140 |
define( 'WPCAROUSELF_VERSION', $this->version ); |
| 141 |
define( 'WPCAROUSELF_PATH', plugin_dir_path( __FILE__ ) ); |
| 142 |
define( 'WPCAROUSELF_INCLUDES', WPCAROUSELF_PATH . '/includes' ); |
| 143 |
define( 'WPCAROUSELF_URL', plugin_dir_url( __FILE__ ) ); |
| 144 |
} |
| 145 |
|
| 146 |
/** |
| 147 |
* Define constant if not already set. |
| 148 |
* |
| 149 |
* @param string $name Constant name. |
| 150 |
* @param string|bool $value Constant Value. |
| 151 |
*/ |
| 152 |
private function define( $name, $value ) { |
| 153 |
if ( ! defined( $name ) ) { |
| 154 |
define( $name, $value ); |
| 155 |
} |
| 156 |
} |
| 157 |
|
| 158 |
/** |
| 159 |
* Included required files. |
| 160 |
* |
| 161 |
* @since 2.0.0 |
| 162 |
* @return void |
| 163 |
*/ |
| 164 |
public function includes() { |
| 165 |
include_once WPCAROUSELF_INCLUDES . '/class-wp-carousel-free-updates.php'; |
| 166 |
include_once WPCAROUSELF_INCLUDES . '/class-wp-carousel-free-loader.php'; |
| 167 |
include_once WPCAROUSELF_INCLUDES . '/class-wp-carousel-free-post-types.php'; |
| 168 |
include_once WPCAROUSELF_PATH . '/admin/views/sp-framework/classes/setup.class.php'; |
| 169 |
include_once WPCAROUSELF_PATH . '/admin/views/notices/admin-notices.php'; |
| 170 |
|
| 171 |
add_action( |
| 172 |
'after_setup_theme', |
| 173 |
function () { |
| 174 |
include_once WPCAROUSELF_PATH . '/admin/views/metabox-config.php'; |
| 175 |
include_once WPCAROUSELF_PATH . '/admin/views/option-config.php'; |
| 176 |
include_once WPCAROUSELF_PATH . '/admin/views/tools-config.php'; |
| 177 |
} |
| 178 |
); |
| 179 |
|
| 180 |
include_once WPCAROUSELF_INCLUDES . '/class-wp-carousel-free-shortcode.php'; |
| 181 |
include_once WPCAROUSELF_INCLUDES . '/class-wp-carousel-free-import-export.php'; |
| 182 |
include_once WPCAROUSELF_PATH . '/public/shortcode-deprecated.php'; |
| 183 |
include_once WPCAROUSELF_PATH . '/public/WPCF_Helper.php'; |
| 184 |
include_once WPCAROUSELF_PATH . '/public/class-wp-carousel-free-public.php'; |
| 185 |
include_once WPCAROUSELF_PATH . '/admin/class-wp-carousel-free-admin.php'; |
| 186 |
include_once WPCAROUSELF_PATH . '/admin/help-page/help.php'; |
| 187 |
include_once WPCAROUSELF_PATH . '/admin/preview/class-wp-carousel-free-preview.php'; |
| 188 |
include_once WPCAROUSELF_PATH . '/admin/class-wp-carousel-free-gutenberg-block.php'; |
| 189 |
include_once WPCAROUSELF_PATH . '/admin/Media_View/class-wp-carousel-free-media-view.php'; |
| 190 |
require_once WPCAROUSELF_PATH . '/admin/class-wp-carousel-free-elementor-block.php'; |
| 191 |
} |
| 192 |
|
| 193 |
/** |
| 194 |
* Load the required dependencies for this plugin. |
| 195 |
* |
| 196 |
* Include the following files that make up the plugin: |
| 197 |
* |
| 198 |
* - WP_Carousel_Free_Loader. Orchestrates the hooks of the plugin. |
| 199 |
* - WP_Carousel_Free_Admin. Defines all hooks for the admin area. |
| 200 |
* - WP_Carousel_Free_Public. Defines all hooks for the public side of the site. |
| 201 |
* |
| 202 |
* Create an instance of the loader which will be used to register the hooks |
| 203 |
* with WordPress. |
| 204 |
* |
| 205 |
* @since 2.0.0 |
| 206 |
* @access private |
| 207 |
*/ |
| 208 |
private function load_dependencies() { |
| 209 |
$this->loader = new WP_Carousel_Free_Loader(); |
| 210 |
} |
| 211 |
|
| 212 |
|
| 213 |
/** |
| 214 |
* Register common hooks. |
| 215 |
* |
| 216 |
* @since 2.0.0 |
| 217 |
* @access private |
| 218 |
*/ |
| 219 |
private function define_common_hooks() { |
| 220 |
$plugin_cpt = new WP_Carousel_Free_Post_Type( $this->get_plugin_name(), $this->get_version() ); |
| 221 |
$plugin_admin_notices = new WP_Carousel_Admin_Notices( $this->get_plugin_name(), $this->get_version() ); |
| 222 |
|
| 223 |
$this->loader->add_action( 'init', $plugin_cpt, 'wp_carousel_post_type', 11 ); |
| 224 |
$this->loader->add_action( 'admin_notices', $plugin_admin_notices, 'display_admin_notice' ); |
| 225 |
$this->loader->add_action( 'wp_ajax_sp-wpcfree-never-show-review-notice', $plugin_admin_notices, 'dismiss_review_notice' ); |
| 226 |
add_action( 'wp_ajax_wp_ajax_install_plugin', 'wp_ajax_install_plugin' ); |
| 227 |
} |
| 228 |
|
| 229 |
/** |
| 230 |
* Register all of the hooks related to the admin area functionality |
| 231 |
* of the plugin. |
| 232 |
* |
| 233 |
* @since 2.0.0 |
| 234 |
* @access private |
| 235 |
*/ |
| 236 |
private function define_admin_hooks() { |
| 237 |
$plugin_admin = new WP_Carousel_Free_Admin( $this->get_plugin_name(), $this->get_version() ); |
| 238 |
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_admin_styles' ); |
| 239 |
$this->loader->add_filter( 'post_updated_messages', $plugin_admin, 'wpcp_carousel_updated_messages', 10, 2 ); |
| 240 |
$this->loader->add_filter( 'manage_sp_wp_carousel_posts_columns', $plugin_admin, 'filter_carousel_admin_column' ); |
| 241 |
$this->loader->add_action( 'manage_sp_wp_carousel_posts_custom_column', $plugin_admin, 'display_carousel_admin_fields', 10, 2 ); |
| 242 |
$this->loader->add_filter( 'plugin_action_links', $plugin_admin, 'add_plugin_action_links', 10, 2 ); |
| 243 |
$this->loader->add_filter( 'plugin_row_meta', $plugin_admin, 'plugin_row_meta', 10, 2 ); |
| 244 |
$this->loader->add_filter( 'admin_footer_text', $plugin_admin, 'sp_wpcp_review_text', 10, 2 ); |
| 245 |
$this->loader->add_filter( 'update_footer', $plugin_admin, 'sp_wpcp_version_text', 11 ); |
| 246 |
$this->loader->add_action( 'before_woocommerce_init', $plugin_admin, 'declare_compatibility_with_woo_hpos_feature' ); |
| 247 |
|
| 248 |
// Export and Import ajax call. |
| 249 |
$import_export = new Wp_Carousel_Free_Import_Export( $this->get_plugin_name(), $this->get_version() ); |
| 250 |
|
| 251 |
$this->loader->add_action( 'wp_ajax_wpcp_export_shortcodes', $import_export, 'export_shortcodes' ); |
| 252 |
$this->loader->add_action( 'wp_ajax_wpcp_import_shortcodes', $import_export, 'import_shortcodes' ); |
| 253 |
|
| 254 |
// Gutenberg block. |
| 255 |
if ( version_compare( $GLOBALS['wp_version'], '5.3', '>=' ) ) { |
| 256 |
new WP_Carousel_Free_Gutenberg_Block(); |
| 257 |
} |
| 258 |
|
| 259 |
// Elementor shortcode block. |
| 260 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 261 |
if ( ( is_plugin_active( 'elementor/elementor.php' ) || is_plugin_active_for_network( 'elementor/elementor.php' ) ) ) { |
| 262 |
new Wp_Carousel_Free_Element_Shortcode_Block(); |
| 263 |
} |
| 264 |
|
| 265 |
/** |
| 266 |
* Polylang plugin support for multi language support. |
| 267 |
*/ |
| 268 |
if ( class_exists( 'Polylang' ) ) { |
| 269 |
/** |
| 270 |
* |
| 271 |
* Multi Language Support |
| 272 |
* |
| 273 |
* @since 2.0 |
| 274 |
*/ |
| 275 |
add_filter( 'pll_get_post_types', array( $this, 'wpcp_polylang_cpt_to_pll' ), 10, 2 ); |
| 276 |
} |
| 277 |
} |
| 278 |
|
| 279 |
/** |
| 280 |
* Polylang_cpt_to_pll |
| 281 |
* |
| 282 |
* @param mixed $post_types post types. |
| 283 |
* @param mixed $is_settings hide. |
| 284 |
* @return array |
| 285 |
*/ |
| 286 |
public function wpcp_polylang_cpt_to_pll( $post_types, $is_settings ) { |
| 287 |
// enables language and translation management. |
| 288 |
$post_types['sp_wp_carousel'] = 'sp_wp_carousel'; |
| 289 |
return $post_types; |
| 290 |
} |
| 291 |
|
| 292 |
|
| 293 |
/** |
| 294 |
* Register all of the hooks related to the public-facing functionality |
| 295 |
* of the plugin. |
| 296 |
* |
| 297 |
* @since 2.0.0 |
| 298 |
* @access private |
| 299 |
*/ |
| 300 |
private function define_public_hooks() { |
| 301 |
$plugin_public = new WP_Carousel_Free_Public( $this->get_plugin_name(), $this->get_version() ); |
| 302 |
$this->loader->add_action( 'wp_loaded', $plugin_public, 'register_all_scripts' ); |
| 303 |
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
| 304 |
$this->loader->add_action( 'save_post', $plugin_public, 'update_page_wp_carousel_option_on_save' ); |
| 305 |
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_public, 'admin_enqueue_scripts' ); |
| 306 |
|
| 307 |
$plugin_shortcode = new WP_Carousel_Free_Shortcode( $this->get_plugin_name(), $this->get_version() ); |
| 308 |
$this->loader->add_shortcode( 'sp_wpcarousel', $plugin_shortcode, 'sp_wp_carousel_shortcode' ); |
| 309 |
} |
| 310 |
|
| 311 |
/** |
| 312 |
* The name of the plugin used to uniquely identify it within the context of |
| 313 |
* WordPress and to define internationalization functionality. |
| 314 |
* |
| 315 |
* @since 2.0.0 |
| 316 |
* @return string The name of the plugin. |
| 317 |
*/ |
| 318 |
public function get_plugin_name() { |
| 319 |
return $this->plugin_name; |
| 320 |
} |
| 321 |
|
| 322 |
/** |
| 323 |
* Retrieve the version number of the plugin. |
| 324 |
* |
| 325 |
* @since 2.0.0 |
| 326 |
* @return string The version number of the plugin. |
| 327 |
*/ |
| 328 |
public function get_version() { |
| 329 |
return $this->version; |
| 330 |
} |
| 331 |
|
| 332 |
/** |
| 333 |
* The reference to the class that orchestrates the hooks with the plugin. |
| 334 |
* |
| 335 |
* @since 2.0.0 |
| 336 |
* @return WP_Carousel_Free_Loader Orchestrates the hooks of the plugin. |
| 337 |
*/ |
| 338 |
public function get_loader() { |
| 339 |
return $this->loader; |
| 340 |
} |
| 341 |
|
| 342 |
/** |
| 343 |
* Run the loader to execute all of the hooks with WordPress. |
| 344 |
* |
| 345 |
* @since 2.0.0 |
| 346 |
*/ |
| 347 |
public function run() { |
| 348 |
$this->loader->run(); |
| 349 |
} |
| 350 |
} // SP_WP_Carousel_Free |
| 351 |
|
| 352 |
/** |
| 353 |
* Main instance of WP Carousel Free |
| 354 |
* |
| 355 |
* Returns the main instance of the WP Carousel Free. |
| 356 |
* |
| 357 |
* @since 2.0.0 |
| 358 |
* @return void |
| 359 |
*/ |
| 360 |
function sp_wpcf() { |
| 361 |
$plugin = SP_WP_Carousel_Free::init(); |
| 362 |
$plugin->loader->run(); |
| 363 |
|
| 364 |
if ( ! defined( 'SHAPEDPLIUGIN_OFFER_BANNER_LOADED' ) ) { |
| 365 |
define( 'SHAPEDPLIUGIN_OFFER_BANNER_LOADED', true ); |
| 366 |
|
| 367 |
/** |
| 368 |
* The file is responsible for generating admin offer banner. |
| 369 |
*/ |
| 370 |
include_once plugin_dir_path( __FILE__ ) . '/admin/views/notices/offer-banner.php'; |
| 371 |
} |
| 372 |
} |
| 373 |
|
| 374 |
/** |
| 375 |
* Load the main functionalities of the plugin. |
| 376 |
* |
| 377 |
* @return void |
| 378 |
*/ |
| 379 |
function load_sp_wordpress_carousel_plugin() { |
| 380 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 381 |
if ( ! ( is_plugin_active( 'wp-carousel-pro/wp-carousel-pro.php' ) || is_plugin_active_for_network( 'wp-carousel-pro/wp-carousel-pro.php' ) ) ) { |
| 382 |
// Launch it out . |
| 383 |
sp_wpcf(); |
| 384 |
} |
| 385 |
} |
| 386 |
|
| 387 |
/** |
| 388 |
* Redirect after activation. |
| 389 |
* |
| 390 |
* @param string $plugin_file Path to the plugin file, relative to the plugin. |
| 391 |
* @return void |
| 392 |
*/ |
| 393 |
function sp_wpcf_redirect_after_activation( $plugin_file ) { |
| 394 |
if ( plugin_basename( __FILE__ ) === $plugin_file && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) && ! ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
| 395 |
exit( esc_url( wp_safe_redirect( admin_url( 'edit.php?post_type=sp_wp_carousel&page=wpcf_help' ) ) ) ); |
| 396 |
} |
| 397 |
} |
| 398 |
|
| 399 |
add_action( 'plugins_loaded', 'load_sp_wordpress_carousel_plugin' ); |
| 400 |
add_action( 'activated_plugin', 'sp_wpcf_redirect_after_activation' ); |
| 401 |
|