Contents
On this page

Bulk Action on Maps - Plugixa Image Map

POST /plugixa-image-map/v1/maps/bulk

Do one thing to up to 100 maps in one request, and get each map’s outcome back.

The capability depends on action: plugixa_image_map_edit for publish and unpublish, plugixa_image_map_delete for trash, restore and purge. It is checked again for each map. See Roles and permissions.

Request

POST https://your-site.example/wp-json/plugixa-image-map/v1/maps/bulk

Request body

Content type: application/json

Field Type Required Description
action string Yes publish, unpublish (back to draft), trash, restore or purge.
ids integer[] Yes The maps, at most 100. Repeats and zeros are dropped.

One map that cannot be changed does not stop the others: the answer lists which ids were done and why each of the rest failed. publish and unpublish do not check rev.

{
  "action": "publish",
  "ids": [
    12,
    13,
    14
  ]
}

Responses

200 OK. data lists each outcome.

{
  "success": true,
  "data": {
    "done": [
      12,
      13
    ],
    "failed": [
      {
        "id": 14,
        "reason": "forbidden"
      }
    ]
  }
}
Field Type Meaning
data.done integer[] The ids that were changed
data.failed[].id integer An id that was not changed
data.failed[].reason string not_found (no such map), forbidden (not allowed on this map), failed (for example trashing a map already in the trash, or restoring one that is not), or an error code such as plugixa_image_map_not_found for publishing a trashed map

The status is 200 even when every map failed. Check data.failed.

Errors

Status Code When
400 plugixa_image_map_invalid_bulk_action action is missing or not one of the five.
400 plugixa_image_map_no_maps ids is empty.
400 plugixa_image_map_too_many_maps ids names more than 100 maps.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-image-map/v1/maps/bulk" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"action":"publish","ids":[12,13,14]}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-image-map/v1/maps/bulk');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'admin:' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode([
        'action' => 'publish',
        'ids'    => [12, 13, 14],
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-image-map/v1/maps/bulk', {
  method: 'POST',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    action: 'publish',
    ids: [12, 13, 14],
  }),
});
const { data } = await response.json();

Quick Links

Share