Skip to content

Commit 013d9de

Browse files
authored
Merge pull request #13 from creativecommons/author-info-post
Add post author information to entry
2 parents 59bfce9 + 03a7d19 commit 013d9de

File tree

13 files changed

+120
-13
lines changed

13 files changed

+120
-13
lines changed

assets/css/styles.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

front/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
"main": "index.js",
66
"dependencies": {},
77
"devDependencies": {
8-
"@creativecommons/vocabulary": "^1.0.0-beta.15",
8+
"@creativecommons/vocabulary": "^1.0.0-beta.16",
99
"@glidejs/glide": "^3.4.1",
1010
"bulma": "^0.8.2",
1111
"copy-webpack-plugin": "^5.1.1",
12-
"css-loader": "^3.5.3",
12+
"css-loader": "^3.6.0",
1313
"mini-css-extract-plugin": "^0.9.0",
1414
"node-sass": "^4.14.1",
1515
"sass-loader": "^8.0.2",
1616
"style-loader": "^1.2.1",
1717
"webpack": "^4.43.0",
18-
"webpack-cli": "^3.3.11"
18+
"webpack-cli": "^3.3.12"
1919
},
2020
"scripts": {
2121
"build": "webpack --mode production",

front/src/styles/modules.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,15 @@
192192
}
193193
}
194194
}
195+
.entry-author {
196+
@extend .padding-vertical-normal;
197+
display: flex;
198+
.author-image {
199+
.avatar {
200+
margin-right: $space-smaller;
201+
}
202+
}
203+
.author-info-group {
204+
padding-left: $space-normal;
205+
}
206+
}

front/src/styles/styles.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
//Import Vocabulary
2+
@import "@creativecommons/vocabulary/scss/color.scss";
3+
@import "@creativecommons/vocabulary/scss/color_overrides.scss";
4+
25
@import "bulma/sass/utilities/_all.sass";
36
@import "bulma/sass/base/_all.sass";
4-
@import "@creativecommons/vocabulary/scss/color.scss";
57
@import "@creativecommons/vocabulary/scss/spacing.scss";
68
@import "@creativecommons/vocabulary/scss/typography.scss";
79

inc/class-cc-site.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,8 @@ public static function get_parent_page() {
160160
return $post->ID;
161161
}
162162
}
163+
public static function get_date_format() {
164+
$date_format = apply_filters('cc_theme_base_date_format', get_option( 'date_format' ) );
165+
return $date_format;
166+
}
163167
}

