build
1 month ago
src
1 month ago
BlockAPI.php
2 years ago
FilterBlocks.php
5 months ago
Integration.php
1 month ago
RegisterBlocks.php
2 years ago
editor.css
2 years ago
editor.js
2 years ago
RegisterBlocks.php
344 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Register Blocks. |
| 4 | * |
| 5 | * @package ShopPress |
| 6 | */ |
| 7 | |
| 8 | namespace ShopPress\BlockEditor; |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | |
| 12 | use ShopPress\Templates; |
| 13 | |
| 14 | class RegisterBlocks { |
| 15 | /** |
| 16 | * Init Register Blocks. |
| 17 | * |
| 18 | * @since 1.4.0 |
| 19 | */ |
| 20 | public static function init() { |
| 21 | add_action( 'init', array( __CLASS__, 'register_blocks' ) ); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Retrieves the list of blocks. |
| 26 | * |
| 27 | * @since 1.4.0 |
| 28 | * |
| 29 | * @return array |
| 30 | */ |
| 31 | public static function get_blocks_list() { |
| 32 | $blocks = array( |
| 33 | 'single-title' => array( |
| 34 | 'is_pro' => false, |
| 35 | 'path' => 'single-product/title', |
| 36 | ), |
| 37 | 'single-price' => array( |
| 38 | 'is_pro' => false, |
| 39 | 'path' => 'single-product/price', |
| 40 | ), |
| 41 | 'single-add-to-cart' => array( |
| 42 | 'is_pro' => false, |
| 43 | 'path' => 'single-product/add-to-cart', |
| 44 | ), |
| 45 | 'single-attributes' => array( |
| 46 | 'is_pro' => false, |
| 47 | 'path' => 'single-product/attributes', |
| 48 | ), |
| 49 | 'single-tabs' => array( |
| 50 | 'is_pro' => false, |
| 51 | 'path' => 'single-product/tabs', |
| 52 | ), |
| 53 | 'single-breadcrumb' => array( |
| 54 | 'is_pro' => false, |
| 55 | 'path' => 'single-product/breadcrumb', |
| 56 | ), |
| 57 | // 'single-call-for-price' => array( |
| 58 | // 'is_pro' => false, |
| 59 | // 'path' => 'single-product/call-for-price', |
| 60 | // ), |
| 61 | 'single-categories' => array( |
| 62 | 'is_pro' => false, |
| 63 | 'path' => 'single-product/categories', |
| 64 | ), |
| 65 | 'single-compare' => array( |
| 66 | 'is_pro' => false, |
| 67 | 'path' => 'single-product/compare', |
| 68 | ), |
| 69 | 'single-description' => array( |
| 70 | 'is_pro' => false, |
| 71 | 'path' => 'single-product/description', |
| 72 | ), |
| 73 | 'single-content' => array( |
| 74 | 'is_pro' => false, |
| 75 | 'path' => 'single-product/content', |
| 76 | ), |
| 77 | 'single-discount' => array( |
| 78 | 'is_pro' => false, |
| 79 | 'path' => 'single-product/discount', |
| 80 | ), |
| 81 | // 'single-flash-sale-countdown' => array( |
| 82 | // 'is_pro' => false, |
| 83 | // 'path' => 'single-product/flash-sale-countdown', |
| 84 | // ), |
| 85 | 'single-images' => array( |
| 86 | 'is_pro' => false, |
| 87 | 'path' => 'single-product/image', |
| 88 | ), |
| 89 | 'single-navigation' => array( |
| 90 | 'is_pro' => false, |
| 91 | 'path' => 'single-product/navigation', |
| 92 | ), |
| 93 | 'single-rating' => array( |
| 94 | 'is_pro' => false, |
| 95 | 'path' => 'single-product/rating', |
| 96 | ), |
| 97 | 'single-review' => array( |
| 98 | 'is_pro' => false, |
| 99 | 'path' => 'single-product/review', |
| 100 | ), |
| 101 | 'single-sale-badge' => array( |
| 102 | 'is_pro' => false, |
| 103 | 'path' => 'single-product/sale-badge', |
| 104 | ), |
| 105 | // 'single-sharing' => array( |
| 106 | // 'is_pro' => false, |
| 107 | // 'path' => 'single-product/sharing', |
| 108 | // ), |
| 109 | 'single-size-chart' => array( |
| 110 | 'is_pro' => false, |
| 111 | 'path' => 'single-product/size-chart', |
| 112 | ), |
| 113 | 'single-sku' => array( |
| 114 | 'is_pro' => false, |
| 115 | 'path' => 'single-product/sku', |
| 116 | ), |
| 117 | 'single-stock' => array( |
| 118 | 'is_pro' => false, |
| 119 | 'path' => 'single-product/stock', |
| 120 | ), |
| 121 | // 'single-stock-progress-bar' => array( |
| 122 | // 'is_pro' => false, |
| 123 | // 'path' => 'single-product/stock-progress-bar', |
| 124 | // ), |
| 125 | // 'single-suggest-price' => array( |
| 126 | // 'is_pro' => false, |
| 127 | // 'path' => 'single-product/suggest-price', |
| 128 | // ), |
| 129 | 'single-tags' => array( |
| 130 | 'is_pro' => false, |
| 131 | 'path' => 'single-product/tags', |
| 132 | ), |
| 133 | 'single-weight' => array( |
| 134 | 'is_pro' => false, |
| 135 | 'path' => 'single-product/weight', |
| 136 | ), |
| 137 | 'single-wishlist' => array( |
| 138 | 'is_pro' => false, |
| 139 | 'path' => 'single-product/wishlist', |
| 140 | ), |
| 141 | 'cart-coupon' => array( |
| 142 | 'is_pro' => false, |
| 143 | 'path' => 'cart/cart-coupon', |
| 144 | ), |
| 145 | 'cart-table' => array( |
| 146 | 'is_pro' => false, |
| 147 | 'path' => 'cart/cart-table', |
| 148 | ), |
| 149 | 'cart-totals' => array( |
| 150 | 'is_pro' => false, |
| 151 | 'path' => 'cart/cart-totals', |
| 152 | ), |
| 153 | 'checkout-additional-fields' => array( |
| 154 | 'is_pro' => false, |
| 155 | 'path' => 'checkout/additional-fields', |
| 156 | ), |
| 157 | 'checkout-form-billing' => array( |
| 158 | 'is_pro' => false, |
| 159 | 'path' => 'checkout/form-billing', |
| 160 | ), |
| 161 | 'checkout-form-coupon' => array( |
| 162 | 'is_pro' => false, |
| 163 | 'path' => 'checkout/form-coupon', |
| 164 | ), |
| 165 | 'checkout-order-review' => array( |
| 166 | 'is_pro' => false, |
| 167 | 'path' => 'checkout/order-review', |
| 168 | ), |
| 169 | 'checkout-payment-method' => array( |
| 170 | 'is_pro' => false, |
| 171 | 'path' => 'checkout/payment-method', |
| 172 | ), |
| 173 | 'checkout-shipping-form' => array( |
| 174 | 'is_pro' => false, |
| 175 | 'path' => 'checkout/shipping-form', |
| 176 | ), |
| 177 | 'thankyou-order-details' => array( |
| 178 | 'is_pro' => false, |
| 179 | 'path' => 'thankyou/order-details', |
| 180 | ), |
| 181 | 'thankyou-order-details-customers' => array( |
| 182 | 'is_pro' => false, |
| 183 | 'path' => 'thankyou/order-details-customer', |
| 184 | ), |
| 185 | 'thankyou-order-review' => array( |
| 186 | 'is_pro' => false, |
| 187 | 'path' => 'thankyou/order-review', |
| 188 | ), |
| 189 | 'my-account' => array( |
| 190 | 'is_pro' => false, |
| 191 | 'path' => 'my-account/my-account', |
| 192 | ), |
| 193 | 'my-account-addresses' => array( |
| 194 | 'is_pro' => false, |
| 195 | 'path' => 'my-account/addresses', |
| 196 | ), |
| 197 | 'my-account-dashboard' => array( |
| 198 | 'is_pro' => false, |
| 199 | 'path' => 'my-account/dashboard', |
| 200 | ), |
| 201 | 'my-account-downloads' => array( |
| 202 | 'is_pro' => false, |
| 203 | 'path' => 'my-account/downloads', |
| 204 | ), |
| 205 | 'my-account-edit-account' => array( |
| 206 | 'is_pro' => false, |
| 207 | 'path' => 'my-account/edit-account', |
| 208 | ), |
| 209 | 'my-account-login' => array( |
| 210 | 'is_pro' => false, |
| 211 | 'path' => 'my-account/login', |
| 212 | ), |
| 213 | 'my-account-notifications' => array( |
| 214 | 'is_pro' => false, |
| 215 | 'path' => 'my-account/notifications', |
| 216 | ), |
| 217 | 'my-account-orders' => array( |
| 218 | 'is_pro' => false, |
| 219 | 'path' => 'my-account/orders', |
| 220 | ), |
| 221 | 'my-wishlist' => array( |
| 222 | 'is_pro' => false, |
| 223 | 'path' => 'my-wishlist', |
| 224 | ), |
| 225 | 'cart-empty-message' => array( |
| 226 | 'is_pro' => false, |
| 227 | 'path' => 'empty-cart/cart-empty-message', |
| 228 | ), |
| 229 | 'cart-return-to-shop' => array( |
| 230 | 'is_pro' => false, |
| 231 | 'path' => 'empty-cart/return-to-shop', |
| 232 | ), |
| 233 | 'compare' => array( |
| 234 | 'is_pro' => false, |
| 235 | 'path' => 'compare', |
| 236 | ), |
| 237 | 'shop-product' => array( |
| 238 | 'is_pro' => false, |
| 239 | 'path' => 'product/shop-product', |
| 240 | ), |
| 241 | 'product-collection' => array( |
| 242 | 'is_pro' => false, |
| 243 | 'path' => 'product/product-collection', |
| 244 | ), |
| 245 | 'related-product' => array( |
| 246 | 'is_pro' => false, |
| 247 | 'path' => 'product/related', |
| 248 | ), |
| 249 | 'upsell-product' => array( |
| 250 | 'is_pro' => false, |
| 251 | 'path' => 'product/upsell', |
| 252 | ), |
| 253 | 'cross-sell-product' => array( |
| 254 | 'is_pro' => false, |
| 255 | 'path' => 'product/cross-sell', |
| 256 | ), |
| 257 | 'loop-add-to-cart' => array( |
| 258 | 'is_pro' => false, |
| 259 | 'path' => 'loop/add-to-cart', |
| 260 | ), |
| 261 | 'loop-categories' => array( |
| 262 | 'is_pro' => false, |
| 263 | 'path' => 'loop/categories', |
| 264 | ), |
| 265 | 'loop-tags' => array( |
| 266 | 'is_pro' => false, |
| 267 | 'path' => 'loop/tags', |
| 268 | ), |
| 269 | 'loop-compare' => array( |
| 270 | 'is_pro' => false, |
| 271 | 'path' => 'loop/compare', |
| 272 | ), |
| 273 | 'loop-description' => array( |
| 274 | 'is_pro' => false, |
| 275 | 'path' => 'loop/description', |
| 276 | ), |
| 277 | 'loop-discount' => array( |
| 278 | 'is_pro' => false, |
| 279 | 'path' => 'loop/discount', |
| 280 | ), |
| 281 | 'loop-price' => array( |
| 282 | 'is_pro' => false, |
| 283 | 'path' => 'loop/price', |
| 284 | ), |
| 285 | 'loop-quick-view' => array( |
| 286 | 'is_pro' => false, |
| 287 | 'path' => 'loop/quick-view', |
| 288 | ), |
| 289 | 'loop-rating' => array( |
| 290 | 'is_pro' => false, |
| 291 | 'path' => 'loop/rating', |
| 292 | ), |
| 293 | 'loop-review' => array( |
| 294 | 'is_pro' => false, |
| 295 | 'path' => 'loop/review', |
| 296 | ), |
| 297 | 'loop-sale-flash' => array( |
| 298 | 'is_pro' => false, |
| 299 | 'path' => 'loop/sale-flash', |
| 300 | ), |
| 301 | 'loop-stock' => array( |
| 302 | 'is_pro' => false, |
| 303 | 'path' => 'loop/stock', |
| 304 | ), |
| 305 | 'loop-sku' => array( |
| 306 | 'is_pro' => false, |
| 307 | 'path' => 'loop/sku', |
| 308 | ), |
| 309 | 'loop-thumbnail' => array( |
| 310 | 'is_pro' => false, |
| 311 | 'path' => 'loop/thumbnail', |
| 312 | ), |
| 313 | 'loop-title' => array( |
| 314 | 'is_pro' => false, |
| 315 | 'path' => 'loop/title', |
| 316 | ), |
| 317 | 'loop-wishlist' => array( |
| 318 | 'is_pro' => false, |
| 319 | 'path' => 'loop/wishlist', |
| 320 | ), |
| 321 | 'shop-filters' => array( |
| 322 | 'is_pro' => false, |
| 323 | 'path' => 'shop/filters', |
| 324 | ), |
| 325 | ); |
| 326 | |
| 327 | return apply_filters( 'shoppress/block_editor/blocks', $blocks ); |
| 328 | } |
| 329 | |
| 330 | /** |
| 331 | * Register the builder blocks for WordPress editor. |
| 332 | * |
| 333 | * @since 1.4.0 |
| 334 | */ |
| 335 | public static function register_blocks() { |
| 336 | $blocks = self::get_blocks_list(); |
| 337 | |
| 338 | foreach ( $blocks as $key => $block ) { |
| 339 | |
| 340 | register_block_type( SHOPPRESS_PATH . "blocks/build/{$block['path']}" ); |
| 341 | } |
| 342 | } |
| 343 | } |
| 344 |