PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 1.3.5
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v1.3.5
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
← All changes | src/init.php +95 -174 2.1.21.3.5 View file →
@@ -1,108 +1,89 @@
1 1 <?php
2 -
2 +
3 3 //Exit if directly acess
4 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()
5 +
6 +
7 + function blockspare_blocks_block_assets()
8 + {
9 +
10 + $min = (SCRIPT_DEBUG == true) ? '' : '.min';
11 +
12 + // Load the compiled styles.
13 + wp_enqueue_style(
14 + 'blockspare-frontend-block-style-css',
15 + plugins_url('dist/blocks.style.build.css', dirname(__FILE__)),
16 + array()
17 + );
18 +
19 + }
20 +
21 + add_action('init', 'blockspare_blocks_block_assets');
22 +
23 +
24 + add_action('wp_enqueue_scripts', 'blockspare_load_scripts');
25 +
26 + function blockspare_load_scripts(){
27 +
28 + $min = (SCRIPT_DEBUG == true) ? '' : '.min';
29 +
30 + wp_enqueue_style(
31 + 'blockspare-blocks-fontawesome-front',
32 + plugins_url('src/assets/fontawesome/css/all.css', dirname(__FILE__)),
33 + array(),
34 + filemtime(plugin_dir_path(__FILE__) . 'assets/fontawesome/css/all.css')
35 + );
36 +
37 + wp_enqueue_style('slick', BLOCKSPARE_PLUGIN_URL . 'src/assets/slick/css/slick.css', array(), '', 'all');
38 + wp_enqueue_script('slick-js', BLOCKSPARE_PLUGIN_URL . 'src/assets/slick/js/slick.js', array('jquery'), '', true);
39 + wp_register_script('countup', BLOCKSPARE_PLUGIN_URL . 'src/assets/js/countup/jquery.counterup' . $min . '.js', array('waypoint'), true);
40 +
41 + wp_enqueue_script('waypoint', BLOCKSPARE_PLUGIN_URL . 'src/assets/js/countup/waypoints.min.js', array('jquery'), '', true);
42 + wp_enqueue_script('jquery-masonry');
43 +
44 + wp_enqueue_script('blockspare-script', BLOCKSPARE_PLUGIN_URL . 'src/assets/js/frontend.js', array('jquery', 'waypoint', 'countup'), '', true);
45 +
46 + wp_enqueue_script('blockspare-tabs', BLOCKSPARE_PLUGIN_URL . 'src/assets/js/tabs.js', array('jquery'), '', true);
47 +
48 + }
49 +
50 + if (!function_exists('blockspare_create_block')) {
51 +
52 +
53 + function blockspare_create_block()
19 54 {
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 - function blockspare_blocks_block_assets(){
36 - wp_enqueue_style(
37 - 'blockspare-blocks-fontawesome-front',
38 - plugins_url('src/assets/fontawesome/css/all.css', dirname(__FILE__)),
39 - array(),
40 - filemtime(plugin_dir_path(__FILE__) . 'assets/fontawesome/css/all.css')
55 +
56 + $min = (SCRIPT_DEBUG == true) ? '' : '.min';
57 + // Register our block script with WordPress
58 + wp_enqueue_script(
59 + 'blockspare-blocks-block-js',
60 + BLOCKSPARE_PLUGIN_URL . 'dist/blocks.build.js',
61 + array('wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-editor')
41 62 );
42 - // Load the compiled styles.
43 - wp_enqueue_style(
44 - 'blockspare-frontend-block-style-css',
45 - plugins_url('dist/style-blocks.css', dirname(__FILE__)),
46 - array()
47 - );
48 63
49 64
50 - wp_enqueue_style('slick-css', BLOCKSPARE_PLUGIN_URL . 'src/assets/slick/css/slick.css', array(), '', 'all');
51 - }
52 -
53 - function blockspare_load_scripts(){
54 - $min = (SCRIPT_DEBUG == true) ? '' : '.min';
55 - wp_enqueue_script('slick-js', BLOCKSPARE_PLUGIN_URL . 'src/assets/slick/js/slick.js', array('jquery'), '', true);
56 - wp_register_script('countup', BLOCKSPARE_PLUGIN_URL . 'src/assets/js/countup/jquery.counterup' . $min . '.js', array('waypoint'), true);
57 - wp_enqueue_script('waypoint', BLOCKSPARE_PLUGIN_URL . 'src/assets/js/countup/waypoints.min.js', array('jquery'), '', true);
58 - wp_enqueue_script('jquery-masonry');
59 - wp_enqueue_script('blockspare-script', BLOCKSPARE_PLUGIN_URL . 'src/assets/js/frontend.js', array('jquery', 'waypoint', 'countup'), '', true);
60 - wp_enqueue_script('blockspare-tabs', BLOCKSPARE_PLUGIN_URL . 'src/assets/js/tabs.js', array('jquery'), '', true);
61 - }
62 -
63 - function blockspare_create_block(){
64 -
65 - $script_dep_path = BLOCKSPARE_BASE_DIR . 'dist/blocks.asset.php';
66 - $script_info = file_exists($script_dep_path) ? include $script_dep_path : array(
67 - 'dependencies' => array() ,
68 - 'version' => BLOCKSPARE_VERSION,
69 - );
70 - if (version_compare(get_bloginfo('version') , '5.8', '<'))
71 - {
72 - $script_dep = array_merge($script_info['dependencies'],array(
73 - 'wp-blocks',
74 - 'wp-i18n',
75 - 'wp-element',
76 - 'wp-components',
77 - 'wp-editor',
78 - 'wp-api-fetch'
79 - ));
80 - }
81 - else
82 - {
83 - $script_dep = $script_info['dependencies'];
84 - }
85 -
86 - wp_enqueue_script('blockspare-blocks-block-js', // Handle.
87 - BLOCKSPARE_PLUGIN_URL . 'dist/blocks.js', $script_dep, // Dependencies, defined above.
88 - $script_info['version'], // AFT_PRICING_TABLE_VERSION.
89 - true
90 - // Enqueue the script in the footer.
91 - );
92 -
65 + // Register our block's editor-specific CSS
93 66 if (is_admin()) :
94 67 wp_enqueue_style(
95 68 'blockspare-block-edit-style',
96 - BLOCKSPARE_PLUGIN_URL . 'dist/blocks.css',
69 + BLOCKSPARE_PLUGIN_URL . 'dist/blocks.editor.build.css',
97 70 array('wp-edit-blocks')
98 71 );
99 72 endif;
100 73
74 + wp_enqueue_style(
75 + 'blockspare-blocks-fontawesome',
76 + plugins_url('src/assets/fontawesome/css/all.css', dirname(__FILE__)),
77 + array(),
78 + filemtime(plugin_dir_path(__FILE__) . 'assets/fontawesome/css/all.css')
79 + );
80 +
101 81
102 - $blockspare_priview_img_url = BLOCKSPARE_PLUGIN_URL . 'src/assets/blockspare-placeholder-img.jpg';
82 + $blockspare_priview_img_url = BLOCKSPARE_PLUGIN_URL . 'dist/images/blockspare-placeholder-img.jpg';
103 83 $blockspare_food_img_url = BLOCKSPARE_PLUGIN_URL . 'src/assets/blockspare-placeholder-img-square.jpg';
104 84
85 +
105 86 $taxonomies = get_categories();
106 87 $txnm = array();
107 88
108 89 foreach( $taxonomies as $type ) {
@@ -112,10 +93,9 @@
112 93 'label' => $type->name,
113 94 'value' => $type->term_id,
114 95 );
115 96 }
116 -
117 -
97 +
118 98 wp_localize_script(
119 99 'blockspare-blocks-block-js',
120 100 'blockspare_globals',
121 101 array(
@@ -122,11 +102,9 @@
122 102 'srcUrl' => untrailingslashit(plugins_url('/', BLOCKSPARE_BASE_DIR . '/dist/')),
123 103 'rest_url' => esc_url(rest_url()),
124 104 'img' => $blockspare_priview_img_url,
125 105 'menu_img_url' => $blockspare_food_img_url,
126 - 'postTypes' => $this->aft_get_post_types(),
127 - 'taxonomies' => $this->aft_get_taxonomies(),
128 - 'postQueryEndpoint'=>'aft/v1/post-query',
106 + 'taxonomies'=> json_encode($txnm),
129 107 'config' => '',
130 108 'configuration' => '',
131 109 'settings' => '',
132 110 )
@@ -131,96 +109,39 @@
131 109 'settings' => '',
132 110 )
133 111 );
134 112 }
135 -
136 - function aft_get_post_types(){
137 - $args = array(
138 - 'public' => true,
139 - 'show_in_rest' => true,
140 - );
141 - $post_types = get_post_types( $args, 'objects' );
142 - $output = array();
143 - foreach ( $post_types as $post_type ) {
144 -
145 - if ( 'attachment' == $post_type->name ) {
146 - continue;
147 - }
148 - $output[] = array(
149 - 'value' => $post_type->name,
150 - 'label' => $post_type->label,
151 - );
152 - }
153 -
154 - return apply_filters( 'aft_blocks_post_types', $output );
155 - }
156 -
157 - function aft_get_taxonomies() {
158 - $post_types = $this->aft_get_post_types();
159 - $output = array();
160 - foreach ( $post_types as $key => $post_type ) {
161 - $taxonomies = get_object_taxonomies( $post_type['value'], 'objects' );
162 - $taxs = array();
163 - foreach ( $taxonomies as $term_slug => $term ) {
164 - if ( ! $term->public || ! $term->show_ui ) {
165 - continue;
166 - }
167 - $taxs[ $term_slug ] = $term;
168 - $terms = get_terms( $term_slug );
169 - $term_items = array();
170 - if ( ! empty( $terms ) ) {
171 - foreach ( $terms as $term_key => $term_item ) {
172 - $term_items[] = array(
173 - 'value' => $term_item->term_id,
174 - 'label' => $term_item->name,
175 - );
176 - }
177 - $output[ $post_type['value'] ]['terms'][ $term_slug ] = $term_items;
178 - }
179 - }
180 - $output[ $post_type['value'] ]['taxonomy'] = $taxs;
181 - }
182 -
183 - return apply_filters( 'aft_blocks_taxonomies', $output );
184 - }
185 -
186 - function blockspare_blocks_loader(){
187 -
113 +
114 + add_action('enqueue_block_editor_assets', 'blockspare_create_block');
115 +
116 + }
117 +
118 +
119 +
120 +
121 + function blockspare_blocks_loader()
122 + {
123 +
188 124 //Load Gutenberg Block php Files
189 125 include(BLOCKSPARE_PLUGIN_DIR . '/src/blocks/social-sharing/index.php');
190 126 include(BLOCKSPARE_PLUGIN_DIR . '/src/blocks/latest-posts-grid/index.php');
191 127 include(BLOCKSPARE_PLUGIN_DIR . '/src/blocks/latest-posts-list/index.php');
128 + //include(BLOCKSPARE_PLUGIN_DIR . '/src/blocks/pattern/pattern.php');
192 129
193 - include(BLOCKSPARE_PLUGIN_DIR . '/src/blocks/latest-posts-express-grid/index.php');
194 130
195 -
196 - include(BLOCKSPARE_PLUGIN_DIR . '/src/blocks/latest-posts-carousel-grid/index.php');
197 - include(BLOCKSPARE_PLUGIN_DIR . '/src/blocks/latest-posts-slider/index.php');
198 -
199 - include(BLOCKSPARE_PLUGIN_DIR . '/src/blocks/banner-1/index.php');
200 - include(BLOCKSPARE_PLUGIN_DIR . '/src/blocks/banner-2/index.php');
201 -
202 -
203 -
204 -
205 -
206 - include(BLOCKSPARE_PLUGIN_DIR . 'src/inc/block-posts-config/class-post-rest-api.php');
207 - include(BLOCKSPARE_PLUGIN_DIR . 'src/inc/block-posts-config/tax-category.php');
208 - include(BLOCKSPARE_PLUGIN_DIR . 'src/inc/block-posts-config/class-bs-post.php');
209 - include(BLOCKSPARE_PLUGIN_DIR . 'src/blocks/utils/post-banner/frontend-render/post-banner-config.php');
210 - include(BLOCKSPARE_PLUGIN_DIR . 'src/blocks/utils/post-banner/frontend-render/post-banner-style.php');
211 - }
212 -
213 - function blockspare_blocks_register_api_endpoints(){
214 -
215 - $posts_controller = new Aft_Post_Rest_Controller();
216 - $posts_controller->register_routes();
217 -
218 -
219 - }
220 -
221 131 }
222 - BlockspareInit::get_instance();
223 -}
132 +
133 + add_action('plugins_loaded', 'blockspare_blocks_loader');
134 +
135 +
136 + add_action('admin_enqueue_scripts', 'blockspare_enqueue_admin_style');
137 +
138 + function blockspare_enqueue_admin_style()
139 + {
140 + wp_enqueue_style('slick', BLOCKSPARE_PLUGIN_URL . 'src/assets/slick/css/slick.css', array(), '', 'all');
141 + }
142 +
143 +
144 +
224 145
225 146
226 147