Standardises certain post data on save.
Author: WooThemes
Ejemplo n.º 1
0
 /**
  * When a term is edited, check for product attributes and update variations
  * @param  id $term_id
  * @param  id $tt_id
  * @param  string $taxonomy
  */
 public static function edited_term($term_id, $tt_id, $taxonomy)
 {
     if (!is_null(self::$editing_term) && strpos($taxonomy, 'pa_') === 0) {
         $edited_term = get_term_by('id', $term_id, $taxonomy);
         if ($edited_term->slug !== self::$editing_term->slug) {
             global $wpdb;
             $wpdb->query($wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_value = %s WHERE meta_key = %s AND meta_value = %s;", $edited_term->slug, 'attribute_' . sanitize_title($taxonomy), self::$editing_term->slug));
         }
     } else {
         self::$editing_term = null;
     }
 }
 /**
  * Grant downloadable file access to any newly added files on any existing.
  * orders for this product that have previously been granted downloadable file access.
  *
  * @param int $product_id product identifier
  * @param int $variation_id optional product variation identifier
  * @param array $downloadable_files newly set files
  * @deprecated and moved to post-data class.
  */
 public function process_product_file_download_paths($product_id, $variation_id, $downloadable_files)
 {
     WC_Post_Data::process_product_file_download_paths($product_id, $variation_id, $downloadable_files);
 }