Completed
Push — master ( a769f5...172323 )
by Justin
07:02
created

wpsc-customizer.php ➔ wpsc_customizer_assets()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 9.4285
1
<?php
2
3
function wpsc_default_customizer_settings( $settings ) {
4
5
    $settings['wpsc_product_width_thumbnails'] = array(
6
        'control' => array(
7
            'class'           => 'WPSC_Customizer_Thumbnail_Control',
8
            'settings'        => array( 'single_view_image_width', 'single_view_image_height' ),
9
            'priority'        => 15,
10
            'type'            => 'wpsc-thumbnail',
11
            'section'         => 'wpsc_thumbnails',
12
            'label'           => __( 'Single Product Thumbnails' ),
13
            'default'         => '',
14
            'description'     => __( 'Sets thumbnail size for single product view.', 'wp-e-commerce' ),
15
        ),
16
        'setting' => array(
17
            'type'              => 'option',
18
            'capability'        => 'manage_options',
19
            'sanitize_callback' => 'absint',
20
            'input'             => 'number'
21
        )
22
    );
23
24
    $settings['wpsc_product_width_archive_thumbnails'] = array(
25
        'control' => array(
26
            'class'           => 'WPSC_Customizer_Thumbnail_Control',
27
            'settings'        => array( 'product_image_width', 'product_image_height' ),
28
            'priority'        => 20,
29
            'type'            => 'wpsc-thumbnail',
30
            'section'         => 'wpsc_thumbnails',
31
            'label'           => __( 'Archive Product Thumbnails' ),
32
            'default'         => '',
33
            'description'     => __( 'Sets thumbnail size for archive product view.', 'wp-e-commerce' ),
34
        ),
35
        'setting' => array(
36
            'type'              => 'option',
37
            'capability'        => 'manage_options',
38
            'sanitize_callback' => 'absint',
39
            'input'             => 'number'
40
        )
41
    );
42
43
    $settings['wpsc_product_width_taxonomy_thumbnails'] = array(
44
        'control' => array(
45
            'class'           => 'WPSC_Customizer_Thumbnail_Control',
46
            'settings'        => array( 'category_image_width', 'category_image_height' ),
47
            'priority'        => 30,
48
            'type'            => 'wpsc-thumbnail',
49
            'section'         => 'wpsc_thumbnails',
50
            'label'           => __( 'Product Category Thumbnails' ),
51
            'default'         => '',
52
            'description'     => __( 'Sets thumbnail size for category images.', 'wp-e-commerce' ),
53
        ),
54
        'setting' => array(
55
            'type'              => 'option',
56
            'capability'        => 'manage_options',
57
            'sanitize_callback' => 'absint',
58
            'input'             => 'number'
59
        )
60
    );
61
62
    $settings['wpsc_crop_thumbnails'] = array(
63
        'control' => array(
64
            'type'            => 'checkbox',
65
            'priority'        => 10,
66
            'section'         => 'wpsc_thumbnails',
67
            'label'           => __( 'Crop Thumbnails' ),
68
            'default'         => false,
69
            'description'     => __( 'Crop images to the specified dimensions using center positions.' ),
70
        ),
71
        'setting' => array(
72
            'type'              => 'option',
73
            'capability'        => 'manage_options',
74
            'default'           => false,
75
            'sanitize_callback' => 'esc_attr',
76
        )
77
    );
78
79
    $settings['wpsc_products_per_page'] = array(
80
        'control' => array(
81
            'type'            => 'number',
82
            'priority'        => 20,
83
            'section'         => 'wpsc_general',
84
            'label'           => __( 'Products Per Page' ),
85
            'default'         => get_option( 'posts_per_page' ),
86
            'description'     => __( 'Set the maximum number of products per page.', 'wp-e-commerce' ),
87
        ),
88
        'setting' => array(
89
            'type'              => 'option',
90
            'capability'        => 'manage_options',
91
            'default'           => 'auto',
92
            'sanitize_callback' => 'is_numeric',
93
        ),
94
        'partial' => array(
95
            'selector'            => '#wpsc-products',
96
            'render_callback'     => function() {
97
                wpsc_get_template_part( 'loop', 'products' );
98
             }
99
        )
100
    );
101
102
    $settings['wpsc_fancy_notifications'] = array(
103
            'control' => array(
104
                'type'            => 'checkbox',
105
                'priority'        => 10,
106
                'section'         => 'wpsc_general',
107
                'label'           => __( 'Add to Cart Notifications' ),
108
                'default'         => false,
109
                'description'     => __( 'Enable Add to Cart notifications. When adding an item to your cart, this will create a popup notification for users.' ),
110
            ),
111
            'setting' => array(
112
                'type'              => 'option',
113
                'capability'        => 'manage_options',
114
                'default'           => false,
115
                'sanitize_callback' => 'esc_attr',
116
            ),
117
            'partial' => array(
118
                'selector'            => '#wpsc-products',
119
                'render_callback'     => function() {
120
                    wpsc_get_template_part( 'loop', 'products' );
121
                 }
122
            )
123
        );
124
125
    // TODO: Modify Body Class via JS. Also, hide products per row based on value
126
    $settings['wpsc_layout'] = array(
127
        'control' => array(
128
            'type'            => 'select',
129
            'priority'        => 10,
130
            'section'         => 'wpsc_layout',
131
            'label'           => __( 'Layout' ),
132
            'default'         => 'grid',
133
            'description'     => __( 'Change the layout of your store.' ),
134
            'choices'         => apply_filters( 'wpsc_layouts', array(
135
                'grid' => __( 'Grid', 'wp-e-commerce' ),
136
                'list' => __( 'List', 'wp-e-commerce' )
137
            ) )
138
        ),
139
        'setting' => array(
140
            'type'              => 'option',
141
            'capability'        => 'manage_options',
142
            'default'           => 'grid',
143
            'sanitize_callback' => 'sanitize_text_field',
144
        )
145
    );
146
147
    $settings['wpsc_products_per_row'] = array(
148
        'control' => array(
149
            'type'            => 'select',
150
            'priority'        => 12,
151
            'section'         => 'wpsc_layout',
152
            'label'           => __( 'Products Per Row' ),
153
            'default'         => 'auto',
154
            'description'     => __( 'Set the maximum number of products per row. Defaults to showing as many as will fit, up to six products per row', 'wp-e-commerce' ),
155
            'choices'         => apply_filters( 'wpsc_products_per_row_options', array(
156
                'auto' => __( 'Automatic', 'wp-e-commerce' ),
157
                '1'    => __( '1', 'wp-e-commerce' ),
158
                '2'    => __( '2', 'wp-e-commerce' ),
159
                '3'    => __( '3', 'wp-e-commerce' ),
160
                '4'    => __( '4', 'wp-e-commerce' ),
161
                '5'    => __( '5', 'wp-e-commerce' ),
162
                '6'    => __( '6', 'wp-e-commerce' ),
163
            ) )
164
        ),
165
        'setting' => array(
166
            'type'              => 'option',
167
            'capability'        => 'manage_options',
168
            'default'           => 'auto',
169
            'sanitize_callback' => function( $value ) { return $value === 'auto' || is_numeric( $value ) ? $value : 'auto'; },
170
        ),
171
        'partial' => array(
172
            'selector'            => '#wpsc-products',
173
            'render_callback'     => function() {
174
                wpsc_get_template_part( 'loop', 'products' );
175
             }
176
        )
177
    );
178
179
    return $settings;
180
}
181
182
add_filter( 'wpsc_customizer_settings', 'wpsc_default_customizer_settings' );
183
184
function wpsc_default_customizer_sections( $sections ) {
185
    return array_merge( array(
186
        'wpsc_general'    => __( 'General', 'wp-e-commerce' ),
187
        'wpsc_layout'     => __( 'Layout', 'wp-e-commerce' ),
188
        'wpsc_thumbnails' => __( 'Thumbnails', 'wp-e-commerce' ),
189
    ), $sections );
190
}
191
192
add_filter( 'wpsc_customizer_sections', 'wpsc_default_customizer_sections' );
193
194
function wpsc_customizer_assets() {
195
    _wpsc_te2_mvc_init();
196
    wp_enqueue_script( 'wpsc-customizer', wpsc_locate_asset_uri( 'js/customizer.js' ), array( 'customize-preview', 'jquery' ), WPSC_VERSION );
197
    wp_enqueue_style( 'wpsc-customizer' , wpsc_locate_asset_uri( 'css/customizer.css' ), array(), WPSC_VERSION );
198
}
199
200
add_action( 'customize_controls_enqueue_scripts', 'wpsc_customizer_assets' );
201
202
require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-customizer.class.php' );
203