acf_sync_import_json_folder

The ACF Pro JSON Sync acf sync import json folder function.

Description

acf_sync_import_json_folder(); 

Usage

  1. if ( !function_exists( 'acf_sync_import_json_folder' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'acf-pro-json-sync/acf-sync.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = acf_sync_import_json_folder(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/acf-sync.php  
  1. function acf_sync_import_json_folder() { 
  2. // tell ACF NOT to save to JSON 
  3.  
  4.  
  5. // Remove previous field groups in DB 
  6. $args = array( 
  7. 'post_type' => 'acf-field-group',  
  8. 'post_status' => 'any',  
  9. 'posts_per_page' => -1 
  10. ); 
  11.  
  12. $query = new WP_Query( $args ); 
  13.  
  14. foreach ( $query->posts as $acf_group ) { 
  15. wp_delete_post( $acf_group->ID, true); 
  16.  
  17. //Get all json save points 
  18. $json_dirs = acf_get_setting('load_json'); 
  19.  
  20. foreach ( $json_dirs as $dir ) { 
  21.