Contents
On this page

Update View - Plugixa Testimonial

PUT /plugixatestimonial/v1/views/{id}

Change a view. name, slug and description are only changed when sent.

Any signed-in user with the plugixa_testimonial_edit capability or WordPress’s edit_posts (Contributors and up, by default).

Note. Two fields do not merge. is_default defaults to false, so an update without is_default: true takes the default flag off the default view, and the site is left with no default view. config, when sent, is merged over the built-in defaults, not over the stored design: every key you leave out goes back to its default. Read the view first and send the whole config back.

Note. There is no existence check: an id that matches nothing still answers 200 with the success message, and nothing changes.

Request

PUT https://your-site.example/wp-json/plugixatestimonial/v1/views/2

Path parameters

Name Type Description
id integer The view’s id

Request body

Content type: application/json

Field Type Required Description
name string No Must not be blank when sent.
slug string No Made unique by appending -1, -2, …
description string No Plain text.
config object No The complete design.
is_default boolean No Treated as false when left out.

config is merged over the built-in defaults, so you can send only the groups and keys you change. Colors, sizes, keywords and fonts are checked, and an invalid value is dropped so the default applies. Google fonts the view uses are downloaded to the site.

{
  "name": "Homepage grid",
  "is_default": true,
  "config": {
    "layout": {
      "style": "grid",
      "columns": {
        "desktop": 3,
        "tablet": 2,
        "mobile": 1
      }
    },
    "display": {
      "showPhoto": true,
      "showRating": true,
      "showDate": true,
      "showCompany": true,
      "showRole": true,
      "showWebsite": false,
      "excerptLength": 150
    },
    "colors": {
      "cardBg": "#ffffff",
      "textColor": "#1d2327",
      "nameColor": "#1d2327",
      "roleColor": "#646970",
      "starColor": "#f59e0b",
      "starEmptyColor": "#d1d5db",
      "borderColor": "#e5e7eb",
      "quoteBg": "#f9fafb"
    },
    "typography": {
      "nameFontSize": 16,
      "nameFontWeight": 600,
      "textFontSize": 14,
      "textFontWeight": 400,
      "roleFontSize": 13
    },
    "spacing": {
      "cardPadding": 24,
      "gap": 24,
      "photoPadding": 0
    },
    "borders": {
      "radius": 8,
      "width": 1
    },
    "shadows": {
      "enabled": true,
      "value": "0 1px 3px rgba(0,0,0,0.1)"
    },
    "categories": {
      "displayStyle": "none",
      "showCategoryDescription": true,
      "colors": {
        "backgroundColor": "#ffffff",
        "textColor": "#1d2327",
        "activeBackgroundColor": "#2271b1",
        "activeTextColor": "#ffffff",
        "borderColor": "#c3c4c7",
        "descriptionColor": "#6b7280",
        "descriptionBackgroundColor": "#f8fafc",
        "descriptionBorderColor": "#2271b1"
      },
      "typography": {
        "fontSize": 14,
        "fontWeight": 500,
        "fontFamily": "inherit"
      },
      "spacing": {
        "padding": 12,
        "gap": 8
      },
      "border": {
        "width": 1,
        "radius": 4
      }
    },
    "photo": {
      "size": 60,
      "sizeUnit": "px",
      "borderRadius": 50,
      "fallbackMode": "initials",
      "fallbackColorMode": "single",
      "fallbackBgColor": "#e5e7eb",
      "fallbackTextColor": "#6b7280",
      "borderWidth": 0,
      "borderColor": "#e5e7eb",
      "borderStyle": "none",
      "position": "inline",
      "grayscale": false,
      "hoverScale": 1.0,
      "opacity": 1.0,
      "shadowEnabled": false,
      "shadowValue": "0 2px 8px rgba(0,0,0,0.15)"
    }
  }
}

Responses

200 OK.

{
  "success": true,
  "message": "View updated successfully",
  "data": {
    "id": 2
  }
}
Field Type Meaning
data.id integer The id you sent
message string A human-readable confirmation, translated to the site language

Errors

Status Code When
400 rest_error “Validation failed”. data.errors names the field: name (blank).
500 rest_error The database refused the update.

Plus the errors every endpoint can return.

Examples

