Add constant for fast requests
This commit is contained in:
parent
52de93549c
commit
3b247122a0
@ -1490,4 +1490,5 @@ define( 'CONSTANT_NAME', value );
|
||||
| FICTIONEER_ENABLE_BROWSER_NOTES | boolean | Whether to inform visitors of missing browser features. Default `false`.
|
||||
| FICTIONEER_DEFER_SCRIPTS | boolean | Whether to defer scripts or load them in the footer. Default `true`.
|
||||
| FICTIONEER_ENABLE_ASYNC_ONLOAD_PATTERN | boolean | Whether the [onload pattern](https://www.filamentgroup.com/lab/load-css-simpler/) for asynchronous CSS loading is used. Default `true`.
|
||||
| FICTIONEER_FAST_REQUESTS | boolean | Whether to enable exiting early for fast AJAX request. Default `true`.
|
||||
| FICTIONEER_EXAMPLE_CHAPTER_ICONS | array | Collection of example Font Awesome icon class strings.
|
||||
|
@ -396,6 +396,11 @@ if ( ! defined( 'FICTIONEER_ENABLE_ASYNC_ONLOAD_PATTERN' ) ) {
|
||||
define( 'FICTIONEER_ENABLE_ASYNC_ONLOAD_PATTERN', true );
|
||||
}
|
||||
|
||||
// Boolean: Asynchronous loading via onload pattern
|
||||
if ( ! defined( 'FICTIONEER_FAST_REQUESTS' ) ) {
|
||||
define( 'FICTIONEER_FAST_REQUESTS', true );
|
||||
}
|
||||
|
||||
/*
|
||||
* Arrays
|
||||
*/
|
||||
|
@ -1380,6 +1380,10 @@ add_filter( 'block_editor_settings_all', 'fictioneer_disable_font_library' );
|
||||
/**
|
||||
* Accelerate AJAX requests by exiting early
|
||||
*
|
||||
* Note: Requests are validated with fictioneer_get_validated_ajax_user(),
|
||||
* making sure that AJAX functions without "_nopriv" are not executed for
|
||||
* unauthenticated users.
|
||||
*
|
||||
* @since 5.15.3
|
||||
*/
|
||||
|
||||
@ -1437,6 +1441,12 @@ function fictioneer_fast_ajax() {
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['fcn_fast_ajax'] ) || isset( $_REQUEST['fcn_fast_comment_ajax'] ) ) {
|
||||
if (
|
||||
FICTIONEER_FAST_REQUESTS &&
|
||||
(
|
||||
isset( $_REQUEST['fcn_fast_ajax'] ) ||
|
||||
isset( $_REQUEST['fcn_fast_comment_ajax'] )
|
||||
)
|
||||
) {
|
||||
add_action( 'init', 'fictioneer_fast_ajax', 99999 );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user