Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show the correct homepage when previewing a theme in the Site Editor #31929

Merged
merged 13 commits into from
Jul 24, 2023

Conversation

okmttdhr
Copy link
Member

@okmttdhr okmttdhr commented Jul 18, 2023

Proposed changes:

Show the correct homepage when previewing a theme in the Site Editor to support Block Theme Previews on dotcom. This is done by overriding the show_on_front option to posts.

I added changes in Jetpack jetpack-mu-wpcom since dotcom wants to support Block Theme Previews both on Simple and Atomic sites.

This PR is part of Automattic/wp-calypso#79221.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

No

Testing instructions:

Atomic sites

  • Create an Atomic site
  • Change your Reading Settings to show a static page as a homepage
  • Patch this PR to your site by following Show the correct homepage when previewing a theme in the Site Editor #31929 (comment)
    • Note that you must set define( 'JETPACK_MU_WPCOM_LOAD_VIA_BETA_PLUGIN', true ); to your wp-config.php
  • Install a theme
  • Go to Block Theme Previews with /wp-admin/site-editor.php?wp_theme_preview=<your-theme> (e.g. ?wp_theme_preview=pendant)
  • Verify Block Theme Previews show Index or Home template as a homepage

Simple sites

  • Create a site
  • Change your Reading Settings to show a static page as a homepage
  • Patch this PR to your sandbox by following Show the correct homepage when previewing a theme in the Site Editor #31929 (comment)
  • Sandbox your testing site AND public-api.wordpress.com
  • Go to Block Theme Previews with /wp-admin/site-editor.php?wp_theme_preview=<your-theme> (e.g. ?wp_theme_preview=pub/pendant)
  • Verify Block Theme Previews show Index or Home template as a homepage

self-hosted site

  • Patch this PR to your site
    • I used jetpack rsync PCYsg-eg0-p2
  • Go to Block Theme Previews with /wp-admin/site-editor.php?wp_theme_preview=<your-installed-theme> (e.g. ?wp_theme_preview=twentytwentytwo)
  • Verify nothing breaks on the Site Editor

@github-actions
Copy link
Contributor

github-actions bot commented Jul 18, 2023

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta > Jetpack and enable the add/site-editor-homepage branch.

  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/site-editor-homepage
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress labels Jul 18, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 18, 2023

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team Review" label and ask someone from your team review the code. Once reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


Jetpack plugin:

  • Next scheduled release: August 1, 2023.
  • Scheduled code freeze: July 24, 2023.

Mu Wpcom plugin:

  • Next scheduled release: August 1, 2023.
  • Scheduled code freeze: July 24, 2023.

@okmttdhr okmttdhr modified the milestone: jetpack/12.4 Jul 18, 2023
@okmttdhr okmttdhr changed the title Show the correct homepage when previewing a theme Show the correct homepage when previewing a theme in the Site Editor Jul 18, 2023
@okmttdhr okmttdhr marked this pull request as ready for review July 18, 2023 08:37
@okmttdhr okmttdhr self-assigned this Jul 18, 2023
taipeicoder
taipeicoder previously approved these changes Jul 19, 2023
Copy link
Contributor

@taipeicoder taipeicoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testes:

Atomic sites: ✅ BTP shows Index of Home template as homepage.
Simple sites: ✅ BTP works as before.
Self-hosted sites: ✅ BTP works as before.

@jeherve jeherve added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Focus] FSE Issues related to the site editor / Full Site Editing / FSE feature in Gutenberg labels Jul 19, 2023
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I fully understand why this is in Jetpack. I think I'm missing some context on this, probably.

If we always want to show the posts page when previewing a new theme, shouldn't we make that change in Core directly, since theme previews will soon be available to everyone?

@arthur791004
Copy link
Contributor

@jeherve Based on pekYwv-1BS-p2 and pekYwv-1BS-p2#comment-1187, I guess Core won't touch the reading settings in the short term since Core won't change the reading settings during the theme switch. So, it makes sense to keep the current reading settings when you're previewing a theme in the site editor on Core.

However, dotcom has a mechanism to update the reading settings based on the headstart annotation of the theme. So, we have to override the show_on_front option dynamically on both simple and atomic sites to make the preview look the same after the theme switch. That's why we made the change on Jetpack.

