PluginProbe ʕ •ᴥ•ʔ
Presto Player / 2.0.7
Presto Player v2.0.7
4.5.0 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.4 4.2.3 4.2.2 4.2.0 4.2.1 trunk 1.10.0 1.10.1 1.10.2 1.11.0 1.12.0 1.13.0 1.14.0 1.14.1 1.5.10 1.5.11 1.5.12 1.5.13 1.5.14 1.5.15 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.13 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3-beta1 2.3.0 2.3.1 2.3.2 2.3.3 3.0.0 3.0.0-beta1 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.1.0 3.1.1 3.1.2 3.1.3 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4
presto-player / inc / Services / API / RestSettingsController.php
presto-player / inc / Services / API Last commit date
RestAudioPresetsController.php 3 years ago RestPresetsController.php 3 years ago RestSettingsController.php 3 years ago RestVideosController.php 2 years ago
RestSettingsController.php
105 lines
1 <?php
2
3 namespace PrestoPlayer\Services\API;
4
5 class RestSettingsController extends \WP_REST_Settings_Controller
6 {
7
8 /**
9 * Constructor.
10 *
11 * @since 4.7.0
12 */
13 public function __construct()
14 {
15 $this->namespace = 'presto-player/v1';
16 $this->rest_base = 'settings';
17 }
18
19 /**
20 * Register controller
21 *
22 * @return void
23 */
24 public function register()
25 {
26 add_action('rest_api_init', [$this, 'register_routes']);
27 }
28
29 /**
30 * Checks if a given request has access to read and manage settings.
31 *
32 * @since 4.7.0
33 *
34 * @param WP_REST_Request $request Full details about the request.
35 * @return bool True if the request has read access for the item, otherwise false.
36 */
37 public function get_item_permissions_check($request)
38 {
39 return current_user_can('edit_posts');
40 }
41
42 /**
43 * Retrieves all of the registered options for the Settings API.
44 *
45 * @since 4.7.0
46 *
47 * @return array Array of registered options.
48 */
49 protected function get_registered_options()
50 {
51 $rest_options = array();
52
53 foreach (get_registered_settings() as $name => $args) {
54 if (!in_array($name, ['presto_player_branding', 'presto_player_youtube', 'presto_player_presets', 'presto_player_audio_presets'])) {
55 continue;
56 }
57
58 if (empty($args['show_in_rest'])) {
59 continue;
60 }
61
62 $rest_args = array();
63
64 if (is_array($args['show_in_rest'])) {
65 $rest_args = $args['show_in_rest'];
66 }
67
68 $defaults = array(
69 'name' => !empty($rest_args['name']) ? $rest_args['name'] : $name,
70 'schema' => array(),
71 );
72
73 $rest_args = array_merge($defaults, $rest_args);
74
75 $default_schema = array(
76 'type' => empty($args['type']) ? null : $args['type'],
77 'description' => empty($args['description']) ? '' : $args['description'],
78 'default' => isset($args['default']) ? $args['default'] : null,
79 );
80
81 $rest_args['schema'] = array_merge($default_schema, $rest_args['schema']);
82 $rest_args['option_name'] = $name;
83
84 // Skip over settings that don't have a defined type in the schema.
85 if (empty($rest_args['schema']['type'])) {
86 continue;
87 }
88
89 /*
90 * Allow the supported types for settings, as we don't want invalid types
91 * to be updated with arbitrary values that we can't do decent sanitizing for.
92 */
93 if (!in_array($rest_args['schema']['type'], array('number', 'integer', 'string', 'boolean', 'array', 'object'), true)) {
94 continue;
95 }
96
97 $rest_args['schema'] = rest_default_additional_properties_to_false($rest_args['schema']);
98
99 $rest_options[$rest_args['name']] = $rest_args;
100 }
101
102 return $rest_options;
103 }
104 }
105