function get_clone_setting_field_choice($field) { // bail early if no field if (!$field) { return __('Unknown field', 'acf'); } // title $title = $field['label'] ? $field['label'] : __('(no title)', 'acf'); // append type $title .= ' (' . $field['type'] . ')'; // ancestors // - allow for AJAX to send through ancestors count $ancestors = isset($field['ancestors']) ? $field['ancestors'] : count(acf_get_field_ancestors($field)); $title = str_repeat('- ', $ancestors) . $title; // return return $title; }
function wp_post_revision_fields($fields, $post = null) { // validate page if (acf_is_screen('revision') || acf_is_ajax('get-revision-diffs')) { // allow } else { // bail early (most likely saving a post) return $fields; } // vars $append = array(); $order = array(); $post_id = acf_maybe_get($post, 'ID'); // compatibility with WP < 4.5 (test) if (!$post_id) { global $post; $post_id = $post->ID; } // get all postmeta $meta = get_post_meta($post_id); // bail early if no meta if (!$meta) { return $fields; } // loop foreach ($meta as $name => $value) { // attempt to find key value $key = acf_maybe_get($meta, '_' . $name); // bail ealry if no key if (!$key) { continue; } // update vars $value = $value[0]; $key = $key[0]; // bail early if $key is a not a field_key if (!acf_is_field_key($key)) { continue; } // get field $field = acf_get_field($key); $field_title = $field['label'] . ' (' . $name . ')'; $field_order = $field['menu_order']; $ancestors = acf_get_field_ancestors($field); // ancestors if (!empty($ancestors)) { // vars $count = count($ancestors); $oldest = acf_get_field($ancestors[$count - 1]); // update vars $field_title = str_repeat('- ', $count) . $field_title; $field_order = $oldest['menu_order'] . '.1'; } // append $append[$name] = $field_title; $order[$name] = $field_order; // hook into specific revision field filter and return local value add_filter("_wp_post_revision_field_{$name}", array($this, 'wp_post_revision_field'), 10, 4); } // append if (!empty($append)) { // vars $prefix = '_'; // add prefix $append = acf_add_array_key_prefix($append, $prefix); $order = acf_add_array_key_prefix($order, $prefix); // sort by name (orders sub field values correctly) array_multisort($order, $append); // remove prefix $append = acf_remove_array_key_prefix($append, $prefix); // append $fields = $fields + $append; } // return return $fields; }