Skip to content

Commit

Permalink
Content updates from Page Editor (#531)
Browse files Browse the repository at this point in the history
* [automated] Sync content from Page Editor.

* Remove the custom download modal

* Parser: Set a parser for the `modal` block, strip newlines from attribute replacements

---------

Co-authored-by: wordpress-org-automations[bot] <68366308+wordpress-org-automations[bot]@users.noreply.github.com>
Co-authored-by: Kelly Dwan <[email protected]>
  • Loading branch information
3 people authored Dec 18, 2024
1 parent e7fa527 commit 0f5b424
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 247 deletions.
1 change: 1 addition & 0 deletions env/export-content/includes/parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function __construct( string $content = '' ) {

// Shared custom blocks.
'wporg/link-wrapper' => new Parsers\HTMLParser( 'a', [ 'href' ] ),
'wporg/modal' => new Parsers\AttributeParser( [ 'label' ] ),
];
}

Expand Down
4 changes: 3 additions & 1 deletion env/export-content/includes/parsers/BlockParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ private function get_attribute( string $attribute_name, array $block ) : array {
private function set_attribute( string $attribute_name, array &$block, array $replacements ) {
if ( isset( $block['attrs'][ $attribute_name ] ) && is_string( $block['attrs'][ $attribute_name ] ) ) {
if ( isset( $replacements[ $block['attrs'][ $attribute_name ] ] ) ) {
$block['attrs'][ $attribute_name ] = $replacements[ $block['attrs'][ $attribute_name ] ];
$replace = $replacements[ $block['attrs'][ $attribute_name ] ];
$replace = str_replace( "\n", ' ', $replace );
$block['attrs'][ $attribute_name ] = $replace;
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions env/export-content/tests/block-parser-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public function data_block_content_strings() {
"<!-- wp:table -->\n<figure class=\"wp-block-table\"><table><thead><tr><th>Cookie</th><th>Logged-in Users Only?</th></tr></thead><tbody><tr><th>welcome-{blog_id}</th><td>No</td></tr><tr><th>showComments</th><td>No</td></tr></tbody></table></figure>\n<!-- /wp:table -->",
[ 'Cookie', 'Logged-in Users Only?', 'welcome-{blog_id}', 'No', 'showComments' ],
],
[
"<!-- wp:wporg/modal {\"closeButtonColor\":\"white\",\"customCloseButtonColor\":\"#ffffff\",\"href\":\"[download_link]\",\"label\":\"Download WordPress [latest_version]\"} -->\n<!-- wp:group {\"style\":{\"elements\":{\"link\":{\"color\":{\"text\":\"var:preset|color|white\"}}},\"spacing\":{\"padding\":{\"top\":\"var:preset|spacing|40\",\"bottom\":\"var:preset|spacing|30\",\"left\":\"var:preset|spacing|40\",\"right\":\"var:preset|spacing|40\"},\"blockGap\":\"var:preset|spacing|10\"}},\"backgroundColor\":\"blueberry-1\",\"textColor\":\"white\",\"layout\":{\"type\":\"constrained\"}} -->\n<div class=\"wp-block-group has-white-color has-blueberry-1-background-color has-text-color has-background has-link-color\" style=\"padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--40)\"><!-- wp:heading {\"style\":{\"spacing\":{\"margin\":{\"top\":\"0\"}}}} -->\n<h2 class=\"wp-block-heading\" style=\"margin-top:0\">Howdy!</h2>\n<!-- /wp:heading --></div>\n<!-- /wp:group -->\n<!-- /wp:wporg/modal -->",
[ 'Download WordPress [latest_version]', 'Howdy!' ],
],
];
}

Expand Down Expand Up @@ -178,6 +182,11 @@ public function data_block_content_i18n_with_shortcode() {
"<!-- wp:buttons -->\n<div class=\"wp-block-buttons\"><!-- wp:button -->\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"[download_link]\">Download WordPress [latest_version]</a></div>\n<!-- /wp:button --></div>\n<!-- /wp:buttons -->",
"<!-- wp:buttons -->\n<div class=\"wp-block-buttons\"><!-- wp:button -->\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"[download_link]\"><?php\n/* translators: [latest_version] is a shortcode and should not be translated. */\n_e( 'Download WordPress [latest_version]', 'wporg' );\n?></a></div>\n<!-- /wp:button --></div>\n<!-- /wp:buttons -->",
],
[
// Modal, with shortcode in the label (shortcode in attribute).
"<!-- wp:wporg/modal {\"closeButtonColor\":\"white\",\"customCloseButtonColor\":\"#ffffff\",\"href\":\"[download_link]\",\"label\":\"Download WordPress [latest_version]\"} -->\n<!-- wp:group -->\n<div class=\"wp-block-group\"><!-- wp:heading {\"style\":{\"spacing\":{\"margin\":{\"top\":\"0\"}}}} -->\n<h2 class=\"wp-block-heading\" style=\"margin-top:0\">Howdy!</h2>\n<!-- /wp:heading --></div>\n<!-- /wp:group -->\n<!-- /wp:wporg/modal -->",
"<!-- wp:wporg/modal {\"closeButtonColor\":\"white\",\"customCloseButtonColor\":\"#ffffff\",\"href\":\"[download_link]\",\"label\":\"<?php /* translators: [latest_version] is a shortcode and should not be translated. */ _e( 'Download WordPress [latest_version]', 'wporg' ); ?>\"} -->\n<!-- wp:group -->\n<div class=\"wp-block-group\"><!-- wp:heading {\"style\":{\"spacing\":{\"margin\":{\"top\":\"0\"}}}} -->\n<h2 class=\"wp-block-heading\" style=\"margin-top:0\"><?php _e( 'Howdy!', 'wporg' ); ?></h2>\n<!-- /wp:heading --></div>\n<!-- /wp:group -->\n<!-- /wp:wporg/modal -->",
],
];
}

