1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BulkWP\BulkDelete\Core\Addon; |
4
|
|
|
|
5
|
|
|
defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Upsell pro add-ons. |
9
|
|
|
* |
10
|
|
|
* @since 6.0.0 |
11
|
|
|
*/ |
12
|
|
|
class Upseller { |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Setup hooks. |
16
|
|
|
*/ |
17
|
|
|
public function load() { |
18
|
|
|
add_action( 'bd_after_modules', array( $this, 'load_upsell_modules' ) ); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Load upsell modules after free modules. |
23
|
|
|
* |
24
|
|
|
* @param \BulkWP\BulkDelete\Core\Base\BaseDeletePage $page The page to which the modules are added. |
25
|
|
|
*/ |
26
|
|
|
public function load_upsell_modules( $page ) { |
27
|
|
|
$upsell_addon_details = $this->get_upsell_addon_details_for_page( $page ); |
28
|
|
|
|
29
|
|
|
foreach ( $upsell_addon_details as $upsell_addon_detail ) { |
30
|
|
|
$page->add_module( new UpsellModule( new AddonInfo( $upsell_addon_detail ) ) ); |
31
|
|
|
} |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Get Upsell add-on to be shown on a particular page. |
36
|
|
|
* |
37
|
|
|
* @param \BulkWP\BulkDelete\Core\Base\BaseDeletePage $page Delete Page in which upsell add-ons to be shown. |
38
|
|
|
* |
39
|
|
|
* @return array List of Upsell modules. |
40
|
|
|
*/ |
41
|
|
|
protected function get_upsell_addon_details_for_page( $page ) { |
42
|
|
|
switch ( $page->get_item_type() ) { |
43
|
|
|
case 'posts': |
44
|
|
|
return $this->get_post_upsell_addons(); |
45
|
|
|
|
46
|
|
|
case 'pages': |
47
|
|
|
return $this->get_page_upsell_addons(); |
48
|
|
|
|
49
|
|
|
case 'users': |
50
|
|
|
return $this->get_user_upsell_addons(); |
51
|
|
|
|
52
|
|
|
case 'metas': |
53
|
|
|
return $this->get_meta_upsell_addons(); |
54
|
|
|
|
55
|
|
|
default: |
56
|
|
|
return array(); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Get upsell add-ons for delete posts page. |
62
|
|
|
* |
63
|
|
|
* Eventually this will come from a feed. |
64
|
|
|
* |
65
|
|
|
* @return array List of upsell add-on details. |
66
|
|
|
*/ |
67
|
|
|
protected function get_post_upsell_addons() { |
68
|
|
|
$addon_details = array( |
69
|
|
|
array( |
70
|
|
|
'name' => 'Bulk Delete Posts by Custom Field', |
71
|
|
|
'description' => 'This addon adds the ability to delete posts based on custom field. This will be really useful, if your plugin or theme uses custom fields to store additional information about a post.', |
72
|
|
|
'slug' => 'bulk-delete-posts-by-custom-field', |
73
|
|
|
'url' => 'https://bulkwp.com/addons/bulk-delete-posts-by-custom-field/', |
74
|
|
|
'buy_url' => '', |
75
|
|
|
'upsell_title' => 'Want to delete Posts based on Custom Field (Post Meta)?', |
76
|
|
|
'upsell_message' => '<strong>Bulk Delete Posts by Custom Field</strong> add-on allows you to delete posts based on custom field (also known as post meta).', |
77
|
|
|
), |
78
|
|
|
array( |
79
|
|
|
'name' => 'Bulk Delete Posts by Title', |
80
|
|
|
'description' => 'This addon adds the ability to delete posts based on title.', |
81
|
|
|
'slug' => 'bulk-delete-posts-by-title', |
82
|
|
|
'url' => 'https://bulkwp.com/addons/bulk-delete-posts-by-title/', |
83
|
|
|
'buy_url' => '', |
84
|
|
|
'upsell_title' => 'Want to delete Posts based on title?', |
85
|
|
|
'upsell_message' => '<strong>Bulk Delete Posts by Title</strong> add-on allows you to delete posts based on title.', |
86
|
|
|
), |
87
|
|
|
array( |
88
|
|
|
'name' => 'Bulk Delete Posts by Duplicate Title', |
89
|
|
|
'description' => 'This addon adds the ability to delete posts based on duplicate title.', |
90
|
|
|
'slug' => 'bulk-delete-posts-by-duplicate-title', |
91
|
|
|
'url' => 'https://bulkwp.com/addons/bulk-delete-posts-by-duplicate-title/', |
92
|
|
|
'buy_url' => '', |
93
|
|
|
'upsell_title' => 'Want to delete Posts that have duplicate titles?', |
94
|
|
|
'upsell_message' => '<strong>Bulk Delete Posts by Duplicate Title</strong> add-on allows you to delete posts that have duplicate title.', |
95
|
|
|
), |
96
|
|
|
array( |
97
|
|
|
'name' => 'Bulk Delete Posts by Content', |
98
|
|
|
'description' => 'This addon adds the ability to delete posts based on content.', |
99
|
|
|
'slug' => 'bulk-delete-posts-by-content', |
100
|
|
|
'url' => 'https://bulkwp.com/addons/bulk-delete-posts-by-content/', |
101
|
|
|
'buy_url' => '', |
102
|
|
|
'upsell_title' => 'Want to delete Posts based on the post content?', |
103
|
|
|
'upsell_message' => '<strong>Bulk Delete Posts by Content</strong> add-on allows you to delete posts based on its post content.', |
104
|
|
|
), |
105
|
|
|
array( |
106
|
|
|
'name' => 'Bulk Delete Posts by User Role', |
107
|
|
|
'description' => 'This addon adds the ability to delete posts based on the author who created the post.', |
108
|
|
|
'slug' => 'bulk-delete-posts-by-user-role', |
109
|
|
|
'url' => 'https://bulkwp.com/addons/bulk-delete-posts-by-user-role/', |
110
|
|
|
'buy_url' => '', |
111
|
|
|
'upsell_title' => 'Want to delete Posts based on the user who created it?', |
112
|
|
|
'upsell_message' => '<strong>Bulk Delete Posts by User</strong> add-on allows you to delete posts based on user who created the post.', |
113
|
|
|
), |
114
|
|
|
array( |
115
|
|
|
'name' => 'Bulk Delete Posts by Attachment', |
116
|
|
|
'description' => 'This addon adds the ability to delete posts based on attachment.', |
117
|
|
|
'slug' => 'bulk-delete-posts-by-attachment', |
118
|
|
|
'url' => 'https://bulkwp.com/addons/bulk-delete-posts-by-attachment/', |
119
|
|
|
'buy_url' => '', |
120
|
|
|
'upsell_title' => 'Want to delete Posts based on whether it has an attachment?', |
121
|
|
|
'upsell_message' => "<strong>Bulk Delete Posts by Attachment</strong> add-on allows you to delete posts based on whether a post contains (or doesn't contain) an attachment.", |
122
|
|
|
), |
123
|
|
|
array( |
124
|
|
|
'name' => 'Bulk Delete From Trash', |
125
|
|
|
'description' => 'This addon adds the ability to delete posts or pages from trash.', |
126
|
|
|
'slug' => 'bulk-delete-from-trash', |
127
|
|
|
'url' => 'https://bulkwp.com/addons/bulk-delete-from-trash/', |
128
|
|
|
'buy_url' => '', |
129
|
|
|
'upsell_title' => 'Want to delete Posts that are in trash?', |
130
|
|
|
'upsell_message' => '<strong>Bulk Delete From Trash</strong> add-on allows you to delete posts that are in trash.', |
131
|
|
|
), |
132
|
|
|
); |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* List of Upsell add-ons based on item type. |
136
|
|
|
* |
137
|
|
|
* @since 6.0.0 |
138
|
|
|
* |
139
|
|
|
* @param array $addon_details Add-on details. |
140
|
|
|
* @param string $item_type Item type. |
141
|
|
|
*/ |
142
|
|
|
return apply_filters( 'bd_upsell_addons', $addon_details, 'posts' ); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Get upsell add-ons for delete pages page. |
147
|
|
|
* |
148
|
|
|
* Eventually this will come from a feed. |
149
|
|
|
* |
150
|
|
|
* @return array List of upsell add-on details. |
151
|
|
|
*/ |
152
|
|
|
protected function get_page_upsell_addons() { |
153
|
|
|
$addon_details = array( |
154
|
|
|
array( |
155
|
|
|
'name' => 'Bulk Delete From Trash', |
156
|
|
|
'description' => 'This addon adds the ability to delete posts or pages from trash.', |
157
|
|
|
'slug' => 'bulk-delete-from-trash', |
158
|
|
|
'url' => 'https://bulkwp.com/addons/bulk-delete-from-trash/', |
159
|
|
|
'buy_url' => '', |
160
|
|
|
'upsell_title' => 'Want to delete pages that are in trash?', |
161
|
|
|
'upsell_message' => '<strong>Bulk Delete From Trash</strong> add-on allows you to delete pages that are in trash.', |
162
|
|
|
), |
163
|
|
|
); |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* List of Upsell add-ons based on item type. |
167
|
|
|
* |
168
|
|
|
* @since 6.0.0 |
169
|
|
|
* |
170
|
|
|
* @param array $addon_details Add-on details. |
171
|
|
|
* @param string $item_type Item type. |
172
|
|
|
*/ |
173
|
|
|
return apply_filters( 'bd_upsell_addons', $addon_details, 'pages' ); |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* Get upsell add-ons for delete users page. |
178
|
|
|
* |
179
|
|
|
* Eventually this will come from a feed. |
180
|
|
|
* |
181
|
|
|
* @return array List of upsell add-on details. |
182
|
|
|
*/ |
183
|
|
|
protected function get_user_upsell_addons() { |
184
|
|
|
/** |
185
|
|
|
* List of Upsell add-ons based on item type. |
186
|
|
|
* |
187
|
|
|
* @since 6.0.0 |
188
|
|
|
* |
189
|
|
|
* @param array $addon_details Add-on details. |
190
|
|
|
* @param string $item_type Item type. |
191
|
|
|
*/ |
192
|
|
|
return apply_filters( 'bd_upsell_addons', array(), 'users' ); |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* Get upsell add-ons for delete metas page. |
197
|
|
|
* |
198
|
|
|
* Eventually this will come from a feed. |
199
|
|
|
* |
200
|
|
|
* @return array List of upsell add-on details. |
201
|
|
|
*/ |
202
|
|
|
protected function get_meta_upsell_addons() { |
203
|
|
|
/** |
204
|
|
|
* List of Upsell add-ons based on item type. |
205
|
|
|
* |
206
|
|
|
* @since 6.0.0 |
207
|
|
|
* |
208
|
|
|
* @param array $addon_details Add-on details. |
209
|
|
|
* @param string $item_type Item type. |
210
|
|
|
*/ |
211
|
|
|
return apply_filters( 'bd_upsell_addons', array(), 'metas' ); |
212
|
|
|
} |
213
|
|
|
} |
214
|
|
|
|