acf_hidden_input($hidden); ?> <input type="text" <?php echo acf_esc_attr($text); ?> /> </div> <?php } /* * render_field_settings() * * Create extra options for your field. This is rendered when editing a field. * The value of $field['name'] can be used (like bellow) to save extra data to the $field * * @type action * @since 3.6 * @date 23/01/13 * * @param $field - an array holding all the field's data */ function render_field_settings($field) { // display_format acf_render_field_setting($field, array('label' => __('Default Value', 'acf'), 'instructions' => '', 'type' => 'text', 'name' => 'default_value', 'placeholder' => '#FFFFFF')); } } // initialize acf_register_field_type(new acf_field_color_picker()); } // class_exists check
* @since 3.6 * @date 23/01/13 * * @param $value - the value which will be saved in the database * @param $post_id - the $post_id of which the value will be saved * @param $field - the field array holding all the field options * * @return $value - the modified value */ function update_single_value($value) { // numeric if (is_numeric($value)) { return $value; } // array? if (is_array($value) && isset($value['ID'])) { return $value['ID']; } // object? if (is_object($value) && isset($value->ID)) { return $value->ID; } // return return $value; } } // initialize acf_register_field_type(new acf_field_gallery()); } // class_exists check
$value = $this->format_value_single($value, $post_id, $field); } // return return $value; } function format_value_single($value, $post_id, $field) { // bail ealry if is empty if (acf_is_empty($value)) { return $value; } // vars $label = acf_maybe_get($field['choices'], $value, $value); // value if ($field['return_format'] == 'value') { // do nothing // label } elseif ($field['return_format'] == 'label') { $value = $label; // array } elseif ($field['return_format'] == 'array') { $value = array('value' => $value, 'label' => $label); } // return return $value; } } // initialize acf_register_field_type(new acf_field_select()); } // class_exists check
* @param $field (array) * @return $field */ function translate_field($field) { return acf_get_field_type('select')->translate_field($field); } /* * format_value() * * This filter is appied to the $value after it is loaded from the db and before it is returned to the template * * @type filter * @since 3.6 * @date 23/01/13 * * @param $value (mixed) the value which was loaded from the database * @param $post_id (mixed) the $post_id from which the value was loaded * @param $field (array) the field array holding all the field options * * @return $value (mixed) the modified value */ function format_value($value, $post_id, $field) { return acf_get_field_type('select')->format_value($value, $post_id, $field); } } // initialize acf_register_field_type(new acf_field_checkbox()); } // class_exists check
* * @type filter * @since 3.6 * @date 23/01/13 * * @param $value (mixed) the value which was loaded from the database * @param $post_id (mixed) the $post_id from which the value was loaded * @param $field (array) the field array holding all the field options * * @return $value (mixed) the modified value */ function format_value($value, $post_id, $field) { // bail early if no value or not for template if (empty($value) || !is_string($value)) { return $value; } // new lines if ($field['new_lines'] == 'wpautop') { $value = wpautop($value); } elseif ($field['new_lines'] == 'br') { $value = nl2br($value); } // return return $value; } } // initialize acf_register_field_type(new acf_field_textarea()); } // class_exists check
// value may be '0' if (!$value) { return false; } // return return $valid; } /* * translate_field * * This function will translate field settings * * @type function * @date 8/03/2016 * @since 5.3.2 * * @param $field (array) * @return $field */ function translate_field($field) { // translate $field['message'] = acf_translate($field['message']); // return return $field; } } // initialize acf_register_field_type(new acf_field_true_false()); } // class_exists check
* @return $value - the modified value */ function update_value($value, $post_id, $field) { // validate if (empty($value)) { return $value; } // format if (is_array($value)) { // array foreach ($value as $k => $v) { // object? if (is_object($v) && isset($v->ID)) { $value[$k] = $v->ID; } } // save value as strings, so we can clearly search for them in SQL LIKE statements $value = array_map('strval', $value); } elseif (is_object($value) && isset($value->ID)) { // object $value = $value->ID; } // return return $value; } } // initialize acf_register_field_type(new acf_field_page_link()); } // class_exists check
* @param $value - the value which will be saved in the database * @param $post_id - the $post_id of which the value will be saved * @param $field - the field array holding all the field options * * @return $value - the modified value */ function update_value($value, $post_id, $field) { // validate if (empty($value)) { return $value; } // force value to array $value = acf_get_array($value); // array foreach ($value as $k => $v) { // object? if (is_object($v) && isset($v->ID)) { $value[$k] = $v->ID; } } // save value as strings, so we can clearly search for them in SQL LIKE statements $value = array_map('strval', $value); // return return $value; } } // initialize acf_register_field_type(new acf_field_relationship()); } // class_exists check
* * This filter is appied to the $value before it is updated in the db * * @type filter * @since 3.6 * @date 23/01/13 * * @param $value - the value which will be saved in the database * @param $field - the field array holding all the field options * @param $post_id - the $post_id of which the value will be saved * * @return $value - the modified value */ function update_value($value, $post_id, $field) { // no formatting needed for empty value if (empty($value)) { return $value; } // remove ',' if (acf_str_exists(',', $value)) { $value = str_replace(',', '', $value); } // return return $value; } } // initialize acf_register_field_type(new acf_field_number()); } // class_exists check
* * Create the HTML interface for your field * * @param $field (array) the $field being rendered * * @type action * @since 3.6 * @date 23/01/13 * * @param $field (array) the $field being edited * @return n/a */ function render_field($field) { // bail early if no html if (!$field['html']) { return; } // html if (is_string($field['html']) && !function_exists($field['html'])) { echo $field['html']; // function } else { call_user_func_array($field['html'], array($field)); } } } // initialize acf_register_field_type(new acf_field_output()); } // class_exists check
return $field; } /* * duplicate_field() * * This filter is appied to the $field before it is duplicated and saved to the database * * @type filter * @since 3.6 * @date 23/01/13 * * @param $field - the field array holding all the field options * * @return $field - the modified field */ function duplicate_field($field) { // get sub fields $sub_fields = acf_extract_var($field, 'sub_fields'); // save field to get ID $field = acf_update_field($field); // duplicate sub fields acf_duplicate_fields($sub_fields, $field['ID']); // return return $field; } } // initialize acf_register_field_type(new acf_field_repeater()); } // class_exists check
// return echo $e; } /* * render_field_settings() * * Create extra options for your field. This is rendered when editing a field. * The value of $field['name'] can be used (like bellow) to save extra data to the $field * * @type action * @since 3.6 * @date 23/01/13 * * @param $field - an array holding all the field's data */ function render_field_settings($field) { // default_value acf_render_field_setting($field, array('label' => __('Default Value', 'acf'), 'instructions' => __('Appears when creating a new post', 'acf'), 'type' => 'text', 'name' => 'default_value')); // placeholder acf_render_field_setting($field, array('label' => __('Placeholder Text', 'acf'), 'instructions' => __('Appears within the input', 'acf'), 'type' => 'text', 'name' => 'placeholder')); // prepend acf_render_field_setting($field, array('label' => __('Prepend', 'acf'), 'instructions' => __('Appears before the input', 'acf'), 'type' => 'text', 'name' => 'prepend')); // append acf_render_field_setting($field, array('label' => __('Append', 'acf'), 'instructions' => __('Appears after the input', 'acf'), 'type' => 'text', 'name' => 'append')); } } // initialize acf_register_field_type(new acf_field_email()); } // class_exists check
* @since 3.6 * @date 23/01/13 * * @param $value - the value which will be saved in the database * @param $post_id - the $post_id of which the value will be saved * @param $field - the field array holding all the field options * * @return $value - the modified value */ function update_value($value, $post_id, $field) { // numeric if (is_numeric($value)) { return $value; } // array? if (is_array($value) && isset($value['ID'])) { return $value['ID']; } // object? if (is_object($value) && isset($value->ID)) { return $value->ID; } // return return $value; } } // initialize acf_register_field_type(new acf_field_image()); } // class_exists check
return $value; } /* * wp_prepare_attachment_for_js * * this filter allows ACF to add in extra data to an attachment JS object * * @type function * @date 1/06/13 * * @param {int} $post_id * @return {int} $post_id */ function wp_prepare_attachment_for_js($response, $attachment, $meta) { // default $fs = '0 kb'; // supress PHP warnings caused by corrupt images if ($i = @filesize(get_attached_file($attachment->ID))) { $fs = size_format($i); } // update JSON $response['filesize'] = $fs; // return return $response; } } // initialize acf_register_field_type(new acf_field_file()); } // class_exists check
// bail ealry if no qneueu if (!acf_get_setting('enqueue_google_maps')) { return; } // vars $api = array('key' => acf_get_setting('google_api_key'), 'client' => acf_get_setting('google_api_client'), 'libraries' => 'places', 'ver' => 3, 'callback' => ''); // filter $api = apply_filters('acf/fields/google_map/api', $api); // remove empty if (empty($api['key'])) { unset($api['key']); } if (empty($api['client'])) { unset($api['client']); } // construct url $url = add_query_arg($api, 'https://maps.googleapis.com/maps/api/js'); ?> <script type="text/javascript"> acf.fields.google_map.url = '<?php echo $url; ?> '; </script> <?php } } // initialize acf_register_field_type(new acf_field_google_map()); } // class_exists check
} /* * acf_clone_field * * This function will update clone field settings based on the origional field * * @type function * @date 28/06/2016 * @since 5.3.8 * * @param $clone (array) * @param $field (array) * @return $clone */ function acf_clone_field($field, $clone_field) { // remove parent_layout // - allows a sub field to be rendered as a normal field unset($field['parent_layout']); // attempt to merger parent_layout if (isset($clone_field['parent_layout'])) { $field['parent_layout'] = $clone_field['parent_layout']; } // return return $field; } } // initialize acf_register_field_type(new acf_field_flexible_content()); } // class_exists check
//cope with deleted users by @adampope if (!is_object($user_data)) { unset($value[$i]); continue; } // append to array $value[$i] = array(); $value[$i]['ID'] = $user_id; $value[$i]['user_firstname'] = $user_data->user_firstname; $value[$i]['user_lastname'] = $user_data->user_lastname; $value[$i]['nickname'] = $user_data->nickname; $value[$i]['user_nicename'] = $user_data->user_nicename; $value[$i]['display_name'] = $user_data->display_name; $value[$i]['user_email'] = $user_data->user_email; $value[$i]['user_url'] = $user_data->user_url; $value[$i]['user_registered'] = $user_data->user_registered; $value[$i]['user_description'] = $user_data->user_description; $value[$i]['user_avatar'] = get_avatar($user_id); } // convert back from array if neccessary if (!$field['multiple']) { $value = array_shift($value); } // return value return $value; } } // initialize acf_register_field_type(new acf_field_user()); } // class_exists check
acf_render_field_setting($field, array('label' => __('End-point', 'acf'), 'instructions' => __('Use this field as an end-point and start a new group of tabs', 'acf'), 'name' => 'endpoint', 'type' => 'true_false', 'ui' => 1)); } /* * load_field() * * This filter is appied to the $field after it is loaded from the database * * @type filter * @since 3.6 * @date 23/01/13 * * @param $field - the field array holding all the field options * * @return $field - the field array holding all the field options */ function load_field($field) { // remove name to avoid caching issue $field['name'] = ''; // remove required to avoid JS issues $field['required'] = 0; // set value other than 'null' to avoid ACF loading / caching issue $field['value'] = false; // return return $field; } } // initialize acf_register_field_type(new acf_field_tab()); } // class_exists check
$choices[$v['id']] = $v['text']; } } acf_render_field_wrap(array('label' => __('Parent', 'acf'), 'name' => 'term_parent', 'type' => 'select', 'allow_null' => 1, 'ui' => 0, 'choices' => $choices)); } ?> <p class="acf-submit"><button class="acf-button button button-primary" type="submit"><?php _e("Add", 'acf'); ?> </button><i class="acf-spinner"></i><span></span></p></form><?php // die die; } } // initialize acf_register_field_type(new acf_field_taxonomy()); } // class_exists check if (!class_exists('acf_taxonomy_field_walker')) { class acf_taxonomy_field_walker extends Walker { var $field = null, $tree_type = 'category', $db_fields = array('parent' => 'parent', 'id' => 'term_id'); function __construct($field) { $this->field = $field; } function start_el(&$output, $term, $depth = 0, $args = array(), $current_object_id = 0) { // vars $selected = in_array($term->term_id, $this->field['value']); // append
$e .= '<input ' . acf_esc_attr($atts) . ' />'; $e .= '</div>'; // return echo $e; } /* * render_field_settings() * * Create extra options for your field. This is rendered when editing a field. * The value of $field['name'] can be used (like bellow) to save extra data to the $field * * @type action * @since 3.6 * @date 23/01/13 * * @param $field - an array holding all the field's data */ function render_field_settings($field) { // placeholder acf_render_field_setting($field, array('label' => __('Placeholder Text', 'acf'), 'instructions' => __('Appears within the input', 'acf'), 'type' => 'text', 'name' => 'placeholder')); // prepend acf_render_field_setting($field, array('label' => __('Prepend', 'acf'), 'instructions' => __('Appears before the input', 'acf'), 'type' => 'text', 'name' => 'prepend')); // append acf_render_field_setting($field, array('label' => __('Append', 'acf'), 'instructions' => __('Appears after the input', 'acf'), 'type' => 'text', 'name' => 'append')); } } // initialize acf_register_field_type(new acf_field_password()); } // class_exists check
acf_render_field_setting($field, array('label' => __('Week Starts On', 'acf'), 'instructions' => '', 'type' => 'select', 'name' => 'first_day', 'choices' => array_values($wp_locale->weekday))); } /* * format_value() * * This filter is appied to the $value after it is loaded from the db and before it is returned to the template * * @type filter * @since 3.6 * @date 23/01/13 * * @param $value (mixed) the value which was loaded from the database * @param $post_id (mixed) the $post_id from which the value was loaded * @param $field (array) the field array holding all the field options * * @return $value (mixed) the modified value */ function format_value($value, $post_id, $field) { // save_format - compatibility with ACF < 5.0.0 if (!empty($field['save_format'])) { return $value; } // return return acf_format_date($value, $field['return_format']); } } // initialize acf_register_field_type(new acf_field_date_picker()); } // class_exists check
/* * format_value() * * This filter is appied to the $value after it is loaded from the db and before it is returned to the template * * @type filter * @since 3.6 * @date 23/01/13 * * @param $value (mixed) the value which was loaded from the database * @param $post_id (mixed) the $post_id from which the value was loaded * @param $field (array) the field array holding all the field options * * @return $value (mixed) the modified value */ function format_value($value, $post_id, $field) { // bail early if no value if (empty($value)) { return $value; } // get oembed $value = $this->wp_oembed_get($value, $field['width'], $field['height']); // return return $value; } } // initialize acf_register_field_type(new acf_field_oembed()); } // class_exists check
} /* * get_posts * * This function will return an array of posts for a given field value * * @type function * @date 13/06/2014 * @since 5.0.0 * * @param $value (array) * @return $value */ function get_posts($value, $field) { // numeric $value = acf_get_numeric($value); // bail early if no value if (empty($value)) { return false; } // get posts $posts = acf_get_posts(array('post__in' => $value, 'post_type' => $field['post_type'])); // return return $posts; } } // initialize acf_register_field_type(new acf_field_post_object()); } // class_exists check
{ // remove name $field['name'] = ''; $field['required'] = 0; // return return $field; } /* * translate_field * * This function will translate field settings * * @type function * @date 8/03/2016 * @since 5.3.2 * * @param $field (array) * @return $field */ function translate_field($field) { // translate $field['message'] = acf_translate($field['message']); // return return $field; } } // initialize acf_register_field_type(new acf_field_message()); } // class_exists check
* format_value() * * This filter is appied to the $value after it is loaded from the db and before it is returned to the template * * @type filter * @since 3.6 * @date 23/01/13 * * @param $value (mixed) the value which was loaded from the database * @param $post_id (mixed) the $post_id from which the value was loaded * @param $field (array) the field array holding all the field options * * @return $value (mixed) the modified value */ function format_value($value, $post_id, $field) { // bail early if no value if (empty($value)) { return $value; } // apply filters $value = apply_filters('acf_the_content', $value); // follow the_content function in /wp-includes/post-template.php $value = str_replace(']]>', ']]>', $value); return $value; } } // initialize acf_register_field_type(new acf_field_wysiwyg()); } // class_exists check
* @param $field (array) * @return $field */ function translate_field($field) { return acf_get_field_type('select')->translate_field($field); } /* * format_value() * * This filter is appied to the $value after it is loaded from the db and before it is returned to the template * * @type filter * @since 3.6 * @date 23/01/13 * * @param $value (mixed) the value which was loaded from the database * @param $post_id (mixed) the $post_id from which the value was loaded * @param $field (array) the field array holding all the field options * * @return $value (mixed) the modified value */ function format_value($value, $post_id, $field) { return acf_get_field_type('select')->format_value($value, $post_id, $field); } } // initialize acf_register_field_type(new acf_field_radio()); } // class_exists check
*/ function validate_value($valid, $value, $field, $input) { // bail early if no $value if (empty($value)) { return $valid; } // bail early if no sub fields if (empty($field['sub_fields'])) { return $valid; } // loop foreach (array_keys($field['sub_fields']) as $i) { // get sub field $sub_field = $field['sub_fields'][$i]; $k = $sub_field['key']; // bail early if valu enot set (conditional logic?) if (!isset($value[$k])) { continue; } // validate acf_validate_value($value[$k], $sub_field, "{$input}[{$k}]"); } // return return $valid; } } // initialize acf_register_field_type(new acf_field_clone()); } // class_exists check
* * description * * @type function * @date 11/02/2014 * @since 5.0.0 * * @param $post_id (int) * @return $post_id (int) */ function validate_value($valid, $value, $field, $input) { // bail early if empty if (empty($value)) { return $valid; } if (strpos($value, '://') !== false) { // url } elseif (strpos($value, '//') === 0) { // protocol relative url } else { $valid = __('Value must be a valid URL', 'acf'); } // return return $valid; } } // initialize acf_register_field_type(new acf_field_url()); } // class_exists check