PluginProbe
Image Source Control Lite – Show Image Credits and Captions / 3.11.0
Image Source Control Lite – Show Image Credits and Captions v3.11.0
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
← All changes | includes/image-sources/renderer/image-source-string.php +7 -21 trunk → 3.11.0 View file →
@@ -16,10 +16,10 @@
16 16 *
17 17 * @param int $image_id Image ID.
18 18 */
19 19 public static function render( int $image_id ) {
20 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, sanitization is done in the get() function
21 - echo self::get( $image_id );
20 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- we need to allow the HTML here and use a custom sanitizer.
21 + echo Image_Sources::sanitize_source_html( self::get( $image_id ) );
22 22 }
23 23
24 24 /**
25 25 * Render source string of single image by its id
@@ -40,18 +40,13 @@
40 40 if ( ! $id ) {
41 41 return false;
42 42 }
43 43
44 - $options = self::get_options();
45 - $metadata['source'] = $data['source'] ?? Image_Sources::get_image_source_text_raw( $id );
46 - $metadata['own'] = $data['own'] ?? Standard_Source::use_standard_source( $id );
47 - $metadata['ai_label'] = $data['ai_label'] ?? Image_Sources::get_ai_label( $id );
48 - $metadata['licence'] = $data['licence'] ?? Image_Sources::get_image_license( $id );
44 + $options = self::get_options();
45 + $metadata['source'] = $data['source'] ?? Image_Sources::get_image_source_text_raw( $id );
46 + $metadata['own'] = $data['own'] ?? Standard_Source::use_standard_source( $id );
47 + $metadata['licence'] = $data['licence'] ?? Image_Sources::get_image_license( $id );
49 48
50 - if ( empty( $options['ai_images']['show_label'] ) ) {
51 - $metadata['ai_label'] = '';
52 - }
53 -
54 49 if ( ! isset( $args['disable-links'] ) ) {
55 50 $metadata['source_url'] = $data['source_url'] ?? Image_Sources::get_image_source_url( $id );
56 51 } else {
57 52 $metadata['source_url'] = '';
@@ -64,15 +59,12 @@
64 59 } elseif ( '' !== $metadata['source'] ) {
65 60 $source = $metadata['source'];
66 61 }
67 62
68 - if ( '' === $source && '' === $metadata['ai_label'] ) {
63 + if ( $source === '' ) {
69 64 return false;
70 65 }
71 66
72 - // sanitize the source string, to avoid XSS attacks
73 - $source = Image_Sources::sanitize_source_html( $source );
74 -
75 67 // wrap link around source, if given
76 68 if ( '' !== $metadata['source_url'] ) {
77 69 $classes = apply_filters( 'isc_public_source_url_html_classes', [], $id, $data, $args, $metadata );
78 70 $class_string = count( $classes ) > 0 ? ' class="' . esc_attr( implode( ' ', $classes ) ) . '"' : '';
@@ -82,14 +74,8 @@
82 74 sprintf( '<a href="%2$s" target="_blank" rel="nofollow"%3$s>%1$s</a>', $source, esc_url_raw( $metadata['source_url'] ), $class_string ),
83 75 $id,
84 76 $metadata
85 77 );
86 - }
87 -
88 - // add AI label icon if enabled
89 - $ai_icon = \ISC\Image_Sources\Ai_Labels::get_icon( $metadata['ai_label'] );
90 - if ( '' !== $ai_icon ) {
91 - $source = trim( sprintf( '%1$s %2$s', $ai_icon, $source ) );
92 78 }
93 79
94 80 // add license if enabled
95 81 if ( $options['enable_licences'] && isset( $metadata['licence'] ) && $metadata['licence'] ) {