PluginProbe
Image Source Control Lite – Show Image Credits and Captions / trunk
Image Source Control Lite – Show Image Credits and Captions vtrunk
3.12.0 3.11.0 trunk 1.1 1.1.1 1.1.2 1.1.2.1 1.1.3 1.10 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.2 1.2.0.1 1.2.0.2 1.2.0.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.4.1 1.3.5 All 110 releases
image-source-control-isc / includes / settings / sections / licenses.php

licenses.php in Image Source Control Lite – Show Image Credits and Captions trunk, at includes/settings/sections/licenses.php

67 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ISC\Settings\Sections;
4
5 use ISC\Settings;
6
7 /**
8 * Handle settings for licenses
9 */
10 class Licenses extends Settings\Section {
11
12 /**
13 * Add settings section
14 */
15 public function add_settings_section() {
16 add_settings_section( 'isc_settings_section_licenses', __( 'Image licenses', 'image-source-control-isc' ), '__return_false', 'isc_settings_page' );
17 add_settings_field( 'enable_licences', __( 'Enable', 'image-source-control-isc' ), [ $this, 'render_field_enable_licences' ], 'isc_settings_page', 'isc_settings_section_licenses' );
18 add_settings_field( 'licences', __( 'List of licenses', 'image-source-control-isc' ), [ $this, 'render_field_licences' ], 'isc_settings_page', 'isc_settings_section_licenses' );
19 }
20
21 /**
22 * Render option to enable the license settings.
23 */
24 public function render_field_enable_licences() {
25 $options = $this->get_options();
26 require_once ISCPATH . '/admin/templates/settings/licenses/enable.php';
27 }
28
29 /**
30 * Render option to define the available licenses
31 */
32 public function render_field_licences() {
33 $options = $this->get_options();
34
35 // fall back to default if field is empty
36 if ( empty( $options['licences'] ) ) {
37 // retrieve default options
38 $default = \ISC\Plugin::default_options();
39 if ( ! empty( $default['licences'] ) ) {
40 $options['licences'] = $default['licences'];
41 }
42 }
43
44 require_once ISCPATH . '/admin/templates/settings/licenses/licenses.php';
45 }
46
47 /**
48 * Validate settings
49 *
50 * @param array $output output data.
51 * @param array $input input data.
52 *
53 * @return array $output
54 */
55 public function validate_settings( array $output, array $input ): array {
56 $output['enable_licences'] = ! empty( $input['enable_licences'] );
57
58 if ( isset( $input['licences'] ) ) {
59 $output['licences'] = esc_textarea( $input['licences'] );
60 } else {
61 $output['licences'] = false;
62 }
63
64 return $output;
65 }
66 }
67