From 875bc8cf4bbe13d65efe4ac306d89ebbfb8e2cac Mon Sep 17 00:00:00 2001 From: mmtr <1233880+mmtr@users.noreply.github.com> Date: Fri, 20 Dec 2024 11:37:20 +0100 Subject: [PATCH 1/3] Show homepage banner --- .../src/features/pages/pages.php | 1 + .../src/features/pages/template-notices.php | 118 ++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 projects/packages/jetpack-mu-wpcom/src/features/pages/template-notices.php diff --git a/projects/packages/jetpack-mu-wpcom/src/features/pages/pages.php b/projects/packages/jetpack-mu-wpcom/src/features/pages/pages.php index 7f51bb4bb27d8..a3bc7d1097ab0 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/pages/pages.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/pages/pages.php @@ -1,3 +1,4 @@ + + + + Date: Fri, 20 Dec 2024 13:38:22 +0100 Subject: [PATCH 2/3] Add changelog --- .../update-remove-duplicate-views-pages-homepage-banner | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/packages/jetpack-mu-wpcom/changelog/update-remove-duplicate-views-pages-homepage-banner diff --git a/projects/packages/jetpack-mu-wpcom/changelog/update-remove-duplicate-views-pages-homepage-banner b/projects/packages/jetpack-mu-wpcom/changelog/update-remove-duplicate-views-pages-homepage-banner new file mode 100644 index 0000000000000..0a2c2efeccc56 --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/update-remove-duplicate-views-pages-homepage-banner @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Pages: Add homepage banner to pages list screen From 74a1639a85ff0892eb3dbf88723e337678472d05 Mon Sep 17 00:00:00 2001 From: mmtr <1233880+mmtr@users.noreply.github.com> Date: Fri, 20 Dec 2024 17:18:31 +0100 Subject: [PATCH 3/3] Get data from template and add actions --- .../src/features/pages/template-notices.php | 99 ++++++++++++++++--- 1 file changed, 86 insertions(+), 13 deletions(-) diff --git a/projects/packages/jetpack-mu-wpcom/src/features/pages/template-notices.php b/projects/packages/jetpack-mu-wpcom/src/features/pages/template-notices.php index 01bcf6040e8cd..108597c5edd99 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/pages/template-notices.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/pages/template-notices.php @@ -42,8 +42,8 @@ function wpcom_show_homepage_notice() { } $show_on_front = get_option( 'show_on_front' ); - $page_on_front = get_option( 'page_on_front' ); - $posts_on_front = $show_on_front === 'posts' || ( $show_on_front === 'page' && ! $page_on_front ); + $front_page_id = get_option( 'page_on_front' ); + $posts_on_front = $show_on_front === 'posts' || ( $show_on_front === 'page' && ! $front_page_id ); if ( ! $posts_on_front ) { return; } @@ -63,17 +63,67 @@ function wpcom_show_homepage_notice() { } } // phpcs:enable WordPress.Security.NonceVerification.Recommended + + $template = resolve_block_template( 'home', array( 'front-page', 'home', 'index' ), '' ); + if ( ! $template ) { + return; + } + + if ( $template->wp_id ) { + $template_title = apply_filters( 'the_title', $template->title, $template->wp_id ); + } else { + $template_title = $template->title; + } + + $can_edit = current_user_can( 'edit_theme_options' ); + $edit_link = '/wp-admin/site-editor.php'; + $view_link = home_url(); + // Link to the wp-admin stats page. + + if ( 'wp-admin' === get_option( 'wpcom_admin_interface' ) ) { + $stats_link = admin_url( sprintf( 'admin.php?page=stats#!/stats/post/0/%d', Jetpack_Options::get_option( 'id', 0 ) ) ); + } else { + $domain = wp_parse_url( home_url(), PHP_URL_HOST ); + $stats_link = sprintf( 'https://wordpress.com/stats/post/0/%s', $domain ); + } + + if ( $can_edit ) { + $main_action = __( 'Edit homepage', 'jetpack-mu-wpcom' ); + $main_link = '/wp-admin/site-editor.php'; + } else { + $main_action = __( 'View homepage', 'jetpack-mu-wpcom' ); + $main_link = home_url(); + } + + /* translators: template title */ + $description = sprintf( __( 'Your homepage uses the %s template.', 'jetpack-mu-wpcom' ), $template_title ); ?> @@ -88,18 +138,41 @@ function wpcom_show_homepage_notice() { gap: 16px; } - .wpcom-homepage-notice h2, - .wpcom-homepage-notice p { - margin: 0; + .wpcom-homepage-notice-icon svg { + width: 24px; + height: 24px; } - .wpcom-homepage-notice h2 { - margin-bottom: 0.25em; + .wpcom-homepage-notice-title, + .wpcom-homepage-notice-description { + margin: 0 0 0.25em; } - .wpcom-homepage-notice svg { - width: 24px; - height: 24px; + .wpcom-homepage-notice-title { + display: flex; + gap: 2px; + } + + .wpcom-homepage-notice a { + text-decoration: none; + } + + .wpcom-homepage-notice-actions { + display: flex; + } + + .wpcom-homepage-notice-actions a { + border-left: 1px solid #a7aaad; + padding: 0 4px; + } + + .wpcom-homepage-notice-actions a:first-child { + border-left: none; + padding-left: 0; + } + + .wpcom-homepage-notice-actions a:last-child { + padding-right: 0; }