wpcf7_stripe_enqueue_scripts()CF7 1.0

Enqueues scripts and styles for the Stripe module.

Хуков нет.

Возвращает

null. Ничего (null).

Использование

wpcf7_stripe_enqueue_scripts();

Код wpcf7_stripe_enqueue_scripts() CF7 6.0.6

function wpcf7_stripe_enqueue_scripts() {
	$service = WPCF7_Stripe::get_instance();

	if ( ! $service->is_active() ) {
		return;
	}

	wp_enqueue_style( 'wpcf7-stripe',
		wpcf7_plugin_url( 'modules/stripe/style.css' ),
		array(), WPCF7_VERSION, 'all'
	);

	wp_register_script(
		'stripe',
		'https://js.stripe.com/v3/',
		array(),
		null
	);

	$assets = include wpcf7_plugin_path( 'modules/stripe/index.asset.php' );

	$assets = wp_parse_args( $assets, array(
		'dependencies' => array(),
		'version' => WPCF7_VERSION,
	) );

	wp_enqueue_script(
		'wpcf7-stripe',
		wpcf7_plugin_url( 'modules/stripe/index.js' ),
		array_merge(
			$assets['dependencies'],
			array(
				'wp-polyfill',
				'contact-form-7',
				'stripe',
			)
		),
		$assets['version'],
		array( 'in_footer' => true )
	);

	$api_keys = $service->get_api_keys();

	if ( $api_keys['publishable'] ) {
		wp_add_inline_script( 'wpcf7-stripe',
			sprintf(
				'var wpcf7_stripe = %s;',
				wp_json_encode( array(
					'publishable_key' => $api_keys['publishable'],
				), JSON_PRETTY_PRINT )
			),
			'before'
		);
	}
}