Passed
Push — 251-fix/delete-posts-by-URL-te... ( a87b70...29261c )
by Sudar
69:45 queued 56:00
created

bd_load_deprecated_post_modules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 16
rs 9.7333
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
use BulkWP\BulkDelete\Deprecated\Addons\DeleteFromTrashModule;
12
use BulkWP\BulkDelete\Deprecated\Addons\DeletePostsByCustomFieldModule;
13
use BulkWP\BulkDelete\Deprecated\Addons\DeletePostsByDuplicateTitleModule;
14
use BulkWP\BulkDelete\Deprecated\Addons\DeletePostsByTitleModule;
15
use BulkWP\BulkDelete\Deprecated\Addons\DeletePostsByUserRoleModule;
16
17
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
18
19
/**
20
 * Load deprecated post modules.
21
 *
22
 * Older version of some add-ons require this compatibility code to work properly.
23
 * This compatibility code will be eventually removed.
24
 *
25
 * @since 6.0.0
26
 *
27
 * @param \BulkWP\BulkDelete\Core\Base\BaseDeletePage $page Page object.
28
 */
29
function bd_load_deprecated_post_modules( $page ) {
30
	$trash_module = new DeleteFromTrashModule();
31
	$trash_module->set_item_type( 'posts' );
32
	$trash_module->load_if_needed( $page );
33
34
	$custom_fields_module = new DeletePostsByCustomFieldModule();
35
	$custom_fields_module->load_if_needed( $page );
36
37
	$title_module = new DeletePostsByTitleModule();
38
	$title_module->load_if_needed( $page );
39
40
	$duplicate_title_module = new DeletePostsByDuplicateTitleModule();
41
	$duplicate_title_module->load_if_needed( $page );
42
43
	$user_role_module = new DeletePostsByUserRoleModule();
44
	$user_role_module->load_if_needed( $page );
45
}
46
add_action( 'bd_after_posts_modules', 'bd_load_deprecated_post_modules' );
47
48
/**
49
 * Load deprecated page modules.
50
 *
51
 * Older version of some add-ons require this compatibility code to work properly.
52
 * This compatibility code will be eventually removed.
53
 *
54
 * @since 6.0.0
55
 *
56
 * @param \BulkWP\BulkDelete\Core\Base\BaseDeletePage $page Page object.
57
 */
58
function bd_load_deprecated_page_modules( $page ) {
59
	$trash_module = new DeleteFromTrashModule();
60
	$trash_module->set_item_type( 'pages' );
61
	$trash_module->load_if_needed( $page );
62
}
63
add_action( 'bd_after_pages_modules', 'bd_load_deprecated_page_modules' );
64