ACF_Local_JSON::maybe_show_save_failure_noticepublicACF 6.8.1

Adds an admin notice when a Local JSON save failure is present in the request.

Method of the class: ACF_Local_JSON{}

No Hooks.

Returns

null. Nothing (null).

Usage

$ACF_Local_JSON = new ACF_Local_JSON();
$ACF_Local_JSON->maybe_show_save_failure_notice( $current_screen );
$current_screen(WP_Screen) (required)
The current WP_Screen object.

Changelog

Since 6.8.1 Introduced.

ACF_Local_JSON::maybe_show_save_failure_notice() code ACF 6.8.8

public function maybe_show_save_failure_notice( $current_screen ) {
	if ( ! acf_maybe_get_GET( 'acf_local_json_save_failed', false ) ) {
		return;
	}

	if ( empty( $current_screen->post_type ) || ! in_array( $current_screen->post_type, acf_get_internal_post_types(), true ) ) {
		return;
	}

	// Match the capability used by ACF internal post type save handlers.
	if ( ! current_user_can( acf_get_setting( 'capability' ) ) ) {
		return;
	}

	acf_add_admin_notice(
		__( 'ACF saved your changes to the database, but could not update the Local JSON file. Check that the configured Local JSON save path is writable.', 'acf' ),
		'warning'
	);
}