Contents
On this page
Update Settings - Plugixa Permalink Manager
PUT /plugixa-permalink-manager/v1/settings
Change one or more settings. Only the keys you send change.
Needs the plugixa_permalink_manager_manage_settings capability. Changing delete_data_on_uninstall also needs the WordPress manage_options capability. POST and PATCH are accepted too.
Note. An unknown key refuses the whole request and nothing is saved. A known key with a value it does not accept is not refused: it is saved as that setting’s default. Read the answer to see what was stored.
Request
PUT https://your-site.example/wp-json/plugixa-permalink-manager/v1/settings
Request body
Content type: application/json
A JSON object of setting keys and their new values, from the list below. null or [] clears a list setting; leaving a key out leaves it alone. Booleans accept true, 1, "1", "true", "on" and "yes" as on, and anything else as off.
{
"redirect_status": 302,
"external_redirect_hosts": [
"shop.example.com"
]
}
Responses
200 OK. data.settings is every setting as saved.
{
"success": true,
"data": {
"settings": {
"delete_data_on_uninstall": false,
"debug_mode": false,
"safe_mode": false,
"wizard_completed": true,
"auto_update_uris": 0,
"force_custom_slugs": 0,
"disable_slug_sanitization": false,
"keep_accents": false,
"show_native_slug_field": false,
"partial_disable_strict": true,
"exclude_post_ids": "",
"exclude_term_ids": "",
"ignore_drafts": 1,
"redirect_status": 302,
"canonical_redirect": true,
"extra_redirects": true,
"setup_redirects": true,
"trailing_slashes": 0,
"trailing_slash_redirect": true,
"copy_query_redirect": true,
"sslwww_redirect": true,
"external_redirect_policy": "allowlist",
"external_redirect_hosts": [
"shop.example.com"
],
"max_redirects_per_item": 50,
"edit_uris_cap": "publish_posts",
"history_retention_days": 90,
"partial_disable": {
"post_types": [
"attachment",
"tribe_events",
"e-landing-page",
"elementor_library"
],
"taxonomies": []
}
}
}
}
| Field | Type | Meaning |
|---|---|---|
data.settings |
object |
Every setting after the save, not only the ones you sent |
Setting keys
Each key is a field on a tab of the Settings screen, where its effect is described.
Addresses
| Key | Values | Default |
|---|---|---|
auto_update_uris |
0, 1 or 2, in the order of the choices under When content is saved |
0 |
force_custom_slugs |
0 the WordPress slug, 1 a slug made from the title, 2 the parent’s custom address plus the slug |
0 |
trailing_slashes |
0 follow the WordPress permalink setting, 1 always add one, 2 never add one |
0 |
keep_accents |
true or false |
false |
disable_slug_sanitization |
true keeps punctuation and capitals as typed |
false |
Content
| Key | Values | Default |
|---|---|---|
partial_disable |
{ "post_types": [ ], "taxonomies": [ ] }: the types that do not have custom addresses |
The four post types listed in Content settings, no taxonomies |
partial_disable_strict |
true skips content types that are not meant to be visited |
true |
exclude_post_ids, exclude_term_ids |
A string of ids and ranges, such as "12, 40-45, 318" |
Empty |
ignore_drafts |
0 drafts get an address, 1 no address for drafts, 2 no address for drafts and pending items |
1 |
Redirects
| Key | Values | Default |
|---|---|---|
redirect_status |
301, 302, 307, 308, or 0 for no redirects at all |
301 |
setup_redirects |
true keeps the old address when an address changes |
true |
extra_redirects |
true serves redirects from old addresses |
true |
canonical_redirect |
true sends WordPress addresses to the custom ones |
true |
trailing_slash_redirect |
true redirects a missing or extra trailing slash |
true |
copy_query_redirect |
true keeps the query string when redirecting |
true |
sslwww_redirect |
true corrects http/https and www in the same redirect |
true |
external_redirect_policy |
allowlist or any |
allowlist |
external_redirect_hosts |
A list of host names | Empty |
max_redirects_per_item |
1 to 500 |
50 |
Advanced
| Key | Values | Default |
|---|---|---|
edit_uris_cap |
edit_posts, publish_posts, publish_pages or edit_theme_options: who sees the address field on the edit screens |
publish_posts |
history_retention_days |
0 to 3650. Stored, but not yet acted on in version 1.0.0 |
90 |
safe_mode |
true stops serving custom addresses and redirects |
false |
debug_mode |
true or false |
false |
delete_data_on_uninstall |
true or false. Changing it also needs the WordPress permission to manage options |
false |
wizard_completed |
true once the setup wizard has been finished |
false |
show_native_slug_field |
true or false. Stored, but not acted on in version 1.0.0 |
false |
Errors
| Status | Code | When |
|---|---|---|
400 |
plugixa_permalink_manager_invalid_settings |
The body is not a JSON object. |
422 |
plugixa_permalink_manager_unknown_settings |
One or more keys do not exist. data.keys lists them. |
401 / 403 |
plugixa_permalink_manager_forbidden |
delete_data_on_uninstall would change and you cannot manage options. |
Plus the errors every endpoint can return.
Examples
curl -s -X PUT "https://your-site.example/wp-json/plugixa-permalink-manager/v1/settings" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"redirect_status":302,"external_redirect_hosts":["shop.example.com"]}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-permalink-manager/v1/settings');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => 'admin:' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'redirect_status' => 302,
'external_redirect_hosts' => ['shop.example.com'],
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const auth = 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`);
const response = await fetch('https://your-site.example/wp-json/plugixa-permalink-manager/v1/settings', {
method: 'PUT',
headers: {
'Authorization': auth,
'Content-Type': 'application/json',
},
body: JSON.stringify({
redirect_status: 302,
external_redirect_hosts: ['shop.example.com'],
}),
});
const { data } = await response.json();
Quick Links
Share