Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1126 break up largo byline #1251

Merged
merged 50 commits into from
Jul 18, 2016
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
dfb27b9
Break the coauthors and non-coauthors (normal user, custom byline) po…
benlk Apr 7, 2016
a1dd532
Better explanation of what largo_byline_normal_or_custom does
benlk Apr 7, 2016
c98d8ac
First pass at breaking up largo_byline into a hooked function
benlk Jul 8, 2016
792a9ad
Move hero functions from inc/post-tags.php into inc/featured-media.php
benlk Jul 8, 2016
101bb1a
Move post social media functions to their own inc/post-social.php
benlk Jul 8, 2016
f5bb75b
Move largo_post_metadata into inc/header-footer.php to be next to lar…
benlk Jul 8, 2016
004d339
Move pagination functions into their own inc/pagination.php
benlk Jul 8, 2016
a30deda
Move largo_hero_with_caption into inc/deprecated.php, because it is
benlk Jul 8, 2016
8400768
Move post_type_icon into inc/term-icons.php
benlk Jul 8, 2016
a07e73a
Split up largo_byline_normal_or_custom into its own action with its o…
benlk Jul 8, 2016
d58d992
Break up the coauthors byline function as well.
benlk Jul 9, 2016
200cfae
Add missing ; in largo_byline_coauthors
benlk Jul 11, 2016
9f6aa17
Unhook all but one largo_byline function, trying to nail down source …
benlk Jul 11, 2016
d69dc00
Fix variable use to reduce argument-wiping by actions on byline hooks…
benlk Jul 11, 2016
94f0298
Double action action was because the action and filter had the same n…
benlk Jul 11, 2016
30bf1f6
Coauthors works now.
benlk Jul 11, 2016
af8dea0
Remove var_logs
benlk Jul 11, 2016
5f819ea
Styles for avatars in bylines
benlk Jul 11, 2016
5ade9e1
Uncomment the byline separator, datetime, and edit link
benlk Jul 11, 2016
6ad5790
Remove reference to largo_byline_normal_or_custom_component_avatar, t…
benlk Jul 11, 2016
e1f5887
Remove default denying gravatars
benlk Jul 12, 2016
9652aeb
Merge in develop and recompile
benlk Jul 12, 2016
10b3b4d
Stub tests for functions introduced in #1248
benlk Jul 12, 2016
fe4287c
Revert "Move post_type_icon into inc/term-icons.php"
benlk Jul 13, 2016
c62bb01
Revert "Move largo_hero_with_caption into inc/deprecated.php, because…
benlk Jul 13, 2016
6b08822
Revert "Move pagination functions into their own inc/pagination.php"
benlk Jul 13, 2016
f35d96c
Revert "Move largo_post_metadata into inc/header-footer.php to be nex…
benlk Jul 13, 2016
8f9985d
Revert "Move post social media functions to their own inc/post-social…
benlk Jul 13, 2016
d9b1fd8
Revert "Move hero functions from inc/post-tags.php into inc/featured-…
benlk Jul 13, 2016
924ad44
Revert "Stub tests for functions introduced in #1248"
benlk Jul 13, 2016
68ccb2b
Create Largo_Byline class for bylines for normal authors.
benlk Jul 13, 2016
9f91d83
And the other half of that commit.
benlk Jul 13, 2016
4f1f1fa
Add Largo_Custom_Byline class, extending Largo_Byline
benlk Jul 13, 2016
340d9a2
Add "Published:" label to Largo_Byline::published_date()
benlk Jul 13, 2016
dcb5c30
Add Largo_CoAuthors_Byline class extending Largo_Byline, with support…
benlk Jul 13, 2016
362fc21
Try fixing avatars in normal bylines, fail
benlk Jul 13, 2016
65abc0e
Fix bug where largo_get_avatar_src was passing email addresses to lar…
benlk Jul 14, 2016
42d77f1
Remove Largo_CoAuthors_Byline::avatar(), as it is unneeded
benlk Jul 14, 2016
a4ea7ed
slightly better avatar function, internal comments in inc/byline_clas…
benlk Jul 14, 2016
0d5be3d
Get edit links to print, finally
benlk Jul 14, 2016
664677a
Fix publish link text
benlk Jul 14, 2016
65d445c
remove a jira.inn.org link
benlk Jul 15, 2016
7104546
How did these deprecated args get set?
benlk Jul 15, 2016
07bc8a6
Update some comments in Largo_Byline to reflect working status of parts
benlk Jul 15, 2016
d754ff9
Document properties fo the byline classes
benlk Jul 15, 2016
60eba84
formatting
aschweigert Jul 18, 2016
6305198
formatting
aschweigert Jul 18, 2016
24dcce2
typo
aschweigert Jul 18, 2016
6333687
formatting
aschweigert Jul 18, 2016
4f1cf60
Default to not show job titles in bylines
benlk Jul 18, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion css/editor-style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/editor-style.min.css

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion css/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/style.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ private function require_files() {
'/inc/open-graph.php',
'/inc/verify.php',
'/inc/post-tags.php',
'/inc/byline_class.php',
'/inc/header-footer.php',
'/inc/related-content.php',
'/inc/featured-content.php',
Expand Down
2 changes: 1 addition & 1 deletion homepages/assets/css/single.min.css

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

2 changes: 1 addition & 1 deletion homepages/assets/css/top-stories.min.css

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

74 changes: 45 additions & 29 deletions inc/avatars/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,76 @@
*/

// Constants
define('LARGO_AVATAR_META_NAME', 'largo_avatar');
define('LARGO_AVATAR_ACTION_NAME', 'largo_avatar_upload');
define('LARGO_AVATAR_INPUT_NAME', 'largo_user_avatar');
define( 'LARGO_AVATAR_META_NAME', 'largo_avatar' );
define( 'LARGO_AVATAR_ACTION_NAME', 'largo_avatar_upload' );
define( 'LARGO_AVATAR_INPUT_NAME', 'largo_user_avatar' );

if (is_admin())
include dirname(__FILE__) . '/admin.php';
if ( is_admin() )
include dirname( __FILE__ ) . '/admin.php';

function largo_get_avatar_filter($avatar, $id_or_email, $size, $default, $alt ) {
$image_src = largo_get_avatar_src($id_or_email, $size);
if (!empty($image_src))
function largo_get_avatar_filter( $avatar, $id_or_email, $size, $default, $alt ) {
$image_src = largo_get_avatar_src( $id_or_email, $size );
if ( ! empty( $image_src ) ) {
return '<img src="' . $image_src[0] . '" alt="'. $alt . '" width="' . $size . '" height="' . $size . '" class="avatar avatar-' . $size . ' photo" />';
else
} else {
return $avatar;
}
}
add_action('get_avatar', 'largo_get_avatar_filter', 1, 5);
add_action( 'get_avatar', 'largo_get_avatar_filter', 1, 5 );

/**
* Get the avatar image HTML for the given user id/email and size
*
* @param int|string $id_or_email a wordpress user ID or user email address;
* @param int $string The size of the avatar
*/
function largo_get_avatar_src( $id_or_email, $size ) {
// get the user ID;
if ( ! is_numeric( $id_or_email ) ) {
$user = get_user_by( 'email', $id_or_email );
$id = $user->ID;
} else {
$id = (int) $id_or_email;
}

function largo_get_avatar_src($id_or_email, $size) {
$avatar_id = largo_get_user_avatar_id($id_or_email);
$avatar_id = largo_get_user_avatar_id( $id );

if (empty($avatar_id))
if ( empty( $avatar_id ) ) {
return false;

}

global $_wp_additional_image_sizes;

$copy = $_wp_additional_image_sizes;
usort($copy, function($a, $b) {
usort( $copy, function( $a, $b ) {
return $a['width'] - $b['width'];
});

$square_image_sizes = array_filter($copy, function($arg) {
return ($arg['width'] / $arg['height']) == 1;
});
$square_image_sizes = array_filter( $copy, function( $arg ) {
return ( $arg['width'] / $arg['height'] ) == 1;
} );

$requested_size = array($size, $size);
$requested_size = array( $size, $size );

foreach ($square_image_sizes as $key => $val) {
if (round((float) ($val['width'] / $val['height']), 1, PHP_ROUND_HALF_DOWN) ==
round((float) ($requested_size[0] / $requested_size[1]), 1, PHP_ROUND_HALF_DOWN))
foreach ( $square_image_sizes as $key => $val ) {
if ( round( ( float ) ( $val['width'] / $val['height'] ), 1, PHP_ROUND_HALF_DOWN ) ==
round( ( float ) ( $requested_size[0] / $requested_size[1]), 1, PHP_ROUND_HALF_DOWN ) )
{
// Try to find an image size equal to or just slightly larger than what was requested
if ($val['width'] >= $requested_size[0]) {
$requested_size = array($val['width'], $val['height']);
if ( $val['width'] >= $requested_size[0] ) {
$requested_size = array( $val['width'], $val['height'] );
break;
}

// If we can't find an image size, set the requested size to the largest of the
// square sizes available
if (end($square_image_sizes) == $square_image_sizes[$key])
$requested_size = array($val['width'], $val['height']);
if ( end( $square_image_sizes ) == $square_image_sizes[$key] )
$requested_size = array( $val['width'], $val['height'] );
}
}
return wp_get_attachment_image_src($avatar_id, $requested_size);
return wp_get_attachment_image_src( $avatar_id, $requested_size );
}

function largo_get_user_avatar_id($user_id) {
return get_user_meta($user_id, LARGO_AVATAR_META_NAME, true);
function largo_get_user_avatar_id( $user_id ) {
return get_user_meta( $user_id, LARGO_AVATAR_META_NAME, true );
}
Loading