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 #143 from xwp/add/changesets-submenu-item
Browse files Browse the repository at this point in the history
Add Changesets link in admin bar submenu item under Customize
  • Loading branch information
westonruter authored Jul 26, 2017
2 parents 1875944 + ab583b5 commit 71374fa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
21 changes: 21 additions & 0 deletions php/class-customize-snapshot-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ static public function is_valid_uuid( $uuid ) {
public function customize_menu( $wp_admin_bar ) {
add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' );
$this->replace_customize_link( $wp_admin_bar );
$this->add_changesets_admin_bar_link( $wp_admin_bar );
$this->add_resume_snapshot_link( $wp_admin_bar );
$this->add_post_edit_screen_link( $wp_admin_bar );
$this->add_snapshot_exit_link( $wp_admin_bar );
Expand Down Expand Up @@ -553,6 +554,26 @@ public function replace_customize_link( $wp_admin_bar ) {
$wp_admin_bar->add_menu( (array) $customize_node );
}

/**
* Adds a link to resume snapshot previewing.
*
* @param \WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance.
*/
public function add_changesets_admin_bar_link( $wp_admin_bar ) {
if ( ! $wp_admin_bar->get_node( 'customize' ) ) {
return;
}
$wp_admin_bar->add_node( array(
'id' => 'customize-changesets',
'parent' => 'customize',
'title' => __( 'Changesets', 'customize-snapshots' ),
'href' => admin_url( 'edit.php?post_type=customize_changeset' ),
'meta' => array(
'class' => 'ab-item',
),
) );
}

/**
* Adds a link to resume snapshot previewing.
*
Expand Down
5 changes: 5 additions & 0 deletions tests/php/test-class-customize-snapshot-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,13 +543,15 @@ public function test_print_admin_bar_styles() {
* Test misc admin bar extensions.
*
* @covers \CustomizeSnapshots\Customize_Snapshot_Manager::add_post_edit_screen_link()
* @covers \CustomizeSnapshots\Customize_Snapshot_Manager::add_changesets_admin_bar_link()
* @covers \CustomizeSnapshots\Customize_Snapshot_Manager::add_snapshot_exit_link()
* @covers \CustomizeSnapshots\Customize_Snapshot_Manager::add_resume_snapshot_link()
* @covers \CustomizeSnapshots\Customize_Snapshot_Manager::remove_all_non_snapshot_admin_bar_links()
*/
public function test_add_post_edit_and_exit_links() {
global $wp_admin_bar;
set_current_screen( 'front' );
wp_set_current_user( $this->user_id );
require_once ABSPATH . WPINC . '/class-wp-admin-bar.php';

$this->manager->post_type->save( array(
Expand All @@ -573,6 +575,9 @@ public function test_add_post_edit_and_exit_links() {
$this->assertEmpty( $wp_admin_bar->get_node( 'exit-customize-snapshot' ) );
$this->assertNotEmpty( $wp_admin_bar->get_node( 'wporg' ) );
$this->assertNotEmpty( $wp_admin_bar->get_node( 'resume-customize-snapshot' ) );
$changesets_node = $wp_admin_bar->get_node( 'customize-changesets' );
$this->assertNotEmpty( $changesets_node );
$this->assertEquals( 'customize', $changesets_node->parent );

$this->go_to( home_url( '?' . $this->front_param . '=' . self::UUID ) );
remove_all_actions( 'admin_bar_menu' );
Expand Down

0 comments on commit 71374fa

Please sign in to comment.