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
editor.js
79 lines
| 1 | const builderType = sp_blocks.custom_type; |
| 2 | const postType = sp_blocks.post_type; |
| 3 | |
| 4 | wp.domReady( function () { |
| 5 | const generalBlocks = [ 'shop-press/product-collection' ]; |
| 6 | |
| 7 | wp.blocks.getBlockTypes().map( function ( blockType ) { |
| 8 | if ( |
| 9 | builderType.length === 0 && |
| 10 | blockType.name.includes( 'shop-press' ) && |
| 11 | ! blockType.name.includes( generalBlocks ) |
| 12 | ) { |
| 13 | wp.blocks.unregisterBlockType( blockType.name ); |
| 14 | } |
| 15 | } ); |
| 16 | |
| 17 | function addWooClass( selector, classes ) { |
| 18 | jQuery( document ).find( selector ).addClass( classes ); |
| 19 | } |
| 20 | |
| 21 | setTimeout( () => { |
| 22 | const interfaceBody = '.interface-interface-skeleton__body'; |
| 23 | const spPages = '.post-type-shoppress_pages'; |
| 24 | const spLoop = '.post-type-shoppress_loop'; |
| 25 | const spMyAccount = '.post-type-shoppress_myaccount'; |
| 26 | const blockPostContent = '.wp-block-post-content'; |
| 27 | const defaultClasses = 'woocommerce woocommerce-page woocommerce-js'; |
| 28 | const accountClassess = |
| 29 | 'woocommerce-account woocommerce-page woocommerce-js woocommerce-edit-account woocommerce-orders woocommerce-downloads woocommerce-edit-address woocommerce-edit-account'; |
| 30 | |
| 31 | if ( 'shoppress_pages' === postType ) { |
| 32 | addWooClass( `${ spPages } ${ interfaceBody }`, defaultClasses ); |
| 33 | |
| 34 | if ( 'single' === builderType || 'quick_view' === builderType ) { |
| 35 | addWooClass( `${ spPages } ${ blockPostContent }`, 'product' ); |
| 36 | } |
| 37 | |
| 38 | if ( 'shop' === builderType || 'archive' === builderType ) { |
| 39 | addWooClass( |
| 40 | `${ spPages } ${ blockPostContent }`, |
| 41 | 'archive tax-product_cat tax-product_tag post-type-archive post-type-archive-product' |
| 42 | ); |
| 43 | } |
| 44 | |
| 45 | if ( 'checkout' === builderType || 'thank_you' === builderType ) { |
| 46 | addWooClass( |
| 47 | `${ spPages } ${ blockPostContent }`, |
| 48 | 'woocommerce-checkout woocommerce-order-received' |
| 49 | ); |
| 50 | } |
| 51 | |
| 52 | if ( 'cart' === builderType || 'empty_cart' === builderType ) { |
| 53 | addWooClass( |
| 54 | `${ spPages } ${ blockPostContent }`, |
| 55 | 'woocommerce-cart' |
| 56 | ); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | if ( 'shoppress_loop' === postType ) { |
| 61 | addWooClass( `${ spLoop } ${ interfaceBody }`, defaultClasses ); |
| 62 | |
| 63 | if ( 'products_loop' === builderType ) { |
| 64 | addWooClass( |
| 65 | `${ spLoop } ${ blockPostContent }`, |
| 66 | 'archive tax-product_cat tax-product_tag post-type-archive post-type-archive-product' |
| 67 | ); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | if ( 'shoppress_myaccount' === postType ) { |
| 72 | addWooClass( |
| 73 | `${ spMyAccount } ${ interfaceBody }`, |
| 74 | accountClassess |
| 75 | ); |
| 76 | } |
| 77 | }, 500 ); |
| 78 | } ); |
| 79 |