Skip to content

Commit

Permalink
Single theme: Use links for sidebar actions
Browse files Browse the repository at this point in the history
Fixes #62
  • Loading branch information
ryelle committed May 16, 2024
1 parent 29001bf commit 9421808
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 33 deletions.
43 changes: 31 additions & 12 deletions source/wp-content/themes/wporg-themes-2024/inc/block-bindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ function get_meta_block_value( $args, $block ) {
return '';
}

$report_url = add_query_arg(
urlencode_deep(
array_filter(
array(
'rep-theme' => "https://wordpress.org/themes/{$theme->slug}/",
'rep-subject' => "Reported Theme: {$theme->name}", // Not translated, email subject.
'rep-name' => wp_get_current_user()->user_login,
)
)
),
'https://make.wordpress.org/themes/report-theme/'
);

switch ( $args['key'] ) {
case 'version':
/* translators: %s: Version number. */
Expand Down Expand Up @@ -108,22 +121,28 @@ function get_meta_block_value( $args, $block ) {
);
case 'support-forum-url':
return esc_url( get_support_url( $theme->slug ) );
case 'support-forum-link':
return sprintf(
'<a href="%s">%s</a>',
esc_url( get_support_url( $theme->slug ) ),
__( 'View support forum', 'wporg-themes' )
);
case 'submit-review-url':
return esc_url( get_support_url( $theme->slug . '/reviews/#new-post' ) );
case 'report-url':
$report_url = add_query_arg(
urlencode_deep(
array_filter(
array(
'rep-theme' => "https://wordpress.org/themes/{$theme->slug}/",
'rep-subject' => "Reported Theme: {$theme->name}", // Not translated, email subject.
'rep-name' => wp_get_current_user()->user_login,
)
)
),
'https://make.wordpress.org/themes/report-theme/'
case 'submit-review-link':
return sprintf(
'<a href="%s">%s</a>',
esc_url( get_support_url( $theme->slug . '/reviews/#new-post' ) ),
__( 'Add my review', 'wporg-themes' )
);
case 'report-url':
return esc_url( $report_url );
case 'report-link':
return sprintf(
'<a href="%s">%s</a>',
esc_url( $report_url ),
__( 'Report this theme', 'wporg-themes' )
);
case 'translate-link':
return sprintf(
'<a href="%s">%s</a>',
Expand Down
30 changes: 9 additions & 21 deletions source/wp-content/themes/wporg-themes-2024/patterns/single.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,9 @@

<!-- wp:wporg/ratings-bars /-->

<!-- wp:buttons {"style":{"spacing":{"margin":{"top":"var:preset|spacing|10"}}}} -->
<div class="wp-block-buttons" style="margin-top:var(--wp--preset--spacing--10)">
<!-- wp:button {"className":"is-style-outline is-small","metadata":{"bindings":{"url":{"source":"wporg-themes/meta","args":{"key":"submit-review-url"}}}}} -->
<div class="wp-block-button is-style-outline is-small"><a class="wp-block-button__link wp-element-button"><?php esc_html_e( 'Add my review', 'wporg-themes' ); ?></a></div>
<!-- /wp:button -->
</div>
<!-- /wp:buttons -->
<!-- wp:paragraph {"style":{"spacing":{"margin":{"top":"var:preset|spacing|10"}}},"metadata":{"bindings":{"content":{"source":"wporg-themes/meta","args":{"key":"submit-review-link"}}}}} -->
<p style="margin-top:var(--wp--preset--spacing--10)">Add my review</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"fontSize":"heading-4"} -->
<h2 class="wp-block-heading has-heading-4-font-size"><?php esc_html_e( 'Support', 'wporg-themes' ); ?></h2>
Expand All @@ -141,13 +137,9 @@
<p><?php esc_html_e( 'Got something to say? Need help?', 'wporg-themes' ); ?></p>
<!-- /wp:paragraph -->

<!-- wp:buttons {"style":{"spacing":{"margin":{"top":"var:preset|spacing|10"}}}} -->
<div class="wp-block-buttons" style="margin-top:var(--wp--preset--spacing--10)">
<!-- wp:button {"className":"is-style-outline is-small","metadata":{"bindings":{"url":{"source":"wporg-themes/meta","args":{"key":"support-forum-url"}}}}} -->
<div class="wp-block-button is-style-outline is-small"><a class="wp-block-button__link wp-element-button"><?php esc_html_e( 'View support forum', 'wporg-themes' ); ?></a></div>
<!-- /wp:button -->
</div>
<!-- /wp:buttons -->
<!-- wp:paragraph {"style":{"spacing":{"margin":{"top":"var:preset|spacing|10"}}},"metadata":{"bindings":{"content":{"source":"wporg-themes/meta","args":{"key":"support-forum-link"}}}}} -->
<p style="margin-top:var(--wp--preset--spacing--10)">View support forum</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"fontSize":"heading-4"} -->
<h2 class="wp-block-heading has-heading-4-font-size"><?php esc_html_e( 'Report', 'wporg-themes' ); ?></h2>
Expand All @@ -157,13 +149,9 @@
<p><?php esc_html_e( 'Does this theme have major issues?', 'wporg-themes' ); ?></p>
<!-- /wp:paragraph -->

<!-- wp:buttons {"style":{"spacing":{"margin":{"top":"var:preset|spacing|10"}}}} -->
<div class="wp-block-buttons" style="margin-top:var(--wp--preset--spacing--10)">
<!-- wp:button {"className":"is-style-outline is-small","metadata":{"bindings":{"url":{"source":"wporg-themes/meta","args":{"key":"report-url"}}}}} -->
<div class="wp-block-button is-style-outline is-small"><a class="wp-block-button__link wp-element-button"><?php esc_html_e( 'Report this theme', 'wporg-themes' ); ?></a></div>
<!-- /wp:button -->
</div>
<!-- /wp:buttons -->
<!-- wp:paragraph {"style":{"spacing":{"margin":{"top":"var:preset|spacing|10"}}},"metadata":{"bindings":{"content":{"source":"wporg-themes/meta","args":{"key":"report-link"}}}}} -->
<p style="margin-top:var(--wp--preset--spacing--10)">Report this theme</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"fontSize":"heading-4"} -->
<h2 class="wp-block-heading has-heading-4-font-size"><?php esc_html_e( 'Translations', 'wporg-themes' ); ?></h2>
Expand Down

0 comments on commit 9421808

Please sign in to comment.