PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 2.4.2
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v2.4.2
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / admin / views / sp-framework / fields / gallery / gallery.php

gallery.php in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 2.4.2, at admin/views/sp-framework/fields/gallery/gallery.php

69 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) {
2 die; } // Cannot access directly.
3 /**
4 *
5 * Field: gallery
6 *
7 * @since 1.0.0
8 * @version 1.0.0
9 */
10 if ( ! class_exists( 'SP_PC_Field_gallery' ) ) {
11 class SP_PC_Field_gallery extends SP_PC_Fields {
12
13 /**
14 * The field constructor.
15 *
16 * @param string $field The field type.
17 * @param string $value The field value.
18 * @param string $unique The unique ID.
19 * @param string $where The place to show the field.
20 * @param string $parent If it has any parent.
21 */
22 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
23 parent::__construct( $field, $value, $unique, $where, $parent );
24 }
25
26 /**
27 * The render function.
28 *
29 * @return void
30 */
31 public function render() {
32
33 $args = wp_parse_args(
34 $this->field,
35 array(
36 'add_title' => esc_html__( 'Add Gallery', 'smart-post-show' ),
37 'edit_title' => esc_html__( 'Edit Gallery', 'smart-post-show' ),
38 'clear_title' => esc_html__( 'Clear', 'smart-post-show' ),
39 )
40 );
41
42 $hidden = ( empty( $this->value ) ) ? ' hidden' : '';
43
44 echo wp_kses_post( $this->field_before() );
45 echo '<a href="#" class="button button-primary spf-button"><i class="fa fa-plus-circle"></i>' . esc_html( $args['add_title'] ) . '</a>';
46 echo '<ul class="sp-gallery-images">';
47 if ( ! empty( $this->value ) ) {
48
49 $values = explode( ',', $this->value );
50
51 foreach ( $values as $id ) {
52 $attachment = wp_get_attachment_image_src( $id, 'thumbnail' );
53 echo '<li><img src="' . esc_url( $attachment[0] ) . '"/></li>';
54 }
55 }
56
57 echo '</ul>';
58
59 echo '<ul><li><a href="#" class="button spf-edit-gallery' . esc_attr( $hidden ) . '"><i class="fa fa-pencil-square-o"></i>' . esc_html( $args['edit_title'] ) . '</a></li></ul>';
60 echo '<ul><li><a href="#" class="button spf-warning-primary spf-clear-gallery' . esc_attr( $hidden ) . '"><i class="fa fa-trash"></i>' . esc_html( $args['clear_title'] ) . '</a></li></ul>';
61 echo '<input type="text" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $this->value ) . '"' . wp_kses_post( $this->field_attributes() ) . '/></span>';
62
63 echo wp_kses_post( $this->field_after() );
64
65 }
66
67 }
68 }
69