Changeset 1815404
- Timestamp:
- 02/05/2018 02:01:27 AM (8 years ago)
- Location:
- wysiwyg-custom-products
- Files:
-
- 14 edited
-
tags/1.1/admin/class-ajax.php (modified) (3 diffs)
-
tags/1.1/common/class-wp-html-helper.php (modified) (4 diffs)
-
tags/1.1/common/utilities.php (modified) (2 diffs)
-
tags/1.1/common/wp-helpers.php (modified) (3 diffs)
-
tags/1.1/frontend/class-frontend.php (modified) (5 diffs)
-
tags/1.1/readme.txt (modified) (1 diff)
-
tags/1.1/wysiwyg-custom-products.php (modified) (3 diffs)
-
trunk/admin/class-ajax.php (modified) (3 diffs)
-
trunk/common/class-wp-html-helper.php (modified) (4 diffs)
-
trunk/common/utilities.php (modified) (2 diffs)
-
trunk/common/wp-helpers.php (modified) (3 diffs)
-
trunk/frontend/class-frontend.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/wysiwyg-custom-products.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wysiwyg-custom-products/tags/1.1/admin/class-ajax.php
r1677949 r1815404 21 21 * 22 22 * @since 1.0.0 23 * @updated 1.1. 223 * @updated 1.1.4 24 24 */ 25 25 class Ajax { … … 69 69 * 70 70 * @since 1.0.0 71 * @updated 1.1. 071 * @updated 1.1.4 72 72 */ 73 73 public function get_image_attr() { … … 78 78 $image = wp_get_attachment_image_src( $attachmentId, $size ); 79 79 // Overriding WP's resizing of image in admin for "editing" 80 $attributes = wc _get_image_size( $size);80 $attributes = wcp_get_image_size( $size, $attachmentId ); 81 81 if ( $attributes ) { 82 82 $image['width'] = maybe_get( $attributes, 'width', $image['width'] ); -
wysiwyg-custom-products/tags/1.1/common/class-wp-html-helper.php
r1603224 r1815404 15 15 * 16 16 * @since 1.0.1 17 * @updated 1.1. 017 * @updated 1.1.4 18 18 */ 19 19 … … 263 263 * 264 264 * @since 1.0.8 265 * @updated 1.1. 0265 * @updated 1.1.4 266 266 */ 267 267 public function svg_sized_img( … … 273 273 // Overriding WP's resizing of image in admin for "editing" 274 274 if ( $forceSize ) { 275 $attributes = wc _get_image_size( $size);275 $attributes = wcp_get_image_size( $size, $attachmentId ); 276 276 if ( $attributes ) { 277 277 $image['width'] = maybe_get( $attributes, 'width', $image['width'] ); … … 283 283 return $this->svg_img( $image['url'], $image['width'], $image['height'], $classes, $id, $attributes, 284 284 $styles ); 285 } 286 287 /** @noinspection MoreThanThreeArgumentsInspection */ 288 /** 289 * Creates SVG <image ... /> tag getting the correct image and size from the WP size string 290 * Escapes href 291 * 292 * @param int $attachmentId 293 * @param string $size 294 * @param bool $forceSize Forces image size based on $size with no manipulation by WP for admin editing 295 * @param string $classes 296 * @param string $id 297 * @param array $attributes 298 * @param array $styles 299 * 300 * @return null|string 301 * 302 * @since 1.1.4 303 */ 304 public function frontend_svg_sized_img( 305 $attachmentId, $size, $forceSize = false, $classes = '', $id = '', array $attributes = [], 306 array $styles = [] 307 ) { 308 $image = wp_get_attachment_image_src( $attachmentId, $size ); 309 310 if ( $forceSize ) { 311 $attributes = wcp_get_image_size( $size ); 312 if ( $attributes ) { 313 $image['width'] = maybe_get( $attributes, 'width', $image['width'] ); 314 $image['height'] = maybe_get( $attributes, 'height', $image['height'] ); 315 } 316 317 } 318 319 return $this->svg_img( $image['url'], $image['width'], $image['height'], $classes, $id, $attributes, 320 $styles ); 285 321 } 286 322 -
wysiwyg-custom-products/tags/1.1/common/utilities.php
r1812372 r1815404 7 7 * 8 8 * @since 1.0.0 9 * @updated 1.1. 39 * @updated 1.1.4 10 10 */ 11 11 … … 169 169 return '#' . substr( '000000' . dechex( $colorValue ), - 6 ); 170 170 } 171 172 /** 173 * Get an image size by name or defined dimensions. Or use $id to get actual image size. 174 * 175 * The returned variable is filtered by woocommerce_get_image_size_{image_size} filter to 176 * allow 3rd party customisation. 177 * 178 * Sizes defined by the theme take priority over settings. Settings are hidden when a theme 179 * defines sizes. 180 * 181 * @param array|string $image_size Name of the image size to get, or an array of dimensions. 182 * @param null|int $attachmentId image attachment id 183 * 184 * @return array Array of dimensions including width, height, and cropping mode. Cropping mode is 0 for no crop, and 1 for hard crop. 185 * 186 * @since 1.1.4 187 */ 188 function wcp_get_image_size( $image_size, $attachmentId = null ) { 189 $size = array( 190 'width' => 600, 191 'height' => 600, 192 'crop' => 0, 193 ); 194 195 if ((null !== $attachmentId) && \wp_attachment_is_image($attachmentId)) { 196 $meta = wp_get_attachment_metadata( $attachmentId); 197 $size['width'] = maybe_get( $meta, 'width', $size['width'] ); 198 $size['height'] = maybe_get( $meta, 'height', $size['height'] ); 199 return $size; 200 } 201 202 return \wc_get_image_size($image_size); 203 } -
wysiwyg-custom-products/tags/1.1/common/wp-helpers.php
r1603224 r1815404 7 7 * 8 8 * @since 1.0.0 9 * @updated 1. 0.69 * @updated 1.1.4 10 10 */ 11 11 … … 394 394 * 395 395 * @since 1.0.8 396 * @updated 1.1.4 396 397 */ 397 398 function wp_get_attachment_image_src( $attachmentId, $size ) { … … 399 400 if ( ! $image ) { 400 401 $image = [ '', 0, 0, false ]; 402 } elseif (3 === \count( $image)) { // Needed because WooCommerce does not include 'intermediate' parameter 403 $image[] = false; 401 404 } 402 405 -
wysiwyg-custom-products/tags/1.1/frontend/class-frontend.php
r1812372 r1815404 19 19 * 20 20 * @since 1.0.0 21 * @updated 1.1. 321 * @updated 1.1.4 22 22 */ 23 23 class Frontend { … … 166 166 } 167 167 168 /** @noinspection MoreThanThreeArgumentsInspection */ 168 169 /** 169 170 * Builds SVG html in $this->h … … 174 175 * @param string|null $divId 175 176 * @param string|null $imageId 176 * 177 * @since 1.0.0 178 * @updated 1.1.0 179 */ 180 private function svg_html( $liveLines, $message = null, $formats = null, $divId = null, $imageId = null ) { 177 * @param bool $forceSize 178 * 179 * @since 1.0.0 180 * @updated 1.1.4 181 */ 182 private function svg_html( $liveLines, $message = null, $formats = null, $divId = null, $imageId = null, 183 $forceSize = false 184 ) { 181 185 $h = $this->h; 182 186 $l = $this->layout; … … 202 206 $h->o_tag( 'g' ); 203 207 204 $h-> svg_sized_img( $l->image, $l->size, false, '', 'svg_image' );208 $h->frontend_svg_sized_img( $l->image, $l->size, $forceSize, '', 'svg_image' ); 205 209 206 210 if ( $formats ) { … … 291 295 $message = $productText ? explode( '|', $productText ) : false; 292 296 293 $this->svg_html( $liveUpdate, $message, $formats, 'front_svg', 'svg_image' );297 $this->svg_html( $liveUpdate, $message, $formats, 'front_svg', 'svg_image', true ); 294 298 $h->tag( 'p', $l->getMultiLineReformatMsg(), 'wcp-hidden wcp-lost-text', 'wcp_multiline' ); 295 299 $h->tag( 'p', $l->getNumberOfLinesMsg(), 'wcp-hidden wcp-lost-text', 'wcp_too_many_lines' ); -
wysiwyg-custom-products/tags/1.1/readme.txt
r1812372 r1815404 124 124 125 125 = 1.1.3 = 126 * Added workaround for changes in woocommerce core functions and image size names. 126 * Added workaround for changes in WooCommerce core functions and image size names. 127 128 = 1.1.4 = 129 * Fixed bug in image sizing from Admin to Frontend. 130 * Added workaround because WooCommerce returns a different image array size in it's application of the 'wp_get_attachment_image_src' filter. 127 131 128 132 == Upgrade Notice == 129 Fixed for WooCommerce 3.3.0 changes. 133 Fixed for WooCommerce 3.3.0 changes. Fixed bug that affected image sizing. 130 134 131 135 == Creating Layouts - Instructions == -
wysiwyg-custom-products/tags/1.1/wysiwyg-custom-products.php
r1812372 r1815404 4 4 * Plugin URI: https://tazziedave.com/wp-plugins/wysiwyg-custom-products 5 5 * Description: Enables a live WYSIWYG preview of custom products where text is edited in text area or text field in woo commerce. 6 * Version: 1.1. 36 * Version: 1.1.4 7 7 * Author: Tazziedave 8 8 * Author URI: https://tazziedave.com … … 62 62 * 63 63 * @since 1.0.0 64 * @updated 1.1. 364 * @updated 1.1.4 65 65 */ 66 66 class Wcp_Plugin { … … 74 74 * Plug in version 75 75 */ 76 const VER = '1.1. 3';76 const VER = '1.1.4'; 77 77 /** 78 78 * Database version. Used in class-plugin to run updates as necessary -
wysiwyg-custom-products/trunk/admin/class-ajax.php
r1677949 r1815404 21 21 * 22 22 * @since 1.0.0 23 * @updated 1.1. 223 * @updated 1.1.4 24 24 */ 25 25 class Ajax { … … 69 69 * 70 70 * @since 1.0.0 71 * @updated 1.1. 071 * @updated 1.1.4 72 72 */ 73 73 public function get_image_attr() { … … 78 78 $image = wp_get_attachment_image_src( $attachmentId, $size ); 79 79 // Overriding WP's resizing of image in admin for "editing" 80 $attributes = wc _get_image_size( $size);80 $attributes = wcp_get_image_size( $size, $attachmentId ); 81 81 if ( $attributes ) { 82 82 $image['width'] = maybe_get( $attributes, 'width', $image['width'] ); -
wysiwyg-custom-products/trunk/common/class-wp-html-helper.php
r1603224 r1815404 15 15 * 16 16 * @since 1.0.1 17 * @updated 1.1. 017 * @updated 1.1.4 18 18 */ 19 19 … … 263 263 * 264 264 * @since 1.0.8 265 * @updated 1.1. 0265 * @updated 1.1.4 266 266 */ 267 267 public function svg_sized_img( … … 273 273 // Overriding WP's resizing of image in admin for "editing" 274 274 if ( $forceSize ) { 275 $attributes = wc _get_image_size( $size);275 $attributes = wcp_get_image_size( $size, $attachmentId ); 276 276 if ( $attributes ) { 277 277 $image['width'] = maybe_get( $attributes, 'width', $image['width'] ); … … 283 283 return $this->svg_img( $image['url'], $image['width'], $image['height'], $classes, $id, $attributes, 284 284 $styles ); 285 } 286 287 /** @noinspection MoreThanThreeArgumentsInspection */ 288 /** 289 * Creates SVG <image ... /> tag getting the correct image and size from the WP size string 290 * Escapes href 291 * 292 * @param int $attachmentId 293 * @param string $size 294 * @param bool $forceSize Forces image size based on $size with no manipulation by WP for admin editing 295 * @param string $classes 296 * @param string $id 297 * @param array $attributes 298 * @param array $styles 299 * 300 * @return null|string 301 * 302 * @since 1.1.4 303 */ 304 public function frontend_svg_sized_img( 305 $attachmentId, $size, $forceSize = false, $classes = '', $id = '', array $attributes = [], 306 array $styles = [] 307 ) { 308 $image = wp_get_attachment_image_src( $attachmentId, $size ); 309 310 if ( $forceSize ) { 311 $attributes = wcp_get_image_size( $size ); 312 if ( $attributes ) { 313 $image['width'] = maybe_get( $attributes, 'width', $image['width'] ); 314 $image['height'] = maybe_get( $attributes, 'height', $image['height'] ); 315 } 316 317 } 318 319 return $this->svg_img( $image['url'], $image['width'], $image['height'], $classes, $id, $attributes, 320 $styles ); 285 321 } 286 322 -
wysiwyg-custom-products/trunk/common/utilities.php
r1812372 r1815404 7 7 * 8 8 * @since 1.0.0 9 * @updated 1.1. 39 * @updated 1.1.4 10 10 */ 11 11 … … 169 169 return '#' . substr( '000000' . dechex( $colorValue ), - 6 ); 170 170 } 171 172 /** 173 * Get an image size by name or defined dimensions. Or use $id to get actual image size. 174 * 175 * The returned variable is filtered by woocommerce_get_image_size_{image_size} filter to 176 * allow 3rd party customisation. 177 * 178 * Sizes defined by the theme take priority over settings. Settings are hidden when a theme 179 * defines sizes. 180 * 181 * @param array|string $image_size Name of the image size to get, or an array of dimensions. 182 * @param null|int $attachmentId image attachment id 183 * 184 * @return array Array of dimensions including width, height, and cropping mode. Cropping mode is 0 for no crop, and 1 for hard crop. 185 * 186 * @since 1.1.4 187 */ 188 function wcp_get_image_size( $image_size, $attachmentId = null ) { 189 $size = array( 190 'width' => 600, 191 'height' => 600, 192 'crop' => 0, 193 ); 194 195 if ((null !== $attachmentId) && \wp_attachment_is_image($attachmentId)) { 196 $meta = wp_get_attachment_metadata( $attachmentId); 197 $size['width'] = maybe_get( $meta, 'width', $size['width'] ); 198 $size['height'] = maybe_get( $meta, 'height', $size['height'] ); 199 return $size; 200 } 201 202 return \wc_get_image_size($image_size); 203 } -
wysiwyg-custom-products/trunk/common/wp-helpers.php
r1592084 r1815404 7 7 * 8 8 * @since 1.0.0 9 * @updated 1. 0.69 * @updated 1.1.4 10 10 */ 11 11 … … 394 394 * 395 395 * @since 1.0.8 396 * @updated 1.1.4 396 397 */ 397 398 function wp_get_attachment_image_src( $attachmentId, $size ) { … … 399 400 if ( ! $image ) { 400 401 $image = [ '', 0, 0, false ]; 402 } elseif (3 === \count( $image)) { // Needed because WooCommerce does not include 'intermediate' parameter 403 $image[] = false; 401 404 } 402 405 -
wysiwyg-custom-products/trunk/frontend/class-frontend.php
r1812372 r1815404 19 19 * 20 20 * @since 1.0.0 21 * @updated 1.1. 321 * @updated 1.1.4 22 22 */ 23 23 class Frontend { … … 166 166 } 167 167 168 /** @noinspection MoreThanThreeArgumentsInspection */ 168 169 /** 169 170 * Builds SVG html in $this->h … … 174 175 * @param string|null $divId 175 176 * @param string|null $imageId 176 * 177 * @since 1.0.0 178 * @updated 1.1.0 179 */ 180 private function svg_html( $liveLines, $message = null, $formats = null, $divId = null, $imageId = null ) { 177 * @param bool $forceSize 178 * 179 * @since 1.0.0 180 * @updated 1.1.4 181 */ 182 private function svg_html( $liveLines, $message = null, $formats = null, $divId = null, $imageId = null, 183 $forceSize = false 184 ) { 181 185 $h = $this->h; 182 186 $l = $this->layout; … … 202 206 $h->o_tag( 'g' ); 203 207 204 $h-> svg_sized_img( $l->image, $l->size, false, '', 'svg_image' );208 $h->frontend_svg_sized_img( $l->image, $l->size, $forceSize, '', 'svg_image' ); 205 209 206 210 if ( $formats ) { … … 291 295 $message = $productText ? explode( '|', $productText ) : false; 292 296 293 $this->svg_html( $liveUpdate, $message, $formats, 'front_svg', 'svg_image' );297 $this->svg_html( $liveUpdate, $message, $formats, 'front_svg', 'svg_image', true ); 294 298 $h->tag( 'p', $l->getMultiLineReformatMsg(), 'wcp-hidden wcp-lost-text', 'wcp_multiline' ); 295 299 $h->tag( 'p', $l->getNumberOfLinesMsg(), 'wcp-hidden wcp-lost-text', 'wcp_too_many_lines' ); -
wysiwyg-custom-products/trunk/readme.txt
r1812372 r1815404 124 124 125 125 = 1.1.3 = 126 * Added workaround for changes in woocommerce core functions and image size names. 126 * Added workaround for changes in WooCommerce core functions and image size names. 127 128 = 1.1.4 = 129 * Fixed bug in image sizing from Admin to Frontend. 130 * Added workaround because WooCommerce returns a different image array size in it's application of the 'wp_get_attachment_image_src' filter. 127 131 128 132 == Upgrade Notice == 129 Fixed for WooCommerce 3.3.0 changes. 133 Fixed for WooCommerce 3.3.0 changes. Fixed bug that affected image sizing. 130 134 131 135 == Creating Layouts - Instructions == -
wysiwyg-custom-products/trunk/wysiwyg-custom-products.php
r1812372 r1815404 4 4 * Plugin URI: https://tazziedave.com/wp-plugins/wysiwyg-custom-products 5 5 * Description: Enables a live WYSIWYG preview of custom products where text is edited in text area or text field in woo commerce. 6 * Version: 1.1. 36 * Version: 1.1.4 7 7 * Author: Tazziedave 8 8 * Author URI: https://tazziedave.com … … 62 62 * 63 63 * @since 1.0.0 64 * @updated 1.1. 364 * @updated 1.1.4 65 65 */ 66 66 class Wcp_Plugin { … … 74 74 * Plug in version 75 75 */ 76 const VER = '1.1. 3';76 const VER = '1.1.4'; 77 77 /** 78 78 * Database version. Used in class-plugin to run updates as necessary
Note: See TracChangeset
for help on using the changeset viewer.