Skip to content

Commit

Permalink
Add visual UI customizer setting
Browse files Browse the repository at this point in the history
  • Loading branch information
helgatheviking committed May 15, 2023
1 parent bbf465e commit 50e9381
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions wc-mnm-variable.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ public function attach_hooks_and_filters() {
// Set and cache the correct product class for mix and match variations.
add_filter( 'woocommerce_product_class', [ $this, 'set_variation_class' ], 10, 4 );

/**
* Customizer.
*/
add_action( 'customize_register', [ $this, 'add_customizer_control' ], 20 );

/**
* Front end
*/
Expand Down Expand Up @@ -391,6 +396,48 @@ public function set_variation_class( $classname, $product_type, $post_type, $pro
return $classname;
}

/*
|--------------------------------------------------------------------------
| Customizer controls.
|--------------------------------------------------------------------------
*/

/**
* Add control to Mix and Match section of the Customizer.
* NB: Eventually this will be an option for MNM core.
*
* @param bool $wp_customize
*/
public function add_customizer_control( $wp_customize ) {

/**
* Display Visual Status UI
*/
$wp_customize->add_setting(
'wc_mnm_visual_status_ui',
array(
'default' => 'no',
'type' => 'option',
'capability' => 'manage_woocommerce',
'sanitize_callback' => 'wc_bool_to_string',
'sanitize_js_callback' => 'wc_string_to_bool',
)
);

$wp_customize->add_control(
new KIA_Customizer_Toggle_Control(
$wp_customize,
'wc_mnm_visual_status_ui',
array(
'label' => esc_html__( 'Display Visual Status UI', 'wc-mnm-variable' ),
'description' => esc_html__( 'May conflict with your theme styles.', 'wc-mnm-variable' ),
'section' => 'wc_mnm',
'type' => 'kia-toggle',
'settings' => 'wc_mnm_visual_status_ui',
)
)
);
}

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -496,14 +543,14 @@ public function frontend_scripts( $auto_enqueue = false ) {
true
);


$params = array(
'wc_ajax_url' => \WC_AJAX::get_endpoint( '%%endpoint%%' ),
'i18n_form_error' => __( 'Failed to initialize form. If this issue persists, please reload the page and try again.', 'wc-mnm-variable' ),
'form_nonce' => wp_create_nonce( 'wc_mnm_container_form' ),
'display_thumbnails' => wc_string_to_bool( get_option( 'wc_mnm_display_thumbnail', 'yes' ) ),
'display_short_description' => wc_string_to_bool( get_option( 'wc_mnm_display_short_description', 'no' ) ),
'display_short_description' => wc_string_to_bool( get_option( 'wc_mnm_display_short_description', 'no' ) ),
'display_plus_minus_buttons' => wc_string_to_bool( get_option( 'wc_mnm_display_plus_minus_buttons', 'no' ) ),
'display_visual_status_ui' => wc_string_to_bool( get_option( 'wc_mnm_visual_status_ui', 'no' ) ),
'num_columns' => (int) apply_filters( 'wc_mnm_grid_layout_columns', get_option( 'wc_mnm_number_columns', 3 ) ),
);

Expand Down

0 comments on commit 50e9381

Please sign in to comment.