1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BulkWP\BulkDelete\Deprecated\Addons; |
4
|
|
|
|
5
|
|
|
use BulkWP\BulkDelete\Core\Base\BaseModule; |
6
|
|
|
|
7
|
|
|
defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Base class for all Deprecated Modules. |
11
|
|
|
* |
12
|
|
|
* This class just extends all the abstract methods with an empty implementation. |
13
|
|
|
* |
14
|
|
|
* @since 6.0.0 |
15
|
|
|
*/ |
16
|
|
|
abstract class DeprecatedModule extends BaseModule { |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Addon class name of the old add-on that is used to find out whether the old add-on is active or not. |
20
|
|
|
* |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
protected $addon_class_name = ''; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Slug of the old add-on. |
27
|
|
|
* |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
protected $addon_slug = ''; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Load the deprecated module if the old add-on is active. |
34
|
|
|
* |
35
|
|
|
* @param \BulkWP\BulkDelete\Core\Base\BaseDeletePage $page Page object. |
36
|
|
|
*/ |
37
|
|
|
public function load_if_needed( $page ) { |
38
|
|
|
if ( ! class_exists( $this->addon_class_name ) ) { |
39
|
|
|
return; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
add_filter( 'bd_upsell_addons', array( $this, 'hide_upsell_module' ), 10, 2 ); |
43
|
|
|
|
44
|
|
|
$page->add_module( $this ); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Hide the upsell message if the add-on is active. |
49
|
|
|
* |
50
|
|
|
* @param array $addon_details Addon Details. |
51
|
|
|
* @param string $item_type Item type. |
52
|
|
|
* |
53
|
|
|
* @return array Modified list of Addon Details. |
54
|
|
|
*/ |
55
|
|
|
public function hide_upsell_module( $addon_details, $item_type ) { |
56
|
|
|
if ( ! class_exists( $this->addon_class_name ) ) { |
57
|
|
|
return $addon_details; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
if ( $this->item_type !== $item_type ) { |
61
|
|
|
return $addon_details; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
$modified_addon_details = array(); |
65
|
|
|
|
66
|
|
|
foreach ( $addon_details as $addon_detail ) { |
67
|
|
|
if ( ! array_key_exists( 'slug', $addon_detail ) ) { |
68
|
|
|
continue; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
if ( $this->addon_slug === $addon_detail['slug'] ) { |
72
|
|
|
continue; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
$modified_addon_details[] = $addon_detail; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
return $modified_addon_details; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Don't do any processing here. |
83
|
|
|
* |
84
|
|
|
* It is currently handled in the add-on. |
85
|
|
|
* |
86
|
|
|
* @param array $request Request object. |
87
|
|
|
*/ |
88
|
|
|
public function process( $request ) { |
89
|
|
|
// Empty by design. Processing of data happens in the add-on. |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
protected function parse_common_filters( $request ) { |
93
|
|
|
return array(); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
protected function convert_user_input_to_options( $request, $options ) { |
97
|
|
|
return $options; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
protected function do_delete( $options ) { |
101
|
|
|
// Empty by design. |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
protected function get_success_message( $items_deleted ) { |
105
|
|
|
// Empty by design. |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|