@iflow-mcp/claudeus-wp-mcp
Version:
The most comprehensive WordPress MCP server - 145 production-ready tools for complete WordPress management with AI
93 lines • 3.12 kB
JavaScript
/**
* WordPress Templates API Client
* Handles FSE (Full Site Editing) templates and template parts
*/
import { BaseApiClient } from './base-client.js';
export class TemplatesApiClient extends BaseApiClient {
// ==========================================
// TEMPLATES
// ==========================================
/**
* Get a list of templates
*/
async getTemplates(filters) {
return this.get('/templates', filters);
}
/**
* Get a single template by ID
* @param id Template ID (slug format, e.g., "twentytwentyfour//home")
*/
async getTemplate(id) {
// Template IDs contain slashes and need special encoding
const encodedId = id.split('/').map(encodeURIComponent).join('/');
return this.get(`/templates/${encodedId}`);
}
/**
* Create a new template
*/
async createTemplate(data) {
return this.post('/templates', data);
}
/**
* Update an existing template
* @param id Template ID
* @param data Template data to update
*/
async updateTemplate(id, data) {
const encodedId = id.split('/').map(encodeURIComponent).join('/');
return this.put(`/templates/${encodedId}`, data);
}
/**
* Delete a template
* @param id Template ID
* @param force Whether to bypass trash and force deletion
*/
async deleteTemplate(id, force = false) {
const encodedId = id.split('/').map(encodeURIComponent).join('/');
const queryString = force ? '?force=true' : '';
return this.delete(`/templates/${encodedId}${queryString}`);
}
// ==========================================
// TEMPLATE PARTS
// ==========================================
/**
* Get a list of template parts
*/
async getTemplateParts(filters) {
return this.get('/template-parts', filters);
}
/**
* Get a single template part by ID
* @param id Template part ID (slug format, e.g., "twentytwentyfour//header")
*/
async getTemplatePart(id) {
const encodedId = id.split('/').map(encodeURIComponent).join('/');
return this.get(`/template-parts/${encodedId}`);
}
/**
* Create a new template part
*/
async createTemplatePart(data) {
return this.post('/template-parts', data);
}
/**
* Update an existing template part
* @param id Template part ID
* @param data Template part data to update
*/
async updateTemplatePart(id, data) {
const encodedId = id.split('/').map(encodeURIComponent).join('/');
return this.put(`/template-parts/${encodedId}`, data);
}
/**
* Delete a template part
* @param id Template part ID
* @param force Whether to bypass trash and force deletion
*/
async deleteTemplatePart(id, force = false) {
const encodedId = id.split('/').map(encodeURIComponent).join('/');
const queryString = force ? '?force=true' : '';
return this.delete(`/template-parts/${encodedId}${queryString}`);
}
}
//# sourceMappingURL=templates.js.map