Skip to content

Conversation

@m1r0
Copy link
Member

@m1r0 m1r0 commented Apr 19, 2023

We were having issues with customizing our blocks in the Course theme using style variations. After some investigation, it turned out that our blocks were initialized too late (during the current_screen hook for the admin and on template_redirect for the frontend). The recommended way is to initialize blocks on the init hook.

Proposed Changes

  • Initialize the blocks on the init hook.
  • Keep the existing logic on the admin side - initialized only on the specified post types, site editor, etc...
  • On the frotnend side, previously the blocks were initialized only on the specified post types but this is no longer the case. To make style variations work, the blocks are now always initialized on the frontend (this is standard practice). The block assets are loaded on the specified post types as before.

Testing Instructions

  1. Create a course/lesson/quiz and make sure the blocks are working as before in the editor and on the frontend.
  2. Make sure the blocks are working in the site editor.
  3. Make sure the loaded assets in the frontend are the same as before.

Pre-Merge Checklist

  • PR title and description contain sufficient detail and accurately describe the changes
  • Acceptance criteria is met
  • Decisions are publicly documented
  • Adheres to coding standards (PHP, JavaScript, CSS, HTML)
  • All strings are translatable (without concatenation, handles plurals)
  • Follows our naming conventions (P6rkRX-4oA-p2)
  • Hooks (p6rkRX-1uS-p2) and functions are documented
  • New UIs are responsive and use a mobile-first approach
  • New UIs match the designs
  • Different user privileges (admin, teacher, subscriber) are tested as appropriate
  • Code is tested on the minimum supported PHP and WordPress versions
  • User interface changes have been tested on the latest versions of Chrome, Firefox and Safari
  • "Needs Documentation" label is added if this change requires updates to documentation
  • Known issues are created as new GitHub issues

@m1r0 m1r0 self-assigned this Apr 19, 2023
@github-actions
Copy link

github-actions bot commented Apr 19, 2023

WordPress Dependencies Report

The github-action-wordpress-dependencies-report action has detected some script changes between the commit 20f484a and trunk. Please review and confirm the following are correct before merging.

Script Handle Added Dependencies Removed Dependencies Total Size Size Diff
course-theme/blocks/index.js 13.8 kB +434 B ( +3.26% 🔼 )

This comment was automatically generated by the github-action-wordpress-dependencies-report action.

@m1r0 m1r0 added this to the 4.14.0 milestone Apr 19, 2023
@codecov
Copy link

codecov bot commented Apr 19, 2023

Codecov Report

Merging #6823 (3c3ae5a) into feature/learning-mode-improvements (51935af) will decrease coverage by 0.19%.
The diff coverage is 86.53%.

❗ Current head 3c3ae5a differs from pull request most recent head 20f484a. Consider uploading reports for the commit 20f484a to get more accurate results

Impacted file tree graph

@@                           Coverage Diff                            @@
##             feature/learning-mode-improvements    #6823      +/-   ##
========================================================================
- Coverage                                 47.38%   47.19%   -0.19%     
- Complexity                                10118    10133      +15     
========================================================================
  Files                                       499      499              
  Lines                                     35977    35895      -82     
  Branches                                    283      283              
========================================================================
- Hits                                      17046    16940     -106     
- Misses                                    18719    18743      +24     
  Partials                                    212      212              
Impacted Files Coverage Δ
includes/class-sensei-autoloader-bundle.php 0.00% <0.00%> (ø)
includes/class-sensei-autoloader.php 0.00% <0.00%> (ø)
includes/class-sensei-bootstrap.php 0.00% <0.00%> (ø)
includes/class-sensei-grading-user-quiz.php 0.00% <ø> (ø)
includes/class-sensei-settings.php 5.41% <0.00%> (ø)
includes/class-sensei.php 26.55% <ø> (ø)
...ncludes/blocks/class-sensei-blocks-initializer.php 97.91% <97.43%> (+8.26%) ⬆️
includes/class-sensei-assets.php 38.82% <100.00%> (-4.71%) ⬇️
includes/class-sensei-course.php 39.46% <100.00%> (+0.07%) ⬆️
includes/class-sensei-modules.php 38.48% <100.00%> (+0.25%) ⬆️

... and 55 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5aad923...20f484a. Read the comment docs.

@m1r0 m1r0 marked this pull request as ready for review April 19, 2023 19:39
@m1r0 m1r0 requested a review from a team April 19, 2023 19:40
Copy link
Contributor

@merkushin merkushin left a comment

Choose a reason for hiding this comment

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

👍

Thanks for tests!

@merkushin merkushin merged commit 1bac3ae into feature/learning-mode-improvements May 4, 2023
@merkushin merkushin deleted the fix/blocks-late-initialization branch May 4, 2023 10:15
@donnapep donnapep modified the milestones: 4.14.0, 4.15.0 May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants