|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* API for interfacing WP eCommerce settings with the Customizer |
|
5
|
|
|
* |
|
6
|
|
|
* @package WP eCommerce |
|
7
|
|
|
* @subpackage Customizer |
|
8
|
|
|
* @since 4.0 |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class used to implement Customizer ( specifically Selective Refresh ) functionality. |
|
13
|
|
|
* |
|
14
|
|
|
* @since 4.0 |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
/** WPSC_Customizer_Thumbnail_Control class */ |
|
18
|
|
|
|
|
19
|
|
|
class WPSC_Customizer { |
|
20
|
|
|
|
|
21
|
|
|
public $settings = array(); |
|
22
|
|
|
public $sections = array(); |
|
23
|
|
|
|
|
24
|
|
|
public function __construct() { |
|
25
|
|
|
|
|
26
|
|
|
$this->settings = apply_filters( 'wpsc_customizer_settings', $this->settings ); |
|
27
|
|
|
$this->sections = apply_filters( 'wpsc_customizer_sections', $this->sections ); |
|
28
|
|
|
|
|
29
|
|
|
$this->init(); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function init() { |
|
33
|
|
|
add_action( 'customize_register', array( $this, 'include_components' ), 0 ); |
|
34
|
|
|
add_action( 'customize_register', array( $this, 'customizer' ) , 200 ); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function include_components() { |
|
38
|
|
|
|
|
39
|
|
|
do_action( 'wpsc_customizer_include_components' ); |
|
40
|
|
|
|
|
41
|
|
|
require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-customizer-thumbnail-control.class.php' ); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Register selective refresh partial. |
|
46
|
|
|
* |
|
47
|
|
|
* @param \WP_Customize_Manager $wp_customize Manager. |
|
48
|
|
|
*/ |
|
49
|
|
|
public function customizer( WP_Customize_Manager $wp_customize ) { |
|
50
|
|
|
|
|
51
|
|
|
if ( ! isset( $wp_customize->selective_refresh ) ) { |
|
52
|
|
|
return; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
$wp_customize->add_panel( 'wpsc', array( |
|
56
|
|
|
'title' => __( 'Store', 'wp-e-commerce' ), |
|
57
|
|
|
'description' => __( 'Presentational settings for your store.', 'wp-e-commerce' ), |
|
58
|
|
|
'priority' => 150, |
|
59
|
|
|
) ); |
|
60
|
|
|
|
|
61
|
|
|
foreach ( $this->sections as $name => $label ) { |
|
62
|
|
|
$wp_customize->add_section( $name, array( |
|
63
|
|
|
'title' => $label, |
|
64
|
|
|
'panel' => 'wpsc', |
|
65
|
|
|
) ); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
foreach ( $this->settings as $name => $settings ) { |
|
69
|
|
|
|
|
70
|
|
|
$wp_customize->add_setting( $name, $settings['setting'] ); |
|
71
|
|
|
|
|
72
|
|
|
if ( isset( $settings['control']['class'] ) ) { |
|
73
|
|
|
|
|
74
|
|
|
$class = $settings['control']['class']; |
|
75
|
|
|
|
|
76
|
|
|
foreach ( $settings['control']['settings'] as $s ) { |
|
77
|
|
|
$wp_customize->add_setting( $s, array( |
|
78
|
|
|
'default' => '', |
|
79
|
|
|
'type' => 'option', |
|
80
|
|
|
'capability' => 'manage_options', |
|
81
|
|
|
'sanitize_callback' => 'absint' |
|
82
|
|
|
) ); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
$wp_customize->add_control( |
|
86
|
|
|
new $class( |
|
87
|
|
|
$wp_customize, |
|
88
|
|
|
$name, |
|
89
|
|
|
array( |
|
90
|
|
|
'label' => $settings['control']['label'], |
|
91
|
|
|
'section' => $settings['control']['section'], |
|
92
|
|
|
'settings' => $settings['control']['settings'] |
|
93
|
|
|
) |
|
94
|
|
|
) |
|
95
|
|
|
); |
|
96
|
|
|
} else { |
|
97
|
|
|
$wp_customize->add_control( $name, $settings['control'] ); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
if ( isset( $settings['partial'] ) ) { |
|
101
|
|
|
$wp_customize->selective_refresh->add_partial( $name, $settings['partial'] ); |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
new WPSC_Customizer(); |
|
108
|
|
|
|