Closed chihsuan closed 1 year ago
@chihsuan What would be the best way to know if the active theme has been modified?
Do you think get_theme_mods is a good function to use for our use cases?
For the via the "Editor" link, what value should we use? We've linked it to Customize your store
on other pages, but that's where the user is on the intro page 🤔
@chihsuan What would be the best way to know if the active theme has been modified?
Do you think get_theme_mods is a good function to use for our use cases?
Hey @moon0326 I think we need to check if the current template, pages, and global style have been modified for block themes (We only support block themes in CYS).
Get the current template and check if modified
field is not null.
// https://github.com/woocommerce/woocommerce/blob/7f9322c85858a17f6e9e9e79eaa3aefeda1a0624/plugins/woocommerce-admin/client/customize-store/design-with-ai/services.ts#L315
const currentTemplate = await resolveSelect(
coreStore
// @ts-ignore No types for this exist yet.
).__experimentalGetTemplateForLink( '/' );
Retrieve the pages and check the value of _links.version_history.count
OR compare whether the date and modification are the same to know whether they have been changed.
import { useEntityRecords } from '@wordpress/core-data';
const { records, isResolving } = useEntityRecords( 'postType', 'page' );
Use useGlobalStylesRevisions
or getCurrentThemeGlobalStylesRevisions
Let me know if you have other questions. Thank you! 🙏
For the via the "Editor" link, what value should we use?
Use /wp-admin/site-editor.php
. 🙂
Hmm, looks like get_theme_mods also works. Let me test your PR first. 🙌
Hey @moon0326 I just tested get_theme_mods
on a fresh JN site.
It seems that even if I haven't modified the theme, it returns an item by default
[22-Sep-2023 05:04:00 UTC] Array
(
[custom_css_post_id] => -1
)
And after I modified the page through the site-editor, it did not change the results.
Thank for checking it @chihsuan 👍
Let's go with your approach in that case. I'll make changes
@chihsuan For the page query, doesn't it also return other custom pages created by users 🤔 ?
import { useEntityRecords } from '@wordpress/core-data';
const { records, isResolving } = useEntityRecords( 'postType', 'page' );
For the page query, doesn't it also return other custom pages created by users
@moon0326 Ah, you're right!
Do you know how we can check if a page was created by a user? 🤔
However, I think we could ignore pages now since we've decided to make the frame not navigable for the MVP (pdnLyh-4it-p2).
User Story
As a new merchant, I want to be presented with simple flows to customize my store, so that I can start selling sooner.
Design
Mrk6SERPZ4KrFHSjM0a8TK-fi-3913%3A288838
Acceptance Criteria