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

Commit

Permalink
Merge pull request #51 from xwp/feature/add-toolbar-link_issue_48
Browse files Browse the repository at this point in the history
Added a toolbar link to edit post screen view.
  • Loading branch information
westonruter committed Jul 5, 2016
2 parents 3653198 + f692f04 commit cb45595
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ env:
- WP_VERSION=trunk WP_MULTISITE=1
- WP_VERSION=latest WP_MULTISITE=1

branches:
only:
- master

install:
- export DEV_LIB_PATH=dev-lib
- if [ ! -e "$DEV_LIB_PATH" ] && [ -L .travis.yml ]; then export DEV_LIB_PATH=$( dirname $( readlink .travis.yml ) ); fi
Expand Down
2 changes: 1 addition & 1 deletion dev-lib
Submodule dev-lib updated 1 files
+1 −1 .eslintrc
36 changes: 34 additions & 2 deletions php/class-customize-snapshot-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -765,11 +765,44 @@ public function get_snapshot_uuid() {
}

/**
* Replaces the "Customize" link in the Toolbar.
* Toolbar modifications for Customize Snapshot
*
* @param \WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance.
*/
public function customize_menu( $wp_admin_bar ) {

$this->replace_customize_link( $wp_admin_bar );
$this->add_post_edit_screen_link( $wp_admin_bar );

add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' );
}

/**
* Adds a "Snapshot in Dashboard" link to the Toolbar when in Snapshot mode.
*
* @param \WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance.
*/
public function add_post_edit_screen_link( $wp_admin_bar ) {
$snapshot_post = $this->snapshot->post();
if ( ! $snapshot_post ) {
return;
}

$wp_admin_bar->add_node( array(
'parent' => 'customize',
'id' => 'snapshot-view-link',
'title' => __( 'View Snapshot', 'customize-snapshots' ),
'href' => get_edit_post_link( $snapshot_post->ID ),
) );
}

/**
* Replaces the "Customize" link in the Toolbar.
*
* @param \WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance.
*/
public function replace_customize_link( $wp_admin_bar ) {

// Don't show for users who can't access the customizer or when in the admin.
if ( ! current_user_can( 'customize' ) || is_admin() ) {
return;
Expand All @@ -795,7 +828,6 @@ public function customize_menu( $wp_admin_bar ) {
),
)
);
add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' );
}

/**
Expand Down
6 changes: 4 additions & 2 deletions tests/php/test-class-customize-snapshot-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,16 @@ function test_clean_current_url() {
}

/**
* Test Customize_Snapshot_Manager::create_post_type().
*
* @see Customize_Snapshot_Manager::create_post_type()
*/
function test_create_post_type() {
$pobj = get_post_type_object( Customize_Snapshot_Manager::POST_TYPE );
$this->assertInstanceOf( 'stdClass', $pobj );
$this->assertNotNull( $pobj );
$this->assertEquals( Customize_Snapshot_Manager::POST_TYPE, $pobj->name );

// Test some defaults
// Test some defaults.
$this->assertFalse( is_post_type_hierarchical( Customize_Snapshot_Manager::POST_TYPE ) );
$this->assertEquals( array(), get_object_taxonomies( Customize_Snapshot_Manager::POST_TYPE ) );
}
Expand Down

0 comments on commit cb45595

Please sign in to comment.