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

300 lines 9.1 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://smartpostshow.com/
12 * @since 2.2.0
13 *
14 * @package Smart_Post_Show
15 * @subpackage Smart_Post_Show/includes
16 */
17
18 /**
19 * The core plugin class that is used to define internationalization,
20 * admin-specific hooks, and public-facing site hooks.
21 */
22 class Smart_Post_Show {
23
24 /**
25 * The loader that's responsible for maintaining and registering all hooks that power
26 * the plugin.
27 *
28 * @since 2.2.0
29 * @access protected
30 * @var Smart_Post_Show_Loader $loader Maintains and registers all hooks for the plugin.
31 */
32 public $loader;
33
34 /**
35 * The unique identifier of this plugin.
36 *
37 * @since 2.2.0
38 * @access protected
39 * @var string $plugin_name The string used to uniquely identify this plugin.
40 */
41 public $plugin_name = SMART_POST_SHOW_BASENAME;
42
43 /**
44 * The current version of the plugin.
45 *
46 * @since 2.2.0
47 * @access protected
48 * @var string $version The current version of the plugin.
49 */
50 public $version = SMART_POST_SHOW_VERSION;
51
52 /**
53 * Define the core functionality of the plugin.
54 *
55 * Set the plugin name and the plugin version that can be used throughout the plugin.
56 * Load the dependencies, define the locale, and set the hooks for the admin area and
57 * the public-facing side of the site.
58 *
59 * @since 2.2.0
60 */
61 public function __construct() {
62 $this->define_constants();
63 $this->load_dependencies();
64 $this->define_common_hooks();
65 $this->define_admin_hooks();
66 $this->define_public_hooks();
67 $this->set_locale();
68 }
69 /**
70 * Define constant if not already set
71 *
72 * @since 2.2.0
73 *
74 * @param string $name Define constant.
75 * @param string|bool $value Define constant.
76 */
77 public function define( $name, $value ) {
78 if ( ! defined( $name ) ) {
79 define( $name, $value );
80 }
81 }
82
83 /**
84 * Define constants
85 *
86 * @since 2.2.0
87 */
88 public function define_constants() {
89 $this->define( 'SP_PC_VERSION', $this->version );
90 $this->define( 'SP_PC_PLUGIN_NAME', $this->plugin_name );
91 $this->define( 'SP_PC_PATH', plugin_dir_path( dirname( __FILE__ ) ) );
92 $this->define( 'SP_PC_TEMPLATE_PATH', plugin_dir_path( dirname( __FILE__ ) ) . 'public/template/' );
93 $this->define( 'SP_PC_URL', plugin_dir_url( dirname( __FILE__ ) ) );
94 $this->define( 'SMART_POST_SHOW_BASENAME', SMART_POST_SHOW_BASENAME );
95 }
96
97 /**
98 * Load the required dependencies for this plugin.
99 *
100 * Include the following files that make up the plugin:
101 *
102 * - Smart_Post_Show_Loader. Orchestrates the hooks of the plugin.
103 * - Smart_Post_Show_i18n. Defines internationalization functionality.
104 * - Smart_Post_Show_Admin. Defines all hooks for the admin area.
105 * - Smart_Post_Show_Public. Defines all hooks for the public side of the site.
106 * - Smart_Post_Show_Public. Defines all hooks for the public side of the site.
107 *
108 * Create an instance of the loader which will be used to register the hooks
109 * with WordPress.
110 *
111 * @since 2.2.0
112 * @access private
113 */
114 private function load_dependencies() {
115
116 /**
117 * The class responsible for orchestrating the actions and filters of the
118 * core plugin.
119 */
120 require_once SP_PC_PATH . 'includes/class-smart-post-show-loader.php';
121 $this->loader = new Smart_Post_Show_Loader();
122
123 /**
124 * The class responsible for defining internationalization functionality
125 * of the plugin.
126 */
127 require_once SP_PC_PATH . 'includes/class-smart-post-show-i18n.php';
128
129 /**
130 * The class responsible for defining internationalization functionality
131 * of the plugin.
132 */
133 require_once SP_PC_PATH . 'includes/class-smart-post-show-post-types.php';
134
135 /**
136 * The class responsible for updates functionality of the plugin.
137 */
138 require_once SP_PC_PATH . 'includes/class-smart-post-show-updates.php';
139
140 /**
141 * The class responsible for Export Import functionality of the plugin.
142 */
143 require_once SP_PC_PATH . 'includes/class-smart-post-show-import-export.php';
144
145 /**
146 * The class responsible for defining all actions that occur in the admin area.
147 */
148 require_once SP_PC_PATH . 'admin/class-smart-post-show-admin.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 review notice.
164 */
165 require_once SP_PC_PATH . 'admin/views/notices/review.php';
166
167 // Elementor shortcode addons.
168 require_once ABSPATH . 'wp-admin/includes/plugin.php';
169 if ( ( is_plugin_active( 'elementor/elementor.php' ) || is_plugin_active_for_network( 'elementor/elementor.php' ) ) ) {
170 require_once SP_PC_PATH . 'admin/class-smart-post-show-element-shortcode-addons.php';
171 }
172
173 /**
174 * Gutenberg block.
175 */
176 if ( version_compare( $GLOBALS['wp_version'], '5.3', '>=' ) ) {
177 require_once SP_PC_PATH . 'admin/class-smart-post-show-gutenberg-block.php';
178 new Smart_Post_Show_Gutenberg_Block();
179 }
180
181 }
182
183 /**
184 * Define the locale for this plugin for internationalization.
185 *
186 * Uses the Smart_Post_Show_i18n class in order to set the domain and to register the hook
187 * with WordPress.
188 *
189 * @since 2.2.0
190 * @access private
191 */
192 private function set_locale() {
193
194 $plugin_i18n = new Smart_Post_Show_i18n();
195
196 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
197
198 }
199
200 /**
201 * Register common hooks.
202 *
203 * @since 2.2.0
204 * @access private
205 */
206 private function define_common_hooks() {
207 $common_hooks = new Smart_Post_Show_Post_Type( SP_PC_PLUGIN_NAME, SP_PC_VERSION );
208 $this->loader->add_action( 'init', $common_hooks, 'register_carousel_post_type', 10 );
209 }
210
211 /**
212 * Register all of the hooks related to the admin area functionality
213 * of the plugin.
214 *
215 * @since 2.2.0
216 * @access private
217 */
218 private function define_admin_hooks() {
219 $plugin_admin = new Smart_Post_Show_Admin( SP_PC_PLUGIN_NAME, SP_PC_VERSION );
220 // Load admin scripts and styles.
221 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
222 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
223 // Admin custom column.
224 $this->loader->add_filter( 'manage_sp_post_carousel_posts_columns', $plugin_admin, 'filter_carousel_admin_column' );
225 $this->loader->add_action( 'manage_sp_post_carousel_posts_custom_column', $plugin_admin, 'display_carousel_admin_fields', 10, 2 );
226
227 $this->loader->add_filter( 'plugin_row_meta', $plugin_admin, 'after_pcp_row_meta', 10, 4 );
228 // Post save and update messages.
229 $this->loader->add_filter( 'post_updated_messages', $plugin_admin, 'sppcp_update', 10, 1 );
230 // Help Page.
231 $help_menu = new SPS_Help();
232 $this->loader->add_action( 'admin_menu', $help_menu, 'help_page_menu', 25 );
233 // Premium Page.
234 $premium_menu = new SPS_Premium();
235 $this->loader->add_action( 'admin_menu', $premium_menu, 'premium_page_menu', 20 );
236
237 $import_export = new Smart_Post_Show_Import_Export( SP_PC_PLUGIN_NAME, SP_PC_VERSION );
238
239 $this->loader->add_action( 'wp_ajax_pcp_export_shortcodes', $import_export, 'export_shortcodes' );
240 $this->loader->add_action( 'wp_ajax_pcp_import_shortcodes', $import_export, 'import_shortcodes' );
241
242 // after activated plugin redirect to help page.
243 $this->loader->add_action( 'activated_plugin', $plugin_admin, 'redirect_help_page' );
244 }
245
246 /**
247 * Register all of the hooks related to the public-facing functionality
248 * of the plugin.
249 *
250 * @since 2.2.0
251 * @access private
252 */
253 private function define_public_hooks() {
254 $plugin_public = new Smart_Post_Show_Public( SP_PC_PLUGIN_NAME, SP_PC_VERSION );
255 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
256 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
257 }
258
259 /**
260 * Run the loader to execute all of the hooks with WordPress.
261 *
262 * @since 2.2.0
263 */
264 public function run() {
265 $this->loader->run();
266 }
267
268 /**
269 * The name of the plugin used to uniquely identify it within the context of
270 * WordPress and to define internationalization functionality.
271 *
272 * @since 2.2.0
273 * @return string The name of the plugin.
274 */
275 public function get_plugin_name() {
276 return $this->plugin_name;
277 }
278
279 /**
280 * The reference to the class that orchestrates the hooks with the plugin.
281 *
282 * @since 2.2.0
283 * @return Smart_Post_Show_Loader Orchestrates the hooks of the plugin.
284 */
285 public function get_loader() {
286 return $this->loader;
287 }
288
289 /**
290 * Retrieve the version number of the plugin.
291 *
292 * @since 2.2.0
293 * @return string The version number of the plugin.
294 */
295 public function get_version() {
296 return $this->version;
297 }
298
299 }
300