curl -s -X PUT "https://your-site.example/wp-json/plugixatestimonial/v1/views/2" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"name":"Homepage grid","is_default":true,"config":{"layout":{"style":"grid","columns":{"desktop":3,"tablet":2,"mobile":1}},"display":{"showPhoto":true,"showRating":true,"showDate":true,"showCompany":true,"showRole":true,"showWebsite":false,"excerptLength":150},"colors":{"cardBg":"#ffffff","textColor":"#1d2327","nameColor":"#1d2327","roleColor":"#646970","starColor":"#f59e0b","starEmptyColor":"#d1d5db","borderColor":"#e5e7eb","quoteBg":"#f9fafb"},"typography":{"nameFontSize":16,"nameFontWeight":600,"textFontSize":14,"textFontWeight":400,"roleFontSize":13},"spacing":{"cardPadding":24,"gap":24,"photoPadding":0},"borders":{"radius":8,"width":1},"shadows":{"enabled":true,"value":"0 1px 3px rgba(0,0,0,0.1)"},"categories":{"displayStyle":"none","showCategoryDescription":true,"colors":{"backgroundColor":"#ffffff","textColor":"#1d2327","activeBackgroundColor":"#2271b1","activeTextColor":"#ffffff","borderColor":"#c3c4c7","descriptionColor":"#6b7280","descriptionBackgroundColor":"#f8fafc","descriptionBorderColor":"#2271b1"},"typography":{"fontSize":14,"fontWeight":500,"fontFamily":"inherit"},"spacing":{"padding":12,"gap":8},"border":{"width":1,"radius":4}},"photo":{"size":60,"sizeUnit":"px","borderRadius":50,"fallbackMode":"initials","fallbackColorMode":"single","fallbackBgColor":"#e5e7eb","fallbackTextColor":"#6b7280","borderWidth":0,"borderColor":"#e5e7eb","borderStyle":"none","position":"inline","grayscale":false,"hoverScale":1.0,"opacity":1.0,"shadowEnabled":false,"shadowValue":"0 2px 8px rgba(0,0,0,0.15)"}}}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixatestimonial/v1/views/2');
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([
        'name'       => 'Homepage grid',
        'is_default' => true,
        'config'     => [
            'layout'     => [
                'style'   => 'grid',
                'columns' => [
                    'desktop' => 3,
                    'tablet'  => 2,
                    'mobile'  => 1,
                ],
            ],
            'display'    => [
                'showPhoto'     => true,
                'showRating'    => true,
                'showDate'      => true,
                'showCompany'   => true,
                'showRole'      => true,
                'showWebsite'   => false,
                'excerptLength' => 150,
            ],
            'colors'     => [
                'cardBg'         => '#ffffff',
                'textColor'      => '#1d2327',
                'nameColor'      => '#1d2327',
                'roleColor'      => '#646970',
                'starColor'      => '#f59e0b',
                'starEmptyColor' => '#d1d5db',
                'borderColor'    => '#e5e7eb',
                'quoteBg'        => '#f9fafb',
            ],
            'typography' => [
                'nameFontSize'   => 16,
                'nameFontWeight' => 600,
                'textFontSize'   => 14,
                'textFontWeight' => 400,
                'roleFontSize'   => 13,
            ],
            'spacing'    => [
                'cardPadding'  => 24,
                'gap'          => 24,
                'photoPadding' => 0,
            ],
            'borders'    => [
                'radius' => 8,
                'width'  => 1,
            ],
            'shadows'    => [
                'enabled' => true,
                'value'   => '0 1px 3px rgba(0,0,0,0.1)',
            ],
            'categories' => [
                'displayStyle'            => 'none',
                'showCategoryDescription' => true,
                'colors'                  => [
                    'backgroundColor'            => '#ffffff',
                    'textColor'                  => '#1d2327',
                    'activeBackgroundColor'      => '#2271b1',
                    'activeTextColor'            => '#ffffff',
                    'borderColor'                => '#c3c4c7',
                    'descriptionColor'           => '#6b7280',
                    'descriptionBackgroundColor' => '#f8fafc',
                    'descriptionBorderColor'     => '#2271b1',
                ],
                'typography'              => [
                    'fontSize'   => 14,
                    'fontWeight' => 500,
                    'fontFamily' => 'inherit',
                ],
                'spacing'                 => [
                    'padding' => 12,
                    'gap'     => 8,
                ],
                'border'                  => [
                    'width'  => 1,
                    'radius' => 4,
                ],
            ],
            'photo'      => [
                'size'              => 60,
                'sizeUnit'          => 'px',
                'borderRadius'      => 50,
                'fallbackMode'      => 'initials',
                'fallbackColorMode' => 'single',
                'fallbackBgColor'   => '#e5e7eb',
                'fallbackTextColor' => '#6b7280',
                'borderWidth'       => 0,
                'borderColor'       => '#e5e7eb',
                'borderStyle'       => 'none',
                'position'          => 'inline',
                'grayscale'         => false,
                'hoverScale'        => 1.0,
                'opacity'           => 1.0,
                'shadowEnabled'     => false,
                'shadowValue'       => '0 2px 8px rgba(0,0,0,0.15)',
            ],
        ],
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixatestimonial/v1/views/2', {
  method: 'PUT',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ name: 'Homepage grid', is_default: true, config: { layout: { style: 'grid', columns: { desktop: 3, tablet: 2, mobile: 1 } }, display: { showPhoto: true, showRating: true, showDate: true, showCompany: true, showRole: true, showWebsite: false, excerptLength: 150 }, colors: { cardBg: '#ffffff', textColor: '#1d2327', nameColor: '#1d2327', roleColor: '#646970', starColor: '#f59e0b', starEmptyColor: '#d1d5db', borderColor: '#e5e7eb', quoteBg: '#f9fafb' }, typography: { nameFontSize: 16, nameFontWeight: 600, textFontSize: 14, textFontWeight: 400, roleFontSize: 13 }, spacing: { cardPadding: 24, gap: 24, photoPadding: 0 }, borders: { radius: 8, width: 1 }, shadows: { enabled: true, value: '0 1px 3px rgba(0,0,0,0.1)' }, categories: { displayStyle: 'none', showCategoryDescription: true, colors: { backgroundColor: '#ffffff', textColor: '#1d2327', activeBackgroundColor: '#2271b1', activeTextColor: '#ffffff', borderColor: '#c3c4c7', descriptionColor: '#6b7280', descriptionBackgroundColor: '#f8fafc', descriptionBorderColor: '#2271b1' }, typography: { fontSize: 14, fontWeight: 500, fontFamily: 'inherit' }, spacing: { padding: 12, gap: 8 }, border: { width: 1, radius: 4 } }, photo: { size: 60, sizeUnit: 'px', borderRadius: 50, fallbackMode: 'initials', fallbackColorMode: 'single', fallbackBgColor: '#e5e7eb', fallbackTextColor: '#6b7280', borderWidth: 0, borderColor: '#e5e7eb', borderStyle: 'none', position: 'inline', grayscale: false, hoverScale: 1.0, opacity: 1.0, shadowEnabled: false, shadowValue: '0 2px 8px rgba(0,0,0,0.15)' } } }),
});
const { data } = await response.json();

Quick Links

Share