PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 1.3.3
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v1.3.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
← All changes | src/init.php +81 -172 2.1.21.3.3 View file →
@@ -1,108 +1,77 @@
1 1 <?php
2 -
2 +
3 3 //Exit if directly acess
4 4 defined('ABSPATH') or die('No script kiddies please!');
5 +
6 +
7 + function blockspare_blocks_block_assets()
8 + {
9 +
10 + $min = (SCRIPT_DEBUG == true) ? '' : '.min';
11 + wp_enqueue_style(
12 + 'blockspare-blocks-fontawesome-front',
13 + plugins_url('src/assets/fontawesome/css/all.css', dirname(__FILE__)),
14 + array(),
15 + filemtime(plugin_dir_path(__FILE__) . 'assets/fontawesome/css/all.css')
16 + );
17 + // Load the compiled styles.
18 + wp_enqueue_style(
19 + 'blockspare-frontend-block-style-css',
20 + plugins_url('dist/blocks.style.build.css', dirname(__FILE__)),
21 + array()
22 + );
5 23
6 - if(!class_exists('BlockspareInit')){
7 - class BlockspareInit{
8 - /**
9 - * Member Variable
10 - *
11 - * @var instance
12 - */
13 - private static $instance;
14 24
15 - /**
16 - * Initiator
17 - */
18 - public static function get_instance()
25 + wp_enqueue_style('slick', BLOCKSPARE_PLUGIN_URL . 'src/assets/slick/css/slick.css', array(), '', 'all');
26 + wp_enqueue_script('slick-js', BLOCKSPARE_PLUGIN_URL . 'src/assets/slick/js/slick.js', array('jquery'), '', true);
27 + wp_register_script('countup', BLOCKSPARE_PLUGIN_URL . 'src/assets/js/countup/jquery.counterup' . $min . '.js', array('waypoint'), true);
28 +
29 + wp_enqueue_script('waypoint', BLOCKSPARE_PLUGIN_URL . 'src/assets/js/countup/waypoints.min.js', array('jquery'), '', true);
30 + wp_enqueue_script('jquery-masonry');
31 +
32 + wp_enqueue_script('blockspare-script', BLOCKSPARE_PLUGIN_URL . 'src/assets/js/frontend.js', array('jquery', 'waypoint', 'countup'), '', true);
33 + wp_enqueue_script('blockspare-tabs', BLOCKSPARE_PLUGIN_URL . 'src/assets/js/tabs.js', array('jquery'), '', true);
34 + }
35 +
36 + add_action('init', 'blockspare_blocks_block_assets');
37 +
38 + if (!function_exists('blockspare_create_block')) {
39 +
40 +
41 + function blockspare_create_block()
19 42 {
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')
43 +
44 + $min = (SCRIPT_DEBUG == true) ? '' : '.min';
45 + // Register our block script with WordPress
46 + wp_enqueue_script(
47 + 'blockspare-blocks-block-js',
48 + BLOCKSPARE_PLUGIN_URL . 'dist/blocks.build.js',
49 + array('wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-editor')
41 50 );
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 51
49 52
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 -
53 + // Register our block's editor-specific CSS
93 54 if (is_admin()) :
94 55 wp_enqueue_style(
95 56 'blockspare-block-edit-style',
96 - BLOCKSPARE_PLUGIN_URL . 'dist/blocks.css',
57 + BLOCKSPARE_PLUGIN_URL . 'dist/blocks.editor.build.css',
97 58 array('wp-edit-blocks')
98 59 );
99 60 endif;
100 61
62 + wp_enqueue_style(
63 + 'blockspare-blocks-fontawesome',
64 + plugins_url('src/assets/fontawesome/css/all.css', dirname(__FILE__)),
65 + array(),
66 + filemtime(plugin_dir_path(__FILE__) . 'assets/fontawesome/css/all.css')
67 + );
68 +
101 69
102 - $blockspare_priview_img_url = BLOCKSPARE_PLUGIN_URL . 'src/assets/blockspare-placeholder-img.jpg';
70 + $blockspare_priview_img_url = BLOCKSPARE_PLUGIN_URL . 'dist/images/blockspare-placeholder-img.jpg';
103 71 $blockspare_food_img_url = BLOCKSPARE_PLUGIN_URL . 'src/assets/blockspare-placeholder-img-square.jpg';
104 72
73 +
105 74 $taxonomies = get_categories();
106 75 $txnm = array();
107 76
108 77 foreach( $taxonomies as $type ) {
@@ -112,10 +81,9 @@
112 81 'label' => $type->name,
113 82 'value' => $type->term_id,
114 83 );
115 84 }
116 -
117 -
85 +
118 86 wp_localize_script(
119 87 'blockspare-blocks-block-js',
120 88 'blockspare_globals',
121 89 array(
@@ -122,11 +90,9 @@
122 90 'srcUrl' => untrailingslashit(plugins_url('/', BLOCKSPARE_BASE_DIR . '/dist/')),
123 91 'rest_url' => esc_url(rest_url()),
124 92 'img' => $blockspare_priview_img_url,
125 93 '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',
94 + 'taxonomies'=> json_encode($txnm),
129 95 'config' => '',
130 96 'configuration' => '',
131 97 'settings' => '',
132 98 )
@@ -131,96 +97,39 @@
131 97 'settings' => '',
132 98 )
133 99 );
134 100 }
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 -
101 +
102 + add_action('enqueue_block_editor_assets', 'blockspare_create_block');
103 +
104 + }
105 +
106 +
107 +
108 +
109 + function blockspare_blocks_loader()
110 + {
111 +
188 112 //Load Gutenberg Block php Files
189 113 include(BLOCKSPARE_PLUGIN_DIR . '/src/blocks/social-sharing/index.php');
190 114 include(BLOCKSPARE_PLUGIN_DIR . '/src/blocks/latest-posts-grid/index.php');
191 115 include(BLOCKSPARE_PLUGIN_DIR . '/src/blocks/latest-posts-list/index.php');
116 + //include(BLOCKSPARE_PLUGIN_DIR . '/src/blocks/pattern/pattern.php');
192 117
193 - include(BLOCKSPARE_PLUGIN_DIR . '/src/blocks/latest-posts-express-grid/index.php');
194 118
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 119 }
222 - BlockspareInit::get_instance();
223 -}
120 +
121 + add_action('plugins_loaded', 'blockspare_blocks_loader');
122 +
123 +
124 + add_action('admin_enqueue_scripts', 'blockspare_enqueue_admin_style');
125 +
126 + function blockspare_enqueue_admin_style()
127 + {
128 + wp_enqueue_style('slick', BLOCKSPARE_PLUGIN_URL . 'src/assets/slick/css/slick.css', array(), '', 'all');
129 + }
130 +
131 +
132 +
224 133
225 134
226 135