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

1360 Admin amp_invalid_url table - replace 'trash' text #1408

Merged
merged 7 commits into from
Sep 7, 2018
65 changes: 62 additions & 3 deletions includes/validation/class-amp-invalid-url-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public static function add_admin_hooks() {
add_action( 'admin_menu', array( __CLASS__, 'add_admin_menu_new_invalid_url_count' ) );
add_filter( 'post_row_actions', array( __CLASS__, 'filter_post_row_actions' ), 10, 2 );
add_filter( sprintf( 'views_edit-%s', self::POST_TYPE_SLUG ), array( __CLASS__, 'filter_table_views' ) );
add_filter( 'bulk_post_updated_messages', array( __CLASS__, 'filter_bulk_post_updated_messages' ), 10, 2 );

// Hide irrelevant "published" label in the invalid URL post list.
add_filter( 'post_date_column_status', function( $status, $post ) {
Expand Down Expand Up @@ -627,7 +628,7 @@ public static function filter_row_actions( $actions, $post ) {
$actions[ self::VALIDATE_ACTION ] = sprintf(
'<a href="%s">%s</a>',
esc_url( self::get_recheck_url( $post ) ),
esc_html__( 'Re-check', 'amp' )
esc_html__( 'Recheck', 'amp' )
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed hyphen from 'Re-check' for consistency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, as it seems the most commonly-accepted spelling is without the hyphen.

);
if ( self::get_post_staleness( $post ) ) {
$actions[ self::VALIDATE_ACTION ] = sprintf( '<em>%s</em>', $actions[ self::VALIDATE_ACTION ] );
Expand All @@ -643,7 +644,13 @@ public static function filter_row_actions( $actions, $post ) {
* @return array $actions The filtered bulk actions.
*/
public static function filter_bulk_actions( $actions ) {
$actions['trash'] = esc_html__( 'Forget', 'amp' );
if ( isset( $actions['trash'] ) ) {
$actions['trash'] = esc_html__( 'Forget', 'amp' );
}

if ( isset( $actions['delete'] ) ) {
$actions['delete'] = esc_html__( 'Forget permanently', 'amp' );
}

unset( $actions['edit'] );
$actions[ self::BULK_VALIDATE_ACTION ] = esc_html__( 'Recheck', 'amp' );
Expand Down Expand Up @@ -1045,7 +1052,7 @@ public static function print_status_meta_box( $post ) {
<div id="minor-publishing-actions">
<div id="re-check-action">
<a class="button button-secondary" href="<?php echo esc_url( self::get_recheck_url( $post ) ); ?>">
<?php esc_html_e( 'Re-check', 'amp' ); ?>
<?php esc_html_e( 'Recheck', 'amp' ); ?>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed hyphen from 'Re-check' for consistency.

</a>
</div>
<?php if ( ! ( AMP_Validation_Manager::is_sanitization_forcibly_accepted() || $is_sanitization_forcibly_accepted_by_filter ) ) : ?>
Expand Down Expand Up @@ -1516,6 +1523,16 @@ public static function filter_post_row_actions( $actions, $post ) {
);
}

if ( isset( $actions['delete'] ) ) {
$actions['delete'] = sprintf(
'<a href="%s" class="submitdelete" aria-label="%s">%s</a>',
get_delete_post_link( $post->ID, '', true ),
/* translators: %s: post title */
esc_attr( sprintf( __( 'Forget &#8220;%s&#8221; permanently', 'amp' ), $post->post_title ) ),
esc_html__( 'Forget Permanently', 'amp' )
);
}

return $actions;
}

Expand All @@ -1532,7 +1549,49 @@ public static function filter_table_views( $views ) {

$views['trash'] = str_replace( $status->label, esc_html__( 'Forgotten', 'amp' ), $views['trash'] );
}

return $views;
}


/**
* Filters messages displayed after bulk updates.
*
* @param array $messages Bulk message text.
* @param array $bulk_counts Post numbers for the current message.
* @return array Filtered messages.
*/
public static function filter_bulk_post_updated_messages( $messages, $bulk_counts ) {
if ( get_current_screen()->id === sprintf( 'edit-%s', self::POST_TYPE_SLUG ) ) {
$messages['post'] = array_merge(
$messages['post'],
array(
/* translators: %s is the number of posts permanently forgotten */
'deleted' => _n(
'%s invalid AMP page permanently forgotten.',
'%s invalid AMP post permanently forgotten.',
$bulk_counts['deleted'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor thing (and other such instances): this could be wrapped in number_format_i18n().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meh, core isn't doing it. So no need for it here.

'amp'
),
/* translators: %s is the number of posts forgotten */
'trashed' => _n(
'%s invalid AMP page forgotten.',
'%s invalid AMP pages fogotten.',
$bulk_counts['trashed'],
'amp'
),
/* translators: %s is the number of posts restored from trash. */
'untrashed' => _n(
'%s invalid AMP page unforgotten.',
'%s invalid AMP pages unforgotten.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“Remembered”? 😄

$bulk_counts['untrashed'],
'amp'
),
)
);
}

return $messages;
}

}