Completed
Pull Request — dev/6.0.1 (#618)
by Sudar
70:21 queued 67:37
created

MetasModule   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 25%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 44
ccs 4
cts 16
cp 0.25
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A render_restrict_settings() 0 2 1
A get_post_type_and_status_args() 0 6 1
A parse_common_filters() 0 13 2
1
<?php
2
3
namespace BulkWP\BulkDelete\Core\Metas;
4
5
use BulkWP\BulkDelete\Core\Base\BaseModule;
6
7 1
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
8
9
/**
10
 * Module for Deleting Meta fields.
11
 *
12
 * @since 6.0.0
13
 */
14
abstract class MetasModule extends BaseModule {
15
	protected $item_type = 'metas';
16
17
	protected function render_restrict_settings( $item = 'posts' ) {
18
		bd_render_restrict_settings( $this->field_slug, $item );
19
	}
20
21
	/**
22
	 * Handle common filters.
23
	 *
24
	 * @param array $request Request array.
25
	 *
26
	 * @return array User options.
27
	 */
28
	protected function parse_common_filters( $request ) {
29
		$options = array();
30
31
		$options['restrict']     = bd_array_get_bool( $request, 'smbd_' . $this->field_slug . '_restrict', false );
32
		$options['limit_to']     = absint( bd_array_get( $request, 'smbd_' . $this->field_slug . '_limit_to', 0 ) );
33
		$options['force_delete'] = bd_array_get_bool( $request, 'smbd_' . $this->field_slug . '_force_delete', false );
34
35
		if ( $options['restrict'] ) {
36
			$options['date_op'] = bd_array_get( $request, 'smbd_' . $this->field_slug . '_op' );
37
			$options['days']    = absint( bd_array_get( $request, 'smbd_' . $this->field_slug . '_days' ) );
38
		}
39
40
		return $options;
41
	}
42
43
	/**
44
	 * Get the Post type and status args.
45
	 *
46
	 * @param string $post_type_and_status Post type and status.
47
	 *
48
	 * @since 6.0.1
49
	 *
50
	 * @return array Args.
51
	 */
52 11
	protected function get_post_type_and_status_args( $post_type_and_status ) {
53 11
		$type_status = $this->split_post_type_and_status( $post_type_and_status );
54
55
		return array(
56 11
			'post_type'   => $type_status['type'],
57 11
			'post_status' => $type_status['status'],
58
		);
59
	}
60
}
61