PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.2
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.2
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.2, at includes/class-smart-post-show.php

355 lines 10.7 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 blocks helper.
169 */
170 require_once SP_PC_PATH . 'blocks/includes/class-block-helper.php';
171
172 \SmartPostShow\Blocks\Helper::set_integration_options();
173
174 $integration_options = \SmartPostShow\Blocks\Helper::get_integration_options();
175
176 $divi_integration = $integration_options['divi'] ?? false;
177 $oxygen_integration = $integration_options['oxygen'] ?? false;
178 $wpbakery_integration = $integration_options['wpbakery'] ?? false;
179 $beaber_integration = $integration_options['beaver'] ?? false;
180 $bricks_integration = $integration_options['bricks'] ?? false;
181
182 /**
183 * Divi.
184 */
185 if ( $divi_integration ) {
186 require_once SP_PC_PATH . 'admin/page-builder/divi/smart-post-show-divi.php';
187 }
188
189 /**
190 * Oxygen.
191 */
192 if ( $oxygen_integration ) {
193 require_once SP_PC_PATH . 'admin/page-builder/oxygen/init.php';
194 }
195
196 /**
197 * WPBakery.
198 */
199 if ( $wpbakery_integration && defined( 'WPB_VC_VERSION' ) ) {
200 require_once SP_PC_PATH . 'admin/page-builder/wpBakery/smart-post-show-wpbakery.php';
201 }
202
203 /**
204 * Beaver Builder.
205 */
206 if ( $beaber_integration && class_exists( 'FLBuilder' ) ) {
207 require_once SP_PC_PATH . 'admin/page-builder/beaver/smart-post-beaver.php';
208 }
209
210 /**
211 * Bricks Builder.
212 */
213 if ( $bricks_integration ) {
214 require_once SP_PC_PATH . 'admin/page-builder/bricks/init.php';
215 }
216
217 // Elementor shortcode addons.
218 require_once ABSPATH . 'wp-admin/includes/plugin.php';
219 if ( ( is_plugin_active( 'elementor/elementor.php' ) || is_plugin_active_for_network( 'elementor/elementor.php' ) ) ) {
220 require_once SP_PC_PATH . 'admin/class-smart-post-show-element-shortcode-addons.php';
221 require_once SP_PC_PATH . 'admin/class-smart-post-show-element-shortcode-addons-deprecated.php';
222 }
223
224 /**
225 * Gutenberg block.
226 */
227 if ( version_compare( $GLOBALS['wp_version'], '5.3', '>=' ) ) {
228 require_once SP_PC_PATH . 'admin/blocks-settings/class-blocks-settings-page.php';
229 new Sp_Smart_Post_Block_Admin_Menu_Page();
230
231 require_once SP_PC_PATH . 'blocks/class-smart-post-show-blocks.php';
232 Sp_Smart_Post_Blocks_Init::instance();
233
234 require_once SP_PC_PATH . 'admin/class-smart-post-show-gutenberg-block.php';
235 new Smart_Post_Show_Gutenberg_Block();
236 }
237 }
238
239 /**
240 * Define the locale for this plugin for internationalization.
241 *
242 * Uses the Smart_Post_Show_i18n class in order to set the domain and to register the hook
243 * with WordPress.
244 *
245 * @since 2.2.0
246 * @access private
247 */
248 private function set_locale() {
249
250 $plugin_i18n = new Smart_Post_Show_i18n();
251
252 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
253 }
254
255 /**
256 * Register common hooks.
257 *
258 * @since 2.2.0
259 * @access private
260 */
261 private function define_common_hooks() {
262 $common_hooks = new Smart_Post_Show_Post_Type( SP_PC_PLUGIN_NAME, SP_PC_VERSION );
263 $this->loader->add_action( 'init', $common_hooks, 'register_carousel_post_type', 10 );
264
265 // Saved Template.
266 $saved_template = new Smart_Post_Show_Saved_Template();
267 $this->loader->add_action( 'init', $saved_template, 'register_template_shortcode' );
268 }
269
270 /**
271 * Register all of the hooks related to the admin area functionality
272 * of the plugin.
273 *
274 * @since 2.2.0
275 * @access private
276 */
277 private function define_admin_hooks() {
278 $plugin_admin = new Smart_Post_Show_Admin( SP_PC_PLUGIN_NAME, SP_PC_VERSION );
279 // Load admin scripts and styles.
280 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
281 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
282 // Admin custom column.
283 $this->loader->add_filter( 'manage_sp_post_carousel_posts_columns', $plugin_admin, 'filter_carousel_admin_column' );
284 $this->loader->add_filter( 'admin_footer_text', $plugin_admin, 'sp_spc_footer_text' );
285 $this->loader->add_filter( 'update_footer', $plugin_admin, 'sp_spc_version_text', 11 );
286 $this->loader->add_action( 'manage_sp_post_carousel_posts_custom_column', $plugin_admin, 'display_carousel_admin_fields', 10, 2 );
287
288 $this->loader->add_filter( 'plugin_row_meta', $plugin_admin, 'after_pcp_row_meta', 10, 4 );
289 // Post save and update messages.
290 $this->loader->add_filter( 'post_updated_messages', $plugin_admin, 'sppcp_update', 10, 1 );
291 // Help Page.
292 SPS_Recommended::instance();
293 $import_export = new Smart_Post_Show_Import_Export( SP_PC_PLUGIN_NAME, SP_PC_VERSION );
294
295 $this->loader->add_action( 'wp_ajax_pcp_export_shortcodes', $import_export, 'export_shortcodes' );
296 $this->loader->add_action( 'wp_ajax_pcp_import_shortcodes', $import_export, 'import_shortcodes' );
297
298 // after activated plugin redirect to help page.
299 $this->loader->add_action( 'activated_plugin', $plugin_admin, 'redirect_help_page' );
300 }
301
302 /**
303 * Register all of the hooks related to the public-facing functionality
304 * of the plugin.
305 *
306 * @since 2.2.0
307 * @access private
308 */
309 private function define_public_hooks() {
310 $plugin_public = new Smart_Post_Show_Public( SP_PC_PLUGIN_NAME, SP_PC_VERSION );
311 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
312 $this->loader->add_action( 'wp_loaded', $plugin_public, 'register_all_scripts' );
313 }
314
315 /**
316 * Run the loader to execute all of the hooks with WordPress.
317 *
318 * @since 2.2.0
319 */
320 public function run() {
321 $this->loader->run();
322 }
323
324 /**
325 * The name of the plugin used to uniquely identify it within the context of
326 * WordPress and to define internationalization functionality.
327 *
328 * @since 2.2.0
329 * @return string The name of the plugin.
330 */
331 public function get_plugin_name() {
332 return $this->plugin_name;
333 }
334
335 /**
336 * The reference to the class that orchestrates the hooks with the plugin.
337 *
338 * @since 2.2.0
339 * @return Smart_Post_Show_Loader Orchestrates the hooks of the plugin.
340 */
341 public function get_loader() {
342 return $this->loader;
343 }
344
345 /**
346 * Retrieve the version number of the plugin.
347 *
348 * @since 2.2.0
349 * @return string The version number of the plugin.
350 */
351 public function get_version() {
352 return $this->version;
353 }
354 }
355