Skip to content

Commit

Permalink
Merge pull request #51 from INN/40-homepage-template
Browse files Browse the repository at this point in the history
Initialize homepage, with menu
  • Loading branch information
benlk authored Jan 22, 2020
2 parents e8092dd + 184f3bf commit aafe507
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 8 deletions.
18 changes: 10 additions & 8 deletions wp-content/themes/ipbs-largo/Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
module.exports = function(grunt) {
'use strict';

// Load all tasks
require('load-grunt-tasks')(grunt);
// Show elapsed time
require('time-grunt')(grunt);

// Force use of Unix newlines
grunt.util.linefeed = '\n';

// Find what the current theme's directory is, relative to the WordPress root
var path = process.cwd().replace(/^[\s\S]+\/wp-content/, "\/wp-content");

var cssLessFiles = {
'css/child-style.css': 'less/style.less',
'homepages/assets/css/homepage.css': 'homepages/assets/less/homepage.less',
};

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

less: {
compile: {
options: {
Expand All @@ -32,11 +33,12 @@ module.exports = function(grunt) {
files: cssLessFiles
}
},

watch: {
less: {
files: [
'less/*.less',
'homepages/assets/less/*.less',
],
tasks: [
'less:compile',
Expand All @@ -49,4 +51,4 @@ module.exports = function(grunt) {
grunt.registerTask('default', 'Build less files', [
'less',
]);
}
}
2 changes: 2 additions & 0 deletions wp-content/themes/ipbs-largo/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ function largo_child_require_files() {
$includes = array(
'/inc/enqueue.php',
'/inc/private_content_sharing_shortcode.php',
// homepage
'/homepages/layout.php',
);

foreach ( $includes as $include ) {
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import (reference) "../../../less/variables.less";
53 changes: 53 additions & 0 deletions wp-content/themes/ipbs-largo/homepages/layout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
include_once get_template_directory() . '/homepages/homepage-class.php';

class IPBS extends Homepage {
const menu_location = 'homepage_quick_links';
var $name = 'IPBS';
var $type = 'ipbs';
var $description = 'The homepage for IPBS.';
var $rightRail = false;

public function __construct( $options = array() ) {
$defaults = array(
'template' => get_stylesheet_directory() . '/homepages/template.php',
'assets' => array(
array(
'homepage',
get_stylesheet_directory_uri() . '/homepages/assets/css/homepage.css',
array(),
filemtime( get_stylesheet_directory() . '/homepages/assets/css/homepage.css' ),
),
),
'prominenceTerms' => array(
array(
'name' => __('Homepage Top Story', 'largo'),
'description' => __('If you are using a "Big story" homepage layout, add this label to a post to make it the top story on the homepage', 'largo'),
'slug' => 'top-story'
),
),
'sidebars' => array(
'Homepage Bottom (The bottom area of the homepage, after the top and featured stories)',
),
);
$options = array_merge( $defaults, $options );

$this->register_nav_menu();
$this->load( $options );
}

/**
* @link https://developer.wordpress.org/reference/functions/register_nav_menu/
*/
public static function register_nav_menu() {
register_nav_menu( IPBS::menu_location, __( 'Homepage Quick Links', 'ipbs' ) );
}
}

/**
* Register this layout with Largo
*/
function ipbs_homepage_layout() {
register_homepage_layout( 'ipbs' );
}
add_action( 'init', 'ipbs_homepage_layout' );
45 changes: 45 additions & 0 deletions wp-content/themes/ipbs-largo/homepages/template.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
global $shown_ids;
$topstory = largo_home_single_top();
$shown_ids[] = $topstory->ID;

?>
<div class="">
<?php
// note that we're making a section containing a background image,
// which goes behind a transparent section that contains:
// - the article heading
// - the article excerpt
// - a "Quick links" menu for the site
?>
<div id="top-story" <?php post_class( '', $topstory->ID ); ?> >
<div class="post-image-top-term-container">
<?php
// The top term
largo_maybe_top_term();
?>
<a class="img" href="<?php echo esc_attr( get_permalink( $topstory ) ); ?>"><?php echo get_the_post_thumbnail( $topstory, 'large' ); ?></a>
</div>
<div class="inner">
<article <?php post_class( '', $topstory ); ?>>
<h2><a href="<?php the_permalink( $topstory ); ?>"><?php echo get_the_title( $topstory ); ?></a></h2>
<div class="excerpt">
<?php largo_excerpt( $topstory, 2 ); ?>
<a class="view-more-link" href="<?php the_permalink( $topstory ); ?>">Full Story</a>
</div>
</article>
<?php
wp_nav_menu( array(
'theme_location' => IPBS::menu_location,
) );
?>
</div>
</div>
</div>
<div class="bottom-widget-area clearfix">
<div class="widget-area">
<?php
dynamic_sidebar( 'Homepage Bottom' );
?>
</div>
</div>
2 changes: 2 additions & 0 deletions wp-content/themes/ipbs-largo/less/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ Author URI: https://labs.inn.org
Template: largo
Version: 0.1
*/

@import "variables.less";
Empty file.

0 comments on commit aafe507

Please sign in to comment.