Does it make sense? Or any thoughts?

@jeherve
Copy link
Member

jeherve commented Jul 19, 2023

Ok, that makes sense. In this situation, and since this is really only interesting for WordPress.com sites (simple and WoA), maybe this should be shipped in the mu-wpcom plugin instead?
https://github.com/Automattic/jetpack/tree/trunk/projects/plugins/mu-wpcom-plugin

arthur791004
arthur791004 previously approved these changes Jul 20, 2023
Copy link
Contributor

@arthur791004 arthur791004 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@okmttdhr okmttdhr force-pushed the add/site-editor-homepage branch 2 times, most recently from 24a67c3 to 9ad0326 Compare July 21, 2023 04:14
@okmttdhr okmttdhr enabled auto-merge (squash) July 21, 2023 04:58
@okmttdhr
Copy link
Member Author

@Automattic/lego I requested your reviews again as I resolved conflicts 🙏 Thank you!

Copy link
Contributor

@fushar fushar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested by using the following scenarios:

  • current theme: Appleton, which has a static homepage set.
  • previewing theme: Pendant, which has the Home template.

Atomic site ✅

Before After
image image

Simple site ❌

Before After
image image

I am not sure what I'm doing wrong. I have sandboxed my site (see the "Sandboxed" badge at the left-corner of the right screenshot). Log:

$ bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/site-editor-homepage
Current checkout is switch-theme-logic-new. Check out trunk? [Y/n] Y

Updating trunk...
# Request received by "phabricator-b06-29.dfw.automattic.com", forwarding to cluster host "phabricator-b12-10.dfw.automattic.com".
# Acquiring read lock for repository "wpcom-git" on device "phabricator-b12-10.dfw.automattic.com"...
# Acquired read lock immediately.
# Device "phabricator-b12-10.dfw.automattic.com" is already a cluster leader and does not need to be synchronized.
# Cleared to fetch on cluster host "phabricator-b12-10.dfw.automattic.com".

Updating files:  53% (12198/23014)
Updating files:  61% (14039/23014)
Updating files: 100% (23014/23014), done.
Determining jetpack-mu-wpcom-plugin download URL...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 10406  100 10406    0     0  47733      0 --:--:-- --:--:-- --:--:-- 47733
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  8181  100  8181    0     0  71763      0 --:--:-- --:--:-- --:--:-- 72398
Downloading jetpack-mu-wpcom-plugin...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 80835  100 80835    0     0   400k      0 --:--:-- --:--:-- --:--:--  398k
Unpacking jetpack-mu-wpcom-plugin...
jetpack-mu-wpcom-plugin add/site-editor-homepage is now checked out in sun!
If you intend to commit it, use `git add -Af wp-content/mu-plugins/jetpack-mu-wpcom-plugin/sun` to ensure all files are added.
To reset your environment instead, use `jetpack-downloader reset jetpack-mu-wpcom-plugin`.

Will test on a JN site soon.

@okmttdhr
Copy link
Member Author

okmttdhr commented Jul 21, 2023

I am not sure what I'm doing wrong. I have sandboxed my site (see the "Sandboxed" badge at the left-corner of the right screenshot).

This is weird. 👀 I will check it Monday!
One thing I want to confirm is if you sandboxed public-api.wordpress.com as well. @fushar

@fushar
Copy link
Contributor

fushar commented Jul 21, 2023

Will test on a JN site soon.

Jetpack-connected self-hosted site ✅

Nothing breaks!

@taipeicoder
Copy link
Contributor

Gave a test on Simple Sites, and it works as expected 👍

Copy link
Contributor

@fushar fushar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update:

Simple site ✅

Before After
image image

Needed to change .config/jetpack-loader.php from moon to sun.

@okmttdhr okmttdhr merged commit f2d46dc into trunk Jul 24, 2023
@okmttdhr okmttdhr deleted the add/site-editor-homepage branch July 24, 2023 07:21
haqadn pushed a commit that referenced this pull request Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] FSE Issues related to the site editor / Full Site Editing / FSE feature in Gutenberg [Package] Jetpack mu wpcom WordPress.com Features [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] mu wpcom jetpack-mu-wpcom plugin [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants