| 1 |
<?php |
| 2 |
/** |
| 3 |
* Registers StoreEngine's core shortcodes with the shortcode → block bridge, so |
| 4 |
* they're all available as configurable blocks in the editor. |
| 5 |
* |
| 6 |
* @package StoreEngine\Blocks |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace StoreEngine\Blocks; |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; |
| 13 |
} |
| 14 |
|
| 15 |
class CoreShortcodes { |
| 16 |
|
| 17 |
public static function register() { |
| 18 |
add_action( 'init', [ __CLASS__, 'register_descriptors' ], 20 ); |
| 19 |
} |
| 20 |
|
| 21 |
public static function register_descriptors() { |
| 22 |
if ( ! function_exists( 'storeengine_register_shortcode_block' ) ) { |
| 23 |
return; |
| 24 |
} |
| 25 |
|
| 26 |
$owner = 'storeengine'; |
| 27 |
$category = __( 'StoreEngine', 'storeengine' ); |
| 28 |
|
| 29 |
// Self-closing, attribute-less page shortcodes: [ title, icon, aBlocks block |
| 30 |
// it converts to ('' when none) ]. |
| 31 |
$simple = [ |
| 32 |
'storeengine_checkout_form' => [ __( 'Checkout Form', 'storeengine' ), 'cart', 'ablocks/storeengine-checkout-form' ], |
| 33 |
'storeengine_order_summary' => [ __( 'Order Summary', 'storeengine' ), 'list-view', '' ], |
| 34 |
'storeengine_cart_list_table' => [ __( 'Cart Items', 'storeengine' ), 'cart', 'ablocks/storeengine-cart-list' ], |
| 35 |
'storeengine_cart_sub_total_table' => [ __( 'Cart Totals', 'storeengine' ), 'money-alt', 'ablocks/storeengine-cart-sub-table' ], |
| 36 |
'storeengine_apply_coupon_form' => [ __( 'Apply Coupon', 'storeengine' ), 'tag', 'ablocks/storeengine-coupon-form' ], |
| 37 |
'storeengine_proceed_to_checkout' => [ __( 'Proceed to Checkout', 'storeengine' ), 'arrow-right-alt', 'ablocks/storeengine-checkout-button' ], |
| 38 |
'storeengine_mini_cart' => [ __( 'Mini Cart', 'storeengine' ), 'cart', 'ablocks/storeengine-mini-cart' ], |
| 39 |
'storeengine_order_details' => [ __( 'Order Details', 'storeengine' ), 'clipboard', 'ablocks/storeengine-order-details' ], |
| 40 |
'storeengine_order_billing_address' => [ __( 'Billing Address', 'storeengine' ), 'admin-home', 'ablocks/storeengine-billing-info' ], |
| 41 |
'storeengine_order_shipping_address'=> [ __( 'Shipping Address', 'storeengine' ), 'admin-home', 'ablocks/storeengine-shipping-info' ], |
| 42 |
'storeengine_thankyou_order_info' => [ __( 'Thank-You Order Info', 'storeengine' ), 'yes-alt', 'ablocks/storeengine-order-info' ], |
| 43 |
'storeengine_thankyou_payment_instructions' => [ __( 'Payment Instructions', 'storeengine' ), 'info', '' ], |
| 44 |
'storeengine_order_downloads' => [ __( 'Order Downloads', 'storeengine' ), 'download', '' ], |
| 45 |
'storeengine_login_form' => [ __( 'Login Form', 'storeengine' ), 'admin-users', 'ablocks/storeengine-login-form' ], |
| 46 |
'storeengine_dashboard' => [ __( 'Customer Dashboard', 'storeengine' ), 'dashboard', '' ], |
| 47 |
'storeengine_continue_shopping' => [ __( 'Continue Shopping', 'storeengine' ), 'arrow-left-alt', 'ablocks/storeengine-continue-button' ], |
| 48 |
// Single-product sections — usable inside the FSE product template. |
| 49 |
'storeengine_single_product_faq' => [ __( 'Product FAQ', 'storeengine' ), 'editor-help', '' ], |
| 50 |
'storeengine_single_product_reviews' => [ __( 'Product Reviews', 'storeengine' ), 'star-filled', '' ], |
| 51 |
'storeengine_single_product_comments' => [ __( 'Product Comments', 'storeengine' ), 'admin-comments', '' ], |
| 52 |
]; |
| 53 |
|
| 54 |
foreach ( $simple as $tag => $meta ) { |
| 55 |
storeengine_register_shortcode_block( [ |
| 56 |
'tag' => $tag, |
| 57 |
'owner' => $owner, |
| 58 |
'title' => $meta[0], |
| 59 |
'category' => $category, |
| 60 |
'icon' => $meta[1], |
| 61 |
'ablocks_block' => $meta[2], |
| 62 |
] ); |
| 63 |
} |
| 64 |
|
| 65 |
// Product grid — a few common presentation attributes. |
| 66 |
storeengine_register_shortcode_block( [ |
| 67 |
'tag' => 'storeengine_products', |
| 68 |
'owner' => $owner, |
| 69 |
'title' => __( 'Products', 'storeengine' ), |
| 70 |
'category' => $category, |
| 71 |
'icon' => 'grid-view', |
| 72 |
'keywords' => [ 'products', 'grid', 'shop' ], |
| 73 |
'ablocks_block' => 'ablocks/storeengine-products', |
| 74 |
'attributes' => [ |
| 75 |
[ |
| 76 |
'name' => 'columns', |
| 77 |
'label' => __( 'Columns', 'storeengine' ), |
| 78 |
'type' => 'range', |
| 79 |
'default' => 3, |
| 80 |
'min' => 1, |
| 81 |
'max' => 6, |
| 82 |
'step' => 1, |
| 83 |
'group' => __( 'Layout', 'storeengine' ), |
| 84 |
'sanitize' => 'int', |
| 85 |
], |
| 86 |
[ |
| 87 |
'name' => 'per_page', |
| 88 |
'label' => __( 'Products per page', 'storeengine' ), |
| 89 |
'type' => 'number', |
| 90 |
'default' => 9, |
| 91 |
'min' => 1, |
| 92 |
'group' => __( 'Layout', 'storeengine' ), |
| 93 |
'sanitize' => 'int', |
| 94 |
], |
| 95 |
[ |
| 96 |
'name' => 'orderby', |
| 97 |
'label' => __( 'Order by', 'storeengine' ), |
| 98 |
'type' => 'select', |
| 99 |
'default' => 'date', |
| 100 |
'group' => __( 'Query', 'storeengine' ), |
| 101 |
'sanitize' => 'key', |
| 102 |
'options' => [ |
| 103 |
[ 'label' => __( 'Newest', 'storeengine' ), 'value' => 'date' ], |
| 104 |
[ 'label' => __( 'Title', 'storeengine' ), 'value' => 'title' ], |
| 105 |
[ 'label' => __( 'Price', 'storeengine' ), 'value' => 'price' ], |
| 106 |
[ 'label' => __( 'Popularity', 'storeengine' ), 'value' => 'popularity' ], |
| 107 |
], |
| 108 |
], |
| 109 |
[ |
| 110 |
'name' => 'order', |
| 111 |
'label' => __( 'Order', 'storeengine' ), |
| 112 |
'type' => 'select', |
| 113 |
'default' => 'DESC', |
| 114 |
'group' => __( 'Query', 'storeengine' ), |
| 115 |
'sanitize' => 'key', |
| 116 |
'options' => [ |
| 117 |
[ 'label' => __( 'Descending', 'storeengine' ), 'value' => 'DESC' ], |
| 118 |
[ 'label' => __( 'Ascending', 'storeengine' ), 'value' => 'ASC' ], |
| 119 |
], |
| 120 |
], |
| 121 |
[ |
| 122 |
'name' => 'ids', |
| 123 |
'label' => __( 'Specific product IDs', 'storeengine' ), |
| 124 |
'type' => 'csv', |
| 125 |
'default' => '', |
| 126 |
'group' => __( 'Query', 'storeengine' ), |
| 127 |
'sanitize' => 'csv', |
| 128 |
], |
| 129 |
], |
| 130 |
] ); |
| 131 |
} |
| 132 |
} |
| 133 |
|