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

DeleteFromTrashModule::initialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
namespace BulkWP\BulkDelete\Deprecated\Addons;
4
5
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
6
7
/**
8
 * Adds backward compatibility for Bulk Delete From Trash add-on v0.3 or below.
9
 *
10
 * This module will eventually be removed once the add-on is updated.
11
 *
12
 * @since 6.0.0
13
 */
14
class DeleteFromTrashModule extends DeprecatedModule {
15
16
	protected function initialize() {
17
		$this->addon_class_name = 'Bulk_Delete_From_Trash';
18
		$this->addon_slug       = 'bulk-delete-from-trash';
19
20
		$this->item_type     = 'posts';
21
		$this->field_slug    = 'trash';
22
		$this->meta_box_slug = 'bd_posts_from_trash';
23
		$this->action        = 'delete_pages_from_trash';
24
		$this->cron_hook     = '';
25
		$this->scheduler_url = '';
26
		$this->messages      = array(
27
			'box_label'  => __( 'Delete Posts from Trash', 'bulk-delete' ),
28
			'scheduled'  => '',
29
			'cron_label' => '',
30
		);
31
	}
32
33
	/**
34
	 * Set the item type of the module.
35
	 * The item type determines in which page the module will be displayed.
36
	 *
37
	 * @param string $item_type Item type. Possible vales are posts or pages.
38
	 */
39
	public function set_item_type( $item_type ) {
40
		$this->item_type     = $item_type;
41
		$this->action        = "delete_{$item_type}_from_trash";
42
		$this->meta_box_slug = "bd_{$item_type}_from_trash";
43
44
		if ( 'pages' === $item_type ) {
45
			$this->messages['box_label'] = __( 'Delete Pages from Trash', 'bulk-delete' );
46
		}
47
	}
48
49
	/**
50
	 * Call the appropriate action to render the add-on.
51
	 */
52
	public function render() {
53
		if ( 'posts' === $this->item_type ) {
54
			/**
55
			 * Render delete posts from trash box.
56
			 *
57
			 * @since 5.4
58
			 */
59
			do_action( 'bd_render_delete_posts_from_trash' );
60
		} elseif ( 'pages' === $this->item_type ) {
61
			/**
62
			 * Render delete pages from trash box.
63
			 *
64
			 * @since 5.4
65
			 */
66
			do_action( 'bd_render_delete_pages_from_trash' );
67
		}
68
	}
69
}
70