|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* WooCommerce Discontinued Products Settings Class |
|
4
|
|
|
* |
|
5
|
|
|
* @package woocommerce |
|
6
|
|
|
* @since 1.1.0 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
if ( ! class_exists( 'DP_Settings' ) ) { |
|
10
|
|
|
/** |
|
11
|
|
|
* DP_Settings Class |
|
12
|
|
|
* |
|
13
|
|
|
* @since 1.1.0 |
|
14
|
|
|
*/ |
|
15
|
|
|
class DP_Settings { |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Inititiate the DP_Settings. |
|
19
|
|
|
* |
|
20
|
|
|
* @since 1.1.0 |
|
21
|
|
|
*/ |
|
22
|
|
|
public function __construct() { |
|
23
|
|
|
|
|
24
|
|
|
add_filter( 'woocommerce_get_sections_products', array( $this, 'add_settings_section' ) ); |
|
25
|
|
|
add_filter( 'woocommerce_get_settings_products', array( $this, 'add_settings_section_fields' ), 10, 2 ); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Add Discontinued Products section. |
|
30
|
|
|
* |
|
31
|
|
|
* @since 1.1.0 |
|
32
|
|
|
* @param array $sections Array of "Product" tab sections. |
|
33
|
|
|
*/ |
|
34
|
|
|
public function add_settings_section( $sections ) { |
|
35
|
|
|
|
|
36
|
|
|
$sections['discontinued_products'] = __( 'Discontinued Products', 'discontinued-products' ); |
|
37
|
|
|
return $sections; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Add Discontinued Products settings. |
|
42
|
|
|
* |
|
43
|
|
|
* @since 1.1.0 |
|
44
|
|
|
* @param array $settings Array of "Product" tab settings. |
|
45
|
|
|
* @param string $current_section current section ID. |
|
46
|
|
|
*/ |
|
47
|
|
|
public function add_settings_section_fields( $settings, $current_section ) { |
|
48
|
|
|
|
|
49
|
|
|
if ( 'discontinued_products' === $current_section ) { |
|
50
|
|
|
$settings = array(); |
|
51
|
|
|
$settings[] = array( |
|
52
|
|
|
'name' => __( 'Discontinued Products', 'discontinued-products' ), |
|
53
|
|
|
'type' => 'title', |
|
54
|
|
|
'desc' => __( 'The following options are global settings for Discontinued Products', 'discontinued-products' ), |
|
55
|
|
|
'id' => 'discontinued_products', |
|
56
|
|
|
); |
|
57
|
|
|
$settings[] = array( |
|
58
|
|
|
'name' => __( 'Hide from shop', 'discontinued-products' ), |
|
59
|
|
|
'id' => 'dp_hide_from_shop', |
|
60
|
|
|
'type' => 'checkbox', |
|
61
|
|
|
'css' => 'min-width:300px;', |
|
62
|
|
|
'desc' => __( 'Hide on product archive pages including the shop page by default.', 'discontinued-products' ), |
|
63
|
|
|
'default' => '', |
|
64
|
|
|
); |
|
65
|
|
|
$settings[] = array( |
|
66
|
|
|
'name' => __( 'Hide from search', 'discontinued-products' ), |
|
67
|
|
|
'id' => 'dp_hide_from_search', |
|
68
|
|
|
'type' => 'checkbox', |
|
69
|
|
|
'css' => 'min-width:300px;', |
|
70
|
|
|
'desc' => __( 'Hide from the product search results page by default.', 'discontinued-products' ), |
|
71
|
|
|
'default' => '', |
|
72
|
|
|
); |
|
73
|
|
|
$settings[] = array( |
|
74
|
|
|
'name' => __( 'Discontinued product text', 'discontinued-products' ), |
|
75
|
|
|
'desc_tip' => __( 'This can be overridden on a per product basis the default is: "This product has been discontinued.".', 'discontinued-products' ), |
|
76
|
|
|
'id' => 'dp_discontinued_text', |
|
77
|
|
|
'type' => 'text', |
|
78
|
|
|
'desc' => __( 'Enter text to be shown when product is discontinued.', 'discontinued-products' ), |
|
79
|
|
|
); |
|
80
|
|
|
$settings[] = array( |
|
81
|
|
|
'name' => __( 'Alternative product text', 'discontinued-products' ), |
|
82
|
|
|
'desc_tip' => __( 'This can be overridden on a per product basis the default is: "You may be interested in:".', 'discontinued-products' ), |
|
83
|
|
|
'id' => 'dp_alt_text', |
|
84
|
|
|
'type' => 'text', |
|
85
|
|
|
'desc' => __( 'Enter text to be shown when alternative product are suggested.', 'discontinued-products' ), |
|
86
|
|
|
); |
|
87
|
|
|
|
|
88
|
|
|
$settings[] = array( |
|
89
|
|
|
'title' => __( 'Discontinued page', 'discontinued-products' ), |
|
90
|
|
|
'id' => 'dp_shop_page_id', |
|
91
|
|
|
'type' => 'single_select_page', |
|
92
|
|
|
'default' => '', |
|
93
|
|
|
'class' => 'wc-enhanced-select-nostd', |
|
94
|
|
|
'css' => 'min-width:300px;', |
|
95
|
|
|
'desc_tip' => __( 'This sets the page of your discontinued products - this is where your discontinued product archive will be.', 'discontinued-products' ), |
|
96
|
|
|
); |
|
97
|
|
|
|
|
98
|
|
|
$settings[] = array( |
|
99
|
|
|
'type' => 'sectionend', |
|
100
|
|
|
'id' => 'discontinued_products', |
|
101
|
|
|
); |
|
102
|
|
|
return $settings; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
return $settings; |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
$dp_settings = new DP_Settings(); |
|
110
|
|
|
} |
|
111
|
|
|
|