PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 3.4.1
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v3.4.1
4.7.2 4.7.1 4.7.0 4.6.6 4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.1 4.5.0 4.4.2 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.3 4.2.2 4.2.1 1.0.3 1.0.4 1.0.5 All 281 releases
← All changes | app/src/BlockLibrary/BlockPatternsService.php +26 -2 1.0.33.4.1 View file →
@@ -24,13 +24,17 @@
24 24 * Set categories and patterns.
25 25 */
26 26 public function __construct() {
27 27 $this->categories = [
28 - 'surecart_form' => [ 'label' => __( 'Checkout Form', 'surecart' ) ],
28 + 'surecart_form' => [ 'label' => __( 'Checkout Form', 'surecart' ) ],
29 + 'surecart_shop' => [ 'label' => __( 'Shop', 'surecart' ) ],
30 + 'surecart_product_page' => [ 'label' => __( 'Product Page', 'surecart' ) ],
31 + 'surecart_related_products' => [ 'label' => __( 'Related Products', 'surecart' ) ],
29 32 ];
30 33
31 34 $this->patterns = [
32 35 'default',
36 + 'full-page',
33 37 'simple',
34 38 'sections',
35 39 'two-column',
36 40 'donation',
@@ -50,9 +54,9 @@
50 54 /**
51 55 * Register block patterns and
52 56 */
53 57 public function registerPatternsAndCategories() {
54 - // $this->registerCategories();
58 + $this->registerCategories();
55 59 $this->registerPatterns();
56 60 }
57 61
58 62 /**
@@ -88,8 +92,28 @@
88 92 *
89 93 * @return void
90 94 */
91 95 public function registerPatterns() {
96 + // register the block patterns from patterns directory.
97 + $patterns = glob( plugin_dir_path( SURECART_PLUGIN_FILE ) . 'templates/patterns/*.php' );
98 +
99 + // sort by priority key.
100 + usort(
101 + $patterns,
102 + function ( $a, $b ) {
103 + $a = require $a;
104 + $b = require $b;
105 + return ( $a['priority'] ?? 0 ) <=> ( $b['priority'] ?? 0 );
106 + }
107 + );
108 +
109 + foreach ( $patterns as $pattern_file ) {
110 + register_block_pattern(
111 + 'surecart-' . basename( $pattern_file, '.php' ),
112 + require $pattern_file
113 + );
114 + }
115 +
92 116 /**
93 117 * Filters the plugin block patterns.
94 118 *
95 119 * @param array $patterns List of block patterns by name.