Expand Down
27 changes: 0 additions & 27 deletions source/wp-content/themes/wporg-main-2022/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,33 +44,6 @@ function enqueue_assets() {
);
wp_style_add_data( 'wporg-main-2022-style', 'rtl', 'replace' );

if ( is_page( 'download' ) ) {
$path = __DIR__ . '/build/download/index.js';
$deps_path = __DIR__ . '/build/download/index.asset.php';
$script_info = file_exists( $deps_path )
? require $deps_path
: array(
'dependencies' => array(),
'version' => filemtime( $path ),
);

wp_enqueue_script(
'wporg-main-2022-download-script',
get_stylesheet_directory_uri() . '/build/download/index.js',
$script_info['dependencies'],
$script_info['version'],
true
);

wp_enqueue_style(
'wporg-main-2022-download-style',
get_stylesheet_directory_uri() . '/build/download/style-index.css',
array(),
filemtime( __DIR__ . '/build/download/style-index.css' )
);
wp_style_add_data( 'wporg-main-2022-download-style', 'rtl', 'replace' );
}

if ( is_page( 'stats' ) ) {
// phpcs:ignore WordPress.WP.EnqueuedResourceParameters
wp_enqueue_script( 'google-charts', 'https://www.gstatic.com/charts/loader.js', [], null, true );
Expand Down
55 changes: 43 additions & 12 deletions source/wp-content/themes/wporg-main-2022/patterns/download.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,51 @@
<p class="is-style-short-text"><?php _e( 'For anyone comfortable getting their own hosting and domain.', 'wporg' ); ?></p>
<!-- /wp:paragraph -->

<!-- wp:buttons {"layout":{"type":"flex","justifyContent":"left"},"style":{"spacing":{"blockGap":"10px"}}} -->
<div class="wp-block-buttons"><!-- wp:button -->
<div class="wp-block-button" id="wporg__download-button"><a class="wp-block-button__link wp-element-button" href="[download_link]"><?php
/* translators: [latest_version] is a shortcode and should not be translated. */
_e( 'Download WordPress [latest_version]', 'wporg' );
?></a></div>
<!-- /wp:button -->
<!-- wp:group {"style":{"spacing":{"blockGap":"var:preset|spacing|10"}},"layout":{"type":"flex","flexWrap":"nowrap"}} -->
<div class="wp-block-group"><!-- wp:wporg/modal {"closeButtonColor":"white","customCloseButtonColor":"#ffffff","href":"[download_link]","label":"<?php /* translators: [latest_version] is a shortcode and should not be translated. */ _e( 'Download WordPress [latest_version]', 'wporg' ); ?>"} -->
<!-- wp:group {"style":{"elements":{"link":{"color":{"text":"var:preset|color|white"}}},"spacing":{"padding":{"top":"var:preset|spacing|40","bottom":"var:preset|spacing|30","left":"var:preset|spacing|40","right":"var:preset|spacing|40"},"blockGap":"var:preset|spacing|10"}},"backgroundColor":"blueberry-1","textColor":"white","layout":{"type":"constrained"}} -->
<div class="wp-block-group has-white-color has-blueberry-1-background-color has-text-color has-background has-link-color" style="padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--40)"><!-- wp:heading {"style":{"spacing":{"margin":{"top":"0"}}}} -->
<h2 class="wp-block-heading" style="margin-top:0"><?php _e( 'Howdy!', 'wporg' ); ?></h2>
<!-- /wp:heading -->

<!-- wp:paragraph {"fontSize":"extra-large","fontFamily":"eb-garamond"} -->
<p class="has-eb-garamond-font-family has-extra-large-font-size"><?php _e( 'Thanks for downloading WordPress', 'wporg' ); ?></p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->

<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|30","bottom":"var:preset|spacing|40","left":"var:preset|spacing|40","right":"var:preset|spacing|40"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group" style="padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)"><!-- wp:paragraph {"className":"is-style-default"} -->
<p class="is-style-default"><?php _e( 'You&#039;re an important part of the global community that has used, built, and transformed the platform into what it is today. Find out more ways you can contribute and make an impact on the future of the web.', 'wporg' ); ?></p>
<!-- /wp:paragraph -->

<!-- wp:group {"className":"is-style-default","style":{"spacing":{"blockGap":"0"}},"layout":{"type":"flex","orientation":"vertical"}} -->
<div class="wp-block-group is-style-default"><!-- wp:paragraph -->
<p><?php _e( '<a href="https://make.wordpress.org/">Get involved in WordPress ↗︎</a>', 'wporg' ); ?></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><?php _e( '<a href="https://www.meetup.com/pro/wordpress/">Join a local WordPress meetup ↗︎</a>', 'wporg' ); ?></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><?php _e( '<a href="https://central.wordcamp.org/">Attend a WordCamp ↗︎</a>', 'wporg' ); ?></p>
<!-- /wp:paragraph -->

<!-- wp:button {"textColor":"blue-1","className":"is-style-outline"} -->
<!-- wp:paragraph -->
<p><?php _e( '<a href="https://wordpressfoundation.org/donate/">Support WordPress and open source education ↗︎</a>', 'wporg' ); ?></p>
<!-- /wp:paragraph --></div>
<!-- /wp:group --></div>
<!-- /wp:group -->
<!-- /wp:wporg/modal -->

<!-- wp:buttons {"style":{"spacing":{"blockGap":"10px"}},"layout":{"type":"flex","justifyContent":"left"}} -->
<div class="wp-block-buttons"><!-- wp:button {"textColor":"blue-1","className":"is-style-outline"} -->
<div class="wp-block-button is-style-outline"><a class="wp-block-button__link has-blue-1-color has-text-color wp-element-button" href="<?php _e( 'https://developer.wordpress.org/advanced-administration/before-install/howto-install/', 'wporg' ); ?>"><?php _e( 'Installation guide', 'wporg' ); ?></a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons -->
<!-- /wp:buttons --></div>
<!-- /wp:group -->

<!-- wp:paragraph {"textColor":"charcoal-4","className":"is-style-short-text","fontSize":"small"} -->
<!-- wp:paragraph {"className":"is-style-short-text","textColor":"charcoal-4","fontSize":"small"} -->
<p class="is-style-short-text has-charcoal-4-color has-text-color has-small-font-size"><?php
/* translators: [recommended_php], [recommended_mysql], [recommended_mariadb] are shortcodes and should not be translated. */
_e( 'Recommend PHP [recommended_php] or greater and MySQL version [recommended_mysql] or MariaDB version [recommended_mariadb] or greater.', 'wporg' );
Expand Down Expand Up @@ -82,7 +113,7 @@
<div class="wp-block-group alignfull has-blueberry-4-background-color has-background" id="features" style="padding-right:var(--wp--preset--spacing--edge-space);padding-left:var(--wp--preset--spacing--edge-space)"><!-- wp:columns {"verticalAlignment":"center","align":"wide","style":{"spacing":{"blockGap":{"top":"var:preset|spacing|30","left":"var:preset|spacing|70"}}}} -->
<div class="wp-block-columns alignwide are-vertically-aligned-center"><!-- wp:column {"verticalAlignment":"center","width":"50%","style":{"spacing":{"padding":{"right":"0"}}}} -->
<div class="wp-block-column is-vertically-aligned-center" style="padding-right:0;flex-basis:50%"><!-- wp:list {"className":"is-style-features"} -->
<ul class="is-style-features"><!-- wp:list-item -->
<ul class="wp-block-list is-style-features"><!-- wp:list-item -->
<li><?php _e( 'Simple', 'wporg' ); ?></li>
<!-- /wp:list-item -->

Expand Down Expand Up @@ -134,7 +165,7 @@

<!-- wp:column -->
<div class="wp-block-column"><!-- wp:list {"className":"is-style-links-list"} -->
<ul class="is-style-links-list"><!-- wp:list-item -->
<ul class="wp-block-list is-style-links-list"><!-- wp:list-item -->
<li><?php _e( '<a href="https://learn.wordpress.org/course/getting-started-with-wordpress-get-setup/">WordPress courses ↗</a>', 'wporg' ); ?></li>
<!-- /wp:list-item -->

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

19 changes: 0 additions & 19 deletions source/wp-content/themes/wporg-main-2022/src/download/index.js

This file was deleted.

101 changes: 0 additions & 101 deletions source/wp-content/themes/wporg-main-2022/src/download/style.scss

This file was deleted.

0 comments on commit 0f5b424

Please sign in to comment.