Skip to content

Backup Field

Overview

The backup field type provides options for importing and exporting settings. This is useful for creating backups of configurations or transferring settings between different environments.

Field Configuration

Below is the general structure for defining a backup field:

php
array(
    'type'  => 'backup',
),

Specific Parameters

ParameterTypeDefaultDescription
typestring-Set to backup to define a backup field.
titlestring-Title for the backup section.

General Parameters

ParameterTypeDefaultDescription
idstring-Unique identifier for the field.
typestring-Defines the field type.
titlestring-The title displayed for the field.
subtitlestring-The text displayed under the title.
classstring-Field additional class.
data_typestringserializeDefines how data is stored (e.g., serialize).
namestring-Custom name for the field.
placeholderstringNot selectedPlaceholder text for the input.
attributesarrayarray()Custom HTML attributes.
beforestring-Content to display before the field.
afterstring-Content to display after the field.
descriptionstring-A detailed description of the field.
descstring-A short description, used if description is not set.
helpstring-Additional helper text for guidance. Usually show on the top right corner of the field.
errorstring-Error message to display when validation fails.
dependenciesarray-Show/Hide a field base on another field value.

Example Usage

Here’s an example of how a backup field might be defined in a settings panel:

php
array(
    'id'    => 'backup_settings',
    'type'  => 'backup',
    'title' => __( 'Backup & Import', 'textdomain' ),
),

Features

  • Export Settings: Allows users to export their configuration settings.
  • Import Settings: Provides an option to import previously saved settings.
  • Backup & Restore: Helps in creating backups for easy restoration of settings.

Notes

  • The backup feature simplifies the migration process for settings.
  • Ensures users can restore previous configurations effortlessly.
  • Useful for developers and administrators who need to transfer settings between environments.