Skip to content

Commit

Permalink
3rd: WooCommerce PayPal Checkout Gateway compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-hai committed Mar 29, 2020
1 parent e13ac3d commit 9cc0021
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 30 deletions.
3 changes: 2 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ Click on the `Advanced View` link at the top of the page, and several more tabs
* New API: iframe lazyload exclude filter.
* Avoid crawler PHP fatal error on Windows OS. (@technisolutions)
* **GUI** human readable seconds. (@MarkCanada)
* **3rd** Default added parallax-image to webp replacement for BB.
* API refactored. * NOTE: All 3rd party plugins that are using previous APIs, especially `LiteSpeed_Cache_API`, need to be adjusted to the latest one. Same for ESI blocks.* ESI shortcode doesn't change.
* **API** New hook `litespeed_update_confs` to settings update.
* **API** New Hooks `litespeed_frontend_shortcut` and `litespeed_backend_shortcut` for dropdown menu. (@callaloo)
Expand All @@ -384,9 +383,11 @@ Click on the `Advanced View` link at the top of the page, and several more tabs
* Code base refactored. New namespace LiteSpeed.
* GUI refactored.
* **Debug** Report can now append notes.
* **3rd** Default added parallax-image to webp replacement for BB.
* **3rd** User Switching plugin compatibility. (@robert Staddon)
* **3rd** Beaver Builder plugin compatibility with v3.0.0.
* **3rd** Avada plugin compatibility w/ BBPress. (@pimg)
* **3rd** WooCommerce PayPal Checkout Gateway compatibility.
* **Network** Fixed potential timeout issue when containing a large volume of sites. (@alican532)
* **Debug** `Disable All Features` now will see the warning banner if ON.
* **Debug** Dropped `log filters` section.
Expand Down
58 changes: 29 additions & 29 deletions src/api.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,65 +60,65 @@ public function init()
/**
* Init
*/
// API::hook_init( $hook ) -> Action `litespeed_init`
// Action `litespeed_init` // @previous API::hook_init( $hook )

/**
* Conf
*/
add_filter( 'litespeed_conf', __NAMESPACE__ . '\Conf::val' ); // API::config($id) -> Filter `litespeed_conf`
// API::conf_append( $name, $default ) -> Action `litespeed_conf_append`
add_filter( 'litespeed_conf', __NAMESPACE__ . '\Conf::val' ); // @previous API::config($id)
// Action `litespeed_conf_append` // @previous API::conf_append( $name, $default )
add_action( 'litespeed_conf_multi_switch', __NAMESPACE__ . '\Base::set_multi_switch', 10, 2 );
// API::force_option( $k, $v ) -> Action ``litespeed_conf_force`
// Action ``litespeed_conf_force` // @previous API::force_option( $k, $v )

