// sort groups ksort( $groups ); // return return $groups; } ?>a will return array before running maybe_unserialize $value = maybe_unserialize( $value ); // add in slashes // - update_post_meta will unslash the value, so we must first slash it to avoid losing backslashes // - https://codex.wordpress.org/Function_Reference/update_post_meta#Character_Escaping if( is_string($value) ) { $value = wp_slash($value); } // update value acf_update_metadata( $to_post_id, $name, $value ); acf_update_metadata( $to_post_id, $name, $key, true ); } } /* * acf_preview_value * * This function will return a human freindly 'preview' for a given field value * * @type function * @date 24/10/16 * @since 5.5.0 * * @param $value (mixed) * @param $post_id (mixed) * @param $field (array) * @return (string) */ function acf_preview_value( $value, $post_id, $field ) { /** * Filters the $value before used in HTML. * * @date 24/10/16 * @since 5.5.0 * * @param mixed $value The value to preview. * @param string $post_id The post ID for this value. * @param array $field The field array. */ $value = apply_filters( "acf/preview_value/type={$field['type']}", $value, $post_id, $field ); $value = apply_filters( "acf/preview_value/name={$field['_name']}", $value, $post_id, $field ); $value = apply_filters( "acf/preview_value/key={$field['key']}", $value, $post_id, $field ); $value = apply_filters( "acf/preview_value", $value, $post_id, $field ); // return return $value; } ?>stors = array(); // loop while( $field && acf_is_field_key($field['parent']) ) { $ancestors[] = $field['parent']; $field = acf_get_field($field['parent']); } // return return $ancestors; } /* * acf_maybe_get_sub_field * * This function will attempt to find a sub field * * @type function * @date 3/10/2016 * @since 5.4.0 * * @param $post_id (int) * @return $post_id (int) */ function acf_maybe_get_sub_field( $selectors, $post_id = false, $strict = true ) { // bail ealry if not enough selectors if( !is_array($selectors) || count($selectors) < 3 ) return false; // vars $offset = acf_get_setting('row_index_offset'); $selector = acf_extract_var( $selectors, 0 ); $selectors = array_values( $selectors ); // reset keys // attempt get field $field = acf_maybe_get_field( $selector, $post_id, $strict ); // bail early if no field if( !$field ) return false; // loop for( $j = 0; $j < count($selectors); $j+=2 ) { // vars $sub_i = $selectors[ $j ]; $sub_s = $selectors[ $j+1 ]; $field_name = $field['name']; // find sub field $field = acf_get_sub_field( $sub_s, $field ); // bail early if no sub field if( !$field ) return false; // add to name $field['name'] = $field_name . '_' . ($sub_i-$offset) . '_' . $field['name']; } // return return $field; } /* * acf_prefix_fields * * This funtion will safely change the prefix for an array of fields * Needed to allow clone field to continue working on nave menu item and widget forms * * @type function * @date 5/9/17 * @since 5.6.0 * * @param $post_id (int) * @return $post_id (int) */ function acf_prefix_fields( &$fields, $prefix = 'acf' ) { // loop foreach( $fields as &$field ) { // replace 'acf' with $prefix $field['prefix'] = substr_replace($field['prefix'], $prefix, 0, 3); } // return return $fields; } /** * acf_apply_field_filters * * description * * @date 11/9/18 * @since 5.7.6 * * @param type $var Description. Default. * @return type Description. */ /* function acf_apply_field_filters( $value ) { // get function args $args = func_get_args(); // find field in $args $field = false; foreach( $args as $arg ) { if( is_array($arg) && isset($arg['key'], $arg['type'], $arg['_name']) ) { $field = $arg; break; } } // vars $filter = current_filter(); // unshift tag to args array_unshift($args, $filter); // apply field filters if( $field ) { // $filter/type=$type $args[0] = "{$filter}/type={$field['type']}"; $value = call_user_func_array('apply_filters', $args); // $filter/name=$name $args[0] = "{$filter}/name={$field['_name']}"; $value = call_user_func_array('apply_filters', $args); // $filter/key=$key $args[0] = "{$filter}/key={$field['key']}"; $value = call_user_func_array('apply_filters', $args); } // return return $value; } */ ?>* acf_get_field_group_edit_link * * Checks if the current user can edit the field group and returns the edit url. * * @date 23/9/18 * @since 5.7.7 * * @param int $post_id The field group ID. * @return string */ function acf_get_field_group_edit_link( $post_id ) { if( $post_id && acf_current_user_can_admin() ) { return admin_url('post.php?post=' . $post_id . '&action=edit'); } return ''; } ?>() function. * * @date 7/10/13 * @since 5.0.0 * @deprecated 5.7.2 */ function acf_get_pretty_taxonomies( $taxonomies = array() ) { return acf_get_taxonomy_labels( $taxonomies ); } /** * acf_get_term * * Similar to get_term() but with some extra functionality. * * @date 19/8/18 * @since 5.7.3 * * @param mixed $term_id The term ID or a string of "taxonomy:slug". * @param string $taxonomy The taxonomyname. * @return WP_Term */ function acf_get_term( $term_id, $taxonomy = '' ) { // allow $term_id parameter to be a string of "taxonomy:slug" or "taxonomy:id" if( is_string($term_id) && strpos($term_id, ':') ) { list( $taxonomy, $term_id ) = explode(':', $term_id); $term = get_term_by( 'slug', $term_id, $taxonomy ); if( $term ) return $term; } // return return get_term( $term_id, $taxonomy ); } /** * acf_encode_term * * Returns a "taxonomy:slug" string for a given WP_Term. * * @date 27/8/18 * @since 5.7.4 * * @param WP_Term $term The term object. * @return string */ function acf_encode_term( $term ) { return "{$term->taxonomy}:{$term->slug}"; } /** * acf_decode_term * * Decodes a "taxonomy:slug" string into an array of taxonomy and slug. * * @date 27/8/18 * @since 5.7.4 * * @param WP_Term $term The term object. * @return string */ function acf_decode_term( $string ) { if( is_string($string) && strpos($string, ':') ) { list( $taxonomy, $slug ) = explode(':', $string); return array( 'taxonomy' => $taxonomy, 'slug' => $slug ); } return false; } /** * acf_get_encoded_terms * * Returns an array of WP_Term objects from an array of encoded strings * * @date 9/9/18 * @since 5.7.5 * * @param array $values The array of encoded strings. * @return array */ function acf_get_encoded_terms( $values ) { // vars $terms = array(); // loop over values foreach( (array) $values as $value ) { // find term from string $term = acf_get_term( $value ); // append if( $term instanceof WP_Term ) { $terms[] = $term; } } // return return $terms; } /** * acf_get_choices_from_terms * * Returns an array of choices from the terms provided. * * @date 8/9/18 * @since 5.7.5 * * @param array $values and array of WP_Terms objects or encoded strings. * @param string $format The value format (term_id, slug). * @return array */ function acf_get_choices_from_terms( $terms, $format = 'term_id' ) { // vars $groups = array(); // get taxonomy lables $labels = acf_get_taxonomy_labels(); // convert array of encoded strings to terms $term = reset($terms); if( !$term instanceof WP_Term ) { $terms = acf_get_encoded_terms( $terms ); } // loop over terms foreach( $terms as $term ) { $group = $labels[ $term->taxonomy ]; $choice = acf_get_choice_from_term( $term, $format ); $groups[ $group ][ $choice['id'] ] = $choice['text']; } // return return $groups; } /** * acf_get_choices_from_grouped_terms * * Returns an array of choices from the grouped terms provided. * * @date 8/9/18 * @since 5.7.5 * * @param array $value A grouped array of WP_Terms objects. * @param string $format The value format (term_id, slug). * @return array */ function acf_get_choices_from_grouped_terms( $value, $format = 'term_id' ) { // vars $groups = array(); // loop over values foreach( $value as $group => $terms ) { $groups[ $group ] = array(); foreach( $terms as $term_id => $term ) { $choice = acf_get_choice_from_term( $term, $format ); $groups[ $group ][ $choice['id'] ] = $choice['text']; } } // return return $groups; } /** * acf_get_choice_from_term * * Returns an array containing the id and text for this item. * * @date 10/9/18 * @since 5.7.6 * * @param object $item The item object such as WP_Post or WP_Term. * @param string $format The value format (term_id, slug) * @return array */ function acf_get_choice_from_term( $term, $format = 'term_id' ) { // vars $id = $term->term_id; $text = acf_get_term_title( $term ); // return format if( $format == 'slug' ) { $id = acf_encode_term($term); } // return return array( 'id' => $id, 'text' => $text ); } ?>cf_get_instance('ACF_Assets')->enqueue_uploader(); } ?>d, 'prepare' ); // append errors if( !empty($errors) ) { $response['acf_errors'] = implode('
', $errors); } // return return $response; } } // instantiate acf_new_instance('ACF_Media'); endif; // class_exists check ?>matches[2]; $meta_key = $matches[1] . $matches[3]; $meta_value = $row['option_value']; // update // memory usage reduced by 50% by using a manual insert vs update_metadata() function. //update_metadata( 'term', $term_id, $meta_name, $meta_value ); $wpdb->insert( $wpdb->termmeta, array( 'term_id' => $term_id, 'meta_key' => $meta_key, 'meta_value' => $meta_value )); // log acf_dev_log('ACF Upgrade 5.5.0 Term.', $term_id, $meta_key); // action do_action('acf/upgrade_550_taxonomy_term', $term_id); }} // action for 3rd party do_action('acf/upgrade_550_taxonomy', $taxonomy); } ?>