diff --git a/assets/css/src/blocks/_categories.scss b/assets/css/src/blocks/_categories.scss index 0511630..7af573f 100644 --- a/assets/css/src/blocks/_categories.scss +++ b/assets/css/src/blocks/_categories.scss @@ -10,7 +10,7 @@ li { margin: 5px; - background-color: var(--wp--preset--color--raft-bg-alt); + background-color: var(--wp--preset--color--ti-bg-alt); border-radius: 25px; padding: 8px 24px; } diff --git a/assets/css/src/blocks/_image.scss b/assets/css/src/blocks/_image.scss index a7c95da..746abcd 100644 --- a/assets/css/src/blocks/_image.scss +++ b/assets/css/src/blocks/_image.scss @@ -28,7 +28,7 @@ figure.wp-block-image { figcaption { @extend %figcaption; - color: var(--wp--preset--color--raft-fg); + color: var(--wp--preset--color--ti-fg); opacity: 0.6; } } diff --git a/assets/css/src/blocks/_navigation.scss b/assets/css/src/blocks/_navigation.scss index 172568c..9155a05 100644 --- a/assets/css/src/blocks/_navigation.scss +++ b/assets/css/src/blocks/_navigation.scss @@ -1,7 +1,7 @@ // Overwrite the selector... .wp-block-navigation:not(.has-background) .wp-block-navigation__responsive-container.is-menu-open { - background: var(--wp--preset--color--raft-bg); - color: var(--wp--preset--color--raft-fg); + background: var(--wp--preset--color--ti-bg); + color: var(--wp--preset--color--ti-fg); } .wp-block-navigation__responsive-container.is-menu-open { diff --git a/assets/css/src/blocks/_post-terms.scss b/assets/css/src/blocks/_post-terms.scss index 6b401f1..0e5de62 100644 --- a/assets/css/src/blocks/_post-terms.scss +++ b/assets/css/src/blocks/_post-terms.scss @@ -7,7 +7,7 @@ a { padding: 8px 24px; margin: 5px; - background-color: var(--wp--preset--color--raft-bg-alt); + background-color: var(--wp--preset--color--ti-bg-alt); border-radius: 25px; } diff --git a/assets/css/src/blocks/_search.scss b/assets/css/src/blocks/_search.scss index 899afd1..1866d3d 100644 --- a/assets/css/src/blocks/_search.scss +++ b/assets/css/src/blocks/_search.scss @@ -6,9 +6,9 @@ } .wp-block-search__button { - background: var(--wp--preset--color--raft-accent); - color: var(--wp--preset--color--raft-fg-alt); - border-color: var(--wp--preset--color--raft-accent); + background: var(--wp--preset--color--ti-accent); + color: var(--wp--preset--color--ti-fg-alt); + border-color: var(--wp--preset--color--ti-accent); border-radius: 5px; } } diff --git a/assets/css/src/blocks/_table.scss b/assets/css/src/blocks/_table.scss index 6bbd123..1dc0561 100644 --- a/assets/css/src/blocks/_table.scss +++ b/assets/css/src/blocks/_table.scss @@ -1,7 +1,7 @@ .wp-block-table { &.is-style-stripes tbody tr:nth-child(odd) { - background-color: var(--wp--preset--color--raft-bg-alt); + background-color: var(--wp--preset--color--ti-bg-alt); } thead { @@ -14,7 +14,7 @@ figcaption { font-size: var(--wp--preset--font-size--small); - color: var(--wp--preset--color--raft-fg); + color: var(--wp--preset--color--ti-fg); opacity: 0.6; } } diff --git a/assets/css/src/common/_color-migration.scss b/assets/css/src/common/_color-migration.scss new file mode 100644 index 0000000..ec51710 --- /dev/null +++ b/assets/css/src/common/_color-migration.scss @@ -0,0 +1,19 @@ +//.has-raft-fg-alt-color +//.has-raft-accent-background-color +$colors: ( + raft-bg : ti-bg, + raft-fg: ti-fg, + raft-bg-alt: ti-bg-alt, + raft-fg-alt: ti-fg-alt, + raft-accent: ti-accent, +); + +// remap color css variables to has-*-color and has-*-background-color +@each $raft, $generic in $colors { + .has-#{$raft}-color { + color: var(--wp--preset--color--#{$generic}); + } + .has-#{$raft}-background-color { + background-color: var(--wp--preset--color--#{$generic}); + } +} diff --git a/assets/css/src/editor.scss b/assets/css/src/editor.scss index 065bd5f..bad6ce2 100644 --- a/assets/css/src/editor.scss +++ b/assets/css/src/editor.scss @@ -4,6 +4,7 @@ @import "common/generic"; @import "common/typography"; + @import "common/color-migration"; @import "blocks/main"; @import "elements/main"; @import "editor/blocks/main"; diff --git a/assets/css/src/elements/_extends.scss b/assets/css/src/elements/_extends.scss index c9f0dda..86e8090 100644 --- a/assets/css/src/elements/_extends.scss +++ b/assets/css/src/elements/_extends.scss @@ -1,8 +1,8 @@ %input-base { border-radius: 5px; - color: var(--wp--preset--color--raft-fg); - background: var(--wp--preset--color--raft-bg); - border: 2px solid var(--wp--preset--color--raft-fg); + color: var(--wp--preset--color--ti-fg); + background: var(--wp--preset--color--ti-bg); + border: 2px solid var(--wp--preset--color--ti-fg); } @mixin button-base { @@ -17,7 +17,7 @@ %button { @include button-base; - color: var(--wp--preset--color--raft-fg-alt); - background: var(--wp--preset--color--raft-accent); - border-color: var(--wp--preset--color--raft-accent); + color: var(--wp--preset--color--ti-fg-alt); + background: var(--wp--preset--color--ti-accent); + border-color: var(--wp--preset--color--ti-accent); } diff --git a/assets/css/src/style.scss b/assets/css/src/style.scss index 1e8293c..30b6568 100644 --- a/assets/css/src/style.scss +++ b/assets/css/src/style.scss @@ -1,5 +1,6 @@ @import "common/generic"; @import "common/typography"; +@import "common/color-migration"; @import "common/vars"; @import "elements/main"; @import "blocks/main"; diff --git a/inc/Core.php b/inc/Core.php index 9aee36a..82a3be8 100644 --- a/inc/Core.php +++ b/inc/Core.php @@ -44,6 +44,7 @@ public function __construct() { new Admin(); new Block_Patterns(); new Block_Styles(); + new Migration(); } /** diff --git a/inc/Migration.php b/inc/Migration.php new file mode 100644 index 0000000..c94bcaa --- /dev/null +++ b/inc/Migration.php @@ -0,0 +1,155 @@ + 'raft_colors_migration', + ); + + /** + * Migration Constructor + */ + public function __construct() { + if ( $this->was_migrated( 'colors' ) ) { + return; + } + + $this->setup_properties(); + + add_action( 'init', array( $this, 'migrate_old_colors' ) ); + } + + + /** + * Setup the properties. + * + * @return void + */ + private function setup_properties() { + $args = array( + 'posts_per_page' => 1, + 'orderby' => 'date', + 'order' => 'desc', + 'post_type' => 'wp_global_styles', + 'post_status' => 'publish', + 'ignore_sticky_posts' => true, + 'no_found_rows' => true, + 'tax_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query + array( + 'taxonomy' => 'wp_theme', + 'field' => 'name', + 'terms' => 'raft', + ), + ), + ); + + $global_style_query = new \WP_Query(); + $recent_posts = $global_style_query->query( $args ); + + if ( empty( $recent_posts ) ) { + return; + } + + $this->global_styles_data = json_decode( $recent_posts[0]->post_content, true ); + $this->global_styles_post_id = $recent_posts[0]->ID; + } + + /** + * Migrate the old color slugs. + * + * @return void + */ + public function migrate_old_colors() { + if ( $this->was_migrated( 'colors' ) ) { + return; + } + + if ( 0 === $this->global_styles_post_id || empty( $this->global_styles_data ) ) { + return; + } + + if ( + ! isset( $this->global_styles_data['settings'] ) || + ! isset( $this->global_styles_data['settings']['color'] ) || + ! isset( $this->global_styles_data['settings']['color']['palette'] ) || + ! isset( $this->global_styles_data['settings']['color']['palette']['theme'] ) + ) { + return; + } + + $colors = $this->global_styles_data['settings']['color']['palette']['theme']; + + array_walk( + $colors, + function ( &$color ) { + $color['slug'] = str_replace( 'raft-', 'ti-', $color['slug'] ); + + return $color; + } + ); + + $this->global_styles_data['settings']['color']['palette']['theme'] = $colors; + + $update = wp_update_post( + array( + 'ID' => $this->global_styles_post_id, + 'post_content' => wp_json_encode( $this->global_styles_data ), + ) + ); + + if ( is_wp_error( $update ) ) { + return; + } + + $this->set_migrated( 'colors' ); + } + + /** + * Check if a migration was already done. + * + * @param string $key The migration key. + * + * @return bool + */ + private function was_migrated( $key ) { + return get_option( self::MIGRATION_FLAGS[ $key ], false ) === true; + } + + /** + * Set a migration as done. + * + * @param string $key The migration key. + * + * @return void + */ + private function set_migrated( $key ) { + update_option( self::MIGRATION_FLAGS[ $key ], true ); + } +} diff --git a/inc/patterns/alternating-feature-columns.php b/inc/patterns/alternating-feature-columns.php index fc0ce10..8391fd8 100644 --- a/inc/patterns/alternating-feature-columns.php +++ b/inc/patterns/alternating-feature-columns.php @@ -47,16 +47,16 @@ - -
+ +
-
-
+
+
diff --git a/inc/patterns/call-to-action.php b/inc/patterns/call-to-action.php index 41be1f0..7d6f6d3 100644 --- a/inc/patterns/call-to-action.php +++ b/inc/patterns/call-to-action.php @@ -16,16 +16,16 @@ 'title' => __( 'Call to action', 'raft' ), 'categories' => array( 'raft' ), 'content' => ' - -
- -

