GravityView_Field_Time
Add custom options for date fields
Source: includes/fields/class-gravityview-field-time.php:11
Details
- Kind:
class - Namespace:
(global) - Extends:
GravityView_Field
Methods
| Method | Description |
|---|---|
__construct() | GravityView_Field_Time constructor. |
modify_sort_id() | Modify the sort key for the time field so it can be parsed by the query filter |
_maybe_filter_gravity_forms_query() | If the sorting key matches the key set in modify_sort_id(), then modify the Gravity Forms query SQL |
_modify_query_sort_by_time_hack() | Modify Gravity Forms query SQL to convert times to numbers |
_get_time_format_for_field() | Return the field's time format by fetching the form ID and checking the field settings |
_filter_date_display_date_format() | Modify the default PHP date formats used by the time field based on the field IDs and the field settings |
date_format() | Get the default date format for a field based on the field ID and the time format setting |
Method Reference
__construct()
public function __construct()
GravityView_Field_Time constructor.
Source: includes/fields/class-gravityview-field-time.php:59
modify_sort_id()
public function modify_sort_id( $sort_field_id, $form_id )
Modify the sort key for the time field so it can be parsed by the query filter
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$sort_field_id | string | Existing sort field ID (like "5") | |
$form_id | int | Gravity Forms Form ID being sorted |
Returns
string— Modified sort key imploded with $_sort_divider, like5\|:time:\|12\|:time:\|h:i A
See Also
_modify_query_sort_by_time_hack
Since: 1.14
Source: includes/fields/class-gravityview-field-time.php:83
_maybe_filter_gravity_forms_query()
public function _maybe_filter_gravity_forms_query( $criteria, $form_ids, $view_id )
If the sorting key matches the key set in modify_sort_id(), then modify the Gravity Forms query SQL
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$criteria | array | Search criteria used by GravityView | |
$form_ids | array | Forms to search | |
$view_id | int | ID of the view being used to search |
Returns
array— $criteria If a match, the sorting will be updated to setis_numericto true and make sure the field ID is an int
See Also
Since: 1.14
Source: includes/fields/class-gravityview-field-time.php:107
_modify_query_sort_by_time_hack()
function _modify_query_sort_by_time_hack( $query )
Modify Gravity Forms query SQL to convert times to numbers
Gravity Forms couldn't sort by time...until NOW
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$query | string | MySQL query |
Returns
string— Modified query, if the query matches the expected Gravity Forms SQL string used for sorting time fields. Otherwise, original query.
Since: 1.14
Source: includes/fields/class-gravityview-field-time.php:154
_get_time_format_for_field()
public static function _get_time_format_for_field( $field_id, $form_id=0 )
Return the field's time format by fetching the form ID and checking the field settings
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$field_id | string | ID for Gravity Forms time field | |
$form_id | int | 0 | ID for Gravity Forms form |
Returns
string— Either "12" or "24". "12" is default.
Since: 1.14
Source: includes/fields/class-gravityview-field-time.php:250
_filter_date_display_date_format()
public function _filter_date_display_date_format()
Modify the default PHP date formats used by the time field based on the field IDs and the field settings
Returns
string— PHP date() format text to to display the correctly formatted time value for the newly created field
Since: 1.14
Source: includes/fields/class-gravityview-field-time.php:277
date_format()
public static function date_format( $time_format='12', $field_id=0 )
Get the default date format for a field based on the field ID and the time format setting
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$time_format | string | '12' | The time format ("12" or "24"). Default: "12" {@since 1.14} |
$field_id | int | 0 | The ID of the field. Used to figure out full time/hours/minutes/am/pm {@since 1.14} |
Returns
string— PHP date format for the time
Since: 1.14
Source: includes/fields/class-gravityview-field-time.php:295