|
1
|
|
|
<?php if ( ! defined( 'ABSPATH' ) ) { exit; |
|
2
|
|
|
} |
|
3
|
|
|
class wps_display_options { |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
function __construct() { |
|
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
add_action( 'admin_init', array( $this, 'declare_display_options' ) ); |
|
9
|
|
|
add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts' ) ); |
|
10
|
|
|
add_filter( 'plugin_action_links_' . WPSHOP_PLUGIN_NAME, array( $this, 'plugin_action_links' ) ); |
|
11
|
|
|
// End if(). |
|
|
|
|
|
|
12
|
|
|
add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_frontend' ) ); |
|
13
|
|
|
} |
|
14
|
|
|
|
|
15
|
|
|
function plugin_action_links( $links ) { |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
$action_links = array( |
|
18
|
|
|
'settings' => '<a href="' . admin_url( 'admin.php?page=' . WPSHOP_URL_SLUG_OPTION ) . '" aria-label="' . esc_attr__( 'View WPShop settings', 'wpshop' ) . '">' . esc_html__( 'Settings' ) . '</a>', |
|
19
|
|
|
); |
|
20
|
|
|
return array_merge( $action_links, $links ); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
function add_scripts( $hook ) { |
|
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
if ( $hook != 'settings_page_wpshop_option' ) { |
|
26
|
|
|
return; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
wp_enqueue_script( 'jquery' ); |
|
30
|
|
|
// End if(). |
|
|
|
|
|
|
31
|
|
|
wp_enqueue_script( 'iris' ); |
|
32
|
|
|
wp_enqueue_script( 'wps_options_display_js', WPS_OPTIONS_URL . WPS_OPTIONS_DIR . '/assets/backend/js/wps_option_display.js', false ); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
function add_scripts_frontend() { |
|
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
add_action( 'wp_print_scripts', array( $this, 'create_customizing_css_rules' ) ); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Init and declare WPShop Display Options |
|
43
|
|
|
*/ |
|
44
|
|
|
function declare_display_options() { |
|
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
// Frontend display options |
|
47
|
|
|
register_setting( 'wpshop_options', 'wpshop_display_option', array( $this, 'display_part_validator' ) ); |
|
48
|
|
|
add_settings_section( 'wpshop_display_options_sections', '<span class="dashicons dashicons-welcome-view-site"></span>' . __( 'Display options', 'wpshop' ), array( $this, 'frontend_display_part_explanation' ), 'wpshop_display_option' ); |
|
49
|
|
|
// Add the different field option for frontend |
|
50
|
|
|
add_settings_field( 'wpshop_display_cat_sheet_output', __( 'Display type for category page', 'wpshop' ), array( $this, 'wpshop_display_cat_sheet_output' ), 'wpshop_display_option', 'wpshop_display_options_sections' ); |
|
51
|
|
|
add_settings_field( 'wpshop_display_list_type', __( 'Display type for element list', 'wpshop' ), array( $this, 'wpshop_display_list_type' ), 'wpshop_display_option', 'wpshop_display_options_sections' ); |
|
52
|
|
|
add_settings_field( 'wpshop_display_grid_element_number', __( 'Number of element by line for grid mode', 'wpshop' ), array( $this, 'wpshop_display_grid_element_number' ), 'wpshop_display_option', 'wpshop_display_options_sections' ); |
|
53
|
|
|
add_settings_field( 'wpshop_display_element_per_page', __( 'Number of element per page', 'wpshop' ), array( $this, 'wpshop_display_element_per_page' ), 'wpshop_display_option', 'wpshop_display_options_sections' ); |
|
54
|
|
|
add_settings_field( 'wpshop_display_latest_products_ordered', __( 'Number of element in "latest products ordered" part', 'wpshop' ), array( $this, 'wpshop_display_latest_products_ordered' ), 'wpshop_display_option', 'wpshop_display_options_sections' ); |
|
55
|
|
|
add_settings_field( 'wpshop_hide_admin_bar', __( 'Hide Wordpress Admin Bar for customers', 'wpshop' ), array( $this, 'wpshop_hide_admin_bar' ), 'wpshop_display_option', 'wpshop_display_options_sections' ); |
|
56
|
|
|
add_settings_field( 'wpshop_display_delete_order', __( 'Display delete order for customers', 'wpshop' ), array( $this, 'wpshop_display_delete_order' ), 'wpshop_display_option', 'wpshop_display_options_sections' ); |
|
57
|
|
|
// Customize WPShop display part |
|
58
|
|
|
register_setting( 'wpshop_options', 'wpshop_customize_display_option', array( $this, 'customize_color_validator' ) ); |
|
59
|
|
|
add_settings_section( 'wpshop_customize_wpshop_display_option', '<span class="dashicons dashicons-admin-appearance"></span>' . __( 'Customize your WPShop', 'wpshop' ), array( $this, 'customize_wpshop_colors_explanation' ), 'wpshop_customize_display_option' ); |
|
60
|
|
|
add_settings_field( 'wpshop_customize_first_button_field', __( 'Change the principal button style', 'wpshop' ), array( $this, 'wps_customize_first_button_style' ), 'wpshop_customize_display_option', 'wpshop_customize_wpshop_display_option' ); |
|
61
|
|
|
add_settings_field( 'wpshop_customize_second_button_field', __( 'Change the second button style', 'wpshop' ), array( $this, 'wps_customize_second_button_style' ), 'wpshop_customize_display_option', 'wpshop_customize_wpshop_display_option' ); |
|
62
|
|
|
add_settings_field( 'wpshop_customize_account_field', __( 'Change the customer account elements style', 'wpshop' ), array( $this, 'wps_customize_account_style' ), 'wpshop_customize_display_option', 'wpshop_customize_wpshop_display_option' ); |
|
63
|
|
|
add_settings_field( 'wpshop_customize_shipping_list_field', __( 'Change The shipping mode choice element style', 'wpshop' ), array( $this, 'wps_customize_shipping_style' ), 'wpshop_customize_display_option', 'wpshop_customize_wpshop_display_option' ); |
|
64
|
|
|
// Admin (Back-end) display options |
|
65
|
|
|
register_setting( 'wpshop_options', 'wpshop_admin_display_option', array( $this, 'admin_part_validator' ) ); |
|
66
|
|
|
add_settings_section( 'wpshop_admin_display_options_sections', '<span class="dashicons dashicons-desktop"></span>' . __( 'Admin display options', 'wpshop' ), array( $this, 'admin_part_explanation' ), 'wpshop_admin_display_option' ); |
|
67
|
|
|
add_settings_field( 'wpshop_admin_display_attribute_set_layout', __( 'Attribute set page layout', 'wpshop' ), array( $this, 'wpshop_admin_display_attr_set_layout' ), 'wpshop_admin_display_option', 'wpshop_admin_display_options_sections' ); |
|
68
|
|
|
add_settings_field( 'wpshop_admin_display_attribute_layout', __( 'Attribute page layout', 'wpshop' ), array( $this, 'wpshop_admin_display_attr_layout' ), 'wpshop_admin_display_option', 'wpshop_admin_display_options_sections' ); |
|
69
|
|
|
add_settings_field( 'wpshop_admin_display_shortcode_product', __( 'Shortcode display in product page', 'wpshop' ), array( $this, 'wpshop_admin_display_shortcode_in_product_page' ), 'wpshop_admin_display_option', 'wpshop_admin_display_options_sections' ); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* *********************************** |
|
74
|
|
|
* *********************************** |
|
75
|
|
|
* FRONTEND GENERALS DISPLAY OPTIONS * |
|
76
|
|
|
* *********************************** |
|
77
|
|
|
* *********************************** |
|
78
|
|
|
*/ |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* VALIDATOR - Frontend part validator |
|
82
|
|
|
* |
|
83
|
|
|
* @param array $input |
|
84
|
|
|
* @return array |
|
85
|
|
|
*/ |
|
86
|
|
|
function display_part_validator( $input ) { |
|
|
|
|
|
|
87
|
|
|
|
|
88
|
|
|
$newinput['wpshop_display_list_type'] = $input['wpshop_display_list_type']; |
|
|
|
|
|
|
89
|
|
|
if ( $input['wpshop_display_grid_element_number'] < WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE_MIN_RANGE ) { |
|
90
|
|
|
$input['wpshop_display_grid_element_number'] = WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE_MIN_RANGE; |
|
91
|
|
|
} elseif ( $input['wpshop_display_grid_element_number'] > WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE_MAX_RANGE ) { |
|
92
|
|
|
$input['wpshop_display_grid_element_number'] = WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE_MAX_RANGE; |
|
93
|
|
|
} |
|
94
|
|
|
$newinput['wpshop_display_grid_element_number'] = $input['wpshop_display_grid_element_number']; |
|
95
|
|
|
$newinput['wpshop_display_cat_sheet_output'] = $input['wpshop_display_cat_sheet_output']; |
|
96
|
|
|
$newinput['wpshop_display_element_per_page'] = ! empty( $input['wpshop_display_element_per_page'] ) ? $input['wpshop_display_element_per_page'] : ''; |
|
97
|
|
|
$newinput['latest_products_ordered'] = $input['latest_products_ordered']; |
|
98
|
|
|
$newinput['wpshop_hide_admin_bar'] = ! empty( $input['wpshop_hide_admin_bar'] ) ? $input['wpshop_hide_admin_bar'] : ''; |
|
99
|
|
|
$newinput['wpshop_display_delete_order'] = ! empty( $input['wpshop_display_delete_order'] ) ? $input['wpshop_display_delete_order'] : ''; |
|
100
|
|
|
return $newinput; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* EXPLANATIONS - Frontend display option explanantion |
|
105
|
|
|
*/ |
|
106
|
|
|
function frontend_display_part_explanation() { |
|
|
|
|
|
|
107
|
|
|
|
|
108
|
|
|
_e( 'Manage here your frontend display options', 'wpshop' ); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* FIELDS - Display Categories output options |
|
113
|
|
|
*/ |
|
114
|
|
|
function wpshop_display_cat_sheet_output() { |
|
|
|
|
|
|
115
|
|
|
|
|
116
|
|
|
$wpshop_display_option = get_option( 'wpshop_display_option' ); |
|
117
|
|
|
$field_identifier = 'wpshop_display_cat_sheet_output'; |
|
118
|
|
|
if ( current_user_can( 'wpshop_edit_options' ) ) { |
|
119
|
|
|
$content = array( 'category_description', 'category_subcategory', 'category_subproduct' ); |
|
120
|
|
|
$option_field_output = ''; |
|
121
|
|
|
foreach ( $content as $content_definition ) { |
|
122
|
|
|
$current_value = (is_array( $wpshop_display_option['wpshop_display_cat_sheet_output'] ) && in_array( $content_definition, $wpshop_display_option['wpshop_display_cat_sheet_output'] )) || ! is_array( $wpshop_display_option['wpshop_display_cat_sheet_output'] ) ? $content_definition : ''; |
|
123
|
|
|
switch ( $content_definition ) { |
|
124
|
|
|
case 'category_description': |
|
125
|
|
|
{ |
|
126
|
|
|
$field_label = __( 'Display product category description', 'wpshop' ); |
|
127
|
|
|
} |
|
128
|
|
|
break; |
|
129
|
|
|
case 'category_subcategory': |
|
130
|
|
|
{ |
|
131
|
|
|
$field_label = __( 'Display sub categories listing', 'wpshop' ); |
|
132
|
|
|
} |
|
133
|
|
|
break; |
|
134
|
|
|
case 'category_subproduct': |
|
135
|
|
|
{ |
|
136
|
|
|
$field_label = __( 'Display products listing', 'wpshop' ); |
|
137
|
|
|
} |
|
138
|
|
|
break; |
|
139
|
|
|
default: |
|
140
|
|
|
{ |
|
141
|
|
|
$field_label = __( 'Nothing defined here', 'wpshop' ); |
|
142
|
|
|
} |
|
143
|
|
|
break; |
|
144
|
|
|
} |
|
145
|
|
|
$option_field_output .= wpshop_form::form_input_check( 'wpshop_display_option[' . $field_identifier . '][]', $field_identifier . '_' . $content_definition, $content_definition, $current_value, 'checkbox' ) . '<label for="' . $field_identifier . '_' . $content_definition . '" >' . $field_label . '</label><br/>'; |
|
146
|
|
|
} |
|
147
|
|
|
} else { |
|
148
|
|
|
$option_field_output = $wpshop_display_option[ $field_identifier ]; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
echo $option_field_output; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* FIELDS - Display products displaying type options (List/Grid) |
|
156
|
|
|
*/ |
|
157
|
|
|
function wpshop_display_list_type() { |
|
|
|
|
|
|
158
|
|
|
|
|
159
|
|
|
$wpshop_display_option = get_option( 'wpshop_display_option' ); |
|
160
|
|
|
$field_identifier = 'wpshop_display_list_type'; |
|
161
|
|
|
if ( current_user_can( 'wpshop_edit_options' ) ) { |
|
162
|
|
|
$option_field_output = wpshop_form::form_input_select( 'wpshop_display_option[' . $field_identifier . ']', $field_identifier, array( |
|
163
|
|
|
'grid' => __( 'Grid', 'wpshop' ), |
|
164
|
|
|
'list' => __( 'List', 'wpshop' ), |
|
165
|
|
|
), $wpshop_display_option[ $field_identifier ], '', 'index' ); |
|
166
|
|
|
} else { |
|
167
|
|
|
$option_field_output = $wpshop_display_option[ $field_identifier ]; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
echo $option_field_output . ' <a href="#" title="' . __( 'Default display mode on shop','wpshop' ) . '" class="wpshop_infobulle_marker">?</a>'; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* FILEDS - Display Grid element number options |
|
175
|
|
|
*/ |
|
176
|
|
|
function wpshop_display_grid_element_number() { |
|
|
|
|
|
|
177
|
|
|
|
|
178
|
|
|
$wpshop_display_option = get_option( 'wpshop_display_option' ); |
|
179
|
|
|
$field_identifier = 'wpshop_display_grid_element_number'; |
|
180
|
|
|
require( wpshop_tools::get_template_part( WPS_OPTIONS_DIR, WPS_OPTIONS_TEMPLATE_DIR, 'backend', 'wps_display_options_grid_field' ) ); |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* FIELDS - Display elements per page option |
|
185
|
|
|
*/ |
|
186
|
|
|
function wpshop_display_element_per_page() { |
|
|
|
|
|
|
187
|
|
|
|
|
188
|
|
|
$wpshop_display_option = get_option( 'wpshop_display_option' ); |
|
189
|
|
|
$field_identifier = 'wpshop_display_element_per_page'; |
|
190
|
|
|
if ( current_user_can( 'wpshop_edit_options' ) ) { |
|
191
|
|
|
$option_field_output = wpshop_form::form_input( 'wpshop_display_option[' . $field_identifier . ']', $field_identifier, ! empty( $wpshop_display_option[ $field_identifier ] ) ? $wpshop_display_option[ $field_identifier ] : 20, 'text' ); |
|
192
|
|
|
} else { |
|
193
|
|
|
$option_field_output = $wpshop_display_option[ $field_identifier ]; |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
echo $option_field_output . ' <a href="#" title="' . __( 'Number of elements per page','wpshop' ) . '" class="wpshop_infobulle_marker">?</a>'; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
/** |
|
200
|
|
|
* FIELDS - Display last products ordered count option |
|
201
|
|
|
*/ |
|
202
|
|
|
function wpshop_display_latest_products_ordered() { |
|
|
|
|
|
|
203
|
|
|
|
|
204
|
|
|
$display_option = get_option( 'wpshop_display_option' ); |
|
205
|
|
|
$output = '<input type="text" value="' . ( ( ! empty( $display_option ) && ! empty( $display_option['latest_products_ordered'] ) ) ? $display_option['latest_products_ordered'] : '') . '" name="wpshop_display_option[latest_products_ordered]" id="wpshop_display_latest_products_ordered" />'; |
|
206
|
|
|
echo $output; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/** |
|
210
|
|
|
* FIELDS - Display WP Admin Bar for customers option |
|
211
|
|
|
*/ |
|
212
|
|
|
function wpshop_hide_admin_bar() { |
|
|
|
|
|
|
213
|
|
|
|
|
214
|
|
|
$wpshop_hide_admin_bar_option = get_option( 'wpshop_display_option' ); |
|
215
|
|
|
$output = '<input type="checkbox" name="wpshop_display_option[wpshop_hide_admin_bar]" ' . ( ( ! empty( $wpshop_hide_admin_bar_option ) && ! empty( $wpshop_hide_admin_bar_option['wpshop_hide_admin_bar'] ) ) ? 'checked="checked"' : '') . '/>'; |
|
216
|
|
|
echo $output; |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* FIELDS - Display delete order for customers option |
|
221
|
|
|
*/ |
|
222
|
|
|
public function wpshop_display_delete_order() { |
|
223
|
|
|
|
|
224
|
|
|
$wpshop_display_delete_order_option = get_option( 'wpshop_display_option' ); |
|
225
|
|
|
$output = '<input type="checkbox" name="wpshop_display_option[wpshop_display_delete_order]" ' . ( ( ! empty( $wpshop_display_delete_order_option ) && ! empty( $wpshop_display_delete_order_option['wpshop_display_delete_order'] ) ) ? 'checked="checked"' : '') . '/>'; |
|
226
|
|
|
echo $output; |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
|
|
230
|
|
|
/** |
|
231
|
|
|
* *********************************** |
|
232
|
|
|
* *********************************** |
|
233
|
|
|
* CUSTOMIZER WPSHOP DISPLAY OPTIONS * |
|
234
|
|
|
* *********************************** |
|
235
|
|
|
* *********************************** |
|
236
|
|
|
*/ |
|
237
|
|
|
|
|
238
|
|
|
/** |
|
239
|
|
|
* VALIDATOR - Customize WPShop validator |
|
240
|
|
|
* |
|
241
|
|
|
* @param array $input |
|
242
|
|
|
* @return array |
|
243
|
|
|
*/ |
|
244
|
|
|
function customize_color_validator( $input ) { |
|
|
|
|
|
|
245
|
|
|
|
|
246
|
|
|
return $input; |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
/** |
|
250
|
|
|
* EXPLANATIONS - Display customize WPShop explanantions |
|
251
|
|
|
*/ |
|
252
|
|
|
function customize_wpshop_colors_explanation() { |
|
|
|
|
|
|
253
|
|
|
|
|
254
|
|
|
_e( 'Here, you can customize your WPShop elements like buttons, customer account parts and selected shipping method colors...', 'wpshop' ); |
|
255
|
|
|
} |
|
256
|
|
|
|
|
257
|
|
|
/** |
|
258
|
|
|
* FIELDS - Display First button customize option |
|
259
|
|
|
*/ |
|
260
|
|
|
function wps_customize_first_button_style() { |
|
|
|
|
|
|
261
|
|
|
|
|
262
|
|
|
$wpshop_customize_display_option = get_option( 'wpshop_customize_display_option' ); |
|
263
|
|
|
require( wpshop_tools::get_template_part( WPS_OPTIONS_DIR, WPS_OPTIONS_TEMPLATE_DIR, 'backend', 'wps_display_options_customize_first_button' ) ); |
|
264
|
|
|
} |
|
265
|
|
|
|
|
266
|
|
|
/** |
|
267
|
|
|
* FIELDS - Display Second button customize option |
|
268
|
|
|
*/ |
|
269
|
|
|
function wps_customize_second_button_style() { |
|
|
|
|
|
|
270
|
|
|
|
|
271
|
|
|
$wpshop_customize_display_option = get_option( 'wpshop_customize_display_option' ); |
|
272
|
|
|
require( wpshop_tools::get_template_part( WPS_OPTIONS_DIR, WPS_OPTIONS_TEMPLATE_DIR, 'backend', 'wps_display_options_customize_second_button' ) ); |
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
|
|
/** |
|
276
|
|
|
* FIELDS - Dsiplay Customer account customize option |
|
277
|
|
|
*/ |
|
278
|
|
|
function wps_customize_account_style() { |
|
|
|
|
|
|
279
|
|
|
|
|
280
|
|
|
$wpshop_customize_display_option = get_option( 'wpshop_customize_display_option' ); |
|
281
|
|
|
require( wpshop_tools::get_template_part( WPS_OPTIONS_DIR, WPS_OPTIONS_TEMPLATE_DIR, 'backend', 'wps_display_options_customize_customer_account' ) ); |
|
282
|
|
|
} |
|
283
|
|
|
|
|
284
|
|
|
/** |
|
285
|
|
|
* FIELDS - Dsiplay Customer account customize option |
|
286
|
|
|
*/ |
|
287
|
|
|
function wps_customize_shipping_style() { |
|
|
|
|
|
|
288
|
|
|
|
|
289
|
|
|
$wpshop_customize_display_option = get_option( 'wpshop_customize_display_option' ); |
|
290
|
|
|
require( wpshop_tools::get_template_part( WPS_OPTIONS_DIR, WPS_OPTIONS_TEMPLATE_DIR, 'backend', 'wps_display_options_customize_shipping_list' ) ); |
|
291
|
|
|
} |
|
292
|
|
|
|
|
293
|
|
|
/** |
|
294
|
|
|
* Print Custom CSS Rules in administration |
|
295
|
|
|
*/ |
|
296
|
|
|
function create_customizing_css_rules() { |
|
|
|
|
|
|
297
|
|
|
|
|
298
|
|
|
$wpshop_customize_display_option = get_option( 'wpshop_customize_display_option' ); |
|
299
|
|
|
require( wpshop_tools::get_template_part( WPS_OPTIONS_DIR, WPS_OPTIONS_TEMPLATE_DIR, 'frontend', 'wps_display_options_customize_css_rules' ) ); |
|
300
|
|
|
} |
|
301
|
|
|
|
|
302
|
|
|
|
|
303
|
|
|
/** |
|
304
|
|
|
* *********************************** |
|
305
|
|
|
* *********************************** |
|
306
|
|
|
* BACK-END GENERALS DISPLAY OPTIONS * |
|
307
|
|
|
* *********************************** |
|
308
|
|
|
* *********************************** |
|
309
|
|
|
*/ |
|
310
|
|
|
|
|
311
|
|
|
/** |
|
312
|
|
|
* VALIDATOR - Admin display option validator |
|
313
|
|
|
* |
|
314
|
|
|
* @param array $input |
|
315
|
|
|
* @return array |
|
316
|
|
|
*/ |
|
317
|
|
|
function admin_part_validator( $input ) { |
|
|
|
|
|
|
318
|
|
|
|
|
319
|
|
|
return $input; |
|
320
|
|
|
} |
|
321
|
|
|
|
|
322
|
|
|
/** |
|
323
|
|
|
* EXPLANATIONS - Admin display options explanation |
|
324
|
|
|
*/ |
|
325
|
|
|
function admin_part_explanation() { |
|
|
|
|
|
|
326
|
|
|
|
|
327
|
|
|
_e( 'You can defined some parameters for admin display', 'wpshop' ); |
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
/** |
|
331
|
|
|
* FIELDS - Display admin option Attributes set layout type |
|
332
|
|
|
*/ |
|
333
|
|
View Code Duplication |
function wpshop_admin_display_attr_set_layout() { |
|
|
|
|
|
|
334
|
|
|
|
|
335
|
|
|
global $attribute_page_layout_types; |
|
336
|
|
|
$field_identifier = 'wpshop_admin_attr_set_layout'; |
|
337
|
|
|
$wpshop_admin_display_option = get_option( 'wpshop_admin_display_option', array() ); |
|
|
|
|
|
|
338
|
|
|
if ( current_user_can( 'wpshop_edit_options' ) ) { |
|
339
|
|
|
$option_field_output = wpshop_form::form_input_select( 'wpshop_admin_display_option[' . $field_identifier . ']', $field_identifier, $attribute_page_layout_types, WPSHOP_ATTRIBUTE_SET_EDITION_PAGE_LAYOUT, '', 'index' ); |
|
340
|
|
|
} else { $option_field_output = $wpshop_admin_display_option[ $field_identifier ]; |
|
341
|
|
|
} |
|
342
|
|
|
|
|
343
|
|
|
echo $option_field_output . ' <a href="#" title="' . __( 'Define if the attribute set edition page is displayed as tab or as separated bloc','wpshop' ) . '" class="wpshop_infobulle_marker">?</a>'; |
|
344
|
|
|
} |
|
345
|
|
|
|
|
346
|
|
|
/** |
|
347
|
|
|
* FIELDS - Display admin option attributes Layout type |
|
348
|
|
|
*/ |
|
349
|
|
View Code Duplication |
function wpshop_admin_display_attr_layout() { |
|
|
|
|
|
|
350
|
|
|
|
|
351
|
|
|
global $attribute_page_layout_types; |
|
352
|
|
|
$field_identifier = 'wpshop_admin_attr_layout'; |
|
353
|
|
|
$wpshop_admin_display_option = get_option( 'wpshop_admin_display_option', array() ); |
|
|
|
|
|
|
354
|
|
|
if ( current_user_can( 'wpshop_edit_options' ) ) { |
|
355
|
|
|
$option_field_output = wpshop_form::form_input_select( 'wpshop_admin_display_option[' . $field_identifier . ']', $field_identifier, $attribute_page_layout_types, WPSHOP_ATTRIBUTE_EDITION_PAGE_LAYOUT, '', 'index' ); |
|
356
|
|
|
} else { $option_field_output = $wpshop_admin_display_option[ $field_identifier ]; |
|
357
|
|
|
} |
|
358
|
|
|
|
|
359
|
|
|
echo $option_field_output . ' <a href="#" title="' . __( 'Define if the attribute edition page is displayed as tab or as separated bloc','wpshop' ) . '" class="wpshop_infobulle_marker">?</a>'; |
|
360
|
|
|
} |
|
361
|
|
|
|
|
362
|
|
|
/** |
|
363
|
|
|
* FIELDS - Display admin options Shortcode layout display |
|
364
|
|
|
*/ |
|
365
|
|
View Code Duplication |
function wpshop_admin_display_shortcode_in_product_page() { |
|
|
|
|
|
|
366
|
|
|
|
|
367
|
|
|
global $product_page_layout_types; |
|
368
|
|
|
$field_identifier = 'wpshop_admin_product_shortcode_display'; |
|
369
|
|
|
$wpshop_admin_display_option = get_option( 'wpshop_admin_display_option', array() ); |
|
|
|
|
|
|
370
|
|
|
if ( current_user_can( 'wpshop_edit_options' ) ) { |
|
371
|
|
|
$option_field_output = wpshop_form::form_input_select( 'wpshop_admin_display_option[' . $field_identifier . ']', $field_identifier, $product_page_layout_types, WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE, '', 'index' ); |
|
372
|
|
|
} else { $option_field_output = $wpshop_admin_display_option[ $field_identifier ]; |
|
373
|
|
|
} |
|
374
|
|
|
|
|
375
|
|
|
echo $option_field_output . ' <a href="#" title="' . __( 'Define how to display the shortcode summary in product edition page','wpshop' ) . '" class="wpshop_infobulle_marker">?</a>'; |
|
376
|
|
|
} |
|
377
|
|
|
} |
|
378
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.