Lorem ipsum sit dolor!

+ +
+ +

Lorem ipsum sit dolor!

diff --git a/inc/patterns/content-columns-with-hero.php b/inc/patterns/content-columns-with-hero.php index 86fc87b..83f9689 100644 --- a/inc/patterns/content-columns-with-hero.php +++ b/inc/patterns/content-columns-with-hero.php @@ -16,8 +16,8 @@ 'title' => __( 'Content columns with hero', 'raft' ), 'categories' => array( 'raft' ), 'content' => ' - -
+ +

Lorem ipsum sit dolor

diff --git a/inc/patterns/cover-background.php b/inc/patterns/cover-background.php index 572ee49..7d1d116 100644 --- a/inc/patterns/cover-background.php +++ b/inc/patterns/cover-background.php @@ -30,8 +30,8 @@
- -
+ +

' . esc_html( $strings['title'] ) . '

diff --git a/inc/patterns/frequently-asked-questions.php b/inc/patterns/frequently-asked-questions.php index be7ea82..430d7d0 100644 --- a/inc/patterns/frequently-asked-questions.php +++ b/inc/patterns/frequently-asked-questions.php @@ -13,8 +13,8 @@ */ $column_markup = ' - -
+ +

Lorem ipsum sit dolor

@@ -50,9 +50,9 @@ diff --git a/inc/patterns/hero-with-columns.php b/inc/patterns/hero-with-columns.php index 0df7e7f..58b194f 100644 --- a/inc/patterns/hero-with-columns.php +++ b/inc/patterns/hero-with-columns.php @@ -38,13 +38,13 @@

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore.

