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

Scope module assets #441

Closed
wants to merge 150 commits into from
Closed

Conversation

pyronaur
Copy link
Member

Overview
At the moment, almost all assets are loaded on every admin page (for example - calendar.js is loaded in "Settings -> General”). Overall there were a lot of inconsistencies in asset enqueuing. The goal of this PR is to provide a reliable and predictable way of enqueuing module assets.

Background
Every Edit Flow module extends the EF_Module class. However, some modules have dedicated views and some modules (like Dashboard widgets module) don’t. That’s where the inconsistencies begin.

Most EF Modules enqueue assets. Some check whether they should enqueue assets, some perform the same checks in a different way, and some don’t check at all. Most of the modules use method EF_Module::is_whitelisted_functional_view which simply always returns true, with a //@todo attached to it :) - the whole asset enqueuing process needed a refactor.

Introducing EF_Module_With_View
The EF modules needed a few methods to make it easy to check whether the any given module is visible at the moment (and therefore, whether they should enqueue assets). In most cases this is either in the edit, list and settings views.

At first I dumped all the necessary methods on EF_Module class because all of the modules already are extending it. But EF_Module is also instantiated directly and it’s also extended by a EF_Dashboard class that doesn’t utilize the any of the “new” methods, so it didn’t make sense to keep them there.

EF_Module_With_View extends EF_Module and is meant to be extended further by modules that have views, that way they have access to necessary methods, like is_current_module_settings_view() and is_active_view()

Adding PHP interfaces
There was no streamlined way of dealing with assets. Even enqueuing method names varied from module to module. That’s why I decided to 2 simple interfaces: EF_Script_Interface and EF_Style_Interface - they will ensure that asset enqueuing methods are consistent and predictable. Also, by reading the class declaration it’s immediately clear whether or not the current module is enqueuing any assets.

Summary

  • Force predictable and consistent enqueuing methods with PHP Interfaces across EF Modules
  • Add a an reusable and easy to use class EF_Module_With_View that provides methods to easily determine whether or not assets are needed
  • Refactor most modules to extend EF_Module_With_View instead of EF_Module and enqueue assets when they’re needed

Fixes #351

goodguyry and others added 30 commits July 29, 2014 22:40
`home_url()` will only add a trailing slash to a site's home URL
if a path is passed as an argument.

If no path is passed, a page preview could be something like:

http://wp.wsu.dev?page_id=1

And it would work fine in most cases.

In a subdirectory multisite configuration, a page preview could be
something like:

http://wp.wsu.dev/site?page_id=1

This could be processed by WordPress as a lookup for a page named
"site" rather than a site with that URL because no trailing slash
exists.

When adding query args to `home_url()`, we should tell it to use
a slash to avoid confusion.

See `_get_page_link()` for how core builds these in a way where a
slash is always added.
fix get_beginning_of_week returning wrong results when given $date is not a start of the week
fix get_beginning_of_week returning wrong results on DST switching
All I did was to replace the timesince function with the human_time_diff function from WordPress. This way, the time difference is automatically created.
Even though this method was never implemented - deprecate it, in case someone is relying on it
Rename `disable_custom_statuses_for_post_type` to `is_module_edit_view`
rinatkhaziev and others added 25 commits June 14, 2018 19:10
…52-feature/270-comments-notification-meta

Revert "Revert "Display who was notified for an editorial comment""
…ated-time

Displaying updated time instead of creation time in Notepad Dashboard Widget
…uttons

The green color doesn't make a lot of sense, and has had an ugly blue shadow for a long time.

Why not remove the green entirely? It looks good with blue buttons, and won't cause headaches in the future if button-primary changes again.
… be responsive and adapt itself to different resolutions.
You shouldn’t receive a notification email unless you are able to view/edit the post.
$authors is never used, so declaring it then merging in an empty array isn’t needed.
General cleanup for the _get_notification_recipients method to align with WP coding standards.

Mostly all spaces, braces, and periods.

The one outlier is the removal of the first declaration of $recipients which is not needed.
When array_filter is used without a callback, it will remove any array items that evalulate to false, namely empty strings and NULLs.
…ation-visibility

Add a "No Access" badge to subscribers that will not be able to receive notifications
… users/groups who were notified

- Updates phpdoc to specify that $comment is WP_Comment
- Near the top, we fetch the list of users/groups from comment meta
- Before the "actions" list, we output the list of people who were notified

Note: This template could use so much love, but for now focusing on putting this new feature in a sensible place, with a plan to return and redesign the template later.
Make @return value more explicit

Co-Authored-By: jerclarke <jer@simianuprising.com>
Update `notification_comment()` to escape `$notification_list` before outputting

Tested by jer and works

Co-Authored-By: jerclarke <jer@simianuprising.com>
@rinatkhaziev rinatkhaziev added this to the 0.9 milestone Dec 19, 2018
…w into scope-module-assets

# Conflicts:
#	modules/calendar/calendar.php
#	modules/custom-status/custom-status.php
#	modules/editorial-comments/editorial-comments.php
@pyronaur
Copy link
Member Author

Oh I messed this one up good, re-opening in #487 :)

@pyronaur pyronaur closed this Dec 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.