diff --git a/lib/register.php b/lib/register.php index a17a811c645ade..32ecb1b05747d2 100644 --- a/lib/register.php +++ b/lib/register.php @@ -151,17 +151,16 @@ function gutenberg_add_edit_links( $actions, $post ) { return $actions; } - if ( gutenberg_post_has_blocks( $post->ID ) ) { - remove_filter( 'get_edit_post_link', 'gutenberg_filter_edit_post_link', 10 ); - add_filter( 'get_edit_post_link', 'gutenberg_filter_edit_post_link', 10, 3 ); - } + remove_filter( 'get_edit_post_link', 'gutenberg_filter_edit_post_link', 10 ); + $classic_url = get_edit_post_link( $post->ID, 'raw' ); + add_filter( 'get_edit_post_link', 'gutenberg_filter_edit_post_link', 10, 3 ); // Build the new edit actions. See also: WP_Posts_List_Table::handle_row_actions(). $title = _draft_or_post_title( $post->ID ); $edit_actions = array( 'classic hide-if-no-js' => sprintf( '%s', - esc_url( get_edit_post_link( $post->ID, 'raw' ) ), + esc_url( $classic_url ), esc_attr( sprintf( /* translators: %s: post title */ __( 'Edit “%s” in the classic editor', 'gutenberg' ), diff --git a/phpunit/class-admin-test.php b/phpunit/class-admin-test.php index ffe0508c6b933e..b55620a3ebb418 100644 --- a/phpunit/class-admin-test.php +++ b/phpunit/class-admin-test.php @@ -80,10 +80,12 @@ function test_gutenberg_add_edit_links() { $actions = apply_filters( 'post_row_actions', $original_actions, get_post( self::$post_with_blocks ) ); $this->assertArrayHasKey( 'gutenberg hide-if-no-js', $actions ); $this->assertArrayHasKey( 'classic hide-if-no-js', $actions ); + $this->assertContains( 'post.php', $actions['classic hide-if-no-js'] ); $actions = apply_filters( 'post_row_actions', $original_actions, get_post( self::$post_without_blocks ) ); $this->assertArrayHasKey( 'gutenberg hide-if-no-js', $actions ); $this->assertArrayHasKey( 'classic hide-if-no-js', $actions ); + $this->assertContains( 'post.php', $actions['classic hide-if-no-js'] ); $trashed_post = $this->factory()->post->create( array( 'post_status' => 'trash',