- -
+ +
-
-
+
+
@@ -64,8 +64,8 @@
- -
+ +
@@ -85,8 +85,8 @@
- -
+ +
diff --git a/inc/patterns/hero.php b/inc/patterns/hero.php index d793474..353fba9 100644 --- a/inc/patterns/hero.php +++ b/inc/patterns/hero.php @@ -26,8 +26,8 @@ 'title' => __( 'Hero section', 'raft' ), 'categories' => array( 'raft' ), 'content' => ' - -
+ +

' . esc_html( $strings['title'] ) . '

@@ -40,9 +40,9 @@
- + diff --git a/inc/patterns/horizontal-content-cards.php b/inc/patterns/horizontal-content-cards.php index 6ba659d..22f1b6c 100644 --- a/inc/patterns/horizontal-content-cards.php +++ b/inc/patterns/horizontal-content-cards.php @@ -28,8 +28,8 @@ 'content' => '
-
-
+
+
@@ -53,8 +53,8 @@
- -
+ +
diff --git a/inc/patterns/image-gallery.php b/inc/patterns/image-gallery.php index 924cb43..c2f179a 100644 --- a/inc/patterns/image-gallery.php +++ b/inc/patterns/image-gallery.php @@ -74,9 +74,9 @@ diff --git a/inc/patterns/inverted-background.php b/inc/patterns/inverted-background.php index 4b315b4..77ff338 100644 --- a/inc/patterns/inverted-background.php +++ b/inc/patterns/inverted-background.php @@ -25,8 +25,8 @@ 'title' => $strings['title'], 'categories' => array( 'raft' ), 'content' => ' - -
+ +
diff --git a/inc/patterns/inverted-gallery-with-title.php b/inc/patterns/inverted-gallery-with-title.php index 4e05326..1145871 100644 --- a/inc/patterns/inverted-gallery-with-title.php +++ b/inc/patterns/inverted-gallery-with-title.php @@ -29,8 +29,8 @@ 'title' => $strings['title'], 'categories' => array( 'raft' ), 'content' => ' - -
+ +
diff --git a/inc/patterns/posts-query-loop-2.php b/inc/patterns/posts-query-loop-2.php index afea91c..4f0b492 100644 --- a/inc/patterns/posts-query-loop-2.php +++ b/inc/patterns/posts-query-loop-2.php @@ -42,8 +42,8 @@ - -

