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 +24 -7 4.2.15.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,8 +47,10 @@
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;
50 55
51 56 // Escape the array of IDs for SQL
@@ -75,21 +80,24 @@
75 80 $src = $this->updir . $data['meta']['file'];
76 81 $data['caption'] = apply_filters( 'mgl_caption', $data['caption'], $id );
77 82 $caption = $this->captions ? $data['caption'] : '';
78 83
79 - $image_size = get_option( 'mgl_image_size', 'srcset' );
84 + $image_size = Meow_MGL_Core::get_plugin_option( 'image_size', 'srcset' );
80 85 $imgSrc = null;
81 86 if ( empty( $image_size ) || $image_size === 'srcset' ) {
82 87 $imgSrc = wp_get_attachment_image( $id, $this->size, false,
83 - $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 + );
84 92 }
85 93 else {
86 94 $info = wp_get_attachment_image_src( $id, $image_size );
87 - $imgSrc = '<img src="' . $info[0] . '" class="' .
95 + $imgSrc = '<img loading="lazy" src="' . $info[0] . '" class="' .
88 96 ( $this->layout === 'carousel' ? 'skip-lazy' : ( 'wp-image-' . $id ) ) . '" />';
89 97 }
90 -
91 98 $attributes = $this->build_inline_attributes( $id, $data );
99 + $attributes = apply_filters( 'mgl_attributes', $attributes, $id, $data );
92 100 if ( !empty( $attributes ) ) {
93 101 $attributes = ' ' . $attributes;
94 102 }
95 103
@@ -94,11 +102,16 @@
94 102 }
95 103
96 104 $linkUrl = null;
97 105 if ( $this->link === 'attachment' )
106 + {
98 107 $linkUrl = get_permalink( (int)$id );
108 + }
99 109 else if ( $this->link === 'media' || $this->link === 'file' )
110 + {
100 111 $linkUrl = $src;
112 + }
113 +
101 114 $linkUrl = apply_filters( 'mgl_link', $linkUrl, (int)$id, $data );
102 115 $isPreview = $this->isPreview;
103 116 ob_start();
104 117 include dirname( __FILE__ ) . '/cell.tpl.php';
@@ -105,8 +118,9 @@
105 118 $html = ob_get_clean();
106 119 return $html;
107 120 }
108 121
122 + // MEMO: Done migration to the React version.
109 123 function build_container_classes() {
110 124 $classes = 'mgl-' . $this->layout . '-container';
111 125
112 126 // Align
@@ -114,8 +128,9 @@
114 128
115 129 return $classes;
116 130 }
117 131
132 + // MEMO: Done migration to the React version.
118 133 function build_classes() {
119 134 $classes = 'mgl-gallery';
120 135
121 136 // Layout
@@ -134,8 +149,9 @@
134 149
135 150 return $classes;
136 151 }
137 152
153 + // MEMO: Done migration to the React version.
138 154 function build_styles() {
139 155 return "";
140 156 }
141 157
@@ -152,8 +168,9 @@
152 168 }
153 169 $out .= '</div>';
154 170 $out = apply_filters( 'mgl_gallery_written', $out, $this->layout );
155 171
172 + // MEMO: Done migration to the React version.
156 173 // Generate gallery container
157 174 $container_classes = $this->build_container_classes();
158 175 $inline_css = $this->inline_css();
159 176 if ( !empty( $inline_css ) ) {