Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature banner to Front Page. #37

Merged
merged 12 commits into from
Nov 14, 2022
Prev Previous commit
Next Next commit
Use an svg.
  • Loading branch information
StevenDufresne committed Nov 11, 2022
commit a7e2ca10f96534b81c4bad71c9f7429d7689fc15
20 changes: 19 additions & 1 deletion source/wp-content/themes/wporg-showcase-2022/functions.php
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
add_filter( 'excerpt_length', __NAMESPACE__ . '\modify_excerpt_length', 999 );
add_filter( 'excerpt_more', __NAMESPACE__ . '\modify_excerpt_more' );
add_filter( 'query_loop_block_query_vars', __NAMESPACE__ . '\modify_query_loop_block_query_vars', 10, 2 );
add_filter( 'upload_mimes', __NAMESPACE__ . '\wporg_add_svg_to_upload_mimes' );

/**
* Enqueue scripts and styles.
@@ -160,7 +161,7 @@ function modify_excerpt_more() {
*
* See: https://github.com/WordPress/gutenberg/issues/41184
*
* @return void
* @return WP_Query
*/
function modify_query_loop_block_query_vars( $query, $block ) {
if ( isset( $block->context['query']['sticky'] ) && 'only' === $block->context['query']['sticky'] ) {
@@ -172,3 +173,20 @@ function modify_query_loop_block_query_vars( $query, $block ) {
return $query;
>>>>>>> 425eda8 (Allow for sticky posts.)
}

/**
* Add SVGs to the list of allowed mime types.
*
* @param array $upload_mimes The existing allowed mime types.
*
* @return array The enhanced allowed mime types.
*/
function wporg_add_svg_to_upload_mimes( $upload_mimes ) {
if ( current_user_can( 'manage_options' ) ) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dd32 Does this make any sense? To allow SVG uploads but lock it down to admins?

Copy link
Member

@dd32 dd32 Nov 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In all honesty, this doesn't belong in the theme, and I'm not sure the context of adding it.

There's also something to say that this should be using unfiltered_upload, but that isn't available to anyone on WordPress.org.

I think I'd rather enable a plugin such as https://wordpress.org/plugins/safe-svg/ (or one of the others) on the site instead if SVG upload is required.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah fair, I'll avoid adding SVG support.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll need SVG support eventually, so I've added a low-priority issue over in mu-plugins: WordPress/wporg-mu-plugins#300

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

$file_types = array();
$file_types['svg'] = 'image/svg+xml';
return array_merge( $file_types, $upload_mimes );
}

return $upload_mimes;
}

This file was deleted.

17 changes: 0 additions & 17 deletions source/wp-content/themes/wporg-showcase-2022/src/style/style.scss
Original file line number Diff line number Diff line change
@@ -148,20 +148,3 @@ button[type="submit"] {
margin-right: var(--wp--preset--spacing--60) !important;
}
}

.wporg-homepage-hero {
position: relative;
}

.wporg-homepage-hero::after {
position: absolute;
content: '';
width: calc( 100% - var(--wp--preset--spacing--60) );
max-width: 800px;
height: 100%;
top: var(--wp--preset--spacing--30);
left: 0;
background-image: url(../../images/showcase.svg);
background-repeat: no-repeat;
background-size: contain;
}