Display Idea Hub notice above WP posts list table if there are new or saved ideas
See original GitHub issueIf there are any new or saved ideas in the Idea Hub module, a corresponding notice that links to the respective area of the Idea Hub widget should be displayed above the WordPress posts list admin table, following the Figma design.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- If the
ideaHubModulefeature flag is enabled and the Idea Hub module is active, a WordPress admin notice should be potentially displayed above the WordPress posts list table:- If there are saved ideas available, the notice should look like in this Figma file except not to include G Site Kit logo.
- If there are no saved but new ideas available, the notice should look like in this Figma file except not to include G Site Kit logo.
- In both cases, the link should lead to the respective tab of the Idea Hub widget in the Site Kit dashboard.
- The results for whether there are new ideas or saved ideas should be cached server-side (e.g. in a transient cached for a day).
- The notice dismissals for the two scenarios should be separately stored, both on the server-side:
- The dismissal for the “New ideas” notice should be stored for 1 week. In other words, if the user after one week still has no saved ideas, the notice should re-appear.
- The dismissal for the “Saved ideas” notice should be permanent, in general. However, there is one particular circumstance when it should be cleared: If the user makes a change that results in them to no longer have any saved ideas (for example unsaving the only saved idea or creating a draft post from the only saved idea), the dismissal should be cleared. In other words, once the user later saves something again, the notice should re-appear.
- To summarize: As long as the user continuously has something in “Saved”, they will not see any notice again once they dismiss it.
- Technically, this requires a new REST data point, e.g.
POST:core/user/data/dismiss-notification, expecting a notification slug.
Implementation Brief
- Once #3272 and #3360 have been merged.
- Create
assets/js/googlesitekit-idea-hub-post-list-notice.js. - Update
webpack.config.jsto add a new entry for the above file similar toanalytics-advanced-tracking. - Edit
includes/Modules/Idea_Hub.php- Edit
setup_assetsmethod to define a newScriptfordist/js/googlesitekit-idea-hub-post-list-notice.jswithCONTEXT_ADMIN_POSTSas context andgooglesitekit-datastore-useras a dependency. - Define 2 slugs which will be unique identifiers saved idea notice and new ideas notice.
- The
admin_noticeshook will be used to display the notifications which should be as per the designs in Figma. The callback function for the hook should do the following:- Ensure it runs only on the posts list screen. This can be done by using the
get_current_screenfunction and then checking whether theidits result is equal toedit-post. - Get a list of dismissed items via the
get_dismissed_itemsmethod of theDismissed_Itemsclass. - Check if there are saved ideas by using the
get_datamethod of the class withsaved-ideasas parameter and whether the notice has not been dismissed by checking if the slug for the saved idea notice does not exist in the list ofget_dismissed_items. If this is the case, then display the notice as per the documentation: and as per the designs in Figma. If there are no saved ideas, clear any dismissed notification using thedeletemethod of theDismissed_Itemsclass. - If there are no saved ideas, check if there are new ideas using the same method as for
saved-ideasbut usingnew-ideasas parameter for theget_datamethod. If there are news ideas and the notice has not been dismissed using the same logic as for the saved idea notice, then display the notice as per the documentation and as per the designs in Figma. - Both type of notices should be dismissible by adding the
is-dismissableclass name to the notice as well as thegoooglesitekit-noticeclass name andgoooglesitekit-notice__savedorgoooglesitekit-notice__newdepending whether it’s a saved ideas notice or new ideas notice. - The results of the saved ideas and new ideas count should be stored server side for 24 hours using the Transients API via the
Google\Site_Kit\Core\Storage\Transientsclass. - In both above cases, the link should lead to the respective tab of the Idea Hub widget in the Site Kit dashboard using the
plugins_urlfunction together with the following hash:#new-ideasfor the new ideas tab#saved-ideasfor the saved ideas tab.
- Ensure it runs only on the posts list screen. This can be done by using the
- Edit
- Update
assets/js/googlesitekit-idea-hub-post-list-notice.js,- to include the
dismissNoticefunction with the following details:- It has the following parameters:
slug: string, unique identifier for the noticeexpiration_time: integer, having default value0.
- It then dispatches the
dismissItemaction of thecore/userdata store passing theslugand optionalexpiration_time. Dispatching the action is done like in other modules, for e.gData.dispatch( CORE_USER ).dismissItem.
- It has the following parameters:
- Check if there are any elements having
goooglesitekit-noticeclass name. If this is the case, add a click event listener on the dismiss button (which has been added automatically by WordPress) which calls thedismissNoticefunction.- If it’s a saved idea notice, then the expiry is set to
0, which means it’s permanently dismissed. - If it’s a new idea notice, then the expiry is set to 1 week.
- If it’s a saved idea notice, then the expiry is set to
- to include the
Test Coverage
- No tests to be added.
Visual Regression Changes
- N/A
QA Brief
- Ensure you have new ideas.
- Open your posts list page. http://sitekit.10uplabs.com/wp-admin/edit.php
- Note the presence of a dismissible notice for new ideas.
- Dismiss the notice and refresh the page, note the absence of the notice.
- Reset the dismissed items by running
wp user meta delete 1 wp_googlesitekitpersistent_dismissed_itemscommand. - Refresh the page again and verify that the dismissible notice is shown again.
===
- Save an idea
- Go back to your posts list page
- Note the presence of a dismissible notice for saved ideas
- Dismiss the notice and refresh the page, verify that neither notice for saved ideas nor notice for new ideas is shown.
- Unsave all saved ideas
- Go back to your posts list page and verify that there is a notice for new ideas
Changelog entry
- Add the Idea Hub notice to the posts list table.
Issue Analytics
- State:
- Created 2 years ago
- Comments:22 (11 by maintainers)
Top Results From Across the Web
Show Idea Hub context for posts based on Idea Hub ... - GitHub
The WordPress posts list table should indicate which posts are drafts created on an Idea Hub idea. Do not alter or remove anything...
Read more >How to Display Recent Posts in WordPress - WPBeginner
In your WordPress dashboard, go to Appearance » Widgets and add the 'Latest Posts' widget block to your sidebar. Add latest post widget...
Read more >29 Creative Office Bulletin Board Ideas In 2023 {Buzzworthy}
The Buzz Board is one of the fun office notice board ideas. It's a chalkboard where you can post something new and buzzworthy...
Read more >How to Display Recent Posts on Any WordPress Page
The Smart Recent Posts Widget allows you to display a list of your latest posts with thumbnails, excerpts, and publish dates included. You...
Read more >admin_notices | Hook - WordPress Developer Resources
In order to display a notice, echo a div with the class notice and one of the following classes: * notice-error – will...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Unfortunately, not yet, @wpdarren
@eugene-manuilov thank you for updating the QAB and 🤦♂️ on the AC! I’ll put this on hold until 3747 is in QA.