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