Passed
Push — 252-fix/delete-post-revision-t... ( 2d4c2c...2c79ef )
by Sudar
08:04 queued 03:02
created

bd_load_deprecated_page_modules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 1
b 0
f 1
1
<?php
2
/**
3
 * Support Old add-ons.
4
 *
5
 * V6.0.0 changed the way add-ons and modules are handled.
6
 * This file contains code to add the backward compatibility layer for old add-ons.
7
 * This compatibility code would be eventually removed once all the add-ons have got upgraded.
8
 *
9
 * @since 6.0.0
10
 */
11
12
use BulkWP\BulkDelete\Deprecated\Addons\DeleteFromTrashModule;
13
use BulkWP\BulkDelete\Deprecated\Addons\DeletePostsByCustomFieldModule;
14
use BulkWP\BulkDelete\Deprecated\Addons\DeletePostsByDuplicateTitleModule;
15
use BulkWP\BulkDelete\Deprecated\Addons\DeletePostsByTitleModule;
16
use BulkWP\BulkDelete\Deprecated\Addons\DeletePostsByUserRoleModule;
17
18
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
19
20
/**
21
 * Load deprecated post modules.
22
 *
23
 * Older version of some add-ons require this compatibility code to work properly.
24
 * This compatibility code will be eventually removed.
25
 *
26
 * @since 6.0.0
27
 *
28
 * @param \BulkWP\BulkDelete\Core\Base\BaseDeletePage $page Page object.
29
 */
30
function bd_load_deprecated_post_modules( $page ) {
31
	$trash_module = new DeleteFromTrashModule();
32
	$trash_module->set_item_type( 'posts' );
33
	$trash_module->load_if_needed( $page );
34
35
	$custom_fields_module = new DeletePostsByCustomFieldModule();
36
	$custom_fields_module->load_if_needed( $page );
37
38
	$title_module = new DeletePostsByTitleModule();
39
	$title_module->load_if_needed( $page );
40
41
	$duplicate_title_module = new DeletePostsByDuplicateTitleModule();
42
	$duplicate_title_module->load_if_needed( $page );
43
44
	$user_role_module = new DeletePostsByUserRoleModule();
45
	$user_role_module->load_if_needed( $page );
46
}
47
add_action( 'bd_after_posts_modules', 'bd_load_deprecated_post_modules' );
48
49
/**
50
 * Load deprecated page modules.
51
 *
52
 * Older version of some add-ons require this compatibility code to work properly.
53
 * This compatibility code will be eventually removed.
54
 *
55
 * @since 6.0.0
56
 *
57
 * @param \BulkWP\BulkDelete\Core\Base\BaseDeletePage $page Page object.
58
 */
59
function bd_load_deprecated_page_modules( $page ) {
60
	$trash_module = new DeleteFromTrashModule();
61
	$trash_module->set_item_type( 'pages' );
62
	$trash_module->load_if_needed( $page );
63
}
64
add_action( 'bd_after_pages_modules', 'bd_load_deprecated_page_modules' );
65