PluginProbe
Meow Gallery / 5.5.5
Meow Gallery v5.5.5
5.5.5 5.5.4 5.5.3 5.5.2 5.5.1 5.5.0 5.4.9 5.4.8 5.4.7 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 All 157 releases
← All changes | classes/builders/core.php +30 -8 4.1.85.5.5 View file →
@@ -16,13 +16,16 @@
16 16 public $isPreview = false;
17 17 public $updir = null;
18 18 public $captions = false;
19 19 public $animation = null;
20 + public $infinite = false;
20 21
21 22 abstract function inline_css();
22 23
24 + // MEMO: Done migration to the React version.
23 25 public function __construct( $atts, $infinite, $isPreview = false ) {
24 26 $wpUploadDir = wp_upload_dir();
27 + $options = get_option( Meow_MGL_Core::get_plugin_option_name(), null );
25 28 $this->id = uniqid();
26 29 $this->size = isset( $atts['size'] ) ? $atts['size'] : $this->size;
27 30 $this->size = apply_filters( 'mgl_media_size', $this->size );
28 31 $this->infinite = $infinite;
@@ -27,19 +30,19 @@
27 30 $this->size = apply_filters( 'mgl_media_size', $this->size );
28 31 $this->infinite = $infinite;
29 32 $this->atts = $atts;
30 33 $this->customClass = isset( $atts['custom-class'] ) ? $atts['custom-class'] : null;
31 - $this->link = isset( $atts['link'] ) ? $atts['link'] : null;
34 + $this->link = isset( $atts['link'] ) ? $atts['link'] : ( $options['link'] ?? null );
32 35 $this->align = isset( $atts['align'] ) ? $atts['align'] : $this->align;
33 36 $this->isPreview = $isPreview;
34 37 $this->class_id = 'mgl-gallery-' . $this->id;
35 38 $this->updir = trailingslashit( $wpUploadDir['baseurl'] );
36 - $this->captions = isset( $atts['captions'] ) ? $atts['captions'] : get_option( 'mgl_captions', 'none' );
39 + $this->captions = isset( $atts['captions'] ) ? $atts['captions'] : ( $options['captions'] ?? 'none' );
37 40 $this->animation = null;
38 41 if ( isset( $atts['animation'] ) && $atts['animation'] != 'default' )
39 42 $this->animation = $atts['animation'];
40 43 else
41 - $this->animation = get_option( 'mgl_animation', null );
44 + $this->animation = $options['animation'] ?? null;
42 45 }
43 46
44 47 function build_inline_attributes( $id, $data ) {
45 48 return '';
@@ -44,15 +47,22 @@
44 47 function build_inline_attributes( $id, $data ) {
45 48 return '';
46 49 }
47 50
51 +
52 + // MEMO: Done migration to the React version.
48 53 function prepare_data( $idsStr ) {
49 54 global $wpdb;
55 +
56 + // Escape the array of IDs for SQL
57 + $ids = array_map( 'intval', explode(',', $idsStr ) );
58 + $idsStr = implode( ',', $ids );
59 +
50 60 $query = "SELECT p.ID id, p.post_excerpt caption, m.meta_value meta
51 61 FROM $wpdb->posts p, $wpdb->postmeta m
52 62 WHERE m.meta_key = '_wp_attachment_metadata'
53 63 AND p.ID = m.post_id
54 - AND p.ID IN (" . esc_sql( $idsStr ) . ")";
64 + AND p.ID IN (" . $idsStr . ")";
55 65 $res = $wpdb->get_results( $query );
56 66 $this->ids = explode( ',', $idsStr );
57 67 foreach ( $res as $r ) {
58 68 $this->data[$r->id] = array( 'caption' => $r->caption,'meta' => unserialize( $r->meta ) );
@@ -70,21 +80,24 @@
70 80 $src = $this->updir . $data['meta']['file'];
71 81 $data['caption'] = apply_filters( 'mgl_caption', $data['caption'], $id );
72 82 $caption = $this->captions ? $data['caption'] : '';
73 83
74 - $image_size = get_option( 'mgl_image_size', 'srcset' );
84 + $image_size = Meow_MGL_Core::get_plugin_option( 'image_size', 'srcset' );
75 85 $imgSrc = null;
76 86 if ( empty( $image_size ) || $image_size === 'srcset' ) {
77 87 $imgSrc = wp_get_attachment_image( $id, $this->size, false,
78 - $this->layout === 'carousel' ? array( 'class' => 'skip-lazy' ) : array( 'class' => 'wp-image-' . $id ) );
88 + $this->layout === 'carousel' ?
89 + [ 'class' => 'skip-lazy' ] :
90 + [ 'class' => 'wp-image-' . $id ]
91 + );
79 92 }
80 93 else {
81 94 $info = wp_get_attachment_image_src( $id, $image_size );
82 - $imgSrc = '<img src="' . $info[0] . '" class="' .
95 + $imgSrc = '<img loading="lazy" src="' . $info[0] . '" class="' .
83 96 ( $this->layout === 'carousel' ? 'skip-lazy' : ( 'wp-image-' . $id ) ) . '" />';
84 97 }
85 -
86 98 $attributes = $this->build_inline_attributes( $id, $data );
99 + $attributes = apply_filters( 'mgl_attributes', $attributes, $id, $data );
87 100 if ( !empty( $attributes ) ) {
88 101 $attributes = ' ' . $attributes;
89 102 }
90 103
@@ -89,11 +102,16 @@
89 102 }
90 103
91 104 $linkUrl = null;
92 105 if ( $this->link === 'attachment' )
106 + {
93 107 $linkUrl = get_permalink( (int)$id );
108 + }
94 109 else if ( $this->link === 'media' || $this->link === 'file' )
110 + {
95 111 $linkUrl = $src;
112 + }
113 +
96 114 $linkUrl = apply_filters( 'mgl_link', $linkUrl, (int)$id, $data );
97 115 $isPreview = $this->isPreview;
98 116 ob_start();
99 117 include dirname( __FILE__ ) . '/cell.tpl.php';
@@ -100,8 +118,9 @@
100 118 $html = ob_get_clean();
101 119 return $html;
102 120 }
103 121
122 + // MEMO: Done migration to the React version.
104 123 function build_container_classes() {
105 124 $classes = 'mgl-' . $this->layout . '-container';
106 125
107 126 // Align
@@ -109,8 +128,9 @@
109 128
110 129 return $classes;
111 130 }
112 131
132 + // MEMO: Done migration to the React version.
113 133 function build_classes() {
114 134 $classes = 'mgl-gallery';
115 135
116 136 // Layout
@@ -129,8 +149,9 @@
129 149
130 150 return $classes;
131 151 }
132 152
153 + // MEMO: Done migration to the React version.
133 154 function build_styles() {
134 155 return "";
135 156 }
136 157
@@ -147,8 +168,9 @@
147 168 }
148 169 $out .= '</div>';
149 170 $out = apply_filters( 'mgl_gallery_written', $out, $this->layout );
150 171
172 + // MEMO: Done migration to the React version.
151 173 // Generate gallery container
152 174 $container_classes = $this->build_container_classes();
153 175 $inline_css = $this->inline_css();
154 176 if ( !empty( $inline_css ) ) {