Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
55 changes: 55 additions & 0 deletions functions/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,61 @@ function sunflower_admin_style() {

add_action( 'admin_enqueue_scripts', 'sunflower_admin_style' );

/**
* Add the last modified column to post, page and event list tables.
*
* @param array<string, string> $columns Existing list table columns.
* @return array<string, string> List table columns including last modified.
*/
function sunflower_add_modified_by_column( $columns ) {
$columns['last_modified_by'] = __( 'Last modified', 'sunflower' );

return $columns;
}

add_filter( 'manage_posts_columns', 'sunflower_add_modified_by_column' );
add_filter( 'manage_pages_columns', 'sunflower_add_modified_by_column' );
add_filter( 'manage_sunflower_event_posts_columns', 'sunflower_add_modified_by_column' );

/**
* Show the last editor and modification timestamp in the custom list table column.
*
* @param string $column Current column name.
* @param int $post_id Current post ID.
*/
function sunflower_fill_modified_by_column( $column, $post_id ) {
if ( 'last_modified_by' !== $column ) {
return;
}

$last_user_id = (int) get_post_meta( $post_id, '_edit_last', true );
if ( ! $last_user_id ) {
$last_user_id = (int) get_post_field( 'post_author', $post_id );
}

$user = get_userdata( $last_user_id );
$user_name = $user ? $user->user_login : __( 'Unknown', 'sunflower' );

$modified_date = get_the_modified_date( 'd.m.Y', $post_id );
$modified_time = get_the_modified_time( 'H:i', $post_id );
$modified_at = sprintf(
/* translators: %1$s is the modification date, %2$s is the modification time. */
__( '%1$s at %2$s', 'sunflower' ),
$modified_date,
$modified_time
);

printf(
'<strong>%1$s</strong><br><small>%2$s</small>',
esc_html( $user_name ),
esc_html( $modified_at )
);
}

add_action( 'manage_posts_custom_column', 'sunflower_fill_modified_by_column', 10, 2 );
add_action( 'manage_pages_custom_column', 'sunflower_fill_modified_by_column', 10, 2 );
add_action( 'manage_sunflower_event_posts_custom_column', 'sunflower_fill_modified_by_column', 10, 2 );

/**
* Add footer note to all backend pages.
*/
Expand Down
Binary file modified languages/de_DE.mo
Binary file not shown.
12 changes: 12 additions & 0 deletions languages/de_DE.po
Original file line number Diff line number Diff line change
Expand Up @@ -1424,3 +1424,15 @@ msgstr ""
#~ msgctxt "block title"
#~ msgid "Accordion (Sunflower)"
#~ msgstr "Akkordeon (Sunflower)"
#: functions/admin.php
msgid "Last modified"
msgstr "Zuletzt geändert"

#: functions/admin.php
msgid "Unknown"
msgstr "Unbekannt"

#. translators: %1$s is the modification date, %2$s is the modification time.
#: functions/admin.php
msgid "%1$s at %2$s"
msgstr "%1$s um %2$s Uhr"
12 changes: 12 additions & 0 deletions languages/sunflower.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1218,3 +1218,15 @@ msgstr ""
msgctxt "Font family name"
msgid "GrueneType Neue"
msgstr ""
#: functions/admin.php
msgid "Last modified"
msgstr ""

#: functions/admin.php
msgid "Unknown"
msgstr ""

#. translators: %1$s is the modification date, %2$s is the modification time.
#: functions/admin.php
msgid "%1$s at %2$s"
msgstr ""