TypeScript definitions for the WordPress Customize Browser API.
Note: This is a modified version of the original TypeScript definitions created by Marek Dědič from the DefinitelyTyped repository.
npm install --save-dev ultrafastcloud/wordpress__customize-browserOr add to your package.json:
"devDependencies": {
"@types/wordpress__customize-browser": "github:ultrafastcloud/wordpress__customize-browser"
}This package provides TypeScript type definitions for the WordPress Customize Browser API (@wordpress/customize-browser), which is part of the WordPress Customizer interface. These type definitions enable TypeScript developers to work with the WordPress Customizer API with proper type checking and autocompletion.
The WordPress Customizer API allows developers to create custom controls, sections, and panels in the WordPress Customizer interface, as well as interact with the preview iframe.
// Access the customize object
const customize = wp.customize;
// Create a new setting
customize.create("my_setting", "default value", {
id: "my_setting",
});
// Get a setting
const setting = customize("my_setting");
if (setting) {
// Update the setting value
setting.set("new value");
}// In the preview iframe
wp.customize.preview.bind("ready", function () {
// The preview is ready
console.log("Preview is ready");
});
// Bind to custom events
wp.customize.preview.bind("custom_event", function (data) {
// Handle the custom event
console.log("Custom event received:", data);
});
// With multiple arguments
wp.customize.preview.bind("complex_event", function (data, moreData) {
console.log("Received data:", data, moreData);
});The package includes TypeScript definitions for various components of the WordPress Customize API:
Customize.d.ts- Main customizer interfaceControl.d.ts- Base control class and interfacesPanel.d.ts- Panel interfacesSection.d.ts- Section interfacesSetting.d.ts- Setting interfacesPreview.d.ts- Preview interfacesPreviewer.d.ts- Previewer interfaces- And many more specialized controls and components
The WordPress Customize API is used to create and manage the WordPress Customizer interface. It provides a framework for creating settings, controls, panels, and sections, as well as handling the preview iframe.
For more information about the WordPress Customize API, see:
Files were exported from DefinitelyTyped.
- Dependencies: @types/jquery
To contribute to this package:
- Fork the repository
- Make your changes
- Run tests (if available)
- Submit a pull request
MIT
The original definitions were written by Marek Dědič as part of the DefinitelyTyped project and have been modified in this repository.