/**
* Get custom field types.
*
* @since 1.5.8
*
* @return array Array of custom field types.
*/
function acadp_get_custom_field_types() {
$types = array(
'text' => __( 'Text', 'advanced-classifieds-and-directory-pro' ),
'textarea' => __( 'Text Area', 'advanced-classifieds-and-directory-pro' ),
'select' => __( 'Select', 'advanced-classifieds-and-directory-pro' ),
'checkbox' => __( 'Checkbox', 'advanced-classifieds-and-directory-pro' ),
'radio' => __( 'Radio Button', 'advanced-classifieds-and-directory-pro' ),
'url' => __( 'URL', 'advanced-classifieds-and-directory-pro' )
);
// Return
return apply_filters( 'acadp_custom_field_types', $types );
}
/**
* Get custom fields.
*
* @since 1.5.8
*
* @param int $category Category ID.
* @return array $field_ids Array of custom field ids.
*/
function acadp_get_custom_field_ids( $category = 0 ) {
// Get global fields
$args = array(
'post_type' => 'acadp_fields',
'post_status' => 'publish',
'posts_per_page' => -1,
'fields' => 'ids',
'meta_query' => array(
array(
'key' => 'associate',
'value' => 'form'
),
)
);
$field_ids = get_posts( $args );
// Get category fields
if( $category > 0 ) {
$args = array(
'post_type' => 'acadp_fields',
'post_status' => 'publish',
'posts_per_page' => -1,
'fields' => 'ids',
'tax_query' => array(
array(
'taxonomy' => 'acadp_categories',
'field' => 'term_id',
'terms' => $category,
'include_children' => false,
),
)
);
$category_fields = get_posts( $args );
$field_ids = array_merge( $field_ids, $category_fields );
$field_ids = array_unique( $field_ids );
}
// Return
if( empty( $field_ids ) ) {
$field_ids = array( 0 );
}
return $field_ids;
}