-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete customizer implementation of settings. See #516.
- Loading branch information
1 parent
90fbe35
commit eac79ce
Showing
8 changed files
with
339 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
wpsc-components/theme-engine-v2/theming/assets/css/customizer.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
li.customize-control-wpsc-thumbnail div { | ||
max-width: 5em; | ||
float: left; | ||
margin-right: 4em; | ||
} |
25 changes: 25 additions & 0 deletions
25
wpsc-components/theme-engine-v2/theming/assets/js/customizer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
( function( $ ) { | ||
wp.customize( 'wpsc_layout', function( value ) { | ||
value.bind( function( to, from ) { | ||
$( 'body' ).removeClass( 'wpsc-' + from ); | ||
$( 'body' ).addClass( 'wpsc-' + to ); | ||
|
||
if ( 'grid' === to ) { | ||
$( '#customize-control-wpsc_products_per_row' ).slideDown( 150 ); | ||
} else { | ||
$( '#customize-control-wpsc_products_per_row' ).slideUp( 150 ); | ||
} | ||
} ); | ||
} ); | ||
|
||
wp.customize.bind( 'ready', function() { | ||
var value = wp.customize.control( 'wpsc_layout' ).setting(); | ||
|
||
if ( 'list' === value ) { | ||
$( '#customize-control-wpsc_products_per_row' ).slideUp( 150 ); | ||
} else { | ||
$( '#customize-control-wpsc_products_per_row' ).slideDown( 150 ); | ||
} | ||
} ); | ||
|
||
} )( jQuery ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
if ( ! class_exists( 'WP_Customize_Control' ) ) { | ||
return; | ||
} | ||
|
||
/** | ||
* Custom control for Customizer. | ||
* | ||
* Allows us to have a width and a height input for thumbnail settings. | ||
* | ||
* @package WP eCommerce | ||
* @subpackage Customizer | ||
* @since 4.0 | ||
*/ | ||
|
||
/** | ||
* Thumbnail setting control for WxH settings in Customizer. | ||
* | ||
* @todo Move to its own file. | ||
* @since 4.0 | ||
*/ | ||
class WPSC_Customizer_Thumbnail_Control extends WP_Customize_Control { | ||
|
||
public $html = array(); | ||
public $type = 'wpsc-thumbnail'; | ||
|
||
public function build_field_html( $key, $setting, $label ) { | ||
$value = ''; | ||
|
||
if ( isset( $this->settings[ $key ] ) ) { | ||
$value = $this->settings[ $key ]->value(); | ||
} | ||
|
||
$this->html[] = '<div><label>' . $label . '<br /><input type="number" value="' . esc_attr( $value ) . '" ' . $this->get_link( $key ).' /></label> | ||
<p>' . $this->description . '</p></div>'; | ||
} | ||
|
||
/** | ||
* Op since we're using JS template. | ||
* | ||
* @since 4.3.0 | ||
* @access protected | ||
*/ | ||
protected function render_content() { | ||
$keys = array_keys( get_object_vars( $this ) ); | ||
|
||
foreach ( $keys as $key ) { | ||
if ( isset( $args[ $key ] ) ) { | ||
$this->$key = $args[ $key ]; | ||
} | ||
} | ||
|
||
$output = '<label class="customize-control-title">' . esc_html( $this->label ) .'</label>'; | ||
|
||
echo $output; | ||
|
||
foreach( $this->settings as $key => $value ) { | ||
$label = absint( $key ) ? __( 'Height', 'wp-e-commerce' ) : __( 'Width', 'wp-e-commerce' ); | ||
$this->build_field_html( $key, $value, $label ); | ||
} | ||
|
||
echo implode( '', $this->html ); | ||
} | ||
|
||
} |
Oops, something went wrong.