acf/settings

Overview

This filter allows you to modify ACF settings which are used throughout the plugin.

Changelog

  • Added in v5.0.0

Settings

Name Type Added Description
path string 5.0.0 Absolute path to ACF plugin folder including trailing slash. Defaults to plugin_dir_path
dir string 5.0.0 URL to ACF plugin folder including trailing slash. Defaults to plugin_dir_url
show_admin boolean 5.0.0 Show/hide ACF menu item. Defaults to true
stripslashes boolean 5.0.0 Runs the function stripslashes on all $_POST data. Some servers / WP instals may require this extra functioanlity. Defaults to false
local boolean 5.0.0 Enable/Disable local (PHP/json) fields. Defaults to true
json boolean 5.0.0 Enable/Disable json fields. Defaults to true
save_json sring 5.0.0 Absolute path to folder where json files will be created when field groups are saved. Defaults to ‘acf-json’ folder within current theme
load_json array 5.0.0 Array of absolutes paths to folders where field group json files can be read. Defaults to an array containing at index 0, the ‘acf-json’ folder within current theme
default_language string 5.0.0 Language code of the default language. Defaults to ”. If WPML is active, ACF will default this to the WPML default language setting
current_language string 5.0.0 Language code of the current post’s language. Defaults to ”. If WPML is active, ACF will default this to the WPML current language
capability string 5.1.9 Capability used for ACF post types and if the current user can see the ACF menu item. Defaults to ‘manage_options’.
show_updates boolean 5.2.2 Enable/Disable updates to appear in plugin list and show/hide the ACF updates admin page. Defaults to true.
export_textdomain string 5.2.9 Used during the ‘Export to PHP’ feature to wrap strings within the __() function. Depreciated in v5.4.4 – please see l10n_textdomain
export_translate array 5.3.2 Array of keys used during the ‘Export to PHP’ feature to wrap strings within the __() function. Defaults to array('title', 'label', 'instructions'). Depreciated in v5.3.4 – please see l10n_field and l10n_field_group
l10n boolean 5.3.4 Allows ACF to translate field and field group settings using the __() function. Defaults to true. Useful to override translation without modifying the textdomain
l10n_textdomain string 5.3.4 Sets the text domain used when translating field and field group settings. Defaults to ”. Strings will not be translated if this setting is empty
l10n_field array 5.3.4 An array of settings to translate when loading and exporting a field. Defaults to array('label', 'instructions'). Depreciated in v5.3.6 – please see acf/translate_field filter
l10n_field_group array 5.3.4 An array of settings to translate when loading and exporting a field group. Defaults to array('title'). Depreciated in v5.3.6 – please see acf/translate_field_group filter
google_api_key string 5.4.0 Specify a Google Maps API authentication key to prevent usage limits. Defaults to ”
google_api_client string 5.4.0 Specify a Google Maps API Client ID to prevent usage limits. Not needed if using google_api_key. Defaults to ”
enqueue_google_maps boolean 5.5.0 Allows ACF to enqueue and load the Google Maps API JS library. Defaults to true
enqueue_select2 boolean 5.5.0 Allows ACF to enqueue and load the Select2 JS/CSS library. Defaults to true
select2_version numeric 5.5.0 Defines which version of Select2 library to enqueue. Either 3 or 4. Defaults to 3
enqueue_datepicker boolean 5.5.0 Allows ACF to enqueue and load the WP datepicker JS/CSS library. Defaults to true
enqueue_datetimepicker boolean 5.5.0 Allows ACF to enqueue and load the datetimepicker JS/CSS library. Defaults to true
row_index_offset numeric 5.5.6 Defines the starting index used in all ‘loop’ and ‘row’ functions. Defaults to 1 (1 is the first row), can be changed to 0 (0 is the first row)

Usage

Filter

Each setting can be modified by it’s own filter ("acf/settings/{$name}") and are listed above.

functions.php

function my_acf_settings_path( $path ) {

    return get_stylesheet_directory() . '/acf/';

}

add_filter('acf/settings/path', 'my_acf_settings_path');

Function

Each setting can also be set using the function acf_update_setting(). This function is best used during the acf/init action.

functions.php

function my_acf_init() {
	
	acf_update_setting('show_admin', false);
	acf_update_setting('google_api_key', 'xxx');
	
}

add_action('acf/init', 'my_acf_init');

Related

Hi all. Server maintenance scheduled this Sunday 28th May. Learn more