| @@ -16,16 +16,13 @@ | ||
| 16 | 16 | public $isPreview = false; |
| 17 | 17 | public $updir = null; |
| 18 | 18 | public $captions = false; |
| 19 | 19 | public $animation = null; |
| 20 | - public $infinite = false; | |
| 21 | 20 | |
| 22 | 21 | abstract function inline_css(); |
| 23 | 22 | |
| 24 | - // MEMO: Done migration to the React version. | |
| 25 | 23 | public function __construct( $atts, $infinite, $isPreview = false ) { |
| 26 | 24 | $wpUploadDir = wp_upload_dir(); |
| 27 | - $options = get_option( Meow_MGL_Core::get_plugin_option_name(), null ); | |
| 28 | 25 | $this->id = uniqid(); |
| 29 | 26 | $this->size = isset( $atts['size'] ) ? $atts['size'] : $this->size; |
| 30 | 27 | $this->size = apply_filters( 'mgl_media_size', $this->size ); |
| 31 | 28 | $this->infinite = $infinite; |
| @@ -30,19 +27,19 @@ | ||
| 30 | 27 | $this->size = apply_filters( 'mgl_media_size', $this->size ); |
| 31 | 28 | $this->infinite = $infinite; |
| 32 | 29 | $this->atts = $atts; |
| 33 | 30 | $this->customClass = isset( $atts['custom-class'] ) ? $atts['custom-class'] : null; |
| 34 | - $this->link = isset( $atts['link'] ) ? $atts['link'] : ( $options['link'] ?? null ); | |
| 31 | + $this->link = isset( $atts['link'] ) ? $atts['link'] : null; | |
| 35 | 32 | $this->align = isset( $atts['align'] ) ? $atts['align'] : $this->align; |
| 36 | 33 | $this->isPreview = $isPreview; |
| 37 | 34 | $this->class_id = 'mgl-gallery-' . $this->id; |
| 38 | 35 | $this->updir = trailingslashit( $wpUploadDir['baseurl'] ); |
| 39 | - $this->captions = isset( $atts['captions'] ) ? $atts['captions'] : ( $options['captions'] ?? 'none' ); | |
| 36 | + $this->captions = isset( $atts['captions'] ) ? $atts['captions'] : get_option( 'mgl_captions', 'none' ); | |
| 40 | 37 | $this->animation = null; |
| 41 | 38 | if ( isset( $atts['animation'] ) && $atts['animation'] != 'default' ) |
| 42 | 39 | $this->animation = $atts['animation']; |
| 43 | 40 | else |
| 44 | - $this->animation = $options['animation'] ?? null; | |
| 41 | + $this->animation = get_option( 'mgl_animation', null ); | |
| 45 | 42 | } |
| 46 | 43 | |
| 47 | 44 | function build_inline_attributes( $id, $data ) { |
| 48 | 45 | return ''; |
| @@ -47,10 +44,8 @@ | ||
| 47 | 44 | function build_inline_attributes( $id, $data ) { |
| 48 | 45 | return ''; |
| 49 | 46 | } |
| 50 | 47 | |
| 51 | - | |
| 52 | - // MEMO: Done migration to the React version. | |
| 53 | 48 | function prepare_data( $idsStr ) { |
| 54 | 49 | global $wpdb; |
| 55 | 50 | |
| 56 | 51 | // Escape the array of IDs for SQL |
| @@ -80,24 +75,21 @@ | ||
| 80 | 75 | $src = $this->updir . $data['meta']['file']; |
| 81 | 76 | $data['caption'] = apply_filters( 'mgl_caption', $data['caption'], $id ); |
| 82 | 77 | $caption = $this->captions ? $data['caption'] : ''; |
| 83 | 78 | |
| 84 | - $image_size = Meow_MGL_Core::get_plugin_option( 'image_size', 'srcset' ); | |
| 79 | + $image_size = get_option( 'mgl_image_size', 'srcset' ); | |
| 85 | 80 | $imgSrc = null; |
| 86 | 81 | if ( empty( $image_size ) || $image_size === 'srcset' ) { |
| 87 | 82 | $imgSrc = wp_get_attachment_image( $id, $this->size, false, |
| 88 | - $this->layout === 'carousel' ? | |
| 89 | - [ 'class' => 'skip-lazy' ] : | |
| 90 | - [ 'class' => 'wp-image-' . $id ] | |
| 91 | - ); | |
| 83 | + $this->layout === 'carousel' ? array( 'class' => 'skip-lazy' ) : array( 'class' => 'wp-image-' . $id ) ); | |
| 92 | 84 | } |
| 93 | 85 | else { |
| 94 | 86 | $info = wp_get_attachment_image_src( $id, $image_size ); |
| 95 | - $imgSrc = '<img loading="lazy" src="' . $info[0] . '" class="' . | |
| 87 | + $imgSrc = '<img src="' . $info[0] . '" class="' . | |
| 96 | 88 | ( $this->layout === 'carousel' ? 'skip-lazy' : ( 'wp-image-' . $id ) ) . '" />'; |
| 97 | 89 | } |
| 90 | + | |
| 98 | 91 | $attributes = $this->build_inline_attributes( $id, $data ); |
| 99 | - $attributes = apply_filters( 'mgl_attributes', $attributes, $id, $data ); | |
| 100 | 92 | if ( !empty( $attributes ) ) { |
| 101 | 93 | $attributes = ' ' . $attributes; |
| 102 | 94 | } |
| 103 | 95 | |
| @@ -102,16 +94,11 @@ | ||
| 102 | 94 | } |
| 103 | 95 | |
| 104 | 96 | $linkUrl = null; |
| 105 | 97 | if ( $this->link === 'attachment' ) |
| 106 | - { | |
| 107 | 98 | $linkUrl = get_permalink( (int)$id ); |
| 108 | - } | |
| 109 | 99 | else if ( $this->link === 'media' || $this->link === 'file' ) |
| 110 | - { | |
| 111 | 100 | $linkUrl = $src; |
| 112 | - } | |
| 113 | - | |
| 114 | 101 | $linkUrl = apply_filters( 'mgl_link', $linkUrl, (int)$id, $data ); |
| 115 | 102 | $isPreview = $this->isPreview; |
| 116 | 103 | ob_start(); |
| 117 | 104 | include dirname( __FILE__ ) . '/cell.tpl.php'; |
| @@ -118,9 +105,8 @@ | ||
| 118 | 105 | $html = ob_get_clean(); |
| 119 | 106 | return $html; |
| 120 | 107 | } |
| 121 | 108 | |
| 122 | - // MEMO: Done migration to the React version. | |
| 123 | 109 | function build_container_classes() { |
| 124 | 110 | $classes = 'mgl-' . $this->layout . '-container'; |
| 125 | 111 | |
| 126 | 112 | // Align |
| @@ -128,9 +114,8 @@ | ||
| 128 | 114 | |
| 129 | 115 | return $classes; |
| 130 | 116 | } |
| 131 | 117 | |
| 132 | - // MEMO: Done migration to the React version. | |
| 133 | 118 | function build_classes() { |
| 134 | 119 | $classes = 'mgl-gallery'; |
| 135 | 120 | |
| 136 | 121 | // Layout |
| @@ -149,9 +134,8 @@ | ||
| 149 | 134 | |
| 150 | 135 | return $classes; |
| 151 | 136 | } |
| 152 | 137 | |
| 153 | - // MEMO: Done migration to the React version. | |
| 154 | 138 | function build_styles() { |
| 155 | 139 | return ""; |
| 156 | 140 | } |
| 157 | 141 | |
| @@ -168,9 +152,8 @@ | ||
| 168 | 152 | } |
| 169 | 153 | $out .= '</div>'; |
| 170 | 154 | $out = apply_filters( 'mgl_gallery_written', $out, $this->layout ); |
| 171 | 155 | |
| 172 | - // MEMO: Done migration to the React version. | |
| 173 | 156 | // Generate gallery container |
| 174 | 157 | $container_classes = $this->build_container_classes(); |
| 175 | 158 | $inline_css = $this->inline_css(); |
| 176 | 159 | if ( !empty( $inline_css ) ) { |