PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 2.7.3
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v2.7.3
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
blockspare / inc / init.php

init.php in BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites 2.7.3, at inc/init.php

311 lines 13.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 //Exit if directly acess
4 defined('ABSPATH') or die('No script kiddies please!');
5
6 if(!class_exists('BlockspareInit')){
7 class BlockspareInit{
8 /**
9 * Member Variable
10 *
11 * @var instance
12 */
13 private static $instance;
14
15 /**
16 * Initiator
17 */
18 public static function get_instance()
19 {
20 if (!isset(self::$instance))
21 {
22 self::$instance = new self();
23 }
24 return self::$instance;
25 }
26 public function __construct()
27 {
28 add_action('init', array($this, 'blockspare_blocks_block_assets' ));
29 add_action('enqueue_block_editor_assets', array($this,'blockspare_create_block'));
30 if (version_compare(get_bloginfo('version') , '5.8', '<')) {
31 add_action('wp_enqueue_scripts', array($this,'blockspare_load_scripts'));
32 }else{
33 add_action('enqueue_block_assets', array($this,'blockspare_load_scripts'));
34 }
35 add_action('plugins_loaded', array($this,'blockspare_blocks_loader'));
36 add_action( 'rest_api_init', array($this,'blockspare_blocks_register_api_endpoints' ));
37
38
39 }
40
41 function blockspare_blocks_block_assets(){
42 wp_register_style(
43 'fontawesome',
44 plugins_url('assets/fontawesome/css/all.css', dirname(__FILE__)),
45 array()
46
47 );
48 // Load the compiled styles.
49 wp_enqueue_style(
50 'blockspare-frontend-block-style-css',
51 plugins_url('dist/style-blocks.css', dirname(__FILE__)),
52 array()
53 );
54
55 wp_register_style('slick', BLOCKSPARE_PLUGIN_URL . 'assets/slick/css/slick.css', array(), '', 'all');
56 if (is_admin()){
57 wp_enqueue_style('slick');
58 }
59
60 include(BLOCKSPARE_PLUGIN_DIR . '/admin/notice-upgrade.php');
61 }
62
63 function blockspare_load_scripts(){
64
65 wp_register_style(
66 'fontawesome',
67 plugins_url('assets/fontawesome/css/all.css', dirname(__FILE__)),
68 array()
69
70 );
71 // Load the compiled styles.
72 wp_enqueue_style(
73 'blockspare-frontend-block-style-css',
74 plugins_url('dist/style-blocks.css', dirname(__FILE__)),
75 array()
76 );
77
78 wp_register_style('slick', BLOCKSPARE_PLUGIN_URL . 'assets/slick/css/slick.css', array(), '', 'all');
79 if (is_admin()){
80 wp_enqueue_style('slick');
81 }
82 //if(has_blocks()){
83
84 wp_enqueue_style('fontawesome');
85 $min = (SCRIPT_DEBUG == true) ? '' : '.min';
86 wp_register_script('slick', BLOCKSPARE_PLUGIN_URL . 'assets/slick/js/slick.js', array('jquery'), '', true);
87 if(has_block('blockspare/blockspare-carousel' )|| has_block('blockspare/blockspare-slider' ) || has_block('blockspare/latest-posts-block-carousel-grid') || has_block('blockspare/blockspare-posts-block-slider')){
88 wp_enqueue_script('slick');
89 wp_enqueue_style('slick');
90
91 }
92
93 wp_register_script('countup', BLOCKSPARE_PLUGIN_URL . 'assets/js/countup/jquery.counterup' . $min . '.js', array('waypoint'), true);
94 wp_enqueue_script('waypoint', BLOCKSPARE_PLUGIN_URL . 'assets/js/countup/waypoints.min.js', array('jquery'), '', true);
95
96 if(has_block('blockspare/blockspare-masonry')){
97 wp_enqueue_script('jquery-masonry');
98 }
99 wp_enqueue_script('blockspare-animation', BLOCKSPARE_PLUGIN_URL . 'dist/block_animation.js', array(), '', true);
100 wp_enqueue_script('blockspare-script', BLOCKSPARE_PLUGIN_URL . 'dist/block_frontend.js', array('jquery', 'waypoint', 'countup'), '', true);
101 if(has_block('blockspare/blockspare-tabs')){
102 wp_enqueue_script('blockspare-tabs', BLOCKSPARE_PLUGIN_URL . 'dist/block_tabs.js', array('jquery'), '', true);
103 }
104 wp_register_script('blockspare-pagination-js', BLOCKSPARE_PLUGIN_URL . 'dist/block_pagination.js', array(), '', true);
105 wp_localize_script('blockspare-pagination-js', 'blocsparePagination',array(
106 'ajaxurl' => admin_url( 'admin-ajax.php' ),
107 'nonce'=>wp_create_nonce('blockspare-load-more-nonce')
108 ));
109 //}
110
111
112 }
113
114 function blockspare_create_block(){
115
116 $script_dep_path = BLOCKSPARE_BASE_DIR . 'dist/blocks.asset.php';
117 $script_info = file_exists($script_dep_path) ? include $script_dep_path : array(
118 'dependencies' => array() ,
119 'version' => BLOCKSPARE_VERSION,
120 );
121 if (version_compare(get_bloginfo('version') , '5.8', '<'))
122 {
123 $script_dep = array_merge($script_info['dependencies'],array(
124 'wp-blocks',
125 'wp-i18n',
126 'wp-element',
127 'wp-components',
128 'wp-editor',
129 'wp-api-fetch'
130 ));
131 }
132 else
133 {
134 $script_dep = $script_info['dependencies'];
135 }
136
137 wp_enqueue_script('blockspare-blocks-block-js', // Handle.
138 BLOCKSPARE_PLUGIN_URL . 'dist/blocks.js', $script_dep, // Dependencies, defined above.
139 $script_info['version'], // AFT_PRICING_TABLE_VERSION.
140 true
141 // Enqueue the script in the footer.
142 );
143
144 if (is_admin()) :
145 wp_enqueue_style('fontawesome');
146 wp_enqueue_style(
147 'blockspare-block-edit-style',
148 BLOCKSPARE_PLUGIN_URL . 'dist/blocks.css',
149 array('wp-edit-blocks')
150 );
151 wp_enqueue_script('blockspare-design-btn', BLOCKSPARE_PLUGIN_URL.'dist/block_design_btn.js',array( 'blockspare-blocks-block-js'), $script_info['version'], true);
152 wp_enqueue_script('blockspare-design', BLOCKSPARE_PLUGIN_URL.'dist/block_design.js',array( 'blockspare-blocks-block-js'), $script_info['version'], true);
153 wp_enqueue_style('blockspare-design', BLOCKSPARE_PLUGIN_URL.'dist/block_design.css',array( 'blockspare-block-edit-style'));
154 endif;
155
156
157 $blockspare_priview_img_url = BLOCKSPARE_PLUGIN_URL . 'assets/blockspare-placeholder-img.jpg';
158 $blockspare_food_img_url = BLOCKSPARE_PLUGIN_URL . 'assets/blockspare-placeholder-img-square.jpg';
159 $blockspare_dashboard_logo = BLOCKSPARE_PLUGIN_URL . 'assets/images/blockspare-logo.png';
160 $taxonomies = get_categories();
161 $txnm = array();
162
163 foreach( $taxonomies as $type ) {
164
165
166 $txnm[] = array(
167 'label' => $type->name,
168 'value' => $type->term_id,
169 );
170 }
171
172 $date = wp_kses_post(date_i18n(get_option('date_format')));
173 wp_localize_script(
174 'blockspare-blocks-block-js',
175 'blockspare_globals',
176 array(
177 'srcUrl' => untrailingslashit(plugins_url('/', BLOCKSPARE_BASE_DIR . '/dist/')),
178 'rest_url' => esc_url(rest_url()),
179 'img' => $blockspare_priview_img_url,
180 'homeUrl'=>home_url(),
181 'blogUrl'=>get_site_url(),
182 'menu_img_url' => $blockspare_food_img_url,
183 'logo'=>$blockspare_dashboard_logo,
184 'postTypes' => $this->aft_get_post_types(),
185 'taxonomies' => $this->aft_get_taxonomies(),
186 'postQueryEndpoint'=>'aft/v1/post-query',
187 'config' => '',
188 'configuration' => '',
189 'settings' => '',
190 'bs_date'=>$date,
191 "imagePath"=> "https://templatespare.com/wp-content/uploads/blockspare/blocks/"
192 )
193 );
194 }
195
196 function aft_get_post_types(){
197 $args = array(
198 'public' => true,
199 'show_in_rest' => true,
200 );
201 $post_types = get_post_types( $args, 'objects' );
202 $output = array();
203 foreach ( $post_types as $post_type ) {
204
205 if ( 'attachment' == $post_type->name ) {
206 continue;
207 }
208 $output[] = array(
209 'value' => $post_type->name,
210 'label' => $post_type->label,
211 );
212 }
213
214 return apply_filters( 'aft_blocks_post_types', $output );
215 }
216
217
218
219 function aft_get_taxonomies() {
220 $post_types = $this->aft_get_post_types();
221 $output = array();
222 foreach ( $post_types as $key => $post_type ) {
223 $taxonomies = get_object_taxonomies( $post_type['value'], 'objects' );
224 $taxs = array();
225 foreach ( $taxonomies as $term_slug => $term ) {
226 if ( ! $term->public || ! $term->show_ui ) {
227 continue;
228 }
229 $taxs[ $term_slug ] = $term;
230 $terms = get_terms( $term_slug );
231 $term_items = array();
232 if ( ! empty( $terms ) ) {
233 foreach ( $terms as $term_key => $term_item ) {
234 $term_items[] = array(
235 'value' => $term_item->term_id,
236 'label' => $term_item->name,
237 );
238 }
239 $output[ $post_type['value'] ]['terms'][ $term_slug ] = $term_items;
240 }
241 }
242 $output[ $post_type['value'] ]['taxonomy'] = $taxs;
243 }
244
245 return apply_filters( 'aft_blocks_taxonomies', $output );
246 }
247
248 function blockspare_blocks_loader(){
249
250 if ( PHP_VERSION_ID >= 50600 ) {
251 require_once BLOCKSPARE_PLUGIN_DIR .'inc/layout/class-image-importer.php';
252 require_once BLOCKSPARE_PLUGIN_DIR . 'inc/layout/functions.php';
253 require_once BLOCKSPARE_PLUGIN_DIR . 'inc/layout/registry.php';
254 require_once BLOCKSPARE_PLUGIN_DIR . 'inc/layout/components.php';
255
256 /**
257 * REST API Endpoints for Layouts.
258 */
259 require_once BLOCKSPARE_PLUGIN_DIR . 'inc/layout/endpoints.php';
260
261 /**
262 * Import Pattern
263 */
264
265 //require_once BLOCKSPARE_PLUGIN_DIR . 'inc/pattern/pattern.php';
266 }
267
268 //Load Gutenberg Block php Files
269 include(BLOCKSPARE_PLUGIN_DIR . 'inc/other-block/date-time/index.php');
270 include(BLOCKSPARE_PLUGIN_DIR . '/inc/other-block/social-sharing/index.php');
271 include(BLOCKSPARE_PLUGIN_DIR . '/inc/latest-post-block/posts-grid/index.php');
272 include(BLOCKSPARE_PLUGIN_DIR . '/inc/latest-post-block/posts-list/index.php');
273
274 include(BLOCKSPARE_PLUGIN_DIR . '/inc/latest-post-block/posts-express-grid/index.php');
275 include(BLOCKSPARE_PLUGIN_DIR . '/inc/latest-post-block/posts-express-grid/post-content.php');
276
277
278 include(BLOCKSPARE_PLUGIN_DIR . '/inc/latest-post-block/posts-carousel-grid/index.php');
279 include(BLOCKSPARE_PLUGIN_DIR . '/inc/latest-post-block/posts-slider/index.php');
280
281 include(BLOCKSPARE_PLUGIN_DIR . '/inc/post-banner/banner-1/index.php');
282 include(BLOCKSPARE_PLUGIN_DIR . '/inc/post-banner/banner-2/index.php');
283 include(BLOCKSPARE_PLUGIN_DIR . '/inc/post-banner/banner-9/index.php');
284 include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-posts-config/ajax-pagination.php');
285 include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-posts-config/class-post-rest-api.php');
286 include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-posts-config/class-multiauthor-backend.php');
287 include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-posts-config/class-multiauthor-frontend.php');
288 include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-posts-config/tax-category.php');
289 include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-posts-config/class-bs-post.php');
290 include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-banner/frontend-render/post-banner-config.php');
291 include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-banner/frontend-render/post-banner-style.php');
292 include(BLOCKSPARE_PLUGIN_DIR . 'inc/other-block/search/index.php');
293 include(BLOCKSPARE_PLUGIN_DIR . 'inc/latest-post-block/posts-flash/index.php');
294 include(BLOCKSPARE_PLUGIN_DIR . 'inc/other-block/popular-tags/index.php');
295 include(BLOCKSPARE_PLUGIN_DIR . 'inc/page-templates/module.php');
296 }
297
298 function blockspare_blocks_register_api_endpoints(){
299
300 $posts_controller = new Aft_Post_Rest_Controller();
301 $posts_controller->register_routes();
302
303
304 }
305
306 }
307 BlockspareInit::get_instance();
308 }
309
310
311