PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 4.6.2
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v4.6.2
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 +28 -5 1.0.54.6.2 View file →
@@ -23,14 +23,11 @@
23 23 /**
24 24 * Set categories and patterns.
25 25 */
26 26 public function __construct() {
27 - $this->categories = [
28 - 'surecart_form' => [ 'label' => __( 'Checkout Form', 'surecart' ) ],
29 - ];
30 -
31 27 $this->patterns = [
32 28 'default',
29 + 'full-page',
33 30 'simple',
34 31 'sections',
35 32 'two-column',
36 33 'donation',
@@ -50,9 +47,15 @@
50 47 /**
51 48 * Register block patterns and
52 49 */
53 50 public function registerPatternsAndCategories() {
54 - // $this->registerCategories();
51 + $this->categories = [
52 + 'surecart_form' => [ 'label' => __( 'Checkout Form', 'surecart' ) ],
53 + 'surecart_shop' => [ 'label' => __( 'Shop', 'surecart' ) ],
54 + 'surecart_product_page' => [ 'label' => __( 'Product Page', 'surecart' ) ],
55 + 'surecart_related_products' => [ 'label' => __( 'Related Products', 'surecart' ) ],
56 + ];
57 + $this->registerCategories();
55 58 $this->registerPatterns();
56 59 }
57 60
58 61 /**
@@ -88,8 +91,28 @@
88 91 *
89 92 * @return void
90 93 */
91 94 public function registerPatterns() {
95 + // register the block patterns from patterns directory.
96 + $patterns = glob( plugin_dir_path( SURECART_PLUGIN_FILE ) . 'templates/patterns/*.php' );
97 +
98 + // sort by priority key.
99 + usort(
100 + $patterns,
101 + function ( $a, $b ) {
102 + $a = require $a;
103 + $b = require $b;
104 + return ( $a['priority'] ?? 0 ) <=> ( $b['priority'] ?? 0 );
105 + }
106 + );
107 +
108 + foreach ( $patterns as $pattern_file ) {
109 + register_block_pattern(
110 + 'surecart-' . basename( $pattern_file, '.php' ),
111 + require $pattern_file
112 + );
113 + }
114 +
92 115 /**
93 116 * Filters the plugin block patterns.
94 117 *
95 118 * @param array $patterns List of block patterns by name.