WebDevStudios / wds-block-starter

A block starter for projects.
15 stars 3 forks source link

Fix Asset Loading Enqueues #5

Closed michealengland closed 4 years ago

michealengland commented 4 years ago

Currently, we're using OOPS-WP as a starting place for enqueuing block assets. Some of the challenges here is that enqueues are not being added to the registered to the correct places.

Here is an example of how I managed this on a different plugin by wrapping editor based files with enqueue_block_editor_assets action hook. https://github.com/michealengland/display-exif-data/blob/master/inc/enqueue-scripts.php

Enqueue Expectations

  1. Frontend styles should only load on the frontend.
  2. Editor styles need to load only in the editor. This would need to register in the enqueue_block_editor_assets action hook.
  3. Block JS should only load in the editor. This would need to register in the enqueue_block_editor_assets action hook.
  4. A frontend JS enqueue would be nice to incorporate.