Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
litespeed_wiki:cache:lscwp:esi_replace [2017/09/25 12:49] Hai Zheng |
litespeed_wiki:cache:lscwp:esi_replace [2017/10/02 14:33] Hai Zheng |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | Note: LiteSpeed WordPress Cache plugin needs to be v1.2.4+. | + | Note: LiteSpeed WordPress Cache plugin needs to be v1.3+. |
Let's take **Caldera Forms Version 1.5.6.1** as the example. | Let's take **Caldera Forms Version 1.5.6.1** as the example. | ||
- | 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 php>public static function nonce_field( $form_id )</code> is where the form nonce is generated. So to convert it to ESI, change |
- | <code> | + | <code php> |
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 14: | Line 14: | ||
to | to | ||
- | <code> | + | <code php> |
public static function nonce_field( $form_id, $from_esi = false ){ | public static function nonce_field( $form_id, $from_esi = false ){ | ||
if ( ! $from_esi ) { | if ( ! $from_esi ) { | ||
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() ) { | ||
- | if ( method_exists( 'LiteSpeed_Cache_API', 'v' ) && LiteSpeed_Cache_API::v( '1.2.4' ) ) { | + | if ( method_exists( 'LiteSpeed_Cache_API', 'v' ) && LiteSpeed_Cache_API::v( '1.3' ) ) { |
$params = array( 'form_id' => $form_id ) ; | $params = array( 'form_id' => $form_id ) ; | ||
return LiteSpeed_Cache_API::esi_url( 'caldera_forms', 'Caldera Forms', $params ) ; | return LiteSpeed_Cache_API::esi_url( 'caldera_forms', 'Caldera Forms', $params ) ; | ||
Line 42: | Line 42: | ||
</code> | </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 php>function __construct()</code> line 146 or other preferred position, add this: |
- | <code> | + | <code php> |
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' ); |