Skip to content

Commit

Permalink
Auto open "Upload Theme" dialog when wpcom-upload=1 param exists (#39045
Browse files Browse the repository at this point in the history
)

* Add auto open upload theme dialog

* Dont use click event add CSS class to body instead

* changelog
  • Loading branch information
DustyReagan authored Aug 23, 2024
1 parent 1a961a8 commit ebbd392
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Auto open Upload Theme dialog if query parameter is present
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,22 @@ function wpcom_themes_add_theme_showcase_menu() {
);
}
add_action( 'admin_menu', 'wpcom_themes_add_theme_showcase_menu' );

/**
* Automatically opens the "Upload Theme" dialog on the theme installation page based on a 'wpcom-upload' query parameter.
*/
function wpcom_auto_open_upload_theme() {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['wpcom-upload'] ) && $_GET['wpcom-upload'] === '1' ) {
if ( ! current_user_can( 'install_themes' ) ) {
return;
}
add_filter(
'admin_body_class',
function ( $classes ) {
return $classes . ' show-upload-view ';
}
);
}
}
add_action( 'load-theme-install.php', 'wpcom_auto_open_upload_theme' );

0 comments on commit ebbd392

Please sign in to comment.