wp-printable-gallery/build/wp-printable-gallery/render.php

32 lines
993 B
PHP

<?php
/**
*
* vim: set ai sw=4 smarttab expandtab: tabstop=8 softtabstop=0
*
* @see https://github.com/WordPress/gutenberg/blob/trunk/docs/reference-guides/block-api/block-metadata.md#render
*/
?>
<div <?php echo get_block_wrapper_attributes(); ?>>
<?php
$gallery_attributes = [
'columns' => 2,
'size' => 'gallery',
'link' => 'file',
];
if ( array_key_exists('print', $_GET)) {
$images = get_attached_media('image');
$ids = array();
foreach ($images as $image_id =>$image) {
if (get_post_meta($image_id, 'wpdfh.print', true) !== '') {
$ids[] = "$image_id";
}
}
$gallery_attributes['ids'] = implode(',', $ids);
// error_log('PHP: rendering printable gallery, $images: '.print_r($images, true), 0);
// error_log('PHP: rendering printable gallery, $_GET: '.print_r($_GET, true), 0);
}
echo gallery_shortcode($gallery_attributes);
?>
</div>