-
Notifications
You must be signed in to change notification settings - Fork 1
wp_lib_script_vars
###Description
This filter allows developers to modify the variables passed to Dashboard JavaScript by WP-Librarian using wp_localize_script. These variables are then accessible to Dashboard JavaScript as the global object wp_lib_vars.
###Context
This is called on every time someone loads the Dashboard. Note that navigation within Dashboard pages is done dynamically (without reloading the page). To be able to access the Dashboard the user must be logged and a Librarian or Library Admin (or any custom library role with at least the level of a Librarian).
###Parameters
$script_vars
(Array) Variables to be passed to Dashboard JS. By default WP-Librarian will pass the following parameters:
| Key | Description |
|---|---|
siteUrl |
URL of Home page via site_url() |
adminUrl |
URL of Admin-end via admin_url() |
pluginsUrl |
URL to access WP-Librarian's plugins folder |
dashUrl |
URL to access Library Dashboard |
siteName |
Name of WP install via get_bloginfo(name)
|
getParams |
All HTTP GET parameters |
debugMode |
Whether WP_LIB_DEBUG_MODE or WP's SCRIPT_DEBUG are True |
Note that some of the above are silly and will probably be removed some time soon.
###Example
Using the following code you can add your own variable to wp_lib_vars:
add_filter('wp_lib_script_vars', 'add_my_variable');
function add_my_variable(Array $wp_lib_vars) {
$wp_lib_vars['my_variable_key'] = 'My variable value';
return $wp_lib_vars;
}
####1. Post Types
Items
Members
Loans
Fines
####2. Taxonomies
Author
Media Type
####3. User Roles
Librarian
Library Admin
####4. Filters
####5. Actions
####6. Releases
6.1 Alpha Releases
Fox Paw
Wolf Tail
Badger Claw
Coyote Snout