function update_value($value, $post_id, $field) { // bail early if no value if (!acf_is_array($value) || !acf_is_array($field['sub_fields'])) { return null; } // modify $field = $this->prepare_field_for_save($field); // loop foreach (array_keys($field['sub_fields']) as $i) { // vars $sub_field = $field['sub_fields'][$i]; $v = false; // key (backend) if (isset($value[$sub_field['key']])) { $v = $value[$sub_field['key']]; // name (frontend) } elseif (isset($value[$sub_field['_name']])) { $v = $value[$sub_field['_name']]; // empty } else { // input is not set (hidden by conditioanl logic) continue; } // update value acf_update_value($v, $post_id, $sub_field); } // return return ''; }
function acf_get_field_group_style($field_group) { // vars $e = ''; // bail early if no array or is empty if (!acf_is_array($field_group['hide_on_screen'])) { return $e; } // add style to html if (in_array('permalink', $field_group['hide_on_screen'])) { $e .= '#edit-slug-box {display: none;} '; } if (in_array('the_content', $field_group['hide_on_screen'])) { $e .= '#postdivrich {display: none;} '; } if (in_array('excerpt', $field_group['hide_on_screen'])) { $e .= '#postexcerpt, #screen-meta label[for=postexcerpt-hide] {display: none;} '; } if (in_array('custom_fields', $field_group['hide_on_screen'])) { $e .= '#postcustom, #screen-meta label[for=postcustom-hide] { display: none; } '; } if (in_array('discussion', $field_group['hide_on_screen'])) { $e .= '#commentstatusdiv, #screen-meta label[for=commentstatusdiv-hide] {display: none;} '; } if (in_array('comments', $field_group['hide_on_screen'])) { $e .= '#commentsdiv, #screen-meta label[for=commentsdiv-hide] {display: none;} '; } if (in_array('slug', $field_group['hide_on_screen'])) { $e .= '#slugdiv, #screen-meta label[for=slugdiv-hide] {display: none;} '; } if (in_array('author', $field_group['hide_on_screen'])) { $e .= '#authordiv, #screen-meta label[for=authordiv-hide] {display: none;} '; } if (in_array('format', $field_group['hide_on_screen'])) { $e .= '#formatdiv, #screen-meta label[for=formatdiv-hide] {display: none;} '; } if (in_array('page_attributes', $field_group['hide_on_screen'])) { $e .= '#pageparentdiv {display: none;} '; } if (in_array('featured_image', $field_group['hide_on_screen'])) { $e .= '#postimagediv, #screen-meta label[for=postimagediv-hide] {display: none;} '; } if (in_array('revisions', $field_group['hide_on_screen'])) { $e .= '#revisionsdiv, #screen-meta label[for=revisionsdiv-hide] {display: none;} '; } if (in_array('categories', $field_group['hide_on_screen'])) { $e .= '#categorydiv, #screen-meta label[for=categorydiv-hide] {display: none;} '; } if (in_array('tags', $field_group['hide_on_screen'])) { $e .= '#tagsdiv-post_tag, #screen-meta label[for=tagsdiv-post_tag-hide] {display: none;} '; } if (in_array('send-trackbacks', $field_group['hide_on_screen'])) { $e .= '#trackbacksdiv, #screen-meta label[for=trackbacksdiv-hide] {display: none;} '; } // return return apply_filters('acf/get_field_group_style', $e, $field_group); }
function format_value($value, $post_id, $field) { // numeric $value = acf_get_numeric($value); // bail early if no value if (empty($value)) { return false; } // load posts if needed if ($field['return_format'] == 'object') { $value = $this->get_posts($value, $field); } // convert back from array if neccessary if (!$field['multiple'] && acf_is_array($value)) { $value = current($value); } // return value return $value; }
function format_value($value, $post_id, $field) { // array if (acf_is_array($value)) { foreach ($value as $i => $v) { $value[$i] = $this->format_value_single($v, $post_id, $field); } } else { $value = $this->format_value_single($value, $post_id, $field); } // return return $value; }