From 9b2c2464dda4811c19ca983d7e7594fe8aa07089 Mon Sep 17 00:00:00 2001 From: Anton Sarukhanov <code@ant.sr> Date: Thu, 19 May 2016 23:23:20 -0400 Subject: [PATCH] Add homepage widget area; Margin fixes; Cleanup stupid WP code spacing --- functions.php | 53 +++++++++++++++++++++++++++++------------------- landing-page.php | 6 ++++++ style.css | 9 ++++++++ 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/functions.php b/functions.php index 6bcd044..9402c6e 100644 --- a/functions.php +++ b/functions.php @@ -4,16 +4,16 @@ */ // Exit if accessed directly -if ( !defined( 'ABSPATH' ) ) { +if (!defined( 'ABSPATH')) { exit; } function remove_parent_theme_crap() { // Remove ads and junk - remove_action( 'admin_menu', 'cyberchimps_add_upsell' ); - remove_action( 'tgmpa_register', 'responsive_install_plugins' ); - remove_action( 'responsive_theme_options', 'responsive_upgrade_bar', 1 ); - remove_action( 'responsive_theme_options', 'responsive_theme_support', 2 ); + remove_action('admin_menu', 'cyberchimps_add_upsell'); + remove_action('tgmpa_register', 'responsive_install_plugins'); + remove_action('responsive_theme_options', 'responsive_upgrade_bar', 1); + remove_action('responsive_theme_options', 'responsive_theme_support', 2); } add_action('after_setup_theme', 'remove_parent_theme_crap'); @@ -24,16 +24,16 @@ add_action('after_setup_theme', 'remove_parent_theme_crap'); * The one in 'responsive' prints author name, which would be stupid here. * */ -if ( !function_exists( 'responsive_post_meta_data' ) ) { +if (!function_exists('responsive_post_meta_data')) { function responsive_post_meta_data() { - printf( __( '<span class="%1$s">Posted on </span>%2$s<span class="%3$s">', 'responsive' ), + printf(__('<span class="%1$s">Posted on </span>%2$s<span class="%3$s">', 'responsive'), 'meta-prep meta-prep-author posted', - sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="timestamp updated" datetime="%3$s">%4$s</time></a>', - esc_url( get_permalink() ), - esc_attr( get_the_title() ), - esc_html( get_the_date('c')), - esc_html( get_the_date() ) + sprintf('<a href="%1$s" title="%2$s" rel="bookmark"><time class="timestamp updated" datetime="%3$s">%4$s</time></a>', + esc_url(get_permalink()), + esc_attr(get_the_title()), + esc_html(get_the_date('c')), + esc_html(get_the_date()) ), 'byline' ); @@ -42,18 +42,29 @@ if ( !function_exists( 'responsive_post_meta_data' ) ) { } -/** +/** * Display Posts Shortcode - Exclude Some Posts - * @link http://wordpress.org/extend/plugins/display-posts-shortcode/ - * - * @param array $args - * @param array $atts - * @return array $args + * @link https://wordpress.org/plugins/display-posts-shortcode/ */ -function be_display_posts_shortcode_exclude_posts( $args, $atts ) { - if( isset( $atts['hide_sticky'] ) ) { +function anton_display_posts_shortcode_exclude_posts($args, $attrs) { + if(isset( $attrs['hide_sticky'])) { $args['post__not_in'] = get_option('sticky_posts'); } return $args; } -add_filter( 'display_posts_shortcode_args', 'be_display_posts_shortcode_exclude_posts', 10, 2 ); +add_filter( 'display_posts_shortcode_args', 'anton_display_posts_shortcode_exclude_posts', 10, 2 ); + +/** + * Add widget area(s) + */ +function anton_widgets_init() { + register_sidebar(array( + 'name' => 'Home After Content', + 'id' => 'home_after_content', + 'before_widget' => '<div>', + 'after_widget' => '</div>', + 'before_title' => '<h3>', + 'after_title' => '</h3>', + )); +} +add_filter('widgets_init', 'anton_widgets_init'); diff --git a/landing-page.php b/landing-page.php index 77f830f..e582c6a 100644 --- a/landing-page.php +++ b/landing-page.php @@ -43,6 +43,12 @@ get_header(); <?php responsive_entry_bottom(); ?> + <?php if (is_active_sidebar('home_after_content')): ?> + <div id="home-after-content" class="widget-area"> + <?php dynamic_sidebar('home_after_content'); ?> + </div> + <?php endif; ?> + <h3>Projects</h3> <?php $args = array( diff --git a/style.css b/style.css index 6bd9fa9..b2047ab 100644 --- a/style.css +++ b/style.css @@ -16,6 +16,14 @@ html { -webkit-text-size-adjust: none; } +p { + margin: 1em 0; +} + +h1, h2, h3, h4, h5, h6 { + margin-bottom: 0.25em; +} + /* General stuff */ #content, #content-full, @@ -39,6 +47,7 @@ p:empty { text-align: right; width: 200px; max-width: 40%; + margin-left: .5em; } .me-sidebar img { width: 160px; -- GitLab