Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
Python
SQL
Shell
Markdown
YAML
JSON
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
TypeScript
Perl
Lua
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
get_meta( 'rtwpvg_images' ); if ( empty ( $rtwpvg_images ) || ! is_array ( $rtwpvg_images ) || count ( $rtwpvg_images ) < 1 ) return $child_product; $gallery = array(); foreach ( $rtwpvg_images as $origin_image_id ) { $image_id = _woogc_synchronize_image( $origin_image_id, $origin_product_blog_ID ); if ( $image_id > 0 ) $gallery[] = $image_id; } if ( count ( $gallery ) > 0 ) { $child_product->update_meta_data( 'rtwpvg_images', $gallery ); } return $child_product; } /** * Synchronize image to child product * * @param mixed $prop_value * @param mixed $origin_product_blog_ID * @param mixed $synchronized_product_ID */ function _woogc_synchronize_image( $prop_value, $origin_product_blog_ID ) { //Check if the current image ID has been previously synchronized tothe current shop global $wpdb; $mysql_query = $wpdb->prepare( "SELECT meta_value FROM ". $wpdb->postmeta . " WHERE meta_key = '_woogc_image_sync_%d_%d'", $origin_product_blog_ID, $prop_value ); $local_image_id = $wpdb->get_var( $mysql_query ); if ( ! empty ( $local_image_id ) ) { //check if the image still exists $image_data = get_post( $local_image_id ); if ( is_object ( $image_data ) && $image_data->post_type == 'attachment' ) return $local_image_id; } switch_to_blog( $origin_product_blog_ID ); $image_data = wp_get_attachment_image_src( $prop_value, 'full' ); restore_current_blog(); $local_image_id = media_sideload_image ( $image_data[0], 0, null, 'id' ); if ( is_int ( $local_image_id ) && $local_image_id > 0 ) { update_post_meta( $local_image_id, '_woogc_image_sync_' . $origin_product_blog_ID . '_' . $prop_value, $local_image_id ); return $local_image_id; } return FALSE; }
Mark as private
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year