class-media-library-organizer-tree-view-admin.php
2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/**
* Tree View Admin class.
*
* @package Media_Library_Organizer
* @author WP Media Library
*/
/**
* Tree View class
*
* @since 1.1.1
*/
class Media_Library_Organizer_Tree_View_Admin {
/**
* Holds the base class object.
*
* @since 1.1.1
*
* @var object
*/
public $base;
/**
* Constructor
*
* @since 1.1.1
*
* @param object $base Base Plugin Class.
*/
public function __construct( $base ) {
// Store base class.
$this->base = $base;
// Settings.
add_filter( 'media_library_organizer_admin_get_screen_addon_tabs', array( $this, 'get_screen_addon_tabs' ), 10, 2 );
add_action( 'media_library_organizer_admin_output_settings_panels', array( $this, 'output_settings_panels' ) );
add_filter( 'media_library_organizer_admin_save_settings', array( $this, 'save_settings' ), 10, 2 );
}
/**
* Adds this Addon as a tab to the Settings screen.
*
* @since 1.1.1
*
* @param array $tabs Tabs.
* @param string $screen Screen.
* @return array Tabs
*/
public function get_screen_addon_tabs( $tabs, $screen ) {
switch ( $screen ) {
/**
* Settings
*/
case 'settings':
// Define tab.
$tabs['tree-view'] = array(
'name' => 'tree-view',
'label' => $this->base->plugin->displayName,
'documentation' => $this->base->plugin->documentation_url . '/setup',
'menu_icon' => 'list',
);
break;
}
return $tabs;
}
/**
* Outputs Settings Panel(s) for this Addon.
*
* @since 1.1.1
*/
public function output_settings_panels() {
// Load View.
require_once $this->base->plugin->folder . '/views/admin/settings.php';
}
/**
* Save Settings for this Addon.
*
* @since 1.1.1
*
* @param mixed $result Result (WP_Error|true).
* @param array $settings Settings.
* @return bool Success
*/
public function save_settings( $result, $settings ) {
// Bail if no settings for this Addon were posted.
if ( ! isset( $settings['tree-view'] ) ) {
return $result;
}
// Save Settings.
return Media_Library_Organizer()->get_class( 'settings' )->update_settings( 'tree-view', $settings['tree-view'] );
}
/**
* Helper method to get the setting value from the Plugin settings
*
* @since 1.1.1
*
* @param string $screen Screen.
* @param string $key Setting Key.
* @return mixed Value
*/
public function get_setting( $screen = '', $key = '' ) {
return Media_Library_Organizer()->get_class( 'settings' )->get_setting( $screen, $key );
}
}