WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

acf_admin_field_group::save_post() public ACF 1.0.0

This function will save all the field group data

{} Это метод класса: acf_admin_field_group{}

Хуков нет.

Возвращает

$post_id. (int)

Использование

$acf_admin_field_group = new acf_admin_field_group();
$acf_admin_field_group->save_post( $post_id, $post );
$post_id (обязательный)
-
$post (обязательный)
-

Список изменений

С версии 1.0.0 Введена.

Код acf_admin_field_group::save_post() ACF 5.9.1

<?php
function save_post( $post_id, $post ) {
	
	// do not save if this is an auto save routine
	if( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
		return $post_id;
	}
	
	// bail early if not acf-field-group
	if( $post->post_type !== 'acf-field-group' ) {
		return $post_id;
	}
	
	// only save once! WordPress save's a revision as well.
	if( wp_is_post_revision($post_id) ) {
    	return $post_id;
        }
        
	// verify nonce
	if( !acf_verify_nonce('field_group') ) {
		return $post_id;
	}
        
        // Bail early if request came from an unauthorised user.
	if( !current_user_can(acf_get_setting('capability')) ) {
		return $post_id;
	}
	
	
        // disable filters to ensure ACF loads raw data from DB
	acf_disable_filters();
	
	
        // save fields
        if( !empty($_POST['acf_fields']) ) {
		
		// loop
		foreach( $_POST['acf_fields'] as $field ) {
			
			// vars
			$specific = false;
			$save = acf_extract_var( $field, 'save' );
			
			
			// only saved field if has changed
			if( $save == 'meta' ) {
				$specific = array(
					'menu_order',
					'post_parent',
				);
			}
			
			// set parent
			if( !$field['parent'] ) {
				$field['parent'] = $post_id;
			}
			
			// save field
			acf_update_field( $field, $specific );
			
		}
	}
	
	
	// delete fields
        if( $_POST['_acf_delete_fields'] ) {
        	
        	// clean
    	$ids = explode('|', $_POST['_acf_delete_fields']);
    	$ids = array_map( 'intval', $ids );
    	
    	
    	// loop
		foreach( $ids as $id ) {
			
			// bai early if no id
			if( !$id ) continue;
			
			
			// delete
			acf_delete_field( $id );
			
		}
		
        }
	
	
	// add args
        $_POST['acf_field_group']['ID'] = $post_id;
        $_POST['acf_field_group']['title'] = $_POST['post_title'];
        
        
	// save field group
        acf_update_field_group( $_POST['acf_field_group'] );
	
	
        // return
        return $post_id;
}