Skip to content

Commit

Permalink
Merge pull request #89 from INN/86-hardcode-digest-sidebar
Browse files Browse the repository at this point in the history
Hardcode the Digest Sidebar, style fixes for certain widgets therein
  • Loading branch information
benlk authored Feb 22, 2020
2 parents 2b413b8 + 2ff2577 commit f5eb130
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 43 deletions.
115 changes: 84 additions & 31 deletions wp-content/themes/midwestenergynews/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wp-content/themes/midwestenergynews/css/style.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion wp-content/themes/midwestenergynews/css/style.min.css

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions wp-content/themes/midwestenergynews/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,22 @@ function mwen_image_sizes() {
add_image_size( 'rect_thumb_half', 400, 300, true ); // smaller version of rect_thumb
}
add_action( 'after_setup_theme', 'mwen_image_sizes' );

/**
* Register custom sidebars that aren't related to the homepage
*
* @link https://codex.wordpress.org/Widgetizing_Themes
*/
function mwen_register_sidebars() {
// @link https://github.com/INN/umbrella-energynewsnetwork/issues/86
register_sidebar( array(
'name' => 'Digest Sidebar',
'id' => 'digest-sidebar',
'description' => __( 'Only output on the category-digest.php template, used on the <a href="/category/digest/">Digests</a> archive.', 'mwen' ),
'before_widget' => '<!-- Sidebar: hardcoded digest-sidebar --><aside id="%1$s" class="%2$s clearfix">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>',
) ) ;
}
add_action( 'widgets_init', 'mwen_register_sidebars', 11 );
15 changes: 15 additions & 0 deletions wp-content/themes/midwestenergynews/less/ninja-forms-compat.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// to prevent injected styles from making buttons wider than they should be
#sidebar {
.field-wrap button,
.field-wrap input[type="button"],
.field-wrap input[type="submit"] {
width: 100%;
max-width: 100%;
box-sizing: border-box;
}
}
// Ninja forms
.home #sidebar .widget.widget_ninja_forms_widget,
.archive #sidebar .widget.widget_ninja_forms_widget {
padding-right: 24px;
}
1 change: 1 addition & 0 deletions wp-content/themes/midwestenergynews/less/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
@import "archive.less";
@import "digest-search.less";
@import "widgets.less";
@import "ninja-forms-compat.less";
@import "print.less";

body.tax-region {
Expand Down
39 changes: 32 additions & 7 deletions wp-content/themes/midwestenergynews/less/widgets.less
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@
}
}

// Override the media query in https://github.com/INN/largo/blob/1744bbc7ae99f501129d158c3b585cddf6b5409e/less/inc/widgets.less#L214-L222
@media ( max-width: 768px ) {
#sidebar .widget {
padding-left: 24px;
}
}

/*
* Mailchimp Newsletter Signup Widget
*/
Expand Down Expand Up @@ -249,28 +256,45 @@
}
}
.header-ad-zone .mailchimp-signup-widget,
.archive .widget_text,
.home .widget_text,
.archive .mailchimp-signup-widget,
.home .mailchimp-signup-widget {
.archive #sidebar .widget_text,
.home #sidebar .widget_text,
.archive #sidebar .mailchimp-signup-widget,
.home #sidebar .mailchimp-signup-widget {
border: 1px solid @greyXL;
.default {
> :first-child {
margin-top: 0;
}
> :last-child {
margin-bottom: 0;
}
}
&.rev {
border: none;
}

box-sizing: content-box;
padding: 18px 34px;
padding: 18px 24px;
// override https://github.com/INN/largo/blob/1744bbc7ae99f501129d158c3b585cddf6b5409e/less/inc/widgets.less#L214-L222
@media ( max-width: 768px ) {
padding-top: 18px;
padding-bottom: 18px;
}
input[type=email] {
margin: 0 auto 12px;
display: block;
padding: 12px;
}
.btn,
input[type=submit] {
.btn-styles('primary');
margin: 16px 0;
padding: 0.75em 2.3em;
width: auto;
padding: 0.75em 0.75em;
text-align: center;
width: 100%;
font-size: 15px;
max-width: 100%;
box-sizing: border-box;
}
input[type=email] {
width: 100%;
Expand Down Expand Up @@ -404,3 +428,4 @@ body .widget.saved-links {
margin-left: 0.3em;
}
}

13 changes: 13 additions & 0 deletions wp-content/themes/midwestenergynews/partials/sidebar-digest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/*
* For the digest category page
*
* Copied from Largo's partials/sidebar-archive.php at 0.6.4
* @package Largo
* @since 0.6.4
* @link https://github.com/INN/umbrella-energynewsnetwork/issues/86
*/
$custom_sidebar = largo_get_custom_sidebar();
if ( !dynamic_sidebar( 'digest-sidebar' ) ) { // try custom sidebar registered in functions.php
// do nothing.
}
9 changes: 6 additions & 3 deletions wp-content/themes/midwestenergynews/sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
<?php
do_action('largo_before_sidebar_widgets');

if (is_archive() && !is_date())
if ( is_category( 'digest' ) ) {
get_template_part('partials/sidebar', 'digest');
} else if (is_archive() && !is_date()) {
get_template_part('partials/sidebar', 'archive');
else if (is_single() || is_singular())
} else if (is_single() || is_singular()) {
get_template_part('partials/sidebar', 'single');
else
} else {
get_template_part('partials/sidebar');
}

do_action('largo_after_sidebar_widgets');
?>
Expand Down

0 comments on commit f5eb130

Please sign in to comment.