esc_html__( 'An unexpected error occurred. Please refresh the page and try again.', 'easy-digital-downloads' ), 'isConnected' => PayPal\has_rest_api_connection(), ) ); } } add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\enqueue_connect_scripts' ); /** * Forces the Cache-Control header on the PayPal Commerce settings page to send the no-store header * which prevents the back-forward cache (bfcache) from storing a copy of this page in local * cache. This helps make sure that page elements modified via AJAX and DOM manipulations aren't * incorrectly shown as if they never changed. * * See: https://github.com/easydigitaldownloads/EDD-Software-Licensing/issues/1346#issuecomment-382159918 * * @since 3.6 * @param array $headers An array of nocache headers. * * @return array */ function _bfcache_buster( $headers ) { if ( ! is_admin() ) { return $headers; } if ( edd_is_admin_page( 'settings' ) && isset( $_GET['section'] ) && 'paypal_commerce' === $_GET['section'] ) { /* phpcs:ignore WordPress.Security.NonceVerification.Recommended */ $headers['Cache-Control'] = 'no-cache, must-revalidate, max-age=0, no-store'; } return $headers; } add_filter( 'nocache_headers', __NAMESPACE__ . '\_bfcache_buster', 10, 1 );