CMB2 Documentation
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  • Hooks
  • Download Docs
  • Github

Packages

  • CMB2
  • Demo
    • CMB2
  • None
  • Tests
    • CMB2

Classes

  • CMB2
  • CMB2_Ajax
  • CMB2_Base
  • CMB2_Bootstrap_2101
  • CMB2_Boxes
  • CMB2_Display_Checkbox
  • CMB2_Display_Colorpicker
  • CMB2_Display_File
  • CMB2_Display_File_List
  • CMB2_Display_Multicheck
  • CMB2_Display_oEmbed
  • CMB2_Display_Select
  • CMB2_Display_Taxonomy_Multicheck
  • CMB2_Display_Taxonomy_Radio
  • CMB2_Display_Text_Date
  • CMB2_Display_Text_Date_Timezone
  • CMB2_Display_Text_Money
  • CMB2_Display_Text_Time
  • CMB2_Display_Text_Url
  • CMB2_Display_Textarea
  • CMB2_Display_Textarea_Code
  • CMB2_Field
  • CMB2_Field_Display
  • CMB2_Hookup
  • CMB2_Hookup_Base
  • CMB2_JS
  • CMB2_Option
  • CMB2_Options
  • CMB2_Options_Hookup
  • CMB2_REST
  • CMB2_REST_Controller
  • CMB2_REST_Controller_Boxes
  • CMB2_REST_Controller_Fields
  • CMB2_Sanitize
  • CMB2_Show_Filters
  • CMB2_Type_Base
  • CMB2_Type_Checkbox
  • CMB2_Type_Colorpicker
  • CMB2_Type_Counter_Base
  • CMB2_Type_File
  • CMB2_Type_File_Base
  • CMB2_Type_File_List
  • CMB2_Type_Multi_Base
  • CMB2_Type_Multicheck
  • CMB2_Type_Oembed
  • CMB2_Type_Picker_Base
  • CMB2_Type_Radio
  • CMB2_Type_Select
  • CMB2_Type_Select_Timezone
  • CMB2_Type_Taxonomy_Base
  • CMB2_Type_Taxonomy_Multicheck
  • CMB2_Type_Taxonomy_Multicheck_Hierarchical
  • CMB2_Type_Taxonomy_Radio
  • CMB2_Type_Taxonomy_Radio_Hierarchical
  • CMB2_Type_Taxonomy_Select
  • CMB2_Type_Taxonomy_Select_Hierarchical
  • CMB2_Type_Text
  • CMB2_Type_Text_Date
  • CMB2_Type_Text_Datetime_Timestamp
  • CMB2_Type_Text_Datetime_Timestamp_Timezone
  • CMB2_Type_Text_Time
  • CMB2_Type_Textarea
  • CMB2_Type_Textarea_Code
  • CMB2_Type_Title
  • CMB2_Type_Wysiwyg
  • CMB2_Types
  • CMB2_Utils
  • Test_CMB2_Utils_WIN

Functions

  • _tests_cmb2_manually_load_plugin
  • cmb2_ajax
  • cmb2_autoload_classes
  • cmb2_bootstrap
  • cmb2_dir
  • cmb2_do_oembed
  • cmb2_get_field
  • cmb2_get_field_value
  • cmb2_get_metabox
  • cmb2_get_metabox_form
  • cmb2_get_metabox_sanitized_values
  • cmb2_get_oembed
  • cmb2_get_option
  • cmb2_metabox_form
  • cmb2_options
  • cmb2_print_metabox_form
  • cmb2_update_option
  • cmb2_utils
  • date_create_from_format
  • date_timestamp_get
  • new_cmb2_box

Hooks

  • Hook Reference

Class CMB2_Sanitize

CMB2 field sanitization

Package: CMB2
Category: WordPress_Plugin
License: GPL-2.0+
Author: CMB2 team
Since: 0.0.4
Link: https://cmb2.io
Located at includes/CMB2_Sanitize.php

Methods summary

public
# __construct( CMB2_Field $field, mixed $value )

Setup our class vars

Setup our class vars

Parameters

$field
A CMB2 field object.
$value
Field value.

Since

1.1.0
public mixed
# __call( string $name, array $arguments )

Catchall method if field's 'sanitization_cb' is NOT defined, or field type does not have a corresponding validation method.

Catchall method if field's 'sanitization_cb' is NOT defined, or field type does not have a corresponding validation method.

Parameters

$name
Non-existent method name.
$arguments
All arguments passed to the method.

Returns

mixed

Since

1.0.0
public
# default_sanitization( )

Default fallback sanitization method. Applies filters.

Default fallback sanitization method. Applies filters.

Since

1.0.2
protected mixed
# _default_sanitization( )

Default sanitization method, sanitize_text_field. Checks if value is array.

Default sanitization method, sanitize_text_field. Checks if value is array.

