wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_prefetch_admin_assets › WordPress Filter Hooks

Seit7.2.0
Veraltetn/v
› apply_filters( 'wp_prefetch_admin_assets', $resources, $next_screen )
Parameter: (2)
  • () resources { Array of resources and their attributes to prefetch. @type array ...$0 { Array of resource attributes. @type string $href URL to prefetch. Required. @type string $as How the browser should treat the resource (`script`, `style`, `image`, `document`, etc). Required. } }
    Erforderlich: Ja
  • () next_screen URL of the screen the assets are being prefetched for. Always points into the admin, since nothing is prefetched otherwise. From the login screen this is the redirect target, already run through wp_validate_redirect() with the admin as the fallback, and it may be relative: it is the value as wp_safe_redirect() will receive it, so a request-supplied path is passed through unchanged and only the fallback is a full URL.
    Erforderlich: Ja
Definiert in:
Codex:

Filters the assets prefetched for the screen the user is expected to open next.

Fires on any screen from which the next one can be predicted, so `$next_screen` is what distinguishes the contexts: the login screen passes the URL it is about to redirect to, and the Dashboard and post list tables pass the editor they expect the user to open. Only the `href` and `as` attributes below are printed; any other key is ignored. Resources sharing an `href` are collapsed to the first of them, so a callback may append without checking what is already there. Returning an empty array turns the prefetching off. On the login screen the URLs are built before the user is authenticated and outside the admin, so there is no current user and `is_admin()` is false. A {@see 'script_loader_src'} or {@see 'style_loader_src'} callback that depends on either can produce a URL the admin screen will not request, which wastes the prefetch; a callback on this filter can correct it.




Quellcode

$resources = apply_filters( 'wp_prefetch_admin_assets', $resources, $next_screen );