Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
litespeed_wiki:cache:lscwp:esi_replace [2017/09/24 15:43] Hai Zheng |
litespeed_wiki:cache:lscwp:esi_replace [2017/09/25 12:49] Hai Zheng |
||
---|---|---|---|
Line 4: | Line 4: | ||
In <code>caldera-forms/classes/render/nonce.php</code> line 86 <code>public static function nonce_field( $form_id )</code> is where the form nonce is generated. So to convert it to ESI, change | In <code>caldera-forms/classes/render/nonce.php</code> line 86 <code>public static function nonce_field( $form_id )</code> is where the form nonce is generated. So to convert it to ESI, change | ||
- | <syntaxhighlight lang='php'> | + | <code> |
public static function nonce_field( $form_id ){ | public static function nonce_field( $form_id ){ | ||
$nonce_field = '<input type="hidden" id="' . esc_attr( self::nonce_field_name( $form_id ) ) . '" name="' . esc_attr( self::nonce_field_name() ) . '" value="' . esc_attr( self::create_verify_nonce( $form_id ) ) . '" data-nonce-time="' . esc_attr( time() ) . '" />'; | $nonce_field = '<input type="hidden" id="' . esc_attr( self::nonce_field_name( $form_id ) ) . '" name="' . esc_attr( self::nonce_field_name() ) . '" value="' . esc_attr( self::create_verify_nonce( $form_id ) ) . '" data-nonce-time="' . esc_attr( time() ) . '" />'; | ||
Line 10: | Line 10: | ||
return $nonce_field; | return $nonce_field; | ||
} | } | ||
- | </syntaxhighlight> | + | </code> |
to | to | ||
- | <syntaxhighlight lang='php'> | + | <code> |
public static function nonce_field( $form_id, $from_esi = false ){ | public static function nonce_field( $form_id, $from_esi = false ){ | ||
Line 40: | Line 40: | ||
exit ; | exit ; | ||
} | } | ||
- | </syntaxhighlight> | + | </code> |
Then go to <code>caldera-forms/classes/core.php</code>, in <code>function __construct()</code> line 146 or other preferred position, add this: | Then go to <code>caldera-forms/classes/core.php</code>, in <code>function __construct()</code> line 146 or other preferred position, add this: | ||
- | <syntaxhighlight lang='php'> | + | <code> |
if ( method_exists( 'LiteSpeed_Cache_API', 'esi_enabled' ) && LiteSpeed_Cache_API::esi_enabled() ) { | if ( method_exists( 'LiteSpeed_Cache_API', 'esi_enabled' ) && LiteSpeed_Cache_API::esi_enabled() ) { | ||
LiteSpeed_Cache_API::hook_tpl_esi( 'caldera_forms', 'Caldera_Forms_Render_Nonce::hook_esi' ); | LiteSpeed_Cache_API::hook_tpl_esi( 'caldera_forms', 'Caldera_Forms_Render_Nonce::hook_esi' ); | ||
} | } | ||
- | </syntaxhighlight> | + | </code> |
Now **Caldera Forms** can be perfectly cached with ESI on. | Now **Caldera Forms** can be perfectly cached with ESI on. |