WC_Shop_Customizer::add_store_notice_section()privateWC 1.0

Store notice section.

Method of the class: WC_Shop_Customizer{}

No Hooks.

Return

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->add_store_notice_section( $wp_customize );
$wp_customize(WP_Customize_Manager) (required)
Theme Customizer object.

WC_Shop_Customizer::add_store_notice_section() code WC 8.7.0

private function add_store_notice_section( $wp_customize ) {
	$wp_customize->add_section(
		'woocommerce_store_notice',
		array(
			'title'    => __( 'Store Notice', 'woocommerce' ),
			'priority' => 10,
			'panel'    => 'woocommerce',
		)
	);

	$wp_customize->add_setting(
		'woocommerce_demo_store',
		array(
			'default'              => 'no',
			'type'                 => 'option',
			'capability'           => 'manage_woocommerce',
			'sanitize_callback'    => 'wc_bool_to_string',
			'sanitize_js_callback' => 'wc_string_to_bool',
		)
	);

	$wp_customize->add_setting(
		'woocommerce_demo_store_notice',
		array(
			'default'           => __( 'This is a demo store for testing purposes — no orders shall be fulfilled.', 'woocommerce' ),
			'type'              => 'option',
			'capability'        => 'manage_woocommerce',
			'sanitize_callback' => 'wp_kses_post',
			'transport'         => 'postMessage',
		)
	);

	$wp_customize->add_control(
		'woocommerce_demo_store_notice',
		array(
			'label'       => __( 'Store notice', 'woocommerce' ),
			'description' => __( 'If enabled, this text will be shown site-wide. You can use it to show events or promotions to visitors!', 'woocommerce' ),
			'section'     => 'woocommerce_store_notice',
			'settings'    => 'woocommerce_demo_store_notice',
			'type'        => 'textarea',
		)
	);

	$wp_customize->add_control(
		'woocommerce_demo_store',
		array(
			'label'    => __( 'Enable store notice', 'woocommerce' ),
			'section'  => 'woocommerce_store_notice',
			'settings' => 'woocommerce_demo_store',
			'type'     => 'checkbox',
		)
	);

	if ( isset( $wp_customize->selective_refresh ) ) {
		$wp_customize->selective_refresh->add_partial(
			'woocommerce_demo_store_notice',
			array(
				'selector'            => '.woocommerce-store-notice',
				'container_inclusive' => true,
				'render_callback'     => 'woocommerce_demo_store',
			)
		);
	}
}