' . esc_html( $strings['no_posts'] ) . '

+ +

' . esc_html( $strings['no_posts'] ) . '

diff --git a/inc/patterns/posts-query-loop.php b/inc/patterns/posts-query-loop.php index 18e0731..cdeb71c 100644 --- a/inc/patterns/posts-query-loop.php +++ b/inc/patterns/posts-query-loop.php @@ -41,7 +41,7 @@ - + @@ -56,8 +56,8 @@ - -

Unfortuna' . esc_html( $strings['no_posts'] ) . 'd

+ +

Unfortuna' . esc_html( $strings['no_posts'] ) . 'd

diff --git a/inc/patterns/pricing-plans-inline-title.php b/inc/patterns/pricing-plans-inline-title.php index c628909..af0ffcc 100644 --- a/inc/patterns/pricing-plans-inline-title.php +++ b/inc/patterns/pricing-plans-inline-title.php @@ -37,8 +37,8 @@
- -
+ +

Agency

@@ -81,8 +81,8 @@
- -
+ +

Enterprise

diff --git a/inc/patterns/pricing-plans.php b/inc/patterns/pricing-plans.php index d8442bb..405c480 100644 --- a/inc/patterns/pricing-plans.php +++ b/inc/patterns/pricing-plans.php @@ -34,8 +34,8 @@
-
-
+
+

Starter

@@ -72,14 +72,14 @@ - - -
+ +

Agency

@@ -116,14 +116,14 @@ - - -
+ +

Enterprise

@@ -160,8 +160,8 @@ -
diff --git a/inc/patterns/team.php b/inc/patterns/team.php index 1a27548..e72c0bc 100644 --- a/inc/patterns/team.php +++ b/inc/patterns/team.php @@ -22,8 +22,8 @@ 'title' => $strings['title'], 'categories' => array( 'raft' ), 'content' => ' - -
+ +

' . esc_html( $strings['title'] ) . '

@@ -48,7 +48,7 @@

CEO / Co-founder

- + @@ -68,7 +68,7 @@

CFO / Co-founder

- + @@ -88,7 +88,7 @@

CTO / Co-founder

- + diff --git a/inc/patterns/testimonial-columns.php b/inc/patterns/testimonial-columns.php index 5fad688..d6cb712 100644 --- a/inc/patterns/testimonial-columns.php +++ b/inc/patterns/testimonial-columns.php @@ -18,8 +18,8 @@ 'title' => __( 'Testimonial Columns', 'raft' ), 'categories' => array( 'raft' ), 'content' => ' - -
+ +
diff --git a/inc/patterns/two-columns-features.php b/inc/patterns/two-columns-features.php index de93e6f..533f354 100644 --- a/inc/patterns/two-columns-features.php +++ b/inc/patterns/two-columns-features.php @@ -52,8 +52,8 @@ 'title' => $strings['title'], 'categories' => array( 'raft' ), 'content' => ' - -
+ +

' . esc_html( $strings['title'] ) . '

diff --git a/parts/header.html b/parts/header.html index d3562b3..4b7cf70 100644 --- a/parts/header.html +++ b/parts/header.html @@ -20,7 +20,7 @@ - +
diff --git a/templates/archive.html b/templates/archive.html index b456280..35ece1b 100644 --- a/templates/archive.html +++ b/templates/archive.html @@ -1,7 +1,7 @@ - -
+
@@ -43,7 +43,7 @@
- + @@ -52,8 +52,8 @@ - -

