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 -6 4.2.75.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,20 +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 98 $attributes = $this->build_inline_attributes( $id, $data );
99 + $attributes = apply_filters( 'mgl_attributes', $attributes, $id, $data );
91 100 if ( !empty( $attributes ) ) {
92 101 $attributes = ' ' . $attributes;
93 102 }
94 103
@@ -93,11 +102,16 @@
93 102 }
94 103
95 104 $linkUrl = null;
96 105 if ( $this->link === 'attachment' )
106 + {
97 107 $linkUrl = get_permalink( (int)$id );
108 + }
98 109 else if ( $this->link === 'media' || $this->link === 'file' )
110 + {
99 111 $linkUrl = $src;
112 + }
113 +
100 114 $linkUrl = apply_filters( 'mgl_link', $linkUrl, (int)$id, $data );
101 115 $isPreview = $this->isPreview;
102 116 ob_start();
103 117 include dirname( __FILE__ ) . '/cell.tpl.php';
@@ -104,8 +118,9 @@
104 118 $html = ob_get_clean();
105 119 return $html;
106 120 }
107 121
122 + // MEMO: Done migration to the React version.
108 123 function build_container_classes() {
109 124 $classes = 'mgl-' . $this->layout . '-container';
110 125
111 126 // Align
@@ -113,8 +128,9 @@
113 128
114 129 return $classes;
115 130 }
116 131
132 + // MEMO: Done migration to the React version.
117 133 function build_classes() {
118 134 $classes = 'mgl-gallery';
119 135
120 136 // Layout
@@ -133,8 +149,9 @@
133 149
134 150 return $classes;
135 151 }
136 152
153 + // MEMO: Done migration to the React version.
137 154 function build_styles() {
138 155 return "";
139 156 }
140 157
@@ -151,8 +168,9 @@
151 168 }
152 169 $out .= '</div>';
153 170 $out = apply_filters( 'mgl_gallery_written', $out, $this->layout );
154 171
172 + // MEMO: Done migration to the React version.
155 173 // Generate gallery container
156 174 $container_classes = $this->build_container_classes();
157 175 $inline_css = $this->inline_css();
158 176 if ( !empty( $inline_css ) ) {