PHP Класс WPAS_Custom_Fields

Автор: ThemeAvenue ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$remove_mb List of metaboxes to remove.

Открытые методы

Метод Описание
__construct ( )
add_custom_column ( array $columns ) : array Add possible custom columns to tickets list.
add_field ( string $name = '', array $args = [] ) : boolean Add a new custom field to the ticket.
check_required_fields ( $go, array $data = [] ) : mixed Checks required custom fields.
custom_column_orderby ( object $query ) : void Reorder custom columns based on custom values.
custom_columns_content ( string $column, integer $post_id ) : void Manage custom columns content
custom_columns_sortable ( array $columns ) : array Make custom columns sortable
custom_taxonomy_filter ( ) : void Add filters for custom taxonomies
custom_taxonomy_filter_convert_id_term ( object $query ) : void Convert taxonomy term ID into term slug.
enqueue_select2_assets ( ) : void Register and enqueue the select2 assets
frontend_submission ( integer $ticket_id ) : void Trigger the custom fields save function upon front-end submission of a new ticket.
get_custom_fields ( ) : array Return the list of fields
have_custom_fields ( boolean $core = false ) : boolean Check if custom fields are registered.
is_field_missing ( array $data = [] ) : boolean | WP_Error Makes sure no required custom field is missing from the data passed.
move_status_first ( array $columns ) : array Reorder the admin columns.
register_taxonomies ( ) : void Register all custom taxonomies.
remove_field ( string $id ) : void Remove a custom field.
remove_taxonomy_metabox ( ) : void Remove taxonomies metaboxes.
save_core_field ( integer $post_id, array $field, mixed $value ) : void Save the core fields.
save_custom_fields ( integer $post_id, array $data = [], boolean $allow_log = true ) : array Save all custom fields given in $data to the database.
status_filter ( ) : void Add status dropdown in the filters bar.
status_filter_by_status ( object $query ) : void Filter tickets by status.
submission_form_fields ( ) : void Display the custom fields on submission form.

Описание методов

__construct() публичный Метод

public __construct ( )

add_custom_column() публичный Метод

Add possible custom columns to tickets list.
С версии: 3.0.0
public add_custom_column ( array $columns ) : array
$columns array List of default columns
Результат array Updated list of columns

add_field() публичный Метод

Add a new custom field to the ticket.
С версии: 3.0.0
public add_field ( string $name = '', array $args = [] ) : boolean
$name string Option name
$args array Field arguments
Результат boolean Whether or not the field was added

check_required_fields() публичный Метод

This function is hooked on the filter wpas_before_submit_new_ticket_checks through the parent class. It checks all required custom fields and if they were correctly filled. If one or more required field(s) is/are missing then the submission process is stopped and an error message is returned.
С версии: 3.0.0
public check_required_fields ( $go, array $data = [] ) : mixed
$data array Array of data containing the custom fields to check for required attribute
Результат mixed True if no error or a WP_Error otherwise

custom_column_orderby() публичный Метод

Reorder custom columns based on custom values.
С версии: 3.0.0
public custom_column_orderby ( object $query ) : void
$query object Main query
Результат void

custom_columns_content() публичный Метод

Manage custom columns content
С версии: 3.0.0
public custom_columns_content ( string $column, integer $post_id ) : void
$column string The name of the column to display
$post_id integer ID of the post being processed
Результат void

custom_columns_sortable() публичный Метод

Make custom columns sortable
С версии: 3.0.0
public custom_columns_sortable ( array $columns ) : array
$columns array Already sortable columns
Результат array New sortable columns

custom_taxonomy_filter() публичный Метод

Add filters for custom taxonomies
С версии: 2.0.0
public custom_taxonomy_filter ( ) : void
Результат void

custom_taxonomy_filter_convert_id_term() публичный Метод

When filtering, WordPress uses the term ID by default in the query but that doesn't work. We need to convert it to the taxonomy term slug.
public custom_taxonomy_filter_convert_id_term ( object $query ) : void
$query object WordPress current main query
Результат void

enqueue_select2_assets() публичный Метод

This method will be called if the select2 parameter is passed with a custom field (could be a select or a taxonomy field).
С версии: 3.3
public enqueue_select2_assets ( ) : void
Результат void

frontend_submission() публичный Метод

Trigger the custom fields save function upon front-end submission of a new ticket.
С версии: 3.2.0
public frontend_submission ( integer $ticket_id ) : void
$ticket_id integer ID of the ticket that's just been added
Результат void

get_custom_fields() публичный Метод

Return the list of fields
С версии: 3.0.0
public get_custom_fields ( ) : array
Результат array List of custom fields

have_custom_fields() публичный Метод

If there are registered custom fields, the method returns true. Core fields are not considered registered custom fields by default but that can be overridden with the $core parameter.
С версии: 3.0.0
public have_custom_fields ( boolean $core = false ) : boolean
$core boolean True if core fields should be counted as registered custom fields.
Результат boolean True if custom fields are present, false otherwise

is_field_missing() публичный Метод

Makes sure no required custom field is missing from the data passed.
С версии: 3.2.0
public is_field_missing ( array $data = [] ) : boolean | WP_Error
$data array Array of data to check
Результат boolean | WP_Error False if no field is missing, WP_Error with the list of missing fields otherwise

move_status_first() публичный Метод

Reorder the admin columns.
С версии: 3.0.0
public move_status_first ( array $columns ) : array
$columns array List of admin columns
Результат array Re-ordered list

register_taxonomies() публичный Метод

Register all custom taxonomies.
С версии: 3.0.0
public register_taxonomies ( ) : void
Результат void

remove_field() публичный Метод

Remove a custom field.
С версии: 3.0.0
public remove_field ( string $id ) : void
$id string ID of the field to remove
Результат void

remove_taxonomy_metabox() публичный Метод

In some cases taxonomies are used as select. Hence, we don't need the standard taxonomy metabox.
С версии: 3.0.0
public remove_taxonomy_metabox ( ) : void
Результат void

save_core_field() публичный Метод

Core fields are processed differently and won't use the same saving function as the standard custom fields of the same type.
С версии: 3.2.0
public save_core_field ( integer $post_id, array $field, mixed $value ) : void
$post_id integer ID of the post being saved
$field array Field array
$value mixed Field new value
Результат void

save_custom_fields() публичный Метод

Save all custom fields given in $data to the database.
С версии: 3.2.0
public save_custom_fields ( integer $post_id, array $data = [], boolean $allow_log = true ) : array
$post_id integer ID of the post being saved
$data array Array of data that might contain custom fields values.
$allow_log boolean Whether or not to allow logging actions. If this is set to false and the custom field is set to true, $log has higher priority. I tis used to prevent logging on ticket creation.
Результат array Array of custom field / value saved to the database

status_filter() публичный Метод

Add status dropdown in the filters bar.
С версии: 2.0.0
public status_filter ( ) : void
Результат void

status_filter_by_status() публичный Метод

When filtering, WordPress uses the ID by default in the query but that doesn't work. We need to convert it to the taxonomy term.
С версии: 3.0.0
public status_filter_by_status ( object $query ) : void
$query object WordPress current main query
Результат void

submission_form_fields() публичный Метод

Display the custom fields on submission form.
С версии: 3.2.0
public submission_form_fields ( ) : void
Результат void

Описание свойств

$remove_mb публичное свойство

List of metaboxes to remove.
public $remove_mb