PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.3
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.3
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / includes / class-smart-post-show.php

class-smart-post-show.php in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.3, at includes/class-smart-post-show.php

363 lines 11.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The core plugin class.
4 *
5 * This is used to define internationalization, admin-specific hooks, and
6 * public-facing site hooks.
7 *
8 * Also maintains the unique identifier of this plugin as well as the current
9 * version of the plugin.
10 *
11 * @link https://wpsmartpost.com/
12 * @since 2.2.0
13 *
14 * @package Smart_Post_Show
15 * @subpackage Smart_Post_Show/includes
16 */
17
18 if ( ! defined( 'ABSPATH' ) ) {
19 exit; // Exit if accessed directly.
20 }
21
22 /**
23 * The core plugin class that is used to define internationalization,
24 * admin-specific hooks, and public-facing site hooks.
25 */
26 class Smart_Post_Show {
27
28 /**
29 * The loader that's responsible for maintaining and registering all hooks that power
30 * the plugin.
31 *
32 * @since 2.2.0
33 * @access protected
34 * @var Smart_Post_Show_Loader $loader Maintains and registers all hooks for the plugin.
35 */
36 public $loader;
37
38 /**
39 * The unique identifier of this plugin.
40 *
41 * @since 2.2.0
42 * @access protected
43 * @var string $plugin_name The string used to uniquely identify this plugin.
44 */
45 public $plugin_name = SMART_POST_SHOW_BASENAME;
46
47 /**
48 * The current version of the plugin.
49 *
50 * @since 2.2.0
51 * @access protected
52 * @var string $version The current version of the plugin.
53 */
54 public $version = SMART_POST_SHOW_VERSION;
55
56 /**
57 * Define the core functionality of the plugin.
58 *
59 * Set the plugin name and the plugin version that can be used throughout the plugin.
60 * Load the dependencies, define the locale, and set the hooks for the admin area and
61 * the public-facing side of the site.
62 *
63 * @since 2.2.0
64 */
65 public function __construct() {
66 $this->define_constants();
67 $this->load_dependencies();
68 $this->define_common_hooks();
69 $this->define_admin_hooks();
70 $this->define_public_hooks();
71 $this->set_locale();
72 }
73
74 /**
75 * Define constants
76 *
77 * @since 2.2.0
78 */
79 public function define_constants() {
80 define( 'SP_PC_VERSION', $this->version );
81 define( 'SP_PC_PLUGIN_NAME', $this->plugin_name );
82 define( 'SP_PC_PATH', plugin_dir_path( __DIR__ ) );
83 define( 'SP_PC_TEMPLATE_PATH', plugin_dir_path( __DIR__ ) . 'public/template/' );
84 define( 'SP_PC_URL', plugin_dir_url( __DIR__ ) );
85 }
86
87 /**
88 * Load the required dependencies for this plugin.
89 *
90 * Include the following files that make up the plugin:
91 *
92 * - Smart_Post_Show_Loader. Orchestrates the hooks of the plugin.
93 * - Smart_Post_Show_i18n. Defines internationalization functionality.
94 * - Smart_Post_Show_Admin. Defines all hooks for the admin area.
95 * - Smart_Post_Show_Public. Defines all hooks for the public side of the site.
96 * - Smart_Post_Show_Public. Defines all hooks for the public side of the site.
97 *
98 * Create an instance of the loader which will be used to register the hooks
99 * with WordPress.
100 *
101 * @since 2.2.0
102 * @access private
103 */
104 private function load_dependencies() {
105
106 /**
107 * The class responsible for orchestrating the actions and filters of the
108 * core plugin.
109 */
110 require_once SP_PC_PATH . 'includes/class-smart-post-show-loader.php';
111 $this->loader = new Smart_Post_Show_Loader();
112
113 /**
114 * The class responsible for defining internationalization functionality
115 * of the plugin.
116 */
117 require_once SP_PC_PATH . 'includes/class-smart-post-show-i18n.php';
118
119 /**
120 * The class responsible for defining internationalization functionality
121 * of the plugin.
122 */
123 require_once SP_PC_PATH . 'includes/class-smart-post-show-post-types.php';
124
125 /**
126 * The class responsible for updates functionality of the plugin.
127 */
128 require_once SP_PC_PATH . 'includes/class-smart-post-show-updates.php';
129
130 /**
131 * The class responsible for Export Import functionality of the plugin.
132 */
133 require_once SP_PC_PATH . 'includes/class-smart-post-show-import-export.php';
134
135 /**
136 * The class responsible for defining all actions that occur in the admin area.
137 */
138 require_once SP_PC_PATH . 'admin/class-smart-post-show-admin.php';
139
140 /**
141 * Weekly events.
142 */
143 require_once SP_PC_PATH . 'admin/class-smart-post-show-cron.php';
144
145 /**
146 * Save template.
147 */
148 require_once SP_PC_PATH . 'includes/class-smart-post-show-saved-template.php';
149
150 /**
151 * The class responsible for defining metabox setup that occur in the admin area.
152 */
153 require_once SP_PC_PATH . '/admin/views/sp-framework/classes/setup.class.php';
154 require_once SP_PC_PATH . '/public/helpers/sp-pc-output.php';
155 /**
156 * The class responsible for defining all actions that occur in the public-facing
157 * side of the site.
158 */
159 require_once SP_PC_PATH . 'public/class-smart-post-show-public.php';
160 require_once SP_PC_PATH . 'admin/preview/class-spsp-preview.php';
161
162 /**
163 * The class responsible for all admin notices.
164 */
165 require_once SP_PC_PATH . 'admin/views/notices/review.php';
166
167 /**
168 * The class responsible for admin promo notices.
169 */
170 require_once SP_PC_PATH . 'includes/Admin/Admin_Notices.php';
171 new \SmartPostShow\Admin\Admin_Notices();
172
173 /**
174 * The class blocks helper.
175 */
176 require_once SP_PC_PATH . 'blocks/includes/class-block-helper.php';
177
178 \SmartPostShow\Blocks\Helper::set_integration_options();
179
180 $integration_options = \SmartPostShow\Blocks\Helper::get_integration_options();
181
182 $divi_integration = $integration_options['divi'] ?? false;
183 $oxygen_integration = $integration_options['oxygen'] ?? false;
184 $wpbakery_integration = $integration_options['wpbakery'] ?? false;
185 $beaber_integration = $integration_options['beaver'] ?? false;
186 $bricks_integration = $integration_options['bricks'] ?? false;
187
188 /**
189 * Divi.
190 */
191 if ( $divi_integration ) {
192 require_once SP_PC_PATH . 'admin/page-builder/divi/smart-post-show-divi.php';
193 }
194
195 /**
196 * Oxygen.
197 */
198 if ( $oxygen_integration ) {
199 require_once SP_PC_PATH . 'admin/page-builder/oxygen/init.php';
200 }
201
202 /**
203 * WPBakery.
204 */
205 if ( $wpbakery_integration && defined( 'WPB_VC_VERSION' ) ) {
206 require_once SP_PC_PATH . 'admin/page-builder/wpBakery/smart-post-show-wpbakery.php';
207 }
208
209 /**
210 * Beaver Builder.
211 */
212 if ( $beaber_integration && class_exists( 'FLBuilder' ) ) {
213 require_once SP_PC_PATH . 'admin/page-builder/beaver/smart-post-beaver.php';
214 }
215
216 /**
217 * Bricks Builder.
218 */
219 if ( $bricks_integration ) {
220 require_once SP_PC_PATH . 'admin/page-builder/bricks/init.php';
221 }
222
223 // Elementor shortcode addons.
224 require_once ABSPATH . 'wp-admin/includes/plugin.php';
225 if ( ( is_plugin_active( 'elementor/elementor.php' ) || is_plugin_active_for_network( 'elementor/elementor.php' ) ) ) {
226 require_once SP_PC_PATH . 'admin/class-smart-post-show-element-shortcode-addons.php';
227 require_once SP_PC_PATH . 'admin/class-smart-post-show-element-shortcode-addons-deprecated.php';
228 }
229
230 /**
231 * Gutenberg block.
232 */
233 if ( version_compare( $GLOBALS['wp_version'], '5.3', '>=' ) ) {
234 require_once SP_PC_PATH . 'admin/blocks-settings/class-blocks-settings-page.php';
235 new Sp_Smart_Post_Block_Admin_Menu_Page();
236
237 require_once SP_PC_PATH . 'blocks/class-smart-post-show-blocks.php';
238 Sp_Smart_Post_Blocks_Init::instance();
239
240 require_once SP_PC_PATH . 'admin/class-smart-post-show-gutenberg-block.php';
241 new Smart_Post_Show_Gutenberg_Block();
242 }
243 }
244
245 /**
246 * Define the locale for this plugin for internationalization.
247 *
248 * Uses the Smart_Post_Show_i18n class in order to set the domain and to register the hook
249 * with WordPress.
250 *
251 * @since 2.2.0
252 * @access private
253 */
254 private function set_locale() {
255
256 $plugin_i18n = new Smart_Post_Show_i18n();
257
258 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
259 }
260
261 /**
262 * Register common hooks.
263 *
264 * @since 2.2.0
265 * @access private
266 */
267 private function define_common_hooks() {
268 $common_hooks = new Smart_Post_Show_Post_Type( SP_PC_PLUGIN_NAME, SP_PC_VERSION );
269 $this->loader->add_action( 'init', $common_hooks, 'register_carousel_post_type', 10 );
270
271 // Saved Template.
272 $saved_template = new Smart_Post_Show_Saved_Template();
273 $this->loader->add_action( 'init', $saved_template, 'register_template_shortcode' );
274 }
275
276 /**
277 * Register all of the hooks related to the admin area functionality
278 * of the plugin.
279 *
280 * @since 2.2.0
281 * @access private
282 */
283 private function define_admin_hooks() {
284 $plugin_admin = new Smart_Post_Show_Admin( SP_PC_PLUGIN_NAME, SP_PC_VERSION );
285 // Load admin scripts and styles.
286 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
287 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
288 // Admin custom column.
289 $this->loader->add_filter( 'manage_sp_post_carousel_posts_columns', $plugin_admin, 'filter_carousel_admin_column' );
290 $this->loader->add_filter( 'admin_footer_text', $plugin_admin, 'sp_spc_footer_text' );
291 $this->loader->add_filter( 'update_footer', $plugin_admin, 'sp_spc_version_text', 11 );
292 $this->loader->add_action( 'manage_sp_post_carousel_posts_custom_column', $plugin_admin, 'display_carousel_admin_fields', 10, 2 );
293
294 $this->loader->add_filter( 'plugin_row_meta', $plugin_admin, 'after_pcp_row_meta', 10, 4 );
295 // Post save and update messages.
296 $this->loader->add_filter( 'post_updated_messages', $plugin_admin, 'sppcp_update', 10, 1 );
297 // Help Page.
298 SPS_Recommended::instance();
299 $import_export = new Smart_Post_Show_Import_Export( SP_PC_PLUGIN_NAME, SP_PC_VERSION );
300
301 $this->loader->add_action( 'wp_ajax_pcp_export_shortcodes', $import_export, 'export_shortcodes' );
302 $this->loader->add_action( 'wp_ajax_pcp_import_shortcodes', $import_export, 'import_shortcodes' );
303 // Get shortcode list for export selection.
304 $this->loader->add_action( 'wp_ajax_pcp_get_shortcode_list_for_export', $import_export, 'get_shortcode_list_for_export' );
305
306 // after activated plugin redirect to help page.
307 $this->loader->add_action( 'activated_plugin', $plugin_admin, 'redirect_help_page' );
308 }
309
310 /**
311 * Register all of the hooks related to the public-facing functionality
312 * of the plugin.
313 *
314 * @since 2.2.0
315 * @access private
316 */
317 private function define_public_hooks() {
318 $plugin_public = new Smart_Post_Show_Public( SP_PC_PLUGIN_NAME, SP_PC_VERSION );
319 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
320 $this->loader->add_action( 'wp_loaded', $plugin_public, 'register_all_scripts' );
321 }
322
323 /**
324 * Run the loader to execute all of the hooks with WordPress.
325 *
326 * @since 2.2.0
327 */
328 public function run() {
329 $this->loader->run();
330 }
331
332 /**
333 * The name of the plugin used to uniquely identify it within the context of
334 * WordPress and to define internationalization functionality.
335 *
336 * @since 2.2.0
337 * @return string The name of the plugin.
338 */
339 public function get_plugin_name() {
340 return $this->plugin_name;
341 }
342
343 /**
344 * The reference to the class that orchestrates the hooks with the plugin.
345 *
346 * @since 2.2.0
347 * @return Smart_Post_Show_Loader Orchestrates the hooks of the plugin.
348 */
349 public function get_loader() {
350 return $this->loader;
351 }
352
353 /**
354 * Retrieve the version number of the plugin.
355 *
356 * @since 2.2.0
357 * @return string The version number of the plugin.
358 */
359 public function get_version() {
360 return $this->version;
361 }
362 }
363