From f9387d04ed2c4cb1f0a0448c0a2ab81d2dd6de23 Mon Sep 17 00:00:00 2001 From: madhusudhand Date: Wed, 13 Apr 2022 17:30:26 +0530 Subject: [PATCH] Skatepark: refactor patterns --- skatepark/functions.php | 45 ++++++++- skatepark/inc/block-patterns.php | 43 --------- skatepark/inc/patterns/blog-posts.php | 37 -------- .../inc/patterns/columns-in-container.php | 54 ----------- .../full-width-image-with-aside-caption.php | 29 ------ skatepark/inc/patterns/hidden-404.php | 19 ---- .../inc/patterns/hidden-home-patterns.php | 54 ----------- .../inc/patterns/mixed-media-in-container.php | 92 ------------------- .../inc/patterns/paragraph-with-quote.php | 48 ---------- skatepark/inc/patterns/testimonial.php | 32 ------- .../inc/patterns/text-list-with-button.php | 39 -------- skatepark/inc/patterns/three-columns.php | 45 --------- skatepark/patterns/blog-posts.php | 34 +++++++ skatepark/patterns/columns-in-container.php | 51 ++++++++++ .../full-width-image-with-aside-caption.php | 26 ++++++ skatepark/patterns/hidden-404.php | 15 +++ skatepark/patterns/hidden-home-patterns.php | 48 ++++++++++ .../patterns/mixed-media-in-container.php | 89 ++++++++++++++++++ skatepark/patterns/paragraph-with-quote.php | 45 +++++++++ skatepark/patterns/testimonial.php | 26 ++++++ skatepark/patterns/text-list-with-button.php | 34 +++++++ skatepark/patterns/three-columns.php | 42 +++++++++ 22 files changed, 453 insertions(+), 494 deletions(-) delete mode 100644 skatepark/inc/block-patterns.php delete mode 100644 skatepark/inc/patterns/blog-posts.php delete mode 100644 skatepark/inc/patterns/columns-in-container.php delete mode 100644 skatepark/inc/patterns/full-width-image-with-aside-caption.php delete mode 100644 skatepark/inc/patterns/hidden-404.php delete mode 100644 skatepark/inc/patterns/hidden-home-patterns.php delete mode 100644 skatepark/inc/patterns/mixed-media-in-container.php delete mode 100644 skatepark/inc/patterns/paragraph-with-quote.php delete mode 100644 skatepark/inc/patterns/testimonial.php delete mode 100644 skatepark/inc/patterns/text-list-with-button.php delete mode 100644 skatepark/inc/patterns/three-columns.php create mode 100644 skatepark/patterns/blog-posts.php create mode 100644 skatepark/patterns/columns-in-container.php create mode 100644 skatepark/patterns/full-width-image-with-aside-caption.php create mode 100644 skatepark/patterns/hidden-404.php create mode 100644 skatepark/patterns/hidden-home-patterns.php create mode 100644 skatepark/patterns/mixed-media-in-container.php create mode 100644 skatepark/patterns/paragraph-with-quote.php create mode 100644 skatepark/patterns/testimonial.php create mode 100644 skatepark/patterns/text-list-with-button.php create mode 100644 skatepark/patterns/three-columns.php diff --git a/skatepark/functions.php b/skatepark/functions.php index 0ccae5c4dd..4f78b9634a 100644 --- a/skatepark/functions.php +++ b/skatepark/functions.php @@ -207,6 +207,47 @@ function skatepark_preload_webfonts() { add_action( 'wp_head', 'skatepark_preload_webfonts' ); -// Add block patterns -require get_template_directory() . '/inc/block-patterns.php'; +/** + * Registers block patterns and categories. + * + * @since Skatepark 1.0 + * + * @return void + */ +function skatepark_register_block_pattern_categories() { + + //Needed until https://github.com/WordPress/gutenberg/issues/39500 is fixed. + $block_pattern_categories = array( + 'featured' => array( 'label' => __( 'Featured', 'skatepark' ) ), + 'columns' => array( 'label' => __( 'Columns', 'skatepark' ) ), + 'images' => array( 'label' => __( 'Images', 'skatepark' ) ), + 'text' => array( 'label' => __( 'Text', 'skatepark' ) ), + 'query' => array( 'label' => __( 'Query', 'skatepark' ) ), + ); + + /** + * Filters the theme block pattern categories. + * + * @since Skatepark 1.0 + * + * @param array[] $block_pattern_categories { + * An associative array of block pattern categories, keyed by category name. + * + * @type array[] $properties { + * An array of block category properties. + * + * @type string $label A human-readable label for the pattern category. + * } + * } + */ + $block_pattern_categories = apply_filters( 'skatepark_block_pattern_categories', $block_pattern_categories ); + + foreach ( $block_pattern_categories as $name => $properties ) { + if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( $name ) ) { + register_block_pattern_category( $name, $properties ); + } + } + +} +add_action( 'init', 'skatepark_register_block_pattern_categories', 9 ); diff --git a/skatepark/inc/block-patterns.php b/skatepark/inc/block-patterns.php deleted file mode 100644 index 861b62c5d6..0000000000 --- a/skatepark/inc/block-patterns.php +++ /dev/null @@ -1,43 +0,0 @@ - __( 'Skatepark', 'skatepark' ) ) - ); - } - - if ( function_exists( 'register_block_pattern' ) ) { - $block_patterns = array( - 'blog-posts', - 'mixed-media-in-container', - 'text-list-with-button', - 'full-width-image-with-aside-caption', - 'hidden-404', - 'hidden-home-patterns', - 'testimonial', - 'three-columns', - 'paragraph-with-quote', - 'columns-in-container', - ); - - foreach ( $block_patterns as $block_pattern ) { - register_block_pattern( - 'skatepark/' . $block_pattern, - require __DIR__ . '/patterns/' . $block_pattern . '.php' - ); - } - } - } -endif; - -add_action( 'init', 'skatepark_register_block_patterns', 9 ); diff --git a/skatepark/inc/patterns/blog-posts.php b/skatepark/inc/patterns/blog-posts.php deleted file mode 100644 index 809b3da637..0000000000 --- a/skatepark/inc/patterns/blog-posts.php +++ /dev/null @@ -1,37 +0,0 @@ - __( 'Blog posts', 'skatepark' ), - 'categories' => array( 'skatepark' ), - 'content' => ' -
- -
- -
-
-
- - - - - - - - -
- - - - - - - -
- ', -); diff --git a/skatepark/inc/patterns/columns-in-container.php b/skatepark/inc/patterns/columns-in-container.php deleted file mode 100644 index 84201cd1ce..0000000000 --- a/skatepark/inc/patterns/columns-in-container.php +++ /dev/null @@ -1,54 +0,0 @@ - __( 'Columns in container', 'skatepark' ), - 'categories' => array( 'skatepark' ), - 'content' => ' - - - - -
-
-
-

' . esc_html__( 'Learn to skate', 'skatepark' ) . '

- - - -

' . esc_html__( 'Skatepark welcomes youth of all ages and experience levels. Whether you’ve never been on a board before, or you can already do tricks, there’s a place for you and something to learn.', 'skatepark' ) . '

-
- - - -
-

' . esc_html__( 'Make new friends', 'skatepark' ) . '

- - - -

' . esc_html__( 'Skateboarding is a social sport! Come hang out and meet some new friends to cheer you on while you skate. We have a strict no-bullying policy and maintain a supportive environment.', 'skatepark' ) . '

-
-
- - - - - - - -
' . esc_html__( 'Close-up of a person riding a skateboard, focusing on their feet and the board. One foot is on the board, while the other foot is up, in motion. A skatepark is blurred in the background.', 'skatepark' ) . '
- - - - - - - -

' . esc_html__( 'Skateboarding can teach people discipline, patience, and resiliency. It’s a great sport for kids with a lot of energy! We’ll help build up some structure and support in your life, all while you meet new people and have a ton of fun learning how to skateboard.', 'skatepark' ) . '

-
- ', -); \ No newline at end of file diff --git a/skatepark/inc/patterns/full-width-image-with-aside-caption.php b/skatepark/inc/patterns/full-width-image-with-aside-caption.php deleted file mode 100644 index 65f69829a9..0000000000 --- a/skatepark/inc/patterns/full-width-image-with-aside-caption.php +++ /dev/null @@ -1,29 +0,0 @@ - __( 'Full width image with aside caption', 'skatepark' ), - 'categories' => array( 'skatepark' ), - 'content' => ' -
' . esc_attr__( 'A skateboarder does a grab trick in a bowl-shaped skate park. In the background is a watching crowd, palm trees, and the ocean.', 'skatepark' ) . '
- - -
-
- - - -
-
- - - -

' . esc_html__( 'Learn the basics of skating along with a group of your peers. More advanced at skating? Our skateboarding coaches will work with you 1:1 to advance your technique.', 'skatepark' ) . '

-
-
- ', -); diff --git a/skatepark/inc/patterns/hidden-404.php b/skatepark/inc/patterns/hidden-404.php deleted file mode 100644 index c17ef47bea..0000000000 --- a/skatepark/inc/patterns/hidden-404.php +++ /dev/null @@ -1,19 +0,0 @@ - __( '404', 'skatepark' ), - 'categories' => array( 'skatepark' ), - 'inserter' => false, - 'content' => ' -

' . esc_html__( "Oops! That page can’t be found.", "skatepark" ) . '

- - - -

' . esc_html__( "It looks like nothing was found at this location. Maybe try a search?", "skatepark" ) . '

-', -); diff --git a/skatepark/inc/patterns/hidden-home-patterns.php b/skatepark/inc/patterns/hidden-home-patterns.php deleted file mode 100644 index 3cb64f5ad2..0000000000 --- a/skatepark/inc/patterns/hidden-home-patterns.php +++ /dev/null @@ -1,54 +0,0 @@ - __( 'Block patterns for home page', 'skatepark' ), - 'categories' => array( 'skatepark' ), - 'inserter' => false, - 'content' => ' -

' . esc_html__( 'Empowering at-risk youth through skateboarding', 'skatepark' ) . '

- - - -
' . esc_attr__( 'A skateboarder does a grab trick in a bowl-shaped skate park. In the background is a watching crowd, palm trees, and the ocean.', 'skatepark' ) . '
- - - -
' . esc_html__( 'Latest posts', 'skatepark' ) . '
- - - -
- -
- - -
- - - - - - - - -
- - - - - - - - - - -
- ', -); diff --git a/skatepark/inc/patterns/mixed-media-in-container.php b/skatepark/inc/patterns/mixed-media-in-container.php deleted file mode 100644 index e784c6b1ad..0000000000 --- a/skatepark/inc/patterns/mixed-media-in-container.php +++ /dev/null @@ -1,92 +0,0 @@ - __( 'Mixed Media in Container', 'skatepark' ), - 'categories' => array( 'skatepark' ), - 'content' => ' - - - - -
-
-
-

' . esc_html__( 'Why Camp?', 'skatepark' ) . '

-
- - - -
-

' . esc_html__( 'Skateboarding can teach people discipline, patience, and resiliency. It’s a great sport for kids with a lot of energy! We’ll help build up some structure and support in your life, all while you meet new people and have a ton of fun learning how to skateboard. Just think of all the cool tricks you’ll learn!', 'skatepark' ) . '

- - - - - - - -
' . esc_attr__( 'A skateboard laying on its side on top of concrete.', 'skatepark' ) . '
- - - - -
-
- - - -
-
-

' . esc_html__( 'Discipline', 'skatepark' ) . '

- - - -

' . esc_html__( 'Skateboarding can teach people discipline, patience, and resiliency. It’s a great sport for kids with a lot of energy! We’ll help build up some structure and support in your life, and you’ll have fun.', 'skatepark' ) . '

- - -
- - - -
- - - -
-

' . esc_html( 'Friendship', 'skatepark' ) . '

- - - -

' . esc_html( 'Skateboarding is a social sport! Come hang out and meet some new friends to cheer you on while you skate. We have a strict no-bullying policy and maintain a supportive environment.', 'skatepark' ) . '

-
-
- - - -
-
-
-
- - - -
-

' . esc_html( 'Mentoring', 'skatepark' ) . '

- - - -

' . esc_html( 'Work 1:1 with our team of coaches to learn how to skate. They’ll be your mentors and guides while you’re at camp. Plus, many of our older campers will mentor the younger skaters.', 'skatepark' ) . '

-
- - - -
-
-
- ', -); diff --git a/skatepark/inc/patterns/paragraph-with-quote.php b/skatepark/inc/patterns/paragraph-with-quote.php deleted file mode 100644 index db7c1d2dbf..0000000000 --- a/skatepark/inc/patterns/paragraph-with-quote.php +++ /dev/null @@ -1,48 +0,0 @@ - __( 'Paragraph with quote', 'skatepark' ), - 'categories' => array( 'skatepark' ), - 'content' => ' -
-
- - - -
-

' . esc_html__( 'Why come to Skatepark?', 'skatepark' ) . '

- - - -

' . esc_html__( 'Skateboarding can teach people discipline, patience, and resiliency. It’s a great sport for kids with a lot of energy! We’ll help build up some structure and support in your life, all while you meet new people and have a ton of fun learning how to skateboard.', 'skatepark' ) . '

- - - -

' . esc_html__( 'Skateboarding is a social sport! Come hang out and meet some new friends to cheer you on while you skate. We have a strict no-bullying policy and maintain a supportive environment for all camp attendees. Plus, you’ll work 1:1 with our team of coaches to learn how to skate.', 'skatepark' ) . '

-
- - - -
- - -
- - - -

' . esc_html__( 'I learned how to do a kick flip and made a bunch of new friends. Can’t wait to go back!', 'skatepark' ) . '

- - - -

' . esc_html__( '– Jane Doe, 11', 'skatepark' ) . '

- - -
-
- ', -); diff --git a/skatepark/inc/patterns/testimonial.php b/skatepark/inc/patterns/testimonial.php deleted file mode 100644 index a1b818c8e3..0000000000 --- a/skatepark/inc/patterns/testimonial.php +++ /dev/null @@ -1,32 +0,0 @@ - __( 'Testimonial', 'skatepark' ), - 'categories' => array( 'skatepark' ), - 'content' => ' -
- -
-
- - - -

' . esc_html__( 'Jane Doe', 'skatepark' ) . '

-
- - - -
-

' . esc_html__( 'I learned how to do a kick flip and made a bunch of new friends. Can’t wait to go back!', 'skatepark' ) . '

-
-
- - - - ', -); diff --git a/skatepark/inc/patterns/text-list-with-button.php b/skatepark/inc/patterns/text-list-with-button.php deleted file mode 100644 index 7c33fa0449..0000000000 --- a/skatepark/inc/patterns/text-list-with-button.php +++ /dev/null @@ -1,39 +0,0 @@ - __( 'Text List with Button', 'skatepark' ), - 'categories' => array( 'skatepark' ), - 'content' => ' -
-
- -
-
-
- - - -

' . esc_html__( 'Visiting Coaches', 'skatepark' ) . '

-
-
- -

' . esc_html__( 'Steph Harper. Buddy Sellers. Mehmet Farrow. Bob Lopez. Tammy Habich. Tye Barclay. Kaden Price. Lily Rivera. Chris Wright. Sammy Sanchez.', 'skatepark' ) . '

- - - -
- - -
-
- ', -); diff --git a/skatepark/inc/patterns/three-columns.php b/skatepark/inc/patterns/three-columns.php deleted file mode 100644 index e3a2289202..0000000000 --- a/skatepark/inc/patterns/three-columns.php +++ /dev/null @@ -1,45 +0,0 @@ - __( 'Footer with 3 columns', 'skatepark' ), - 'categories' => array( 'skatepark' ), - 'content' => ' - - ', -); diff --git a/skatepark/patterns/blog-posts.php b/skatepark/patterns/blog-posts.php new file mode 100644 index 0000000000..ae5778aab8 --- /dev/null +++ b/skatepark/patterns/blog-posts.php @@ -0,0 +1,34 @@ + + + +
+ +
+ +
+
+
+ + + + + + + + +
+ + + + + + + +
+ diff --git a/skatepark/patterns/columns-in-container.php b/skatepark/patterns/columns-in-container.php new file mode 100644 index 0000000000..f192a26dcd --- /dev/null +++ b/skatepark/patterns/columns-in-container.php @@ -0,0 +1,51 @@ + + + + + + + +
+
+
+

+ + + +

+
+ + + +
+

+ + + +

+
+
+ + + + + + + +
<?php echo esc_html__( 'Close-up of a person riding a skateboard, focusing on their feet and the board. One foot is on the board, while the other foot is up, in motion. A skatepark is blurred in the background.', 'skatepark' ); ?>
+ + + + + + + +

+
+ diff --git a/skatepark/patterns/full-width-image-with-aside-caption.php b/skatepark/patterns/full-width-image-with-aside-caption.php new file mode 100644 index 0000000000..2f548ab0e7 --- /dev/null +++ b/skatepark/patterns/full-width-image-with-aside-caption.php @@ -0,0 +1,26 @@ + + + +
<?php echo esc_attr__( 'A skateboarder does a grab trick in a bowl-shaped skate park. In the background is a watching crowd, palm trees, and the ocean.', 'skatepark' ); ?>
+ + +
+
+ + + +
+
+ + + +

+
+
+ diff --git a/skatepark/patterns/hidden-404.php b/skatepark/patterns/hidden-404.php new file mode 100644 index 0000000000..520eb16f51 --- /dev/null +++ b/skatepark/patterns/hidden-404.php @@ -0,0 +1,15 @@ + + + +

+ + + +

+ diff --git a/skatepark/patterns/hidden-home-patterns.php b/skatepark/patterns/hidden-home-patterns.php new file mode 100644 index 0000000000..4f626f5660 --- /dev/null +++ b/skatepark/patterns/hidden-home-patterns.php @@ -0,0 +1,48 @@ + + + +

+ + + +
<?php echo esc_attr__( 'A skateboarder does a grab trick in a bowl-shaped skate park. In the background is a watching crowd, palm trees, and the ocean.', 'skatepark' ); ?>
+ + + +
+ + + +
+ +
+ + +
+ + + + + + + + +
+ + + + + + + + + + +
+ diff --git a/skatepark/patterns/mixed-media-in-container.php b/skatepark/patterns/mixed-media-in-container.php new file mode 100644 index 0000000000..d76450633d --- /dev/null +++ b/skatepark/patterns/mixed-media-in-container.php @@ -0,0 +1,89 @@ + + + + + + + +
+
+
+

+
+ + + +
+

+ + + + + + + +
<?php echo esc_attr__( 'A skateboard laying on its side on top of concrete.', 'skatepark' ); ?>
+ + + + +
+
+ + + +
+
+

+ + + +

+ + +
+ + + +
+ + + +
+

+ + + +

+
+
+ + + +
+
+
+
+ + + +
+

+ + + +

+
+ + + +
+
+
+ diff --git a/skatepark/patterns/paragraph-with-quote.php b/skatepark/patterns/paragraph-with-quote.php new file mode 100644 index 0000000000..9f9cad440a --- /dev/null +++ b/skatepark/patterns/paragraph-with-quote.php @@ -0,0 +1,45 @@ + + + +
+
+ + + +
+

+ + + +

+ + + +

+
+ + + +
+ + +
+ + + +

+ + + +

+ + +
+
+ diff --git a/skatepark/patterns/testimonial.php b/skatepark/patterns/testimonial.php new file mode 100644 index 0000000000..9ec9ad47be --- /dev/null +++ b/skatepark/patterns/testimonial.php @@ -0,0 +1,26 @@ + + + +
+ +
+
+ + + +

+
+ + + +
+

+
+
+ diff --git a/skatepark/patterns/text-list-with-button.php b/skatepark/patterns/text-list-with-button.php new file mode 100644 index 0000000000..5759390189 --- /dev/null +++ b/skatepark/patterns/text-list-with-button.php @@ -0,0 +1,34 @@ + + + +
+
+ +
+
+
+ + + +

+
+
+ +

+ + +
+
+
+
+ + +
+
+ diff --git a/skatepark/patterns/three-columns.php b/skatepark/patterns/three-columns.php new file mode 100644 index 0000000000..d7ee07e0de --- /dev/null +++ b/skatepark/patterns/three-columns.php @@ -0,0 +1,42 @@ + + + + +