/**
* Cache Control Hooks
*/
// API::hook_control($tags) && action `litespeed_api_control` -> Action `litespeed_control_finalize`
add_action( 'litespeed_control_set_private', __NAMESPACE__ . '\Control::set_private' ); // API::set_cache_private() -> Action `litespeed_control_set_private`
add_action( 'litespeed_control_set_nocache', __NAMESPACE__ . '\Control::set_nocache' ); // API::set_nocache( $reason = false ) -> Action `litespeed_control_set_nocache`
add_action( 'litespeed_control_set_cacheable', __NAMESPACE__ . '\Control::set_cacheable' ); // API::set_cacheable( $reason ) -> Action `litespeed_control_set_cacheable` // Might needed if not call hook `wp`
add_action( 'litespeed_control_force_cacheable', __NAMESPACE__ . '\Control::force_cacheable' ); // API::set_force_cacheable( $reason ) -> Action `litespeed_control_force_cacheable` // Set cache status to force cacheable ( Will ignore most kinds of non-cacheable conditions )
add_action( 'litespeed_control_force_public', __NAMESPACE__ . '\Control::set_public_forced' ); // API::set_force_public( $reason ) -> Action `litespeed_control_force_public` // Set cache to force public cache if cacheable ( Will ignore most kinds of non-cacheable conditions )
add_filter( 'litespeed_control_cacheable', __NAMESPACE__ . '\Control::is_cacheable', 3 ); // API::not_cacheable() -> Filter `litespeed_control_cacheable` // Note: Read-Only. Directly append to this filter won't work. Call actions above to set cacheable or not
add_action( 'litespeed_control_set_ttl', __NAMESPACE__ . '\Control::set_custom_ttl', 10, 2 ); // API::set_ttl( $val ) -> Action `litespeed_control_set_ttl`
add_filter( 'litespeed_control_ttl', __NAMESPACE__ . '\Control::get_ttl', 3 ); // API::get_ttl() -> Filter `litespeed_control_ttl`
// Action `litespeed_control_finalize` // @previous API::hook_control($tags) && action `litespeed_api_control`
add_action( 'litespeed_control_set_private', __NAMESPACE__ . '\Control::set_private' ); // @previous API::set_cache_private()
add_action( 'litespeed_control_set_nocache', __NAMESPACE__ . '\Control::set_nocache' ); // @previous API::set_nocache( $reason = false )
add_action( 'litespeed_control_set_cacheable', __NAMESPACE__ . '\Control::set_cacheable' ); // Might needed if not call hook `wp` // @previous API::set_cacheable( $reason )
add_action( 'litespeed_control_force_cacheable', __NAMESPACE__ . '\Control::force_cacheable' ); // Set cache status to force cacheable ( Will ignore most kinds of non-cacheable conditions ) // @previous API::set_force_cacheable( $reason )
add_action( 'litespeed_control_force_public', __NAMESPACE__ . '\Control::set_public_forced' ); // Set cache to force public cache if cacheable ( Will ignore most kinds of non-cacheable conditions ) // @previous API::set_force_public( $reason )
add_filter( 'litespeed_control_cacheable', __NAMESPACE__ . '\Control::is_cacheable', 3 ); // Note: Read-Only. Directly append to this filter won't work. Call actions above to set cacheable or not // @previous API::not_cacheable()
add_action( 'litespeed_control_set_ttl', __NAMESPACE__ . '\Control::set_custom_ttl', 10, 2 ); // @previous API::set_ttl( $val )
add_filter( 'litespeed_control_ttl', __NAMESPACE__ . '\Control::get_ttl', 3 ); // @previous API::get_ttl()

/**
* Tag Hooks
*/
// API::hook_tag( $hook ) -> Action `litespeed_tag_finalize`
add_action( 'litespeed_tag_add', __NAMESPACE__ . '\Tag::add' ); // API::tag_add( $tag ) -> Action `litespeed_tag_add`
// Action `litespeed_tag_finalize` // @previous API::hook_tag( $hook )
add_action( 'litespeed_tag_add', __NAMESPACE__ . '\Tag::add' ); // @previous API::tag_add( $tag )
add_action( 'litespeed_tag_add_post', __NAMESPACE__ . '\Tag::add_post' );
add_action( 'litespeed_tag_add_widget', __NAMESPACE__ . '\Tag::add_widget' );
add_action( 'litespeed_tag_add_private', __NAMESPACE__ . '\Tag::add_private' ); // API::tag_add_private( $tags ) -> Action `litespeed_tag_add_private`
add_action( 'litespeed_tag_add_private', __NAMESPACE__ . '\Tag::add_private' ); // @previous API::tag_add_private( $tags )
add_action( 'litespeed_tag_add_private_esi', __NAMESPACE__ . '\Tag::add_private_esi' );

/**
* Purge Hooks
*/
// API::hook_purge($tags) -> Action `litespeed_purge_finalize`
add_action( 'litespeed_purge', __NAMESPACE__ . '\Purge::add' ); // API::purge($tags) -> Action `litespeed_purge`
// Action `litespeed_purge_finalize` // @previous API::hook_purge($tags)
add_action( 'litespeed_purge', __NAMESPACE__ . '\Purge::add' ); // @previous API::purge($tags)
add_action( 'litespeed_purge_all', __NAMESPACE__ . '\Purge::purge_all' );
add_action( 'litespeed_purge_post', __NAMESPACE__ . '\Purge::purge_post' ); // API::purge_post( $pid ) -> Action `litespeed_purge_post`
add_action( 'litespeed_purge_post', __NAMESPACE__ . '\Purge::purge_post' ); // @previous API::purge_post( $pid )
add_action( 'litespeed_purge_posttype', __NAMESPACE__ . '\Purge::purge_posttype' );
add_action( 'litespeed_purge_url', __NAMESPACE__ . '\Purge::purge_url' );
add_action( 'litespeed_purge_widget', __NAMESPACE__ . '\Purge::purge_widget' );
add_action( 'litespeed_purge_esi', __NAMESPACE__ . '\Purge::purge_esi' );
add_action( 'litespeed_purge_private', __NAMESPACE__ . '\Purge::add_private' ); // API::purge_private( $tags ) -> Action `litespeed_purge_private`
add_action( 'litespeed_purge_private', __NAMESPACE__ . '\Purge::add_private' ); // @previous API::purge_private( $tags )
add_action( 'litespeed_purge_private_esi', __NAMESPACE__ . '\Purge::add_private_esi' );
add_action( 'litespeed_purge_private_all', __NAMESPACE__ . '\Purge::add_private_all' ); // API::purge_private_all() -> Action `litespeed_purge_private_all`
// API::hook_purge_post($hook) -> Action `litespeed_api_purge_post` // Triggered when purge a post
add_action( 'litespeed_purge_private_all', __NAMESPACE__ . '\Purge::add_private_all' ); // @previous API::purge_private_all()
// Action `litespeed_api_purge_post` // Triggered when purge a post // @previous API::hook_purge_post($hook)

