PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 2.5.3
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v2.5.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.5.3, at inc/init.php

239 lines 9.8 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 add_action('wp_enqueue_scripts', array($this,'blockspare_load_scripts'));
31 add_action('plugins_loaded', array($this,'blockspare_blocks_loader'));
32 add_action( 'rest_api_init', array($this,'blockspare_blocks_register_api_endpoints' ));
33
34
35 }
36
37 function blockspare_blocks_block_assets(){
38 wp_enqueue_style(
39 'blockspare-blocks-fontawesome-front',
40 plugins_url('assets/fontawesome/css/all.css', dirname(__FILE__)),
41 array()
42 );
43 // Load the compiled styles.
44 wp_enqueue_style(
45 'blockspare-frontend-block-style-css',
46 plugins_url('dist/style-blocks.css', dirname(__FILE__)),
47 array()
48 );
49
50
51 wp_enqueue_style('slick-css', BLOCKSPARE_PLUGIN_URL . 'assets/slick/css/slick.css', array(), '', 'all');
52 }
53
54 function blockspare_load_scripts(){
55 $min = (SCRIPT_DEBUG == true) ? '' : '.min';
56 wp_enqueue_script('slick-js', BLOCKSPARE_PLUGIN_URL . 'assets/slick/js/slick.js', array('jquery'), '', true);
57 wp_register_script('countup', BLOCKSPARE_PLUGIN_URL . 'assets/js/countup/jquery.counterup' . $min . '.js', array('waypoint'), true);
58 wp_enqueue_script('waypoint', BLOCKSPARE_PLUGIN_URL . 'assets/js/countup/waypoints.min.js', array('jquery'), '', true);
59 wp_enqueue_script('jquery-masonry');
60 wp_enqueue_script('blockspare-animation', BLOCKSPARE_PLUGIN_URL . 'dist/block_animation.js', array(), '', true);
61 wp_enqueue_script('blockspare-script', BLOCKSPARE_PLUGIN_URL . 'dist/block_frontend.js', array('jquery', 'waypoint', 'countup'), '', true);
62 wp_enqueue_script('blockspare-tabs', BLOCKSPARE_PLUGIN_URL . 'dist/block_tabs.js', array('jquery'), '', true);
63 wp_enqueue_script('blockspare-pagination-js', BLOCKSPARE_PLUGIN_URL . 'dist/block_pagination.js', array(), '', true);
64
65 wp_localize_script('blockspare-pagination-js', 'blocsparePagination',array(
66 'ajaxurl' => admin_url( 'admin-ajax.php' ),
67 'nonce'=>wp_create_nonce('blockspare-load-more-nonce')
68 ));
69 }
70
71 function blockspare_create_block(){
72
73 $script_dep_path = BLOCKSPARE_BASE_DIR . 'dist/blocks.asset.php';
74 $script_info = file_exists($script_dep_path) ? include $script_dep_path : array(
75 'dependencies' => array() ,
76 'version' => BLOCKSPARE_VERSION,
77 );
78 if (version_compare(get_bloginfo('version') , '5.8', '<'))
79 {
80 $script_dep = array_merge($script_info['dependencies'],array(
81 'wp-blocks',
82 'wp-i18n',
83 'wp-element',
84 'wp-components',
85 'wp-editor',
86 'wp-api-fetch'
87 ));
88 }
89 else
90 {
91 $script_dep = $script_info['dependencies'];
92 }
93
94 wp_enqueue_script('blockspare-blocks-block-js', // Handle.
95 BLOCKSPARE_PLUGIN_URL . 'dist/blocks.js', $script_dep, // Dependencies, defined above.
96 $script_info['version'], // AFT_PRICING_TABLE_VERSION.
97 true
98 // Enqueue the script in the footer.
99 );
100
101 if (is_admin()) :
102 wp_enqueue_style(
103 'blockspare-block-edit-style',
104 BLOCKSPARE_PLUGIN_URL . 'dist/blocks.css',
105 array('wp-edit-blocks')
106 );
107 endif;
108
109
110 $blockspare_priview_img_url = BLOCKSPARE_PLUGIN_URL . 'assets/blockspare-placeholder-img.jpg';
111 $blockspare_food_img_url = BLOCKSPARE_PLUGIN_URL . 'assets/blockspare-placeholder-img-square.jpg';
112
113 $taxonomies = get_categories();
114 $txnm = array();
115
116 foreach( $taxonomies as $type ) {
117
118
119 $txnm[] = array(
120 'label' => $type->name,
121 'value' => $type->term_id,
122 );
123 }
124
125
126 wp_localize_script(
127 'blockspare-blocks-block-js',
128 'blockspare_globals',
129 array(
130 'srcUrl' => untrailingslashit(plugins_url('/', BLOCKSPARE_BASE_DIR . '/dist/')),
131 'rest_url' => esc_url(rest_url()),
132 'img' => $blockspare_priview_img_url,
133 'menu_img_url' => $blockspare_food_img_url,
134 'postTypes' => $this->aft_get_post_types(),
135 'taxonomies' => $this->aft_get_taxonomies(),
136 'postQueryEndpoint'=>'aft/v1/post-query',
137 'config' => '',
138 'configuration' => '',
139 'settings' => '',
140 )
141 );
142 }
143
144 function aft_get_post_types(){
145 $args = array(
146 'public' => true,
147 'show_in_rest' => true,
148 );
149 $post_types = get_post_types( $args, 'objects' );
150 $output = array();
151 foreach ( $post_types as $post_type ) {
152
153 if ( 'attachment' == $post_type->name ) {
154 continue;
155 }
156 $output[] = array(
157 'value' => $post_type->name,
158 'label' => $post_type->label,
159 );
160 }
161
162 return apply_filters( 'aft_blocks_post_types', $output );
163 }
164
165
166
167 function aft_get_taxonomies() {
168 $post_types = $this->aft_get_post_types();
169 $output = array();
170 foreach ( $post_types as $key => $post_type ) {
171 $taxonomies = get_object_taxonomies( $post_type['value'], 'objects' );
172 $taxs = array();
173 foreach ( $taxonomies as $term_slug => $term ) {
174 if ( ! $term->public || ! $term->show_ui ) {
175 continue;
176 }
177 $taxs[ $term_slug ] = $term;
178 $terms = get_terms( $term_slug );
179 $term_items = array();
180 if ( ! empty( $terms ) ) {
181 foreach ( $terms as $term_key => $term_item ) {
182 $term_items[] = array(
183 'value' => $term_item->term_id,
184 'label' => $term_item->name,
185 );
186 }
187 $output[ $post_type['value'] ]['terms'][ $term_slug ] = $term_items;
188 }
189 }
190 $output[ $post_type['value'] ]['taxonomy'] = $taxs;
191 }
192
193 return apply_filters( 'aft_blocks_taxonomies', $output );
194 }
195
196 function blockspare_blocks_loader(){
197
198 //Load Gutenberg Block php Files
199 include(BLOCKSPARE_PLUGIN_DIR . 'inc/other-block/date-time/index.php');
200 include(BLOCKSPARE_PLUGIN_DIR . '/inc/other-block/social-sharing/index.php');
201 include(BLOCKSPARE_PLUGIN_DIR . '/inc/latest-post-block/posts-grid/index.php');
202 include(BLOCKSPARE_PLUGIN_DIR . '/inc/latest-post-block/posts-list/index.php');
203
204 include(BLOCKSPARE_PLUGIN_DIR . '/inc/latest-post-block/posts-express-grid/index.php');
205
206
207 include(BLOCKSPARE_PLUGIN_DIR . '/inc/latest-post-block/posts-carousel-grid/index.php');
208 include(BLOCKSPARE_PLUGIN_DIR . '/inc/latest-post-block/posts-slider/index.php');
209
210 include(BLOCKSPARE_PLUGIN_DIR . '/inc/post-banner/banner-1/index.php');
211 include(BLOCKSPARE_PLUGIN_DIR . '/inc/post-banner/banner-2/index.php');
212 include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-posts-config/ajax-pagination.php');
213 include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-posts-config/class-post-rest-api.php');
214 include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-posts-config/class-multiauthor-backend.php');
215 include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-posts-config/class-multiauthor-frontend.php');
216 include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-posts-config/tax-category.php');
217 include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-posts-config/class-bs-post.php');
218 include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-banner/frontend-render/post-banner-config.php');
219 include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-banner/frontend-render/post-banner-style.php');
220 include(BLOCKSPARE_PLUGIN_DIR . 'inc/other-block/search/index.php');
221 include(BLOCKSPARE_PLUGIN_DIR . 'inc/latest-post-block/posts-flash/index.php');
222 include(BLOCKSPARE_PLUGIN_DIR . 'inc/other-block/popular-tags/index.php');
223 include(BLOCKSPARE_PLUGIN_DIR . 'inc/page-templates/module.php');
224 }
225
226 function blockspare_blocks_register_api_endpoints(){
227
228 $posts_controller = new Aft_Post_Rest_Controller();
229 $posts_controller->register_routes();
230
231
232 }
233
234 }
235 BlockspareInit::get_instance();
236 }
237
238
239