| @@ -26,18 +26,25 @@ | ||
| 26 | 26 | public function __construct() |
| 27 | 27 | { |
| 28 | 28 | add_action('init', array($this, 'blockspare_blocks_block_assets' )); |
| 29 | 29 | add_action('enqueue_block_editor_assets', array($this,'blockspare_create_block')); |
| 30 | - add_action('wp_enqueue_scripts', array($this,'blockspare_load_scripts')); | |
| 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 | + } | |
| 31 | 35 | add_action('plugins_loaded', array($this,'blockspare_blocks_loader')); |
| 32 | 36 | add_action( 'rest_api_init', array($this,'blockspare_blocks_register_api_endpoints' )); |
| 37 | + | |
| 38 | + | |
| 33 | 39 | } |
| 34 | 40 | |
| 35 | 41 | function blockspare_blocks_block_assets(){ |
| 36 | - wp_enqueue_style( | |
| 37 | - 'blockspare-blocks-fontawesome-front', | |
| 42 | + wp_register_style( | |
| 43 | + 'fontawesome', | |
| 38 | 44 | plugins_url('assets/fontawesome/css/all.css', dirname(__FILE__)), |
| 39 | 45 | array() |
| 46 | + | |
| 40 | 47 | ); |
| 41 | 48 | // Load the compiled styles. |
| 42 | 49 | wp_enqueue_style( |
| 43 | 50 | 'blockspare-frontend-block-style-css', |
| @@ -43,28 +50,66 @@ | ||
| 43 | 50 | 'blockspare-frontend-block-style-css', |
| 44 | 51 | plugins_url('dist/style-blocks.css', dirname(__FILE__)), |
| 45 | 52 | array() |
| 46 | 53 | ); |
| 47 | - | |
| 48 | - | |
| 49 | - wp_enqueue_style('slick-css', BLOCKSPARE_PLUGIN_URL . 'assets/slick/css/slick.css', array(), '', 'all'); | |
| 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 | + include(BLOCKSPARE_PLUGIN_DIR . '/admin/notice-setup.php'); | |
| 60 | + include(BLOCKSPARE_PLUGIN_DIR . '/admin/notice-upgrade.php'); | |
| 50 | 61 | } |
| 51 | 62 | |
| 52 | 63 | function blockspare_load_scripts(){ |
| 53 | - $min = (SCRIPT_DEBUG == true) ? '' : '.min'; | |
| 54 | - wp_enqueue_script('slick-js', BLOCKSPARE_PLUGIN_URL . 'assets/slick/js/slick.js', array('jquery'), '', true); | |
| 55 | - wp_register_script('countup', BLOCKSPARE_PLUGIN_URL . 'assets/js/countup/jquery.counterup' . $min . '.js', array('waypoint'), true); | |
| 56 | - wp_enqueue_script('waypoint', BLOCKSPARE_PLUGIN_URL . 'assets/js/countup/waypoints.min.js', array('jquery'), '', true); | |
| 57 | - wp_enqueue_script('jquery-masonry'); | |
| 58 | - wp_enqueue_script('blockspare-animation', BLOCKSPARE_PLUGIN_URL . 'dist/block_animation.js', array(), '', true); | |
| 59 | - wp_enqueue_script('blockspare-script', BLOCKSPARE_PLUGIN_URL . 'dist/block_frontend.js', array('jquery', 'waypoint', 'countup'), '', true); | |
| 60 | - wp_enqueue_script('blockspare-tabs', BLOCKSPARE_PLUGIN_URL . 'dist/block_tabs.js', array('jquery'), '', true); | |
| 61 | - wp_enqueue_script('blockspare-pagination-js', BLOCKSPARE_PLUGIN_URL . 'dist/block_pagination.js', array(), '', true); | |
| 62 | 64 | |
| 63 | - wp_localize_script('blockspare-pagination-js', 'blocsparePagination',array( | |
| 64 | - 'ajaxurl' => admin_url( 'admin-ajax.php' ), | |
| 65 | - 'nonce'=>wp_create_nonce('blockspare-load-more-nonce') | |
| 66 | - )); | |
| 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 | + | |
| 67 | 112 | } |
| 68 | 113 | |
| 69 | 114 | function blockspare_create_block(){ |
| 70 | 115 | |
| @@ -96,19 +141,23 @@ | ||
| 96 | 141 | // Enqueue the script in the footer. |
| 97 | 142 | ); |
| 98 | 143 | |
| 99 | 144 | if (is_admin()) : |
| 145 | + wp_enqueue_style('fontawesome'); | |
| 100 | 146 | wp_enqueue_style( |
| 101 | 147 | 'blockspare-block-edit-style', |
| 102 | 148 | BLOCKSPARE_PLUGIN_URL . 'dist/blocks.css', |
| 103 | 149 | array('wp-edit-blocks') |
| 104 | 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')); | |
| 105 | 154 | endif; |
| 106 | 155 | |
| 107 | 156 | |
| 108 | 157 | $blockspare_priview_img_url = BLOCKSPARE_PLUGIN_URL . 'assets/blockspare-placeholder-img.jpg'; |
| 109 | 158 | $blockspare_food_img_url = BLOCKSPARE_PLUGIN_URL . 'assets/blockspare-placeholder-img-square.jpg'; |
| 110 | - | |
| 159 | + $blockspare_dashboard_logo = BLOCKSPARE_PLUGIN_URL . 'assets/images/blockspare-logo.png'; | |
| 111 | 160 | $taxonomies = get_categories(); |
| 112 | 161 | $txnm = array(); |
| 113 | 162 | |
| 114 | 163 | foreach( $taxonomies as $type ) { |
| @@ -119,9 +168,34 @@ | ||
| 119 | 168 | 'value' => $type->term_id, |
| 120 | 169 | ); |
| 121 | 170 | } |
| 122 | 171 | |
| 123 | - | |
| 172 | + $date = wp_kses_post(date_i18n(get_option('date_format'))); | |
| 173 | + $open_design = false; | |
| 174 | + if(isset($_GET['blockspare_show_intro'])){ | |
| 175 | + if($_GET['blockspare_show_intro'] =='true'){ | |
| 176 | + $open_design = true; | |
| 177 | + } | |
| 178 | + } | |
| 179 | + $date_format = date_i18n(get_option('date_format'), current_time('timestamp')); | |
| 180 | + | |
| 181 | + $blockData =''; | |
| 182 | + if(isset($_GET['blockspare_create_block'])){ | |
| 183 | + $blockName = $_GET['blockspare_create_block']; | |
| 184 | + $blocks_lists = array(); | |
| 185 | + | |
| 186 | + $filterdata = apply_filters( 'blockspare_template_library', $blocks_lists ); | |
| 187 | + | |
| 188 | + | |
| 189 | + foreach ($filterdata as $block) { | |
| 190 | + if (isset($block['key']) && $block['key'] === $blockName) { | |
| 191 | + // Found the block with the desired key, retrieve the content | |
| 192 | + $blockData = $block['content']; | |
| 193 | + break; // Stop looping once the desired block is found | |
| 194 | + } | |
| 195 | + } | |
| 196 | + } | |
| 197 | + | |
| 124 | 198 | wp_localize_script( |
| 125 | 199 | 'blockspare-blocks-block-js', |
| 126 | 200 | 'blockspare_globals', |
| 127 | 201 | array( |
| @@ -127,9 +201,12 @@ | ||
| 127 | 201 | array( |
| 128 | 202 | 'srcUrl' => untrailingslashit(plugins_url('/', BLOCKSPARE_BASE_DIR . '/dist/')), |
| 129 | 203 | 'rest_url' => esc_url(rest_url()), |
| 130 | 204 | 'img' => $blockspare_priview_img_url, |
| 205 | + 'homeUrl'=>home_url(), | |
| 206 | + 'blogUrl'=>get_site_url(), | |
| 131 | 207 | 'menu_img_url' => $blockspare_food_img_url, |
| 208 | + 'logo'=>$blockspare_dashboard_logo, | |
| 132 | 209 | 'postTypes' => $this->aft_get_post_types(), |
| 133 | 210 | 'taxonomies' => $this->aft_get_taxonomies(), |
| 134 | 211 | 'postQueryEndpoint'=>'aft/v1/post-query', |
| 135 | 212 | 'config' => '', |
| @@ -134,8 +211,15 @@ | ||
| 134 | 211 | 'postQueryEndpoint'=>'aft/v1/post-query', |
| 135 | 212 | 'config' => '', |
| 136 | 213 | 'configuration' => '', |
| 137 | 214 | 'settings' => '', |
| 215 | + 'bs_date'=>$date, | |
| 216 | + "imagePath"=> "https://templatespare.com/wp-content/uploads/blockspare-demo-data/blocks/", | |
| 217 | + "open_design"=> $open_design, | |
| 218 | + 'date_format '=>$date_format, | |
| 219 | + 'blockData'=>$blockData, | |
| 220 | + 'template_link'=>admin_url('edit.php?post_type=bs_templates'), | |
| 221 | + 'newTemlateUrl'=>admin_url('post-new.php?post_type=bs_templates&blockspare_create_block&blockspare_show_intro=true'), | |
| 138 | 222 | ) |
| 139 | 223 | ); |
| 140 | 224 | } |
| 141 | 225 | |
| @@ -159,8 +243,10 @@ | ||
| 159 | 243 | |
| 160 | 244 | return apply_filters( 'aft_blocks_post_types', $output ); |
| 161 | 245 | } |
| 162 | 246 | |
| 247 | + | |
| 248 | + | |
| 163 | 249 | function aft_get_taxonomies() { |
| 164 | 250 | $post_types = $this->aft_get_post_types(); |
| 165 | 251 | $output = array(); |
| 166 | 252 | foreach ( $post_types as $key => $post_type ) { |
| @@ -189,22 +275,44 @@ | ||
| 189 | 275 | return apply_filters( 'aft_blocks_taxonomies', $output ); |
| 190 | 276 | } |
| 191 | 277 | |
| 192 | 278 | function blockspare_blocks_loader(){ |
| 279 | + | |
| 280 | + if ( PHP_VERSION_ID >= 50600 ) { | |
| 281 | + require_once BLOCKSPARE_PLUGIN_DIR .'inc/layout/class-image-importer.php'; | |
| 282 | + require_once BLOCKSPARE_PLUGIN_DIR . 'inc/layout/functions.php'; | |
| 283 | + require_once BLOCKSPARE_PLUGIN_DIR . 'inc/layout/registry.php'; | |
| 284 | + require_once BLOCKSPARE_PLUGIN_DIR . 'inc/layout/components.php'; | |
| 285 | + | |
| 286 | + /** | |
| 287 | + * REST API Endpoints for Layouts. | |
| 288 | + */ | |
| 289 | + require_once BLOCKSPARE_PLUGIN_DIR . 'inc/layout/endpoints.php'; | |
| 290 | + require_once BLOCKSPARE_PLUGIN_DIR . 'inc/layout/save-templates.php'; | |
| 291 | + | |
| 292 | + /** | |
| 293 | + * Import Pattern | |
| 294 | + */ | |
| 295 | + | |
| 296 | + //require_once BLOCKSPARE_PLUGIN_DIR . 'inc/pattern/pattern.php'; | |
| 297 | + } | |
| 193 | 298 | |
| 194 | 299 | //Load Gutenberg Block php Files |
| 300 | + include(BLOCKSPARE_PLUGIN_DIR . 'inc/other-block/date-time/index.php'); | |
| 195 | 301 | include(BLOCKSPARE_PLUGIN_DIR . '/inc/other-block/social-sharing/index.php'); |
| 196 | 302 | include(BLOCKSPARE_PLUGIN_DIR . '/inc/latest-post-block/posts-grid/index.php'); |
| 197 | 303 | include(BLOCKSPARE_PLUGIN_DIR . '/inc/latest-post-block/posts-list/index.php'); |
| 198 | 304 | |
| 199 | 305 | include(BLOCKSPARE_PLUGIN_DIR . '/inc/latest-post-block/posts-express-grid/index.php'); |
| 306 | + include(BLOCKSPARE_PLUGIN_DIR . '/inc/latest-post-block/posts-express-grid/post-content.php'); | |
| 200 | 307 | |
| 201 | 308 | |
| 202 | 309 | include(BLOCKSPARE_PLUGIN_DIR . '/inc/latest-post-block/posts-carousel-grid/index.php'); |
| 203 | 310 | include(BLOCKSPARE_PLUGIN_DIR . '/inc/latest-post-block/posts-slider/index.php'); |
| 204 | 311 | |
| 205 | - include(BLOCKSPARE_PLUGIN_DIR . '/inc/block-banner/banner-1/index.php'); | |
| 206 | - include(BLOCKSPARE_PLUGIN_DIR . '/inc/block-banner/banner-2/index.php'); | |
| 312 | + include(BLOCKSPARE_PLUGIN_DIR . '/inc/post-banner/banner-1/index.php'); | |
| 313 | + include(BLOCKSPARE_PLUGIN_DIR . '/inc/post-banner/banner-2/index.php'); | |
| 314 | + include(BLOCKSPARE_PLUGIN_DIR . '/inc/post-banner/banner-9/index.php'); | |
| 207 | 315 | include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-posts-config/ajax-pagination.php'); |
| 208 | 316 | include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-posts-config/class-post-rest-api.php'); |
| 209 | 317 | include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-posts-config/class-multiauthor-backend.php'); |
| 210 | 318 | include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-posts-config/class-multiauthor-frontend.php'); |
| @@ -211,8 +319,13 @@ | ||
| 211 | 319 | include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-posts-config/tax-category.php'); |
| 212 | 320 | include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-posts-config/class-bs-post.php'); |
| 213 | 321 | include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-banner/frontend-render/post-banner-config.php'); |
| 214 | 322 | include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-banner/frontend-render/post-banner-style.php'); |
| 323 | + include(BLOCKSPARE_PLUGIN_DIR . 'inc/other-block/search/index.php'); | |
| 324 | + include(BLOCKSPARE_PLUGIN_DIR . 'inc/latest-post-block/posts-flash/index.php'); | |
| 325 | + include(BLOCKSPARE_PLUGIN_DIR . 'inc/other-block/popular-tags/index.php'); | |
| 326 | + include(BLOCKSPARE_PLUGIN_DIR . 'inc/page-templates/module.php'); | |
| 327 | + include(BLOCKSPARE_PLUGIN_DIR . 'inc/block-banner/frontend-render/post-category-style.php'); | |
| 215 | 328 | } |
| 216 | 329 | |
| 217 | 330 | function blockspare_blocks_register_api_endpoints(){ |
| 218 | 331 | |