PluginProbe
Carousel, Slider, Photo Gallery with Lightbox, Video Slider, by WP Carousel / 2.7.6
Carousel, Slider, Photo Gallery with Lightbox, Video Slider, by WP Carousel v2.7.6
2.7.12 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.17 2.1.18 2.1.19 2.1.2 2.1.20 All 89 releases
wp-carousel-free / wp-carousel-free.php

wp-carousel-free.php in Carousel, Slider, Photo Gallery with Lightbox, Video Slider, by WP Carousel 2.7.6, at wp-carousel-free.php

395 lines 12.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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: The most powerful and user-friendly carousel, slider, and gallery plugin for WordPress. Create unlimited beautiful carousels, sliders, and galleries in minutes using images, posts, WooCommerce products, etc.
12 * Version: 2.7.6
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.0.2
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 = '5.6';
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.6';
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_I18n. Defines internationalization functionality.
200 * - WP_Carousel_Free_Admin. Defines all hooks for the admin area.
201 * - WP_Carousel_Free_Public. Defines all hooks for the public side of the site.
202 *
203 * Create an instance of the loader which will be used to register the hooks
204 * with WordPress.
205 *
206 * @since 2.0.0
207 * @access private
208 */
209 private function load_dependencies() {
210 $this->loader = new WP_Carousel_Free_Loader();
211 }
212
213
214 /**
215 * Register common hooks.
216 *
217 * @since 2.0.0
218 * @access private
219 */
220 private function define_common_hooks() {
221 $plugin_cpt = new WP_Carousel_Free_Post_Type( $this->get_plugin_name(), $this->get_version() );
222 $plugin_admin_notices = new WP_Carousel_Admin_Notices( $this->get_plugin_name(), $this->get_version() );
223
224 $this->loader->add_action( 'init', $plugin_cpt, 'wp_carousel_post_type', 11 );
225 $this->loader->add_action( 'admin_notices', $plugin_admin_notices, 'display_admin_notice' );
226 $this->loader->add_action( 'wp_ajax_sp-wpcfree-never-show-review-notice', $plugin_admin_notices, 'dismiss_review_notice' );
227 add_action( 'wp_ajax_wp_ajax_install_plugin', 'wp_ajax_install_plugin' );
228 $this->loader->add_action( 'admin_notices', $plugin_admin_notices, 'show_admin_offer_banner' );
229 $this->loader->add_action( 'wp_ajax_sp-carousel-hide-offer-banner', $plugin_admin_notices, 'dismiss_friday_offer_banner' );
230 }
231
232 /**
233 * Register all of the hooks related to the admin area functionality
234 * of the plugin.
235 *
236 * @since 2.0.0
237 * @access private
238 */
239 private function define_admin_hooks() {
240 $plugin_admin = new WP_Carousel_Free_Admin( $this->get_plugin_name(), $this->get_version() );
241 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_admin_styles' );
242 $this->loader->add_filter( 'post_updated_messages', $plugin_admin, 'wpcp_carousel_updated_messages', 10, 2 );
243 $this->loader->add_filter( 'manage_sp_wp_carousel_posts_columns', $plugin_admin, 'filter_carousel_admin_column' );
244 $this->loader->add_action( 'manage_sp_wp_carousel_posts_custom_column', $plugin_admin, 'display_carousel_admin_fields', 10, 2 );
245 $this->loader->add_filter( 'plugin_action_links', $plugin_admin, 'add_plugin_action_links', 10, 2 );
246 $this->loader->add_filter( 'plugin_row_meta', $plugin_admin, 'plugin_row_meta', 10, 2 );
247 $this->loader->add_filter( 'admin_footer_text', $plugin_admin, 'sp_wpcp_review_text', 10, 2 );
248 $this->loader->add_filter( 'update_footer', $plugin_admin, 'sp_wpcp_version_text', 11 );
249 $this->loader->add_action( 'before_woocommerce_init', $plugin_admin, 'declare_compatibility_with_woo_hpos_feature' );
250
251 // Export and Import ajax call.
252 $import_export = new Wp_Carousel_Free_Import_Export( $this->get_plugin_name(), $this->get_version() );
253
254 $this->loader->add_action( 'wp_ajax_wpcp_export_shortcodes', $import_export, 'export_shortcodes' );
255 $this->loader->add_action( 'wp_ajax_wpcp_import_shortcodes', $import_export, 'import_shortcodes' );
256
257 // Gutenberg block.
258 if ( version_compare( $GLOBALS['wp_version'], '5.3', '>=' ) ) {
259 new WP_Carousel_Free_Gutenberg_Block();
260 }
261
262 // Elementor shortcode block.
263 require_once ABSPATH . 'wp-admin/includes/plugin.php';
264 if ( ( is_plugin_active( 'elementor/elementor.php' ) || is_plugin_active_for_network( 'elementor/elementor.php' ) ) ) {
265 new Wp_Carousel_Free_Element_Shortcode_Block();
266 }
267
268 /**
269 * Polylang plugin support for multi language support.
270 */
271 if ( class_exists( 'Polylang' ) ) {
272 /**
273 *
274 * Multi Language Support
275 *
276 * @since 2.0
277 */
278 add_filter( 'pll_get_post_types', array( $this, 'wpcp_polylang_cpt_to_pll' ), 10, 2 );
279 }
280 }
281
282 /**
283 * Polylang_cpt_to_pll
284 *
285 * @param mixed $post_types post types.
286 * @param mixed $is_settings hide.
287 * @return array
288 */
289 public function wpcp_polylang_cpt_to_pll( $post_types, $is_settings ) {
290 // enables language and translation management.
291 $post_types['sp_wp_carousel'] = 'sp_wp_carousel';
292 return $post_types;
293 }
294
295
296 /**
297 * Register all of the hooks related to the public-facing functionality
298 * of the plugin.
299 *
300 * @since 2.0.0
301 * @access private
302 */
303 private function define_public_hooks() {
304 $plugin_public = new WP_Carousel_Free_Public( $this->get_plugin_name(), $this->get_version() );
305 $this->loader->add_action( 'wp_loaded', $plugin_public, 'register_all_scripts' );
306 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
307 $this->loader->add_action( 'save_post', $plugin_public, 'update_page_wp_carousel_option_on_save' );
308 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_public, 'admin_enqueue_scripts' );
309
310 $plugin_shortcode = new WP_Carousel_Free_Shortcode( $this->get_plugin_name(), $this->get_version() );
311 $this->loader->add_shortcode( 'sp_wpcarousel', $plugin_shortcode, 'sp_wp_carousel_shortcode' );
312 }
313
314 /**
315 * The name of the plugin used to uniquely identify it within the context of
316 * WordPress and to define internationalization functionality.
317 *
318 * @since 2.0.0
319 * @return string The name of the plugin.
320 */
321 public function get_plugin_name() {
322 return $this->plugin_name;
323 }
324
325 /**
326 * Retrieve the version number of the plugin.
327 *
328 * @since 2.0.0
329 * @return string The version number of the plugin.
330 */
331 public function get_version() {
332 return $this->version;
333 }
334
335 /**
336 * The reference to the class that orchestrates the hooks with the plugin.
337 *
338 * @since 2.0.0
339 * @return WP_Carousel_Free_Loader Orchestrates the hooks of the plugin.
340 */
341 public function get_loader() {
342 return $this->loader;
343 }
344
345 /**
346 * Run the loader to execute all of the hooks with WordPress.
347 *
348 * @since 2.0.0
349 */
350 public function run() {
351 $this->loader->run();
352 }
353 } // SP_WP_Carousel_Free
354
355 /**
356 * Main instance of WP Carousel Free
357 *
358 * Returns the main instance of the WP Carousel Free.
359 *
360 * @since 2.0.0
361 * @return void
362 */
363 function sp_wpcf() {
364 $plugin = SP_WP_Carousel_Free::init();
365 $plugin->loader->run();
366 }
367
368 /**
369 * Load the main functionalities of the plugin.
370 *
371 * @return void
372 */
373 function load_sp_wordpress_carousel_plugin() {
374 require_once ABSPATH . 'wp-admin/includes/plugin.php';
375 if ( ! ( is_plugin_active( 'wp-carousel-pro/wp-carousel-pro.php' ) || is_plugin_active_for_network( 'wp-carousel-pro/wp-carousel-pro.php' ) ) ) {
376 // Launch it out .
377 sp_wpcf();
378 }
379 }
380
381 /**
382 * Redirect after activation.
383 *
384 * @param string $plugin_file Path to the plugin file, relative to the plugin.
385 * @return void
386 */
387 function sp_wpcf_redirect_after_activation( $plugin_file ) {
388 if ( plugin_basename( __FILE__ ) === $plugin_file && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) && ! ( defined( 'WP_CLI' ) && WP_CLI ) ) {
389 exit( esc_url( wp_safe_redirect( admin_url( 'edit.php?post_type=sp_wp_carousel&page=wpcf_help' ) ) ) );
390 }
391 }
392
393 add_action( 'plugins_loaded', 'load_sp_wordpress_carousel_plugin' );
394 add_action( 'activated_plugin', 'sp_wpcf_redirect_after_activation' );
395