1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Deprecated and backward compatibility code. |
4
|
|
|
* Don't depend on the code in this file. It would be removed in future versions of the plugin. |
5
|
|
|
* |
6
|
|
|
* @author Sudar |
7
|
|
|
* @package BulkDelete\Util\Deprecated |
8
|
|
|
* @since 5.5 |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
defined( 'ABSPATH' ) || exit; // Exit if accessed directly |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Backward compatibility for delete options. |
15
|
|
|
* |
16
|
|
|
* @since 5.5 |
17
|
|
|
* @param array $options Old options. |
18
|
|
|
* @return array New options. |
19
|
|
|
*/ |
20
|
|
|
function bd_delete_options_compatibility( $options ) { |
21
|
|
|
// Convert bool keys to boolean |
22
|
|
|
$bool_keys = array( 'restrict', 'force_delete', 'private' ); |
23
|
|
|
foreach ( $bool_keys as $key ) { |
24
|
|
|
if ( array_key_exists( $key, $options ) ) { |
25
|
|
|
$options[ $key ] = bd_to_bool( $options[ $key ] ); |
26
|
|
|
} |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
// convert old date comparison operators |
30
|
|
|
if ( array_key_exists( 'date_op', $options ) && array_key_exists( 'days', $options ) ) { |
31
|
|
|
if ( '<' == $options['date_op'] ) { |
32
|
|
|
$options['date_op'] = 'before'; |
33
|
|
|
} else if ( '>' == $options['date_op'] ) { |
34
|
|
|
$options['date_op'] = 'after'; |
35
|
|
|
} |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
return $options; |
39
|
|
|
} |
40
|
|
|
add_filter( 'bd_delete_options', 'bd_delete_options_compatibility' ); |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Enable cron for old pro addons that required separate JavaScript. |
44
|
|
|
* This will be removed in v6.0 |
45
|
|
|
* |
46
|
|
|
* @since 5.5 |
47
|
|
|
* @param array $js_array JavaScript Array |
48
|
|
|
* @return array Modified JavaScript Array |
49
|
|
|
*/ |
50
|
|
|
function bd_enable_cron_for_old_addons( $js_array ) { |
51
|
|
|
if ( ! function_exists( 'is_plugin_active' ) ) { |
52
|
|
|
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
if ( is_plugin_active( 'bulk-delete-scheduler-for-deleting-users-by-role/bulk-delete-scheduler-for-deleting-users-by-role.php' ) ) { |
56
|
|
|
$js_array['pro_iterators'][] = 'u_role'; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
return $js_array; |
60
|
|
|
} |
61
|
|
|
add_filter( 'bd_javascript_array', 'bd_enable_cron_for_old_addons' ); |
62
|
|
|
?> |
63
|
|
|
|