/**
* ESI
*/
// API::nonce_action( $action ) & API::nonce( $action = -1, $defence_for_html_filter = true ) -> Action `litespeed_nonce`
add_filter( 'litespeed_esi_status', __NAMESPACE__ . '\Router::esi_enabled' ); // API::esi_enabled() -> Filter `litespeed_esi_status` // Get ESI enable status
add_filter( 'litespeed_esi_url', __NAMESPACE__ . '\ESI::sub_esi_block', 10, 8 ); // API::esi_url( $block_id, $wrapper, $params = array(), $control = 'private,no-vary', $silence = false, $preserved = false, $svar = false, $inline_val = false ) // Generate ESI block url
// API::hook_widget_default_options( $hook ) -> Filter `litespeed_widget_default_options` // Hook widget default settings value. Currently used in Woo 3rd
// API::hook_esi_param( $hook ) -> Filter `litespeed_esi_params`
// API::hook_tpl_not_esi($hook) && Action `litespeed_is_not_esi_template` -> Action `litespeed_tpl_normal`
// API::hook_tpl_esi($block, $hook) -> Action `litespeed_esi_block-$block` // add_action( 'litespeed_esi_load-' . $block, $hook )
// Action `litespeed_nonce` // @previous API::nonce_action( $action ) & API::nonce( $action = -1, $defence_for_html_filter = true )
add_filter( 'litespeed_esi_status', __NAMESPACE__ . '\Router::esi_enabled' ); // Get ESI enable status // @previous API::esi_enabled()
add_filter( 'litespeed_esi_url', __NAMESPACE__ . '\ESI::sub_esi_block', 10, 8 ); // Generate ESI block url // @previous API::esi_url( $block_id, $wrapper, $params = array(), $control = 'private,no-vary', $silence = false, $preserved = false, $svar = false, $inline_val = false )
// Filter `litespeed_widget_default_options` // Hook widget default settings value. Currently used in Woo 3rd // @previous API::hook_widget_default_options( $hook )
// Filter `litespeed_esi_params` // @previous API::hook_esi_param( $hook )
// Action `litespeed_tpl_normal` // @previous API::hook_tpl_not_esi($hook) && Action `litespeed_is_not_esi_template`
// Action `litespeed_esi_block-$block` // @usage add_action( 'litespeed_esi_load-' . $block, $hook ) // @previous API::hook_tpl_esi($block, $hook)

/**
* Vary
Expand Down
1 change: 1 addition & 0 deletions thirdparty/entry.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
'User_Switching',
'WCML',
'WooCommerce',
'Woo_Paypal',
'Wp_Polls',
'WP_PostRatings',
'Wpdiscuz',
Expand Down
21 changes: 21 additions & 0 deletions thirdparty/woo-paypal.cls.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* The Third Party integration with WooCommerce PayPal Checkout Gateway
* @ref https://wordpress.org/plugins/woocommerce-gateway-paypal-express-checkout/
*
* @since 3.0
*/
namespace LiteSpeed\Thirdparty;
defined( 'WPINC' ) || exit;

class Woo_Paypal
{
public static function detect()
{
if ( ! defined( 'WC_GATEWAY_PPEC_VERSION' ) ) return;

do_action( 'litespeed_nonce', '_wc_ppec_update_shipping_costs_nonce private' );
do_action( 'litespeed_nonce', '_wc_ppec_start_checkout_nonce private' );
do_action( 'litespeed_nonce', '_wc_ppec_generate_cart_nonce private' );
}
}

0 comments on commit 9cc0021

Please sign in to comment.