inc/class-components.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static function card_post(
6868
$card_image = ( $use_post_data ) ? get_the_post_thumbnail( $post_id, 'landscape-medium' ) : wp_get_attachment_image( $image_id, 'landscape-medium' );
6969
$card_title = ( $use_post_data ) ? get_the_title( $post_id ) : $title;
7070
$card_url = ( $use_post_data ) ? get_permalink( $post_id ) : $url;
71-
$card_date = ( $use_post_data ) ? get_the_date( 'd F Y', $post_id ) : $date;
71+
$card_date = ( $use_post_data ) ? get_the_date( CC_Site::get_date_format(), $post_id ) : $date;
7272
$card_border = ( $has_border ) ? '' : ' no-border ';
7373
$button_color = ( $button_color ) ? $button_color : 'is-primary';
7474
$button_size = ( $button_size ) ? $button_size : 'big';
@@ -358,7 +358,7 @@ public static function simple_entry( $post_id, $has_content = true, $has_image =
358358
}
359359
$out .= '<div class="entry-content column">';
360360
$out .= '<h4 class="b-header"><a href="' . get_permalink( $post_id ) . '">' . get_the_title( $post_id ) . '</a></h4>';
361-
$out .= '<span class="entry-date">' . get_the_date( 'd F Y' ) . '</span>';
361+
$out .= '<span class="entry-date">' . get_the_date( CC_Site::get_date_format() ) . '</span>';
362362
if ( $has_content ) {
363363
$the_post = get_post( $post_id );
364364
$out .= '<div class="entry-description">';
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
if ( class_exists( 'coauthors_plus' ) ) { // Get the Co-Authors for the post
4+
$co_authors = get_coauthors();
5+
} else {
6+
$co_authors = array();
7+
}
8+
echo '<div class="entry-author">';
9+
echo '<div class="author-image">';
10+
$author_bio_avatar_size = apply_filters( 'cc_author_bio_avatar_size', 50 );
11+
if (count($co_authors)){
12+
foreach ($co_authors as $an_author){
13+
if ($an_author->type == 'guest-author') {
14+
echo get_avatar( get_the_author_meta( 'user_email', $an_author->ID ), $author_bio_avatar_size );
15+
} else {
16+
echo '<a href="' . get_author_posts_url(get_the_author_meta( 'ID', $an_author->ID ), get_the_author_meta( 'user_nicename', $an_author->ID )) . '">' . get_avatar( get_the_author_meta( 'user_email', $an_author->ID ), $author_bio_avatar_size ) . '</a>';
17+
}
18+
}
19+
} else {
20+
echo '<a href="' . get_author_posts_url(get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' )) . '">' . get_avatar( get_the_author_meta( 'user_email' ), $author_bio_avatar_size ) . '</a>';
21+
}
22+
echo '</div>';
23+
echo '<div class="author-info-group">';
24+
echo '<div class="author-name">';
25+
if ( function_exists( 'coauthors_posts_links' ) ) {
26+
if (count($co_authors)){
27+
$x = 1;
28+
foreach ($co_authors as $an_author){
29+
if ($an_author->type == 'guest-author') {
30+
echo $an_author->display_name;
31+
} else {
32+
echo '<a href="' . get_author_posts_url($an_author->ID, $an_author->user_nicename) . '">' . $an_author->display_name . '</a>';
33+
}
34+
if ($x != count($co_authors)) { echo ' and '; }
35+
$x++;
36+
}
37+
}
38+
} else {
39+
the_author_posts_link();
40+
}
41+
echo '</div>';
42+
echo '<div class="author-date">'. get_the_date( CC_Site::get_date_format() ); '</div>';
43+
echo '</div>';
44+
echo '</div>';
45+
echo '</div>';

inc/partials/post_formats/content-default.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<h2><?php the_title(); ?></h2>
2-
<span class="entry-date"><?php the_date( 'F d, Y' ); ?></span>
2+
<?php
3+
global $_set;
4+
$settings = $_set->settings;
5+
if ( $settings['show_authors'] ) {
6+
get_template_part( 'inc/partials/entry/entry','author' );
7+
} else {
8+
echo '<span class="entry-date">'. get_the_date( CC_Site::get_date_format() ) .'</span>';
9+
}
10+
?>
311
<?php
412
if ( function_exists( 'yoast_breadcrumb' ) ) {
513
yoast_breadcrumb( '<p id="breadcrumbs">', '</p>' );

inc/partials/post_formats/content-gallery.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@
1919
}
2020
?>
2121
<h2><?php the_title(); ?></h2>
22-
<span class="entry-date"><?php the_date( 'F d, Y' ); ?></span>
22+
<?php
23+
global $_set;
24+
$settings = $_set->settings;
25+
if ( $settings['show_authors'] ) {
26+
get_template_part( 'inc/partials/entry/entry','author' );
27+
} else {
28+
echo '<span class="entry-date">'. get_the_date( CC_Site::get_date_format() ) .'</span>';
29+
}
30+
?>
2331
<?php
2432
if ( function_exists( 'yoast_breadcrumb' ) ) {
2533
yoast_breadcrumb( '<p id="breadcrumbs">', '</p>' );

inc/partials/post_formats/content-image.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66
}
77
?>
88
<h2><?php the_title(); ?></h2>
9-
<span class="entry-date"><?php the_date( 'F d, Y' ); ?></span>
9+
<?php
10+
global $_set;
11+
$settings = $_set->settings;
12+
if ( $settings['show_authors'] ) {
13+
get_template_part( 'inc/partials/entry/entry','author' );
14+
} else {
15+
echo '<span class="entry-date">'. get_the_date( CC_Site::get_date_format() ) .'</span>';
16+
}
17+
?>
1018
<?php
1119
if ( function_exists( 'yoast_breadcrumb' ) ) {
1220
yoast_breadcrumb( '<p id="breadcrumbs">', '</p>' );

0 commit comments

Comments
 (0)