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 / page-list.php

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

130 lines 4.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 page-list image source displays
9 */
10 class Page_List extends Settings\Section {
11
12 /**
13 * Add settings section
14 */
15 public function add_settings_section() {
16 add_settings_section( 'isc_settings_section_list_below_content', __( 'Per-page list', 'image-source-control-isc' ), [ $this, 'render_settings_section' ], 'isc_settings_page' );
17 add_settings_field( 'source_type_list', __( 'Enable', 'image-source-control-isc' ), [ $this, 'render_field_source_type_list' ], 'isc_settings_page', 'isc_settings_section_list_below_content' );
18 add_settings_field( 'image_list_headline', __( 'Headline', 'image-source-control-isc' ), [ $this, 'render_field_list_headline' ], 'isc_settings_page', 'isc_settings_section_list_below_content' );
19 add_settings_field( 'list_layout', __( 'Layout', 'image-source-control-isc' ), [ $this, 'render_field_list_layout' ], 'isc_settings_page', 'isc_settings_section_list_below_content' );
20 add_settings_field( 'below_content_included_images', __( 'Included images', 'image-source-control-isc' ), [ $this, 'render_field_below_content_included_images' ], 'isc_settings_page', 'isc_settings_section_list_below_content' );
21 }
22
23 /**
24 * Render the settings section
25 */
26 public function render_settings_section() {
27 require_once ISCPATH . '/admin/templates/settings/page-list/section.php';
28 }
29
30 /**
31 * Render the options to enable the Per-page list
32 */
33 public function render_field_source_type_list() {
34 $options = $this->get_options();
35 require_once ISCPATH . '/admin/templates/settings/page-list/enable.php';
36 }
37
38 /**
39 * Render option to define a headline for the image list
40 */
41 public function render_field_list_headline() {
42 $options = $this->get_options();
43 require_once ISCPATH . '/admin/templates/settings/page-list/headline.php';
44 }
45
46 /**
47 * Render option to define the layout of the image list
48 */
49 public function render_field_list_layout() {
50 $options = $this->get_options();
51 $list_layout_details = ! empty( ( $options['list_layout'] ?? [] )['details'] ?? false );
52 $is_pro_enabled = \ISC\Plugin::is_pro();
53 require_once ISCPATH . '/admin/templates/settings/page-list/layout.php';
54 }
55
56 /**
57 * Render option to define which images to show on the sources list of the current page
58 */
59 public function render_field_below_content_included_images() {
60 $options = $this->get_options();
61 $included_images = ! empty( $options['list_included_images'] ) ? $options['list_included_images'] : '';
62 $included_images_options = $this->get_included_images_options();
63 require_once ISCPATH . '/admin/templates/settings/page-list/included-images.php';
64 }
65
66
67 /**
68 * Get the options for included images in the sources list
69 */
70 public function get_included_images_options() {
71 $included_images_options = [
72 'default' => [
73 'label' => __( 'Images in the content', 'image-source-control-isc' ),
74 'description' => sprintf(
75 // translators: %1$s is "img" and %2$s stands for "the_content" wrapped in "code" tags
76 __( 'Technically: %1$s tags within %2$s and the featured image.', 'image-source-control-isc' ),
77 '<code>img</code>',
78 '<code>the_content</code>'
79 ),
80 'value' => '',
81 'coming_soon' => false,
82 ],
83 'body_img' => [
84 'label' => __( 'Images on the whole page', 'image-source-control-isc' ),
85 'description' =>
86 __( 'Including header, sidebar, and footer.', 'image-source-control-isc' ) . ' ' .
87 sprintf(
88 // translators: %1$s is "img" and %2$s stands for "body" wrapped in "code" tags
89 __( 'Technically: %1$s tags within %2$s.', 'image-source-control-isc' ),
90 '<code>img</code>',
91 '<code>body</code>'
92 ),
93 'value' => 'body_img',
94 'is_pro' => true,
95 ],
96 'body_urls' => [
97 'label' => __( 'Any image URL', 'image-source-control-isc' ),
98 'description' =>
99 __( 'Including CSS background, JavaScript, or HTML attributes.', 'image-source-control-isc' ) . ' ' .
100 sprintf(
101 // translators: %s stands for "body" wrapped in "code" tags
102 __( 'Technically: any image URL found in %s.', 'image-source-control-isc' ),
103 '<code>html</code>'
104 ),
105 'value' => 'body_urls',
106 'is_pro' => true,
107 ],
108 ];
109
110 return apply_filters( 'isc_list_included_images_options', $included_images_options );
111 }
112
113 /**
114 * Validate settings
115 *
116 * @param array $output output data.
117 * @param array $input input data.
118 *
119 * @return array $output
120 */
121 public function validate_settings( array $output, array $input ): array {
122 $output['list_on_archives'] = ! empty( $input['list_on_archives'] );
123 $output['list_on_excerpts'] = ! empty( $input['list_on_excerpts'] );
124 $output['image_list_headline'] = isset( $input['image_list_headline'] ) ? esc_html( $input['image_list_headline'] ) : '';
125 $output['list_included_images'] = isset( $input['list_included_images'] ) ? esc_attr( $input['list_included_images'] ) : '';
126
127 return $output;
128 }
129 }
130