r no benefit.
*/
$inner_block_offsets = array();
$collect_offsets = ! empty( $computed_attributes );
if ( ! $options['dynamic'] || empty( $this->block_type->skip_inner_blocks ) ) {
$index = 0;
foreach ( $this->inner_content as $chunk ) {
if ( is_string( $chunk ) ) {
$block_content .= $chunk;
} else {
if ( $collect_offsets ) {
$inner_block_offsets[] = strlen( $block_content );
}
$inner_block = $this->inner_blocks[ $index ];
$parent_block = $this;
/** This filter is documented in wp-includes/blocks.php */
$pre_render = apply_filters( 'pre_render_block', null, $inner_block->parsed_block, $parent_block );
if ( ! is_null( $pre_render ) ) {
$block_content .= $pre_render;
} else {
$source_block = $inner_block->parsed_block;
$inner_block_context = $inner_block->context;
/** This filter is documented in wp-includes/blocks.php */
$inner_block->parsed_block = apply_filters( 'render_block_data', $inner_block->parsed_block, $source_block, $parent_block );
/** This filter is documented in wp-includes/blocks.php */
$inner_block->context = apply_filters( 'render_block_context', $inner_block->context, $inner_block->parsed_block, $parent_block );
/*
* The `refresh_context_dependents()` method already calls `refresh_parsed_block_dependents()`.
* Therefore the second condition is irrelevant if the first one is satisfied.
*/
if ( $inner_block->context !== $inner_block_context ) {
$inner_block->refresh_context_dependents();
} elseif ( $inner_block->parsed_block !== $source_block ) {
$inner_block->refresh_parsed_block_dependents();
}
$block_content .= $inner_block->render();
}
++$index;
}
}
}
if ( ! empty( $computed_attributes ) && ! empty( $block_content ) ) {
foreach ( $computed_attributes as $attribute_name => $source_value ) {
$updated_block_content = $this->replace_html( $block_content, $attribute_name, $source_value, $inner_block_offsets );
/*
* The offsets describe $block_content as it was assembled. A
* replacement that modifies the markup shifts byte positions, so
* once the content changes the remaining attributes fall back to
* offset-free replacement rather than clamp at a stale position.
* Attributes that leave the markup untouched keep the offsets
* valid: the computed `metadata` attribute produced by a pattern
* overrides `__default` binding has no HTML source, so it must
* not invalidate the offsets for the rich text that follows it.
*/
if ( $updated_block_content !== $block_content ) {
$inner_block_offsets = array();
}
$block_content = $updated_block_content;
}
}
if ( $is_dynamic ) {
$global_post = $post;
$parent = WP_Block_Supports::$block_to_render;
WP_Block_Supports::$block_to_render = $this->parsed_block;
$block_content = (string) call_user_func( $this->block_type->render_callback, $this->attributes, $block_content, $this );
WP_Block_Supports::$block_to_render = $parent;
$post = $global_post;
}
if ( ( ! empty( $this->block_type->script_handles ) ) ) {
foreach ( $this->block_type->script_handles as $script_handle ) {
wp_enqueue_script( $script_handle );
}
}
if ( ! empty( $this->block_type->view_script_handles ) ) {
foreach ( $this->block_type->view_script_handles as $view_script_handle ) {
wp_enqueue_script( $view_script_handle );
}
}
if ( ! empty( $this->block_type->view_script_module_ids ) ) {
foreach ( $this->block_type->view_script_module_ids as $view_script_module_id ) {
wp_enqueue_script_module( $view_script_module_id );
}
}
/*
* For Core blocks, these styles are only enqueued if `wp_should_load_separate_core_block_assets()` returns
* true. Otherwise these `wp_enqueue_style()` calls will not have any effect, as the Core blocks are relying on
* the combined 'wp-block-library' stylesheet instead, which is unconditionally enqueued.
*/
if ( ( ! empty( $this->block_type->style_handles ) ) ) {
foreach ( $this->block_type->style_handles as $style_handle ) {
wp_enqueue_style( $style_handle );
}
}
if ( ( ! empty( $this->block_type->view_style_handles ) ) ) {
foreach ( $this->block_type->view_style_handles as $view_style_handle ) {
wp_enqueue_style( $view_style_handle );
}
}
/**
* Filters the content of a single block.
*
* @since 5.0.0
* @since 5.9.0 The `$instance` parameter was added.
*
* @param string $block_content The block content.
* @param array $block The full block, including name and attributes.
* @param WP_Block $instance The block instance.
*/
$block_content = apply_filters( 'render_block', $block_content, $this->parsed_block, $this );
/**
* Filters the content of a single block.
*
* The dynamic portion of the hook name, `$name`, refers to
* the block name, e.g. "core/paragraph".
*
* @since 5.7.0
* @since 5.9.0 The `$instance` parameter was added.
*
* @param string $block_content The block content.
* @param array $block The full block, including name and attributes.
* @param WP_Block $instance The block instance.
*/
$block_content = apply_filters( "render_block_{$this->name}", $block_content, $this->parsed_block, $this );
if ( $root_interactive_block === $this ) {
// The root interactive block has finished rendering. Time to process directives.
$block_content = wp_interactivity_process_directives( $block_content );
$root_interactive_block = null;
}
// Capture the new assets enqueued during rendering, and restore the queues the state prior to rendering.
$after_styles_queue = wp_styles()->queue;
$after_scripts_queue = wp_scripts()->queue;
$after_script_modules_queue = wp_script_modules()->get_queue();
/*
* As a very special case, a dynamic block may in fact include a call to wp_head() (and thus wp_enqueue_scripts()),
* in which all of its enqueued assets are targeting wp_footer. In this case, nothing would be printed, but this
* shouldn't indicate that the just-enqueued assets should be dequeued due to it being an empty block.
*/
$just_did_wp_enqueue_scripts = ( did_action( 'wp_enqueue_scripts' ) !== $before_wp_enqueue_scripts_count );
$has_new_styles = ( $before_styles_queue !== $after_styles_queue );
$has_new_scripts = ( $before_scripts_queue !== $after_scripts_queue );
$has_new_script_modules = ( $before_script_modules_queue !== $after_script_modules_queue );
// Dequeue the newly enqueued assets with the existing assets if the rendered block was empty & wp_enqueue_scripts did not fire.
if (
! $just_did_wp_enqueue_scripts &&
( $has_new_styles || $has_new_scripts || $has_new_script_modules ) &&
(
trim( $block_content ) === '' &&
/**
* Filters whether to enqueue assets for a block which has no rendered content.
*
* @since 6.9.0
*
* @param bool $enqueue Whether to enqueue assets.
* @param string $block_name Block name.
*/
! (bool) apply_filters( 'enqueue_empty_block_content_assets', false, $this->name )
)
) {
foreach ( array_diff( $after_styles_queue, $before_styles_queue ) as $handle ) {
wp_dequeue_style( $handle );
}
foreach ( array_diff( $after_scripts_queue, $before_scripts_queue ) as $handle ) {
wp_dequeue_script( $handle );
}
foreach ( array_diff( $after_script_modules_queue, $before_script_modules_queue ) as $handle ) {
wp_dequeue_script_module( $handle );
}
}
return $block_content;
}
}
pending, or failed.
* @property string|\Stripe\Transfer $transfer ID of the transfer to the destination account (only applicable if the charge was created using the destination parameter).
* @property null|\Stripe\StripeObject $transfer_data An optional dictionary including the account to automatically transfer to as part of a destination charge. See the Connect documentation for details.
* @property null|string $transfer_group A string that identifies this transaction as part of a group. See the Connect documentation for details.
*/
class Charge extends ApiResource
{
const OBJECT_NAME = 'charge';
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Retrieve;
use ApiOperations\Search;
use ApiOperations\Update;
const STATUS_FAILED = 'failed';
const STATUS_PENDING = 'pending';
const STATUS_SUCCEEDED = 'succeeded';
/**
* Possible string representations of decline codes.
* These strings are applicable to the decline_code property of the \Stripe\Exception\CardException exception.
*
* @see https://stripe.com/docs/declines/codes
*/
const DECLINED_AUTHENTICATION_REQUIRED = 'authentication_required';
const DECLINED_APPROVE_WITH_ID = 'approve_with_id';
const DECLINED_CALL_ISSUER = 'call_issuer';
const DECLINED_CARD_NOT_SUPPORTED = 'card_not_supported';
const DECLINED_CARD_VELOCITY_EXCEEDED = 'card_velocity_exceeded';
const DECLINED_CURRENCY_NOT_SUPPORTED = 'currency_not_supported';
const DECLINED_DO_NOT_HONOR = 'do_not_honor';
const DECLINED_DO_NOT_TRY_AGAIN = 'do_not_try_again';
const DECLINED_DUPLICATED_TRANSACTION = 'duplicate_transaction';
const DECLINED_EXPIRED_CARD = 'expired_card';
const DECLINED_FRAUDULENT = 'fraudulent';
const DECLINED_GENERIC_DECLINE = 'generic_decline';
const DECLINED_INCORRECT_NUMBER = 'incorrect_number';
const DECLINED_INCORRECT_CVC = 'incorrect_cvc';
const DECLINED_INCORRECT_PIN = 'incorrect_pin';
const DECLINED_INCORRECT_ZIP = 'incorrect_zip';
const DECLINED_INSUFFICIENT_FUNDS = 'insufficient_funds';
const DECLINED_INVALID_ACCOUNT = 'invalid_account';
const DECLINED_INVALID_AMOUNT = 'invalid_amount';
const DECLINED_INVALID_CVC = 'invalid_cvc';
const DECLINED_INVALID_EXPIRY_YEAR = 'invalid_expiry_year';
const DECLINED_INVALID_NUMBER = 'invalid_number';
const DECLINED_INVALID_PIN = 'invalid_pin';
const DECLINED_ISSUER_NOT_AVAILABLE = 'issuer_not_available';
const DECLINED_LOST_CARD = 'lost_card';
const DECLINED_MERCHANT_BLACKLIST = 'merchant_blacklist';
const DECLINED_NEW_ACCOUNT_INFORMATION_AVAILABLE = 'new_account_information_available';
const DECLINED_NO_ACTION_TAKEN = 'no_action_taken';
const DECLINED_NOT_PERMITTED = 'not_permitted';
const DECLINED_OFFLINE_PIN_REQUIRED = 'offline_pin_required';
const DECLINED_ONLINE_OR_OFFLINE_PIN_REQUIRED = 'online_or_offline_pin_required';
const DECLINED_PICKUP_CARD = 'pickup_card';
const DECLINED_PIN_TRY_EXCEEDED = 'pin_try_exceeded';
const DECLINED_PROCESSING_ERROR = 'processing_error';
const DECLINED_REENTER_TRANSACTION = 'reenter_transaction';
const DECLINED_RESTRICTED_CARD = 'restricted_card';
const DECLINED_REVOCATION_OF_ALL_AUTHORIZATIONS = 'revocation_of_all_authorizations';
const DECLINED_REVOCATION_OF_AUTHORIZATION = 'revocation_of_authorization';
const DECLINED_SECURITY_VIOLATION = 'security_violation';
const DECLINED_SERVICE_NOT_ALLOWED = 'service_not_allowed';
const DECLINED_STOLEN_CARD = 'stolen_card';
const DECLINED_STOP_PAYMENT_ORDER = 'stop_payment_order';
const DECLINED_TESTMODE_DECLINE = 'testmode_decline';
const DECLINED_TRANSACTION_NOT_ALLOWED = 'transaction_not_allowed';
const DECLINED_TRY_AGAIN_LATER = 'try_again_later';
const DECLINED_WITHDRAWAL_COUNT_LIMIT_EXCEEDED = 'withdrawal_count_limit_exceeded';
/**
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Charge the captured charge
*/
public function capture($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/capture';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\SearchResult the charge search results
*/
public static function search($params = null, $opts = null)
{
$url = '/v1/charges/search';
return self::_searchResource($url, $params, $opts);
}
}