Skip to content

Commit

Permalink
Revert PR #23, as it's not needed
Browse files Browse the repository at this point in the history
The same issue that caused
the submenus to not display
also caused the link
to not display.
Now that the capability is added
earlier, this works.
  • Loading branch information
kienstra committed Oct 18, 2020
1 parent 49d2b7d commit a06a117
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 52 deletions.
39 changes: 9 additions & 30 deletions php/Admin/Onboarding.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,15 @@ public function show_welcome_notice() {
<h2><span role="image" aria-label="<?php esc_attr_e( 'Waving hand emoji', 'genesis-custom-blocks' ); ?>">👋</span> <?php esc_html_e( 'Hi, and welcome!', 'genesis-custom-blocks' ); ?></h2>
<p class="intro"><?php esc_html_e( 'Genesis Custom Blocks makes it easy to build your own blocks for the WordPress editor.', 'genesis-custom-blocks' ); ?></p>
<p><strong><?php esc_html_e( 'Want to see how it\'s done?', 'genesis-custom-blocks' ); ?></strong> <?php esc_html_e( 'Here\'s one we prepared earlier.', 'genesis-custom-blocks' ); ?></p>
<p>
<a class="button button--white button_cta" href="<?php echo esc_url( $this->get_edit_link( $example_post_id ) ); ?>">
<?php esc_html_e( 'Let\'s get started!', 'genesis-custom-blocks' ); ?>
</a>
</p>
<?php
edit_post_link(
__( 'Let\'s get started!', 'genesis-custom-blocks' ),
'<p>',
'</p>',
$example_post_id,
'button button--white button_cta'
);
?>
<p class="ps"><?php esc_html_e( 'P.S. We don\'t like to nag. This message won\'t be shown again.', 'genesis-custom-blocks' ); ?></p>
<p class="ps">
<?php
Expand All @@ -169,31 +173,6 @@ public function show_welcome_notice() {
<?php
}

/**
* Gets the link to edit a post.
*
* A forked and simplified version of get_edit_post_link().
*
* @param string|int $post_id The ID of the post.
* @return string|null The URL to edit the post.
*/
public function get_edit_link( $post_id ) {
$post = get_post( $post_id );
if ( ! $post ) {
return null;
}

$post_type_object = get_post_type_object( $post->post_type );
if ( empty( $post_type_object->_edit_link ) ) {
return null;
}

$link = admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=edit', $post->ID ) );

/** This filter is documented in wp-includes/link-template.php */
return apply_filters( 'get_edit_post_link', $link, $post->ID, 'display' );
}

/**
* Render the Edit Your First Block message.
*/
Expand Down
22 changes: 0 additions & 22 deletions tests/php/Unit/Admin/TestOnboarding.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,6 @@ public function test_show_welcome_notice_should_display() {
$this->assertContains( strval( $post_id ), $output );
}

/**
* Test get_edit_link when the post ID is not for a post.
*
* @covers \Genesis\CustomBlocks\Admin\Onboarding::get_edit_link()
*/
public function test_get_edit_link_no_post() {
$this->assertEmpty( $this->instance->get_edit_link( 123456789 ) );
}

/**
* Test get_edit_link when there is a valid post.
*
* @covers \Genesis\CustomBlocks\Admin\Onboarding::get_edit_link()
*/
public function test_get_edit_link_with_post() {
$post_id = $this->factory()->post->create( [ 'post_type' => 'genesis_custom_block' ] );
$this->assertContains(
"post.php?post={$post_id}&amp;action=edit",
$this->instance->get_edit_link( $post_id )
);
}

/**
* Test plugin_activation.
*
Expand Down

0 comments on commit a06a117

Please sign in to comment.