Skip to content

Commit

Permalink
Fix not being able to create bylines
Browse files Browse the repository at this point in the history
  • Loading branch information
lakrisgubben committed Dec 14, 2020
1 parent 3717ca6 commit 957acd5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
1 change: 0 additions & 1 deletion bylines.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ function bylines_action_admin_notices_warn_requirements() {
// Admin customizations.
add_action( 'admin_init', array( 'Bylines\Post_Editor', 'action_admin_init' ) );
add_filter( 'manage_edit-byline_columns', array( 'Bylines\Byline_Editor', 'filter_manage_edit_byline_columns' ) );
add_filter( 'list_table_primary_column', array( 'Bylines\Byline_Editor', 'filter_list_table_primary_column' ) );
add_filter( 'manage_byline_custom_column', array( 'Bylines\Byline_Editor', 'filter_manage_byline_custom_column' ), 10, 3 );
add_filter( 'user_row_actions', array( 'Bylines\Byline_Editor', 'filter_user_row_actions' ), 10, 2 );
add_action( 'byline_edit_form_fields', array( 'Bylines\Byline_Editor', 'action_byline_edit_form_fields' ) );
Expand Down
20 changes: 2 additions & 18 deletions src/Byline_Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function filter_manage_edit_byline_columns( $columns ) {
$new_columns = array();
foreach ( $columns as $key => $title ) {
if ( 'name' === $key ) {
$new_columns['byline_name'] = __( 'Name', 'bylines' );
$new_columns['name'] = $title;
$new_columns['byline_user_email'] = __( 'Email', 'bylines' );
} else {
$new_columns[ $key ] = $title;
Expand All @@ -38,15 +38,6 @@ public static function filter_manage_edit_byline_columns( $columns ) {
return $new_columns;
}

/**
* Set our custom name column as the primary column
*
* @return string
*/
public static function filter_list_table_primary_column() {
return 'byline_name';
}

/**
* Render and return custom column
*
Expand All @@ -55,14 +46,7 @@ public static function filter_list_table_primary_column() {
* @param int $term_id Term ID.
*/
public static function filter_manage_byline_custom_column( $retval, $column_name, $term_id ) {
if ( 'byline_name' === $column_name ) {
$byline = Byline::get_by_term_id( $term_id );
$avatar = get_avatar( $byline->user_email, 32 );
// Such hack. Lets us reuse the rendering without duplicate code.
$term = get_term_by( 'id', $term_id, 'byline' );
$wp_list_table = _get_list_table( 'WP_Terms_List_Table' );
$retval = $avatar . ' ' . $wp_list_table->column_name( $term );
} elseif ( 'byline_user_email' === $column_name ) {
if ( 'byline_user_email' === $column_name ) {
$byline = Byline::get_by_term_id( $term_id );
if ( $byline->user_email ) {
$retval = '<a href="' . esc_url( 'mailto:' . $byline->user_email ) . '">' . esc_html( $byline->user_email ) . '</a>';
Expand Down

0 comments on commit 957acd5

Please sign in to comment.