- WordPress 6.9.4 (es_ES) with Kadence theme - Homepage: Hero, La Asociación, Pilares, Beneficios, Eventos, Miembros, Hazte Miembro, Contacto - Brand identity: #13294b navy, #a12932 burgundy, #c69c48 gold - Fonts: Raleway (headings) + Source Sans 3 (body) + Lato (UI) - Plugins: Kadence Blocks, Polylang, Contact Form 7 - Custom CSS with full brand styling and responsive layout - HTTPS enforced via wp-config.php proxy detection
37 lines
913 B
PHP
37 lines
913 B
PHP
<?php declare( strict_types=1 );
|
|
|
|
namespace KadenceWP\KadenceBlocks\Traits\Rest;
|
|
|
|
/**
|
|
* Shared image related functionality for REST controllers.
|
|
*
|
|
* @mixin \WP_REST_Controller
|
|
*/
|
|
trait Image_Trait {
|
|
|
|
/**
|
|
* Sanitizes an array of Pexels image sizes.
|
|
*
|
|
* @param mixed|array<int, array{id: int, width: int, height: int, crop: bool}> $sizes One or more size arrays.
|
|
*
|
|
* @return array|array<int, array{id: int, width: int, height: int, crop: bool}>
|
|
*/
|
|
public function sanitize_image_sizes_array( $sizes ): array {
|
|
$new_sizes = [];
|
|
|
|
if ( ! empty( $sizes ) || ! is_array( $sizes ) ) {
|
|
foreach ( $sizes as $value ) {
|
|
$new_sizes[] = [
|
|
'id' => sanitize_text_field( $value['id'] ),
|
|
'width' => absint( $value['width'] ),
|
|
'height' => absint( $value['height'] ),
|
|
'crop' => filter_var( $value['crop'], FILTER_VALIDATE_BOOLEAN ),
|
|
];
|
|
}
|
|
}
|
|
|
|
return $new_sizes;
|
|
}
|
|
|
|
}
|