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