self::$_post_id, ]; $inline_tags = [ '', rtrim( Tag::TYPE_ESI, '.' ), Tag::TYPE_ESI . 'yith_wcwl_add' ]; $inline_tags = implode( ',', array_map( function ( $val ) { return 'public:' . LSWCP_TAG_PREFIX . '_' . $val; }, $inline_tags ) ); $inline_tags .= ',' . LSWCP_TAG_PREFIX . '_tag_priv'; do_action( 'litespeed_esi_combine', 'yith_wcwl_add' ); $inline_params = [ 'val' => $template, 'tag' => $inline_tags, 'control' => 'private,no-vary,max-age=' . Conf::cls()->conf( Base::O_CACHE_TTL_PRIV ), ]; return apply_filters( 'litespeed_esi_url', 'yith_wcwl_add', 'YITH ADD TO WISHLIST', $params, 'private,no-vary', false, false, false, $inline_params ); } /** * Load the add to wishlist button HTML for ESI output. * * @since 1.1.0 * * @param array $params ESI parameters, expects product id under ESI_PARAM_POSTID. * @return void */ public static function load_add_to_wishlist( $params ) { $pid = isset( $params[ self::ESI_PARAM_POSTID ] ) ? (int) $params[ self::ESI_PARAM_POSTID ] : 0; // Output the rendered shortcode safely. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- wp_kses_post handles allowed HTML. echo wp_kses_post( \YITH_WCWL_Shortcode::add_to_wishlist( [ 'product_id' => $pid ] ) ); do_action( 'litespeed_control_set_private', 'yith wishlist' ); do_action( 'litespeed_vary_no' ); } /** * Generate ESI inline value. * * @since 3.4.2 * * @param mixed $res Current response (array or anything); will be normalized to array. * @param array $params ESI parameters that include product id. * @return array Inline ESI payload with value, control and tags. */ public static function inline_add_to_wishlist( $res, $params ) { if ( ! is_array( $res ) ) { $res = []; } $pid = isset( $params[ self::ESI_PARAM_POSTID ] ) ? (int) $params[ self::ESI_PARAM_POSTID ] : 0; $res['val'] = \YITH_WCWL_Shortcode::add_to_wishlist( [ 'product_id' => $pid ] ); $res['control'] = 'private,no-vary,max-age=' . Conf::cls()->conf( Base::O_CACHE_TTL_PRIV ); $inline_tags = [ '', rtrim( Tag::TYPE_ESI, '.' ), Tag::TYPE_ESI . 'yith_wcwl_add' ]; $inline_tags = implode( ',', array_map( function ( $val ) { return 'public:' . LSWCP_TAG_PREFIX . '_' . $val; }, $inline_tags ) ); $inline_tags .= ',' . LSWCP_TAG_PREFIX . '_tag_priv'; $res['tag'] = $inline_tags; return $res; } }