|
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, and specifically Selective Refresh, functionality. |
|
13
|
|
|
* |
|
14
|
|
|
* @since 4.0 |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
class WPSC_Customizer { |
|
18
|
|
|
|
|
19
|
|
|
public $settings = array(); |
|
20
|
|
|
public $sections = array(); |
|
21
|
|
|
|
|
22
|
|
|
public function __construct() { |
|
23
|
|
|
$this->settings = apply_filters( 'wpsc_customizer_settings', $this->settings ); |
|
24
|
|
|
$this->sections = apply_filters( 'wpsc_customizer_sections', $this->sections ); |
|
25
|
|
|
|
|
26
|
|
|
$this->init(); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
private function init() { |
|
30
|
|
|
add_action( 'customize_register', array( $this, 'register_partials' ), 100 ); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Register selective refresh partial. |
|
35
|
|
|
* |
|
36
|
|
|
* @param \WP_Customize_Manager $wp_customize Manager. |
|
37
|
|
|
*/ |
|
38
|
|
|
public function register_partials( WP_Customize_Manager $wp_customize ) { |
|
39
|
|
|
|
|
40
|
|
|
if ( ! isset( $wp_customize->selective_refresh ) ) { |
|
41
|
|
|
return; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
$wp_customize->add_panel( 'wpsc', array( |
|
45
|
|
|
'title' => __( 'Store', 'wp-e-commerce' ), |
|
46
|
|
|
'description' => __( 'Presentational settings for your store.' ), // Include html tags such as <p>. |
|
47
|
|
|
'priority' => 160, // Mixed with top-level-section hierarchy. |
|
48
|
|
|
) ); |
|
49
|
|
|
|
|
50
|
|
|
foreach ( $this->sections as $name => $label ) { |
|
51
|
|
|
$wp_customize->add_section( $name, array( |
|
52
|
|
|
'title' => $label, |
|
53
|
|
|
'panel' => 'wpsc', |
|
54
|
|
|
) ); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
foreach ( $this->settings as $name => $setting ) { |
|
58
|
|
|
|
|
59
|
|
|
$wp_customize->selective_refresh->add_partial( $name, $setting ); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
function wpsc_default_customizer_settings( $settings ) { |
|
66
|
|
|
$settings['setting'] = array( |
|
67
|
|
|
array( |
|
68
|
|
|
'selector' => '.site-description', |
|
69
|
|
|
'container_inclusive' => false, |
|
70
|
|
|
'render_callback' => function() { |
|
71
|
|
|
bloginfo( 'description' ); |
|
72
|
|
|
} |
|
73
|
|
|
) |
|
74
|
|
|
); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
add_filter( 'wpsc_customizer_settings', 'wpsc_default_customizer_settings' ); |
|
78
|
|
|
|
|
79
|
|
|
function wpsc_default_customizer_sections( $sections ) { |
|
|
|
|
|
|
80
|
|
|
return array( |
|
81
|
|
|
'general' => __( 'General', 'wp-e-commerce' ), |
|
82
|
|
|
'layout' => __( 'Layout', 'wp-e-commerce' ), |
|
83
|
|
|
); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
add_filter( 'wpsc_customizer_settings', 'wpsc_default_customizer_sections' ); |
|
87
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.