Unfortunately no posts were found

+ +

Unfortunately no posts were found

diff --git a/templates/index.html b/templates/index.html index 9f57654..0ce1519 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,7 +1,7 @@ - -
+

Our awesome blog

@@ -31,7 +31,7 @@

Our awesome blog

- + @@ -42,8 +42,8 @@

Our awesome blog

- -

Unfortunately no posts were found

+ +

Unfortunately no posts were found

@@ -51,8 +51,8 @@

Our awesome blog

- -
+ +

Power-up your Gutenberg layouts with Otter

diff --git a/templates/page.html b/templates/page.html index 395a418..396012b 100644 --- a/templates/page.html +++ b/templates/page.html @@ -1,7 +1,7 @@ - -
+ +
diff --git a/templates/search.html b/templates/search.html index 2b3f698..f3443c3 100644 --- a/templates/search.html +++ b/templates/search.html @@ -1,7 +1,7 @@ - -
+
@@ -10,7 +10,7 @@

Search results

- +
@@ -44,7 +44,7 @@

Search results

- + @@ -55,8 +55,8 @@

Search results

- -

Unfortunately no posts were + +

Unfortunately no posts were found

diff --git a/templates/single.html b/templates/single.html index bc693c9..cced6f9 100644 --- a/templates/single.html +++ b/templates/single.html @@ -1,7 +1,7 @@ - -
+
diff --git a/theme.json b/theme.json index 540a16f..bc23c03 100644 --- a/theme.json +++ b/theme.json @@ -5,27 +5,27 @@ "color": { "palette": [ { - "slug": "raft-bg", + "slug": "ti-bg", "color": "#EBE8E6", "name": "Background" }, { - "slug": "raft-fg", + "slug": "ti-fg", "color": "#1D1F25", "name": "Foreground" }, { - "slug": "raft-bg-alt", + "slug": "ti-bg-alt", "color": "rgba(255, 255, 255, 0.6)", "name": "Background Alt" }, { - "slug": "raft-fg-alt", + "slug": "ti-fg-alt", "color": "#FDFDFD", "name": "Foreground Alt" }, { - "slug": "raft-accent", + "slug": "ti-accent", "color": "#C26148", "name": "Accent" } @@ -224,8 +224,8 @@ }, "styles": { "color": { - "background": "var(--wp--preset--color--raft-bg)", - "text": "var(--wp--preset--color--raft-fg)" + "background": "var(--wp--preset--color--ti-bg)", + "text": "var(--wp--preset--color--ti-fg)" }, "typography": { "fontSize": "var(--wp--preset--font-size--normal)", @@ -236,7 +236,7 @@ "elements": { "link": { "color": { - "text": "var(--wp--preset--color--raft-fg)" + "text": "var(--wp--preset--color--ti-fg)" }, "typography": { "textDecoration": "none" @@ -291,8 +291,8 @@ "radius": "3px" }, "color": { - "background": "var(--wp--preset--color--raft-accent)", - "text": "var(--wp--preset--color--raft-fg-alt)" + "background": "var(--wp--preset--color--ti-accent)", + "text": "var(--wp--preset--color--ti-fg-alt)" }, "spacing": { "padding": { @@ -312,7 +312,7 @@ "radius": "5px" }, "color": { - "background": "var(--wp--preset--color--raft-bg-alt)" + "background": "var(--wp--preset--color--ti-bg-alt)" }, "spacing": { "padding": { @@ -350,7 +350,7 @@ "fontSize": "var(--wp--preset--font-size--small)" }, "color": { - "text": "var(--wp--preset--color--raft-accent)" + "text": "var(--wp--preset--color--ti-accent)" } } } @@ -367,13 +367,13 @@ }, "woocommerce/mini-cart-contents": { "color": { - "text": "var(--wp--preset--color--raft-fg)", - "background": "var(--wp--preset--color--raft-bg)" + "text": "var(--wp--preset--color--ti-fg)", + "background": "var(--wp--preset--color--ti-bg)" }, "elements": { "link": { "color": { - "text": "var(--wp--preset--color--raft-accent)" + "text": "var(--wp--preset--color--ti-accent)" } } } @@ -403,7 +403,8 @@ "name": "header", "title": "Header", "area": "header" - },{ + }, + { "name": "header-centered", "title": "Header Centered", "area": "header"