Add filter to AJAx user data

This commit is contained in:
Tetrakern 2023-08-28 14:06:37 +02:00
parent 15eb144b48
commit 519c3e9db0
2 changed files with 21 additions and 0 deletions

View File

@ -36,6 +36,23 @@ Filters the intermediate output array of the tab pills inside the `fictioneer_se
--- ---
### `apply_filters( 'fictioneer_filter_ajax_get_user_data', $data, $user )`
Filters the data to be returned as JSON by the `fictioneer_ajax_get_user_data()` function, which is used to set up the users local environment with Follows, Checkmarks, Reminders, and so forth to get around caching. Note that this function is accelerated and skips the WordPress initialization, as well as most plugins if the optional MU plugin has been installed.
**$data:**
* $user_id (int) The user ID.
* $timestamp (int) Milliseconds elapsed since the epoch.
* $follows (array|false) The users Follows data or false if disabled.
* $reminders (array|false) The users Reminders data or false if disabled.
* $checkmarks (array|false) The users Checkmarks data or false if disabled.
* $bookmarks (string) The users Bookmarks JSON as string. `'{}'` if disabled.
* $fingerprint (string) The users unique hash.
**Parameters:**
* $user (WP_User) The user object.
---
### `apply_filters( 'fictioneer_filter_breadcrumbs_array', $breadcrumbs, $args )` ### `apply_filters( 'fictioneer_filter_breadcrumbs_array', $breadcrumbs, $args )`
Filters the array of breadcrumb tuples inside the `fictioneer_get_breadcrumbs( $args )` function before the HTML is build. Filters the array of breadcrumb tuples inside the `fictioneer_get_breadcrumbs( $args )` function before the HTML is build.

View File

@ -1005,6 +1005,10 @@ function fictioneer_ajax_get_user_data() {
$data['bookmarks'] = $bookmarks ? $bookmarks : '{}'; $data['bookmarks'] = $bookmarks ? $bookmarks : '{}';
} }
// --- FILTER ----------------------------------------------------------------
$data = apply_filters( 'fictioneer_filter_ajax_get_user_data', $data, $user );
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Response // Response