bump
This commit is contained in:
commit
84700d5ff2
9
home.php
9
home.php
|
@ -36,7 +36,6 @@ get_header();
|
|||
<?php get_template_part( 'global-templates/left-sidebar-check', 'none' ); ?>
|
||||
<?php if ( 'masonry' === $posts_style ) : ?>
|
||||
<div class="card-columns"><?php endif; ?>
|
||||
|
||||
<main class="site-main" id="main">
|
||||
|
||||
<?php if ( have_posts() ) : ?>
|
||||
|
@ -47,9 +46,13 @@ get_header();
|
|||
|
||||
<?php
|
||||
if ( 'masonry' === $posts_style ) :
|
||||
get_template_part( 'loop-templates/content-card' );
|
||||
get_template_part( 'loop-templates/content', 'card' );
|
||||
elseif ( 'grid' === $posts_style ) :
|
||||
|
||||
get_template_part( 'loop-templates/content', 'grid' );
|
||||
else :
|
||||
/* Include the Post-Format-specific template for the content.
|
||||
/*
|
||||
* Include the Post-Format-specific template for the content.
|
||||
* If you want to override this in a child theme, then include a file
|
||||
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
|
||||
*/
|
||||
|
|
|
@ -1,139 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Based on Roots Sage Gallery: https://github.com/roots/sage/blob/5b9786b8ceecfe717db55666efe5bcf0c9e1801c/lib/gallery.php
|
||||
*
|
||||
* @package understrap
|
||||
*/
|
||||
|
||||
// Remove built in shortcode.
|
||||
remove_shortcode( 'gallery', 'gallery_shortcode' );
|
||||
|
||||
/*
|
||||
* Replace with custom shortcode
|
||||
*/
|
||||
function shortcode_gallery( $attr ) {
|
||||
$post = get_post();
|
||||
static $instance = 0;
|
||||
$instance ++;
|
||||
if ( ! empty( $attr['ids'] ) ) {
|
||||
if ( empty( $attr['orderby'] ) ) {
|
||||
$attr['orderby'] = 'post__in';
|
||||
}
|
||||
$attr['include'] = $attr['ids'];
|
||||
}
|
||||
$output = apply_filters( 'post_gallery', '', $attr );
|
||||
if ( $output != '' ) {
|
||||
return $output;
|
||||
}
|
||||
if ( isset( $attr['orderby'] ) ) {
|
||||
$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
|
||||
if ( ! $attr['orderby'] ) {
|
||||
unset( $attr['orderby'] );
|
||||
}
|
||||
}
|
||||
extract( shortcode_atts( [
|
||||
'order' => 'ASC',
|
||||
'orderby' => 'menu_order ID',
|
||||
'id' => $post->ID,
|
||||
'itemtag' => '',
|
||||
'icontag' => '',
|
||||
'captiontag' => '',
|
||||
'columns' => 3,
|
||||
'size' => 'thumbnail',
|
||||
'include' => '',
|
||||
'exclude' => '',
|
||||
'link' => '',
|
||||
], $attr ) );
|
||||
$id = intval( $id );
|
||||
$columns = ( 12 % $columns == 0 ) ? $columns : 3;
|
||||
$grid = sprintf( 'col-sm-%1$s col-lg-%1$s', 12 / $columns );
|
||||
if ( $order === 'RAND' ) {
|
||||
$orderby = 'none';
|
||||
}
|
||||
if ( ! empty( $include ) ) {
|
||||
$_attachments = get_posts( [ 'include' => $include,
|
||||
'post_status' => 'inherit',
|
||||
'post_type' => 'attachment',
|
||||
'post_mime_type' => 'image',
|
||||
'order' => $order,
|
||||
'orderby' => $orderby
|
||||
] );
|
||||
$attachments = [];
|
||||
foreach ( $_attachments as $key => $val ) {
|
||||
$attachments[ $val->ID ] = $_attachments[ $key ];
|
||||
}
|
||||
} elseif ( ! empty( $exclude ) ) {
|
||||
$attachments = get_children( [ 'post_parent' => $id,
|
||||
'exclude' => $exclude,
|
||||
'post_status' => 'inherit',
|
||||
'post_type' => 'attachment',
|
||||
'post_mime_type' => 'image',
|
||||
'order' => $order,
|
||||
'orderby' => $orderby
|
||||
] );
|
||||
} else {
|
||||
$attachments = get_children( [ 'post_parent' => $id,
|
||||
'post_status' => 'inherit',
|
||||
'post_type' => 'attachment',
|
||||
'post_mime_type' => 'image',
|
||||
'order' => $order,
|
||||
'orderby' => $orderby
|
||||
] );
|
||||
}
|
||||
if ( empty( $attachments ) ) {
|
||||
return '';
|
||||
}
|
||||
if ( is_feed() ) {
|
||||
$output = "\n";
|
||||
foreach ( $attachments as $att_id => $attachment ) {
|
||||
$output .= wp_get_attachment_link( $att_id, $size, true ) . "\n";
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
$unique = ( get_query_var( 'page' ) ) ? $instance . '-p' . get_query_var( 'page' ) : $instance;
|
||||
$output = '<div class="gallery gallery-' . $id . '-' . $unique . '">';
|
||||
$i = 0;
|
||||
foreach ( $attachments as $id => $attachment ) {
|
||||
switch ( $link ) {
|
||||
case 'file':
|
||||
$image = wp_get_attachment_link( $id, $size, false, false );
|
||||
break;
|
||||
case 'none':
|
||||
$image = wp_get_attachment_image( $id, $size, false, [ 'class' => 'thumbnail img-thumbnail' ] );
|
||||
break;
|
||||
default:
|
||||
$image = wp_get_attachment_link( $id, $size, true, false );
|
||||
break;
|
||||
}
|
||||
$output .= ( $i % $columns == 0 ) ? '<div class="row gallery-row">' : '';
|
||||
$output .= '<div class="' . $grid . '">' . $image;
|
||||
if ( trim( $attachment->post_excerpt ) ) {
|
||||
$output .= '<div class="caption hidden">' . wptexturize( $attachment->post_excerpt ) . '</div>';
|
||||
}
|
||||
$output .= '</div>';
|
||||
$i ++;
|
||||
$output .= ( $i % $columns == 0 ) ? '</div>' : '';
|
||||
}
|
||||
$output .= ( $i % $columns != 0 ) ? '</div>' : '';
|
||||
$output .= '</div>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
add_shortcode( 'gallery', 'shortcode_gallery' );
|
||||
|
||||
/**
|
||||
* Add class="thumbnail img-thumbnail" to attachment items
|
||||
*
|
||||
* @param string $html markup.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function attachment_link_class( $html ) {
|
||||
$html = str_replace( '<a', '<a class="thumbnail img-thumbnail"', $html );
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
add_filter( 'wp_get_attachment_link', 'attachment_link_class', 10, 1 );
|
|
@ -156,10 +156,55 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) {
|
|||
'choices' => array(
|
||||
'default' => __( 'Default', 'understrap' ),
|
||||
'masonry' => __( 'Masonry', 'understrap' ),
|
||||
'grid' => __( 'Grid', 'understrap' ),
|
||||
),
|
||||
'priority' => '30',
|
||||
)
|
||||
) );
|
||||
|
||||
// Columns setup for grid posts.
|
||||
/**
|
||||
* Function and callback to check when grid is enabled.
|
||||
* @return bool
|
||||
*/
|
||||
function is_grid_enabled ()
|
||||
{
|
||||
return 'grid' == get_theme_mod( 'understrap_posts_index_style' );
|
||||
}
|
||||
if ( is_grid_enabled() ) {
|
||||
// How many columns to use each grid post
|
||||
$wp_customize->add_setting( 'understrap_grid_post_columns', array(
|
||||
'default' => '6',
|
||||
'type' => 'theme_mod',
|
||||
'capability' => 'edit_theme_options',
|
||||
'transport' => 'refresh',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Control(
|
||||
$wp_customize,
|
||||
'understrap_grid_post_columns', array(
|
||||
'label' => __( 'Grid Post Columns', 'understrap' ),
|
||||
'description' => __( "Choose how many columns to use in grid posts", 'understrap' ),
|
||||
'section' => 'understrap_theme_layout_options',
|
||||
'settings' => 'understrap_grid_post_columns',
|
||||
'type' => 'select',
|
||||
'choices' => array(
|
||||
'6' => '6',
|
||||
'4' => '4',
|
||||
'3' => '3',
|
||||
'2' => '2',
|
||||
'1' => '1',
|
||||
),
|
||||
'default' => 6,
|
||||
'priority' => '30',
|
||||
'transport' => 'refresh',
|
||||
)
|
||||
) );
|
||||
|
||||
}
|
||||
// hook to auto-hide/show depending the understrap_posts_index_style option
|
||||
$wp_customize->get_control( 'understrap_grid_post_columns' )->active_callback = 'is_grid_enabled';
|
||||
}
|
||||
}
|
||||
add_action( 'customize_register', 'understrap_theme_customize_register' );
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
/**
|
||||
* Partial template to display latest posts (home.php) as grid.
|
||||
*
|
||||
* @package understrap
|
||||
*/
|
||||
$col = get_theme_mod( 'understrap_grid_post_columns' );
|
||||
?>
|
||||
<a href="<?php echo esc_url( get_permalink() ); ?>" rel="bookmark">
|
||||
<div class="col-md-<?php echo esc_html( $col ); ?> col-xs-12">
|
||||
|
||||
|
||||
<div class="card card-inverse ">
|
||||
|
||||
<article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
|
||||
<?php $alt = get_post_meta( get_post_thumbnail_id( $post->ID ), '_wp_attachment_image_alt', true ); ?>
|
||||
<img class="card-img "
|
||||
src="<?php echo esc_html( get_the_post_thumbnail_url( $post->ID, 'large' ) ) ?>" alt="<?php echo esc_html( $alt ); ?>">
|
||||
|
||||
<div class="card-img-overlay">
|
||||
|
||||
<header class="entry-header">
|
||||
<h4 class="card-title"><?php the_title(); ?></h4>
|
||||
|
||||
<?php if ( 'post' === get_post_type() ) : ?>
|
||||
|
||||
<p class="entry-meta card-text">
|
||||
<small>Posted: <?php the_date(); ?> at: <?php the_time(); ?></small>
|
||||
</p>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</header>
|
||||
|
||||
</div>
|
||||
|
||||
</article>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</a>
|
Reference in New Issue