PluginProbe
Carousel, Slider, Photo Gallery with Lightbox, Video Slider, by WP Carousel / 2.7.3
Carousel, Slider, Photo Gallery with Lightbox, Video Slider, by WP Carousel v2.7.3
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.3, at wp-carousel-free.php

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