Skip to content

Commit

Permalink
Github Deployments i1: Add Github deployments submenu to Tools menu i…
Browse files Browse the repository at this point in the history
…tem (#35350)

* add github deployments submenu to Tools

* changelog
  • Loading branch information
vykes-mac authored Feb 1, 2024
1 parent 251401f commit 179c60a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

Wordpress.com Tools Menu: Add Github Deployments submenu and gate behind a constant
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,13 @@ public function add_tools_menu() {
* Adds the WordPress.com Site Monitoring submenu under the main Tools menu.
*/
add_submenu_page( 'tools.php', esc_attr__( 'Site Monitoring', 'jetpack' ), __( 'Site Monitoring', 'jetpack' ), 'manage_options', 'https://wordpress.com/site-monitoring/' . $this->domain, null, 7 );

/**
* Adds the WordPress.com Github Deployments submenu under the main Tools menu.
*/
if ( apply_filters( 'jetpack_show_wpcom_github_deployments_menu', false ) ) {
add_submenu_page( 'tools.php', esc_attr__( 'Github Deployments', 'jetpack' ), __( 'Github Deployments', 'jetpack' ), 'manage_options', 'https://wordpress.com/github-deployments/' . $this->domain, null, 7 );
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,4 +366,29 @@ public function test_add_site_monitoring_menu() {

$this->assertSame( 'https://wordpress.com/site-monitoring/' . static::$domain, $submenu['tools.php'][ $menu_position ][2] );
}

/**
* Tests add_github_deployments_menu
*
* @covers ::add_tools_menu
*/
public function test_add_github_deployments_menu() {
global $submenu;

add_filter( 'jetpack_show_wpcom_github_deployments_menu', '__return_false', 99 );
static::$admin_menu->add_tools_menu();
remove_filter( 'jetpack_show_wpcom_github_deployments_menu', '__return_false', 99 );

$links = wp_list_pluck( array_values( $submenu['tools.php'] ), 2 );

$this->assertNotContains( 'https://wordpress.com/github-deployments/' . static::$domain, $links );

add_filter( 'jetpack_show_wpcom_github_deployments_menu', '__return_true', 99 );
static::$admin_menu->add_tools_menu();
remove_filter( 'jetpack_show_wpcom_github_deployments_menu', '__return_true', 99 );

$links = wp_list_pluck( array_values( $submenu['tools.php'] ), 2 );

$this->assertContains( 'https://wordpress.com/github-deployments/' . static::$domain, $links );
}
}

0 comments on commit 179c60a

Please sign in to comment.