Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Merge 0ccfd16 into cb45595
Browse files Browse the repository at this point in the history
  • Loading branch information
miina committed Jul 5, 2016
2 parents cb45595 + 0ccfd16 commit c2ae620
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
21 changes: 19 additions & 2 deletions php/class-customize-snapshot-manager.php
Expand Up @@ -436,6 +436,14 @@ public function filter_post_row_actions( $actions, $post ) {
),
$actions
);

$frontend_view_url = add_query_arg( array_map( 'rawurlencode', $args ), home_url() );
$actions = array_merge(
array(
'front-view' => sprintf( '<a href="%s">%s</a>', esc_url( $frontend_view_url ), esc_html__( 'Preview Snapshot', 'customize-snapshots' ) ),
),
$actions
);
} elseif ( isset( $actions['edit'] ) ) {
$actions['edit'] = sprintf(
'<a href="%s" aria-label="%s">%s</a>',
Expand Down Expand Up @@ -486,15 +494,24 @@ public function render_data_metabox( $post ) {
echo '</p>';

if ( 'publish' !== $post->post_status ) {
echo '<p>';
$args = array(
'customize_snapshot_uuid' => $post->post_name,
);
$customize_url = add_query_arg( array_map( 'rawurlencode', $args ), wp_customize_url() );
echo sprintf(
'<p><a href="%s" class="button button-secondary">%s</a></p>',
'<a href="%s" class="button button-secondary">%s</a> ',
esc_url( $customize_url ),
esc_html__( 'Edit in Customizer', 'customize-snapshots' )
);

$frontend_view_url = add_query_arg( array_map( 'rawurlencode', $args ), home_url() );
echo sprintf(
'<a href="%s" class="button button-secondary">%s</a>',
esc_url( $frontend_view_url ),
esc_html__( 'Preview Snapshot', 'customize-snapshots' )
);
echo '</p>';
}

echo '<hr>';
Expand Down Expand Up @@ -791,7 +808,7 @@ public function add_post_edit_screen_link( $wp_admin_bar ) {
$wp_admin_bar->add_node( array(
'parent' => 'customize',
'id' => 'snapshot-view-link',
'title' => __( 'View Snapshot', 'customize-snapshots' ),
'title' => __( 'Inspect Snapshot', 'customize-snapshots' ),
'href' => get_edit_post_link( $snapshot_post->ID ),
) );
}
Expand Down
5 changes: 4 additions & 1 deletion tests/php/test-class-customize-snapshot-manager.php
Expand Up @@ -11,6 +11,7 @@ class Test_Customize_Snapshot_Manager extends \WP_UnitTestCase {

/**
* A valid UUID.
*
* @type string
*/
const UUID = '65aee1ff-af47-47df-9e14-9c69b3017cd3';
Expand Down Expand Up @@ -219,6 +220,7 @@ function test_filter_post_row_actions_draft() {
$filtered = $manager->filter_post_row_actions( $actions, $post );
$extected = array(
'customize' => '<a href="http://example.org/wp-admin/customize.php?customize_snapshot_uuid=' . $post->post_name . '">Customize</a>',
'front-view' => '<a href="http://example.org?customize_snapshot_uuid=' . $post->post_name . '">Preview Snapshot</a>',
);
$this->assertEquals( $extected, $filtered );
}
Expand Down Expand Up @@ -283,6 +285,7 @@ function test_render_data_metabox() {
$metabox = ob_get_clean();
$this->assertContains( $post->post_name, $metabox );
$this->assertContains( 'Edit in Customizer', $metabox );
$this->assertContains( 'Preview Snapshot', $metabox );
$this->assertContains( 'foo_value', $metabox );
}

Expand Down Expand Up @@ -430,7 +433,7 @@ public function test_customize_menu() {
do_action_ref_array( 'admin_bar_menu', array( &$wp_admin_bar ) );
$this->assertEquals( $customize_url, $wp_admin_bar->get_node( 'customize' )->href );
}

/**
* @see Customize_Snapshot_Manager::customize_menu()
*/
Expand Down

0 comments on commit c2ae620

Please sign in to comment.