# darkify/1.4.0/src/Admin/Framework/fields/gallery/gallery.php

Darkify – Dark Mode &amp; Night Mode for Website &amp; Admin (Dark Theme Included), version 1.4.0. 53 lines.

- Page: https://pluginprobe.com/plugins/darkify/1.4.0/code/src/Admin/Framework/fields/gallery/gallery.php
- Raw: https://pluginprobe.com/plugins/darkify/1.4.0/raw/src/Admin/Framework/fields/gallery/gallery.php
- Modified: 2025-05-15T13:43:26+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/darkify/1.4.0/code/src/Admin/Framework/fields/gallery/gallery.php#L10-L20`.

```php
<?php if ( ! defined( 'ABSPATH' ) ) {
	die; } // Cannot access directly.
/**
 *
 * Field: gallery
 *
 * @since 1.0.0
 * @version 1.0.0
 */
if ( ! class_exists( 'DarkifyField_gallery' ) ) {
	class DarkifyField_gallery extends DarkifyFields {

		public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
			parent::__construct( $field, $value, $unique, $where, $parent );
		}

		public function render() {

			$args = wp_parse_args(
				$this->field,
				array(
					'add_title'   => esc_html__( 'Add Gallery', 'darkify' ),
					'edit_title'  => esc_html__( 'Edit Gallery', 'darkify' ),
					'clear_title' => esc_html__( 'Clear', 'darkify' ),
				)
			);

			$hidden = ( empty( $this->value ) ) ? ' hidden' : '';

			echo wp_kses_post( $this->field_before() );

			echo '<ul>';
			if ( ! empty( $this->value ) ) {

				$values = explode( ',', $this->value );

				foreach ( $values as $id ) {
					$attachment = wp_get_attachment_image_src( $id, 'thumbnail' );
					echo '<li><img src="' . esc_url( $attachment[0] ) . '" /></li>';
				}
			}
			echo '</ul>';

			echo '<a href="#" class="button button-primary darkify-button">' . esc_html($args['add_title']) . '</a>';
			echo '<a href="#" class="button darkify-edit-gallery' . esc_attr( $hidden ) . '">' . esc_html($args['edit_title']) . '</a>';
			echo '<a href="#" class="button darkify-warning-primary darkify-clear-gallery' . esc_attr( $hidden ) . '">' . esc_html($args['clear_title']) . '</a>';
			echo '<input type="hidden" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $this->value ) . '"' . wp_kses_post( $this->field_attributes() ) . '/>';

			echo wp_kses_post( $this->field_after() );
		}
	}
}

```
