Changeset 3264867
- Timestamp:
- 04/01/2025 06:29:07 AM (12 months ago)
- Location:
- lemonink
- Files:
-
- 12 edited
- 1 copied
-
tags/0.8.0 (copied) (copied from lemonink/trunk)
-
tags/0.8.0/includes/class-wc-lemonink-download-handler.php (modified) (2 diffs)
-
tags/0.8.0/includes/class-wc-lemonink-integration.php (modified) (1 diff)
-
tags/0.8.0/includes/class-wc-lemonink-order.php (modified) (4 diffs)
-
tags/0.8.0/includes/class-wc-lemonink-product.php (modified) (5 diffs)
-
tags/0.8.0/lemonink.php (modified) (3 diffs)
-
tags/0.8.0/readme.txt (modified) (1 diff)
-
trunk/includes/class-wc-lemonink-download-handler.php (modified) (2 diffs)
-
trunk/includes/class-wc-lemonink-integration.php (modified) (1 diff)
-
trunk/includes/class-wc-lemonink-order.php (modified) (4 diffs)
-
trunk/includes/class-wc-lemonink-product.php (modified) (5 diffs)
-
trunk/lemonink.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lemonink/tags/0.8.0/includes/class-wc-lemonink-download-handler.php
r2476246 r3264867 30 30 return true; 31 31 } 32 32 33 33 public function download_product( $user_email, $order_key, $product_id, $user_id, $download_id, $order_id ) { 34 34 if ( $this->is_lemoninkable_download( $download_id ) ) { 35 35 $meta_prefix = "_li_product_{$product_id}_"; 36 36 37 $transaction_id = get_post_meta( $order_id, $meta_prefix . 'transaction_id', true ); 38 $transaction = $this->settings->get_api_client()->find( 'transaction', $transaction_id ); 39 37 $transaction_data = WC_LemonInk_Order_Metadata::get_transaction_data( $order_id, $meta_prefix ); 38 if (!$transaction_data || !$transaction_data['id']) { 39 return; 40 } 41 42 $transaction = $this->settings->get_api_client()->find( 'transaction', $transaction_data['id'] ); 43 40 44 $product = wc_get_product( $product_id ); 41 45 $files = get_downloads( $product ); 42 46 43 47 $format = strtolower($files[$download_id]['name']); 44 48 45 49 WC_Download_Handler::download( $transaction->getUrl($format), $product_id ); 46 50 exit; … … 55 59 $product = wc_get_product( $product_id ); 56 60 $files = get_downloads( $product ); 57 61 58 62 foreach ($files as $download_id => $file) { 59 63 if ( $this->is_lemoninkable_download( $download_id ) ) { -
lemonink/tags/0.8.0/includes/class-wc-lemonink-integration.php
r3106535 r3264867 66 66 } else { 67 67 $this->settings['api_key'] = $this->get_field_value( 'api_key', $fields['api_key'], $post_data ); 68 } 69 68 } 69 70 70 $option_key = $this->get_option_key(); 71 71 do_action( 'woocommerce_update_option', array( 'id' => $option_key ) ); 72 72 $result = update_option( $option_key, apply_filters( 'woocommerce_settings_api_sanitized_fields_' . $this->id, $this->settings ), 'yes' ); 73 73 74 74 // Fetch API key from settings and reload form fields to reflect changes 75 75 $this->forget_api_key(); 76 76 $this->get_settings(); 77 77 $this->init_form_fields(); 78 78 79 79 return $result; 80 80 } -
lemonink/tags/0.8.0/includes/class-wc-lemonink-order.php
r3173483 r3264867 25 25 public function create_transaction( $download_data ) { 26 26 $meta_prefix = "_li_product_{$download_data['product_id']}_"; 27 $transaction_exists = get_post_meta( $download_data['order_id'], $meta_prefix . 'transaction_id', 'yes' ); 27 $transaction_data = WC_LemonInk_Order_Metadata::get_transaction_data( $download_data['order_id'], $meta_prefix ); 28 $transaction_exists = !!$transaction_data; 28 29 29 30 $product = wc_get_product( $download_data['product_id'] ); … … 40 41 if ( $parent_id ) { 41 42 $parent_meta_prefix = "_li_product_{$parent_id}_"; 42 $transaction_id = get_post_meta( $download_data['order_id'], $parent_meta_prefix . 'transaction_id', 'yes' ); 43 $transaction_token = get_post_meta( $download_data['order_id'], $parent_meta_prefix . 'transaction_token', 'yes' ); 43 $parent_transaction_data = WC_LemonInk_Order_Metadata::get_transaction_data( $download_data['order_id'], $parent_meta_prefix ); 44 44 45 if ( $transaction_id ) { 46 add_post_meta( $download_data['order_id'], $meta_prefix . 'transaction_id', $transaction_id, true ); 47 add_post_meta( $download_data['order_id'], $meta_prefix . 'transaction_token', $transaction_token, true ); 45 if ( $parent_transaction_data ) { 46 WC_LemonInk_Order_Metadata::set_transaction_data( 47 $download_data['order_id'], 48 $meta_prefix, 49 $parent_transaction_data['id'], 50 $parent_transaction_data['token'] 51 ); 48 52 $transaction_exists = true; 49 53 } … … 66 70 $transaction->setWatermarkParams( $this->watermark_params( $user->getWatermarkParams(), $order ) ); 67 71 } else { 68 $watermark_value = get_post_meta( $download_data['order_id'], '_li_watermark_value', 'yes');72 $watermark_value = WC_LemonInk_Order_Metadata::get_watermark_value( $download_data['order_id'] ); 69 73 if ( !isset($watermark_value) ) { 70 74 $watermark_value = $this->watermark_value( $download_data['order_id'], $download_data['user_email'] ); … … 75 79 $this->settings->get_api_client()->save($transaction); 76 80 77 add_post_meta( $download_data['order_id'], $meta_prefix . 'transaction_id', $transaction->getId(), true ); 78 add_post_meta( $download_data['order_id'], $meta_prefix . 'transaction_token', $transaction->getToken(), true ); 81 WC_LemonInk_Order_Metadata::set_transaction_data( 82 $download_data['order_id'], 83 $meta_prefix, 84 $transaction->getId(), 85 $transaction->getToken() 86 ); 79 87 } 80 88 } -
lemonink/tags/0.8.0/includes/class-wc-lemonink-product.php
r2763015 r3264867 95 95 96 96 } 97 97 98 98 public function save_product( $product_id ) { 99 99 $post = get_post( $product_id ); … … 114 114 '_li_master_id' => trim( $_POST['variable_li_master_id'][ $i ] ) 115 115 ); 116 116 117 117 $this->_save_product( $product_id, $params ); 118 118 } … … 140 140 141 141 $files = array(); 142 142 143 143 if ( $master ) { 144 144 foreach ( $master->getFormats() as $format ) { … … 168 168 if ( !$exists_on_disk ) { 169 169 $master_id = preg_replace( '/\.([^.]+)$/', '', $file_url); 170 170 171 171 return !!preg_match( '/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i', $master_id ); 172 172 } else { … … 178 178 if ( !$exists_on_disk ) { 179 179 $master_id = preg_replace( '/\.([^.]+)$/', '', $file_url); 180 180 181 181 $master = $this->settings->get_api_client()->find( 'master', $master_id ); 182 182 -
lemonink/tags/0.8.0/lemonink.php
r3173483 r3264867 5 5 * Plugin URI: https://www.lemonink.co/ 6 6 * Description: Watermark EPUB, MOBI and PDF files in your WooCommerce store using the LemonInk service. 7 * Version: 0. 7.27 * Version: 0.8.0 8 8 * Author: LemonInk 9 9 * Author URI: https://www.lemonink.co/ 10 10 * Requires at least: 4.4 11 * Tested up to: 6. 6.211 * Tested up to: 6.8 12 12 * 13 13 * Text Domain: lemonink … … 79 79 80 80 include_once plugin_dir_path( __FILE__ ) . "vendor/autoload.php"; 81 require_once( dirname( __FILE__ ) . '/includes/class-wc-lemonink-order-metadata.php' ); 81 82 82 83 include_once plugin_dir_path( __FILE__ ) . 'includes/class-wc-lemonink-product.php'; … … 88 89 include_once plugin_dir_path( __FILE__ ) . 'includes/class-wc-lemonink-download-handler.php'; 89 90 new WC_LemonInk_Download_Handler( $this->settings ); 91 90 92 } 91 93 -
lemonink/tags/0.8.0/readme.txt
r3173483 r3264867 3 3 Tags: lemonink, ecommerce, e-commerce, downloadable, downloads, ebooks, drm, watermark, watermarking, epub, mobi, pdf, Kindle, woocommerce 4 4 Requires at least: 4.4 5 Tested up to: 6. 6.26 Stable tag: 0. 7.25 Tested up to: 6.8 6 Stable tag: 0.8.0 7 7 License: MIT 8 8 -
lemonink/trunk/includes/class-wc-lemonink-download-handler.php
r2476246 r3264867 30 30 return true; 31 31 } 32 32 33 33 public function download_product( $user_email, $order_key, $product_id, $user_id, $download_id, $order_id ) { 34 34 if ( $this->is_lemoninkable_download( $download_id ) ) { 35 35 $meta_prefix = "_li_product_{$product_id}_"; 36 36 37 $transaction_id = get_post_meta( $order_id, $meta_prefix . 'transaction_id', true ); 38 $transaction = $this->settings->get_api_client()->find( 'transaction', $transaction_id ); 39 37 $transaction_data = WC_LemonInk_Order_Metadata::get_transaction_data( $order_id, $meta_prefix ); 38 if (!$transaction_data || !$transaction_data['id']) { 39 return; 40 } 41 42 $transaction = $this->settings->get_api_client()->find( 'transaction', $transaction_data['id'] ); 43 40 44 $product = wc_get_product( $product_id ); 41 45 $files = get_downloads( $product ); 42 46 43 47 $format = strtolower($files[$download_id]['name']); 44 48 45 49 WC_Download_Handler::download( $transaction->getUrl($format), $product_id ); 46 50 exit; … … 55 59 $product = wc_get_product( $product_id ); 56 60 $files = get_downloads( $product ); 57 61 58 62 foreach ($files as $download_id => $file) { 59 63 if ( $this->is_lemoninkable_download( $download_id ) ) { -
lemonink/trunk/includes/class-wc-lemonink-integration.php
r3106535 r3264867 66 66 } else { 67 67 $this->settings['api_key'] = $this->get_field_value( 'api_key', $fields['api_key'], $post_data ); 68 } 69 68 } 69 70 70 $option_key = $this->get_option_key(); 71 71 do_action( 'woocommerce_update_option', array( 'id' => $option_key ) ); 72 72 $result = update_option( $option_key, apply_filters( 'woocommerce_settings_api_sanitized_fields_' . $this->id, $this->settings ), 'yes' ); 73 73 74 74 // Fetch API key from settings and reload form fields to reflect changes 75 75 $this->forget_api_key(); 76 76 $this->get_settings(); 77 77 $this->init_form_fields(); 78 78 79 79 return $result; 80 80 } -
lemonink/trunk/includes/class-wc-lemonink-order.php
r3173483 r3264867 25 25 public function create_transaction( $download_data ) { 26 26 $meta_prefix = "_li_product_{$download_data['product_id']}_"; 27 $transaction_exists = get_post_meta( $download_data['order_id'], $meta_prefix . 'transaction_id', 'yes' ); 27 $transaction_data = WC_LemonInk_Order_Metadata::get_transaction_data( $download_data['order_id'], $meta_prefix ); 28 $transaction_exists = !!$transaction_data; 28 29 29 30 $product = wc_get_product( $download_data['product_id'] ); … … 40 41 if ( $parent_id ) { 41 42 $parent_meta_prefix = "_li_product_{$parent_id}_"; 42 $transaction_id = get_post_meta( $download_data['order_id'], $parent_meta_prefix . 'transaction_id', 'yes' ); 43 $transaction_token = get_post_meta( $download_data['order_id'], $parent_meta_prefix . 'transaction_token', 'yes' ); 43 $parent_transaction_data = WC_LemonInk_Order_Metadata::get_transaction_data( $download_data['order_id'], $parent_meta_prefix ); 44 44 45 if ( $transaction_id ) { 46 add_post_meta( $download_data['order_id'], $meta_prefix . 'transaction_id', $transaction_id, true ); 47 add_post_meta( $download_data['order_id'], $meta_prefix . 'transaction_token', $transaction_token, true ); 45 if ( $parent_transaction_data ) { 46 WC_LemonInk_Order_Metadata::set_transaction_data( 47 $download_data['order_id'], 48 $meta_prefix, 49 $parent_transaction_data['id'], 50 $parent_transaction_data['token'] 51 ); 48 52 $transaction_exists = true; 49 53 } … … 66 70 $transaction->setWatermarkParams( $this->watermark_params( $user->getWatermarkParams(), $order ) ); 67 71 } else { 68 $watermark_value = get_post_meta( $download_data['order_id'], '_li_watermark_value', 'yes');72 $watermark_value = WC_LemonInk_Order_Metadata::get_watermark_value( $download_data['order_id'] ); 69 73 if ( !isset($watermark_value) ) { 70 74 $watermark_value = $this->watermark_value( $download_data['order_id'], $download_data['user_email'] ); … … 75 79 $this->settings->get_api_client()->save($transaction); 76 80 77 add_post_meta( $download_data['order_id'], $meta_prefix . 'transaction_id', $transaction->getId(), true ); 78 add_post_meta( $download_data['order_id'], $meta_prefix . 'transaction_token', $transaction->getToken(), true ); 81 WC_LemonInk_Order_Metadata::set_transaction_data( 82 $download_data['order_id'], 83 $meta_prefix, 84 $transaction->getId(), 85 $transaction->getToken() 86 ); 79 87 } 80 88 } -
lemonink/trunk/includes/class-wc-lemonink-product.php
r2763015 r3264867 95 95 96 96 } 97 97 98 98 public function save_product( $product_id ) { 99 99 $post = get_post( $product_id ); … … 114 114 '_li_master_id' => trim( $_POST['variable_li_master_id'][ $i ] ) 115 115 ); 116 116 117 117 $this->_save_product( $product_id, $params ); 118 118 } … … 140 140 141 141 $files = array(); 142 142 143 143 if ( $master ) { 144 144 foreach ( $master->getFormats() as $format ) { … … 168 168 if ( !$exists_on_disk ) { 169 169 $master_id = preg_replace( '/\.([^.]+)$/', '', $file_url); 170 170 171 171 return !!preg_match( '/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i', $master_id ); 172 172 } else { … … 178 178 if ( !$exists_on_disk ) { 179 179 $master_id = preg_replace( '/\.([^.]+)$/', '', $file_url); 180 180 181 181 $master = $this->settings->get_api_client()->find( 'master', $master_id ); 182 182 -
lemonink/trunk/lemonink.php
r3173483 r3264867 5 5 * Plugin URI: https://www.lemonink.co/ 6 6 * Description: Watermark EPUB, MOBI and PDF files in your WooCommerce store using the LemonInk service. 7 * Version: 0. 7.27 * Version: 0.8.0 8 8 * Author: LemonInk 9 9 * Author URI: https://www.lemonink.co/ 10 10 * Requires at least: 4.4 11 * Tested up to: 6. 6.211 * Tested up to: 6.8 12 12 * 13 13 * Text Domain: lemonink … … 79 79 80 80 include_once plugin_dir_path( __FILE__ ) . "vendor/autoload.php"; 81 require_once( dirname( __FILE__ ) . '/includes/class-wc-lemonink-order-metadata.php' ); 81 82 82 83 include_once plugin_dir_path( __FILE__ ) . 'includes/class-wc-lemonink-product.php'; … … 88 89 include_once plugin_dir_path( __FILE__ ) . 'includes/class-wc-lemonink-download-handler.php'; 89 90 new WC_LemonInk_Download_Handler( $this->settings ); 91 90 92 } 91 93 -
lemonink/trunk/readme.txt
r3173483 r3264867 3 3 Tags: lemonink, ecommerce, e-commerce, downloadable, downloads, ebooks, drm, watermark, watermarking, epub, mobi, pdf, Kindle, woocommerce 4 4 Requires at least: 4.4 5 Tested up to: 6. 6.26 Stable tag: 0. 7.25 Tested up to: 6.8 6 Stable tag: 0.8.0 7 7 License: MIT 8 8
Note: See TracChangeset
for help on using the changeset viewer.