Skip to content

Commit

Permalink
Improve the reusable blocks Export as JSON link. (#10003)
Browse files Browse the repository at this point in the history
  • Loading branch information
afercia authored Sep 18, 2018
1 parent 7c7e764 commit 779c3c5
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,22 @@ function gutenberg_add_edit_link_filters() {
* @return array Updated post actions.
*/
function gutenberg_add_edit_link( $actions, $post ) {
// Build the classic edit action. See also: WP_Posts_List_Table::handle_row_actions().
$title = _draft_or_post_title( $post->ID );

if ( 'wp_block' === $post->post_type ) {
unset( $actions['edit'] );
unset( $actions['inline hide-if-no-js'] );
$actions['export'] = sprintf(
'<a class="wp-list-reusable-blocks__export" href="#" data-id="%s" aria-label="%s">%s</a>',
'<button type="button" class="wp-list-reusable-blocks__export button-link" data-id="%s" aria-label="%s">%s</button>',
$post->ID,
__( 'Export as JSON', 'gutenberg' ),
esc_attr(
sprintf(
/* translators: %s: post title */
__( 'Export &#8220;%s&#8221; as JSON', 'gutenberg' ),
$title
)
),
__( 'Export as JSON', 'gutenberg' )
);
return $actions;
Expand All @@ -276,8 +285,6 @@ function gutenberg_add_edit_link( $actions, $post ) {
$edit_url = get_edit_post_link( $post->ID, 'raw' );
$edit_url = add_query_arg( 'classic-editor', '', $edit_url );

// Build the classic edit action. See also: WP_Posts_List_Table::handle_row_actions().
$title = _draft_or_post_title( $post->ID );
$edit_action = array(
'classic' => sprintf(
'<a href="%s" aria-label="%s">%s</a>',
Expand Down

0 comments on commit 779c3c5

Please sign in to comment.