PHP Class RCCWP_CustomField, Magic-Fields

ファイルを表示 Open project: hunk/Magic-Fields Class Usage Examples

Public Methods

Method Description
Create ( id $customGroupId, string $name, string $label, integer $order = 1, integer $required_field, integer $type, array $options = null, array $default_value = null, array $properties = null, $duplicate, $helptext = null, $css = null ) : the Create a new custom field
Delete ( integer $customFieldId = null ) Delete a field
Get ( integer $customFieldId ) : an Get the field information including properties, options and default value(s)
GetCustomFieldTypes ( integer $customFieldTypeId = null ) : a Retrieves information about a specified type
GetCustomFieldValues ( boolean $single, integer $postId, string $customFieldName, integer $groupIndex = 1, integer $fieldIndex = 1 ) : mixed Retrieves the value of a custom field for a specified post
GetDataField ( string $customFieldName, integer $groupIndex = 1, integer $fieldIndex = 1, integer $postId ) Get Data Field
GetFieldDuplicates ( integer $postId, $fieldName, $groupIndex ) : number Get number of group duplicates given field name. The function returns 1 if there are no duplicates (just he original group), 2 if there is one duplicate and so on.
GetFieldGroupDuplicates ( integer $postId, $fieldName ) : number Get number of group duplicates given field name. The function returns 1 if there are no duplicates (just the original group), 2 if there is one duplicate and so on.
GetFieldsOrder ( $postId, $fieldName, $groupId ) : array Get field duplicates
GetInfoByName ( string $customFieldName, $post_id ) : array Retrieves the id and type of a custom field given field name for the current post.
GetMetaID ( integer $postId, $customFieldName, integer $groupIndex = 1, integer $fieldIndex = 1 ) : integer Get the Meta ID from a custom field with this id is possible get the value of the custom field from the Post Meta table of wordpress
GetOrderDuplicates ( integer $postId, $fieldName ) : order Get the order of group duplicates given the field name. The function returns a array with the orden
Update ( integer $customFieldId, string $name, string $label, integer $order = 1, integer $required_field, integer $type, array $options = null, array $default_value = null, array $properties = null, $duplicate, $helptext = null ) Updates the properties of a custom field.

Method Details

Create() public static method

Create a new custom field
public static Create ( id $customGroupId, string $name, string $label, integer $order = 1, integer $required_field, integer $type, array $options = null, array $default_value = null, array $properties = null, $duplicate, $helptext = null, $css = null ) : the
$customGroupId id the id of the group that will contain the field
$name string the name of the field, the name is used to uniquely identify the field when retrieving its value.
$label string the label of the field, the label is displayed beside the field in Write tab.
$order integer the order of the field when it is displayed in the Write tab.
$required_field integer whether this field is a required field. Required fields doesn't allow users to save a post if they are null.
$type integer the type of the field. Use $FIELD_TYPES defined in MF_Constant.php
$options array array of strings that represent the list of the field if its type is list.
$default_value array array of strings that represent default value(s) of of the field if its type is list.
$properties array an array containing extra properties of the field.
return the new field id

Delete() public static method

Delete a field
public static Delete ( integer $customFieldId = null )
$customFieldId integer field id

Get() public static method

Get the field information including properties, options and default value(s)
public static Get ( integer $customFieldId ) : an
$customFieldId integer field id
return an object containing information about fields. The object contains 3 objects: properties, options and default_value

GetCustomFieldTypes() public static method

Retrieves information about a specified type
public static GetCustomFieldTypes ( integer $customFieldTypeId = null ) : a
$customFieldTypeId integer the type id, if null, a list of all types will be returned
return a list/object containing information about the specified type. The information includes id, name, description, has_options, has_properties, and allow_multiple_values (whether fields of that type can have more than one default value)

GetCustomFieldValues() public static method

Retrieves the value of a custom field for a specified post
public static GetCustomFieldValues ( boolean $single, integer $postId, string $customFieldName, integer $groupIndex = 1, integer $fieldIndex = 1 ) : mixed
$single boolean
$postId integer
$customFieldName string
$groupIndex integer
$fieldIndex integer
return mixed

GetDataField() public static method

@param string $customFieldName
public static GetDataField ( string $customFieldName, integer $groupIndex = 1, integer $fieldIndex = 1, integer $postId )
$customFieldName string
$groupIndex integer @param integer $fieldIndex @param integer $postId
$fieldIndex integer
$postId integer

GetFieldDuplicates() public static method

Get number of group duplicates given field name. The function returns 1 if there are no duplicates (just he original group), 2 if there is one duplicate and so on.
public static GetFieldDuplicates ( integer $postId, $fieldName, $groupIndex ) : number
$postId integer post id
return number of groups

GetFieldGroupDuplicates() public static method

Get number of group duplicates given field name. The function returns 1 if there are no duplicates (just the original group), 2 if there is one duplicate and so on.
public static GetFieldGroupDuplicates ( integer $postId, $fieldName ) : number
$postId integer post id
return number of groups

GetFieldsOrder() public static method

@param $postId the id of the post
public static GetFieldsOrder ( $postId, $fieldName, $groupId ) : array
$fieldName the name of the field @param $groupId the groupId @return array return the order of the field sorted
return array

GetInfoByName() public static method

Retrieves the id and type of a custom field given field name for the current post.
Author: Edgar García - hunk ([email protected])
public static GetInfoByName ( string $customFieldName, $post_id ) : array
$customFieldName string
return array with custom field id and custom field type

GetMetaID() public static method

@param integer $postId Post id
public static GetMetaID ( integer $postId, $customFieldName, integer $groupIndex = 1, integer $fieldIndex = 1 ) : integer
$postId integer
$groupIndex integer
$fieldIndex integer
return integer

GetOrderDuplicates() public static method

Get the order of group duplicates given the field name. The function returns a array with the orden
public static GetOrderDuplicates ( integer $postId, $fieldName ) : order
$postId integer post id
return order of one group

Update() public static method

Updates the properties of a custom field.
public static Update ( integer $customFieldId, string $name, string $label, integer $order = 1, integer $required_field, integer $type, array $options = null, array $default_value = null, array $properties = null, $duplicate, $helptext = null )
$customFieldId integer the id of the field to be updated
$name string the name of the field, the name is used to uniquely identify the field when retrieving its value.
$label string the label of the field, the label is displayed beside the field in Write tab.
$order integer the order of the field when it is displayed in the Write tab.
$required_field integer whether this field is a required field. Required fields doesn't allow users to save a post if they are null.
$type integer the type of the field. Use $FIELD_TYPES defined in MF_Constant.php
$options array array of strings that represent the list of the field if its type is list.
$default_value array array of strings that represent default value(s) of of the field if its type is list.
$properties array an array containing extra properties of the field.