Completed
Push — 137-feature/construct-post-mod... ( 2fadb4...c92423 )
by Maria Daniel Deepak
03:42
created

BD_Settings   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 50
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create_settings() 0 22 1
A check_license() 0 7 1
1
<?php
2
/**
3
 * Encapsulates the settings API for Bulk Delete Plugin.
4
 *
5
 * @since      5.0
6
 *
7
 * @author     Sudar
8
 *
9
 * @package    BulkDelete\Settings
10
 */
11
defined( 'ABSPATH' ) || exit; // Exit if accessed directly
12
13
class BD_Settings {
14
	/**
15
	 * Register settings used by the plugin.
16
	 *
17
	 * @since 5.0
18
	 * @static
19
	 */
20
	public static function create_settings() {
21
		register_setting(
22
			Bulk_Delete::SETTING_OPTION_GROUP,        // Option group
23
			Bulk_Delete::SETTING_OPTION_NAME,         // Option name
24
			array( 'BD_Settings', 'check_license' )   // Sanitize
25
		);
26
27
		add_settings_section(
28
			Bulk_Delete::SETTING_SECTION_ID,          // ID
29
			__( 'Add Addon License', 'bulk-delete' ), // Title
30
			'__return_null',                          // Callback
31
			Bulk_Delete::ADDON_PAGE_SLUG              // Page
32
		);
33
34
		/**
35
		 * Runs just after registering license form fields.
36
		 *
37
		 * This action is primarily for adding more fields to the license form
38
		 *
39
		 * @since 5.0
40
		 */
41
		do_action( 'bd_license_field' );
42
	}
43
44
	/**
45
	 * Callback for sanitizing settings.
46
	 *
47
	 * @since 5.0
48
	 * @static
49
	 *
50
	 * @param array $input
51
	 *
52
	 * @return array
53
	 */
54
	public static function check_license( $input ) {
55
		/**
56
		 * Filter license form inputs.
57
		 *
58
		 * @since 5.0
59
		 */
60
		return apply_filters( 'bd_license_input', $input );
61
	}
62
}
63
64
// hooks
65
add_action( 'admin_init', array( 'BD_Settings', 'create_settings' ), 100 );
66