Files added to the
/private directory are not web accessible, but can be accessed by an application’s theme, plugins, or CLI commands.
/private directory can be used for storing files that contain secrets or settings that are useful to application code, but should not be accessible to public traffic.
Paths to files in the
/private directory must be referenced in code with the VIP constant
WPCOM_VIP_PRIVATE_DIR. For the
WPCOM_VIP_PRIVATE_DIR constant to be available and work as expected, WordPress must already be loaded. For this reason, the
WPCOM_VIP_PRIVATE_DIR constant should be used within theme or plugin code but not a file such as
vip-config.php. Most of WordPress is not available when
vip-config.php is loaded.
In this code example, a file named
sites.json that has been added to
/private is referenced in a theme’s
file_get_contents( WPCOM_VIP_PRIVATE_DIR . '/sites.json' );
Last updated: December 22, 2023