Returns

mixed
Sanitized value.

Since

2.2.4
public mixed
# taxonomy( )

Sets the object terms to the object (if not options-page) and optionally returns the sanitized term values.

Sets the object terms to the object (if not options-page) and optionally returns the sanitized term values.

Returns

mixed
Blank value, or sanitized term values if "cmb2_return_taxonomy_values_{$cmb_id}" is true.

Since

2.2.4
public string|false
# checkbox( )

Simple checkbox validation

Simple checkbox validation

Returns

string|false
'on' or false

Since

1.0.1
public string
# text_url( )

Validate url in a meta value.

Validate url in a meta value.

Returns

string
Empty string or escaped url

Since

1.0.1
public
# colorpicker( )
public string
# text_email( )

Validate email in a meta value

Validate email in a meta value

Returns

string
Empty string or sanitized email

Since

1.0.1
public string
# text_money( )

Validate money in a meta value

Validate money in a meta value

Returns

string
Empty string or sanitized money value

Since

1.0.1
public string
# text_date_timestamp( )

Converts text date to timestamp

Converts text date to timestamp

Returns

string
Timestring

Since

1.0.2
public string|array
# text_datetime_timestamp( boolean $repeat = false )

Datetime to timestamp

Datetime to timestamp

Parameters

$repeat
Whether or not to repeat.

Returns

string|array
Timestring

Since

1.0.1
public string
# text_datetime_timestamp_timezone( boolean $repeat = false )

Datetime to timestamp with timezone

Datetime to timestamp with timezone

Parameters

$repeat
Whether or not to repeat.

Returns

string
Timestring

Since

1.0.1
public string
# textarea( )

Sanitize textareas and wysiwyg fields

Sanitize textareas and wysiwyg fields

Returns

string
Sanitized data

Since

1.0.1
public string
# textarea_code( boolean $repeat = false )

Sanitize code textareas

Sanitize code textareas

Parameters

$repeat
Whether or not to repeat.

Returns

string
Sanitized data

Since

1.0.2
public string
# file( )

Handles saving of attachment post ID and sanitizing file url

Handles saving of attachment post ID and sanitizing file url

Returns

string
Sanitized url

Since

1.1.0
public array
# _get_group_file_value_array( mixed $id_key )

Gets the values for the file field type from the data being saved.

Gets the values for the file field type from the data being saved.

Parameters

$id_key
ID key to use.

Returns

array

Since

2.2.0
public mixed
# _save_file_id_value( mixed $file_id_key )

Peforms saving of file attachement's ID

Peforms saving of file attachement's ID

Parameters

$file_id_key
ID key to use.

Returns

mixed

Since

1.1.0
public mixed
# _save_utc_value( mixed $utc_key, mixed $utc_stamp )

Peforms saving of text_datetime_timestamp_timezone utc timestamp

Peforms saving of text_datetime_timestamp_timezone utc timestamp

Parameters

$utc_key
UTC key.
$utc_stamp
UTC timestamp.

Returns

mixed

Since

2.2.0
public CMB2_Field
# _new_supporting_field( mixed $new_field_id )

Returns a new, supporting, CMB2_Field object based on a new field id.

Returns a new, supporting, CMB2_Field object based on a new field id.

Parameters

$new_field_id
New field ID.

Returns

CMB2_Field

Since

2.2.0
public mixed
# _check_repeat( string $method, boolean $repeat )

If repeating, loop through and re-apply sanitization method

If repeating, loop through and re-apply sanitization method

Parameters

$method
Class method.
$repeat
Whether repeating or not.

Returns

mixed
Sanitized value

Since

1.1.0
public boolean
# _is_empty_array( mixed $to_check )

Determine if passed value is an empty array

Determine if passed value is an empty array

Parameters

$to_check
Value to check.

Returns

boolean
Whether value is an array that's empty

Since

2.0.6
public static string
# sanitize_and_secure_url( string $url, array $protocols = null, string $default = null )

Sanitize a URL. Make the default scheme HTTPS.

Sanitize a URL. Make the default scheme HTTPS.

Parameters

$url
$value Unescaped URL.
$protocols
Allowed protocols for URL.
$default
Default value if no URL found.

Returns

string
escaped URL.

Since

2.10.0
public boolean
# is_empty_value( )

Check if the current field's value is empty.

Check if the current field's value is empty.

Returns

boolean
Wether value is empty.

Since

2.9.1
public boolean
# is_valid_date_value( )

Check if the current field's value is a valid date value.

Check if the current field's value is a valid date value.

Returns

boolean
Wether value is a valid date value.

Since

2.9.1

Magic methods summary

public string
# _id( )

Returns

string

Properties summary

public CMB2_Field $field

A CMB field object

A CMB field object

#
public mixed $value

Field's value

Field's value

#
CMB2 Documentation API documentation generated by ApiGen