| 
                                                        @@ -1,21 +1,21 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    1
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -<?php if ( !defined( 'ABSPATH' ) ) exit;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    1
                                                                                                                                                                                                 | 
                                                            +<?php if (!defined('ABSPATH')) exit; | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    2
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    2
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    3
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    3
                                                                                                                                                                                                 | 
                                                             class wps_download_file_ctr { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    4
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    4
                                                                                                                                                                                                 | 
                                                             	public function __construct() { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    5
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -		add_action( 'admin_post_wps_download_file', array( $this, 'wps_download_file' ) );  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    6
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -		add_action( 'admin_post_nopriv_wps_download_file', array( $this, 'wps_download_file' ) );  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    5
                                                                                                                                                                                                 | 
                                                            +		add_action('admin_post_wps_download_file', array($this, 'wps_download_file')); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    6
                                                                                                                                                                                                 | 
                                                            +		add_action('admin_post_nopriv_wps_download_file', array($this, 'wps_download_file')); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    7
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    7
                                                                                                                                                                                                 | 
                                                             	}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    8
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    8
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    9
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    9
                                                                                                                                                                                                 | 
                                                             	// Function to find download link by  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    10
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -	public static function get_product_download_link( $oid, $item ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    10
                                                                                                                                                                                                 | 
                                                            +	public static function get_product_download_link($oid, $item) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    11
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    11
                                                                                                                                                                                                 | 
                                                             		global $wpdb;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    12
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    12
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    13
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    13
                                                                                                                                                                                                 | 
                                                             		$parent_def = array();  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    14
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    14
                                                                                                                                                                                                 | 
                                                             		$item_id = $item['item_id'];  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    15
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -		$item_post_type = get_post_type( $item['item_id'] );  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    16
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -		if ( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item_post_type ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    17
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -			$parent_def = wpshop_products::get_parent_variation( $item['item_id'] );  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    18
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -			if ( ! empty( $parent_def ) && ! empty( $parent_def['parent_post'] ) ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    15
                                                                                                                                                                                                 | 
                                                            +		$item_post_type = get_post_type($item['item_id']);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    16
                                                                                                                                                                                                 | 
                                                            +		if (WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item_post_type) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    17
                                                                                                                                                                                                 | 
                                                            +			$parent_def = wpshop_products::get_parent_variation($item['item_id']);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    18
                                                                                                                                                                                                 | 
                                                            +			if (!empty($parent_def) && !empty($parent_def['parent_post'])) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    19
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    19
                                                                                                                                                                                                 | 
                                                             				$parent_post = $parent_def['parent_post'];  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    20
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    20
                                                                                                                                                                                                 | 
                                                             				$item_id = $parent_post->ID;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    21
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    21
                                                                                                                                                                                                 | 
                                                             				$item_title = $parent_post->post_title;  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -25,42 +25,42 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    25
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    25
                                                                                                                                                                                                 | 
                                                             		$download_link = '';  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    26
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    26
                                                                                                                                                                                                 | 
                                                             		$item_id_for_download = null;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    27
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    27
                                                                                                                                                                                                 | 
                                                             		/** Check if the product or the head product is a download product	*/  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    28
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -		if ( ! empty( $parent_def ) ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    28
                                                                                                                                                                                                 | 
                                                            +		if (!empty($parent_def)) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    29
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    29
                                                                                                                                                                                                 | 
                                                             			$parent_meta = $parent_def['parent_post_meta'];  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    30
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -			if ( ! empty( $parent_meta['is_downloadable_'] ) ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    31
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				$query = $wpdb->prepare( 'SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $parent_meta['is_downloadable_'] );  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    32
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				$downloadable_option_value = $wpdb->get_var( $query );  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    33
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				if ( ! empty( $downloadable_option_value ) ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    30
                                                                                                                                                                                                 | 
                                                            +			if (!empty($parent_meta['is_downloadable_'])) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    31
                                                                                                                                                                                                 | 
                                                            +				$query = $wpdb->prepare('SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $parent_meta['is_downloadable_']); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    32
                                                                                                                                                                                                 | 
                                                            +				$downloadable_option_value = $wpdb->get_var($query);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    33
                                                                                                                                                                                                 | 
                                                            +				if (!empty($downloadable_option_value)) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    34
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    34
                                                                                                                                                                                                 | 
                                                             					$item['item_is_downloadable_'] = $downloadable_option_value;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    35
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    35
                                                                                                                                                                                                 | 
                                                             				}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    36
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    36
                                                                                                                                                                                                 | 
                                                             			}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    37
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    37
                                                                                                                                                                                                 | 
                                                             		}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    38
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -		if ( ! empty( $item ) && ! empty( $item['item_is_downloadable_'] ) && ( strtolower( __( $item['item_is_downloadable_'], 'wpshop') ) == strtolower( __('Yes', 'wpshop') ) ) ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    38
                                                                                                                                                                                                 | 
                                                            +		if (!empty($item) && !empty($item['item_is_downloadable_']) && (strtolower(__($item['item_is_downloadable_'], 'wpshop')) == strtolower(__('Yes', 'wpshop')))) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    39
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    39
                                                                                                                                                                                                 | 
                                                             			$item_id_for_download = $item_id;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    40
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    40
                                                                                                                                                                                                 | 
                                                             		}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    41
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -		if ( isset( $item['item_meta']['variations'] ) ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    42
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -			foreach ( $item['item_meta']['variations'] as $variation_id => $variation ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    43
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				if ( isset( $variation['item_meta']['is_downloadable_'] ) ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    41
                                                                                                                                                                                                 | 
                                                            +		if (isset($item['item_meta']['variations'])) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    42
                                                                                                                                                                                                 | 
                                                            +			foreach ($item['item_meta']['variations'] as $variation_id => $variation) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    43
                                                                                                                                                                                                 | 
                                                            +				if (isset($variation['item_meta']['is_downloadable_'])) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    44
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    44
                                                                                                                                                                                                 | 
                                                             					$item_id_for_download = $item_id . '__' . $variation_id;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    45
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    45
                                                                                                                                                                                                 | 
                                                             				}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    46
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    46
                                                                                                                                                                                                 | 
                                                             			}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    47
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    47
                                                                                                                                                                                                 | 
                                                             		}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    48
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    48
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    49
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    49
                                                                                                                                                                                                 | 
                                                             		/** In case there is a item identifier defined for download */  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    50
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -		if ( null !== $item_id_for_download ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    51
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -			$download_codes = get_user_meta( get_current_user_id(), '_order_download_codes_' . $oid, true );  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    50
                                                                                                                                                                                                 | 
                                                            +		if (null !== $item_id_for_download) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    51
                                                                                                                                                                                                 | 
                                                            +			$download_codes = get_user_meta(get_current_user_id(), '_order_download_codes_' . $oid, true);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    52
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    52
                                                                                                                                                                                                 | 
                                                             			/**	Check if the current product exist into download code list, if not check if there is a composition between parent product and children product	*/  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    53
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -			if ( empty( $download_codes[ $item_id_for_download ] ) ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    54
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				$item_id_component = explode( "__", $item_id_for_download );  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    55
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				if ( ! empty( $item_id_component ) && ( $item_id_component[0] != $item_id_for_download ) ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    53
                                                                                                                                                                                                 | 
                                                            +			if (empty($download_codes[$item_id_for_download])) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    54
                                                                                                                                                                                                 | 
                                                            +				$item_id_component = explode("__", $item_id_for_download); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    55
                                                                                                                                                                                                 | 
                                                            +				if (!empty($item_id_component) && ($item_id_component[0] != $item_id_for_download)) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    56
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    56
                                                                                                                                                                                                 | 
                                                             					$item_id_for_download = $item_id_component[0];  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    57
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				} elseif ( ! empty( $download_codes[ $item['item_id'] ] ) ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    57
                                                                                                                                                                                                 | 
                                                            +				} elseif (!empty($download_codes[$item['item_id']])) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    58
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    58
                                                                                                                                                                                                 | 
                                                             					$item_id_for_download = $item['item_id'];  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    59
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    59
                                                                                                                                                                                                 | 
                                                             				}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    60
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    60
                                                                                                                                                                                                 | 
                                                             			}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    61
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    61
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    62
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -			if ( ! empty( $download_codes ) && ! empty( $download_codes[ $item_id_for_download ] ) && ! empty( $download_codes[ $item_id_for_download ]['download_code'] ) ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    63
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				$download_link = admin_url( 'admin-post.php?action=wps_download_file&oid=' . $oid . '&download=' . $download_codes[ $item_id_for_download ]['download_code'] );  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    62
                                                                                                                                                                                                 | 
                                                            +			if (!empty($download_codes) && !empty($download_codes[$item_id_for_download]) && !empty($download_codes[$item_id_for_download]['download_code'])) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    63
                                                                                                                                                                                                 | 
                                                            +				$download_link = admin_url('admin-post.php?action=wps_download_file&oid=' . $oid . '&download=' . $download_codes[$item_id_for_download]['download_code']); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    64
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    64
                                                                                                                                                                                                 | 
                                                             			}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    65
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    65
                                                                                                                                                                                                 | 
                                                             		}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    66
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    66
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -69,31 +69,31 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    69
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    69
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    70
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    70
                                                                                                                                                                                                 | 
                                                             	// Download product downloadable  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    71
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    71
                                                                                                                                                                                                 | 
                                                             	public function wps_download_file() { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    72
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -		$download = !empty( $_GET['download'] ) ? sanitize_text_field( $_GET['download'] ) : '';  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    73
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -		$oid = !empty( $_GET['oid'] ) ? (int) $_GET['oid'] : 0;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    72
                                                                                                                                                                                                 | 
                                                            +		$download = !empty($_GET['download']) ? sanitize_text_field($_GET['download']) : '';  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    73
                                                                                                                                                                                                 | 
                                                            +		$oid = !empty($_GET['oid']) ? (int)$_GET['oid'] : 0;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    74
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    74
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    75
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -		if ( !empty( $download ) && !empty( $oid ) ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    75
                                                                                                                                                                                                 | 
                                                            +		if (!empty($download) && !empty($oid)) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    76
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    76
                                                                                                                                                                                                 | 
                                                             			$variation_id = '';  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    77
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    77
                                                                                                                                                                                                 | 
                                                             			$order = get_post_meta($oid, '_order_postmeta', true);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    78
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -			if(!empty($order) && !empty( $order['customer_id'] )) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    79
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				$download_codes = get_user_meta( /*wps_customer_ctr::get_author_id_by_customer_id(*/ $order['customer_id'] /*)*/, '_order_download_codes_'.$oid, true);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    80
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				if ( !empty($download_codes) && is_array($download_codes) ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    81
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -					foreach ( $download_codes as $downloadable_product_id => $d ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    78
                                                                                                                                                                                                 | 
                                                            +			if (!empty($order) && !empty($order['customer_id'])) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    79
                                                                                                                                                                                                 | 
                                                            +				$download_codes = get_user_meta( /*wps_customer_ctr::get_author_id_by_customer_id(*/ $order['customer_id'] /*)*/, '_order_download_codes_' . $oid, true);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    80
                                                                                                                                                                                                 | 
                                                            +				if (!empty($download_codes) && is_array($download_codes)) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    81
                                                                                                                                                                                                 | 
                                                            +					foreach ($download_codes as $downloadable_product_id => $d) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    82
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    82
                                                                                                                                                                                                 | 
                                                             						$is_encrypted = false;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    83
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -						if ( $d['download_code'] == $download ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    84
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -							wpshop_tools::create_custom_hook ('encrypt_actions_for_downloadable_product', array( 'order_id' => $oid, 'download_product_id' => $downloadable_product_id ) ); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    83
                                                                                                                                                                                                 | 
                                                            +						if ($d['download_code'] == $download) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    84
                                                                                                                                                                                                 | 
                                                            +							wpshop_tools::create_custom_hook('encrypt_actions_for_downloadable_product', array('order_id' => $oid, 'download_product_id' => $downloadable_product_id)); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    85
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    85
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    86
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -							if ( get_post_type( $downloadable_product_id ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    87
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								$parent_def = wpshop_products::get_parent_variation( $downloadable_product_id );  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    88
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								if ( !empty($parent_def) && !empty($parent_def['parent_post']) ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    86
                                                                                                                                                                                                 | 
                                                            +							if (get_post_type($downloadable_product_id) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    87
                                                                                                                                                                                                 | 
                                                            +								$parent_def = wpshop_products::get_parent_variation($downloadable_product_id);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    88
                                                                                                                                                                                                 | 
                                                            +								if (!empty($parent_def) && !empty($parent_def['parent_post'])) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    89
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    89
                                                                                                                                                                                                 | 
                                                             									$parent_post = $parent_def['parent_post'];  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    90
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    90
                                                                                                                                                                                                 | 
                                                             									$variation_id = $downloadable_product_id;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    91
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    91
                                                                                                                                                                                                 | 
                                                             									$downloadable_product_id = $parent_post->ID;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    92
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    92
                                                                                                                                                                                                 | 
                                                             								}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    93
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    93
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    94
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    94
                                                                                                                                                                                                 | 
                                                             							} else { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    95
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								$downloadable_product_id = explode( "__", $downloadable_product_id );  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    96
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								$downloadable_product_id = isset( $downloadable_product_id[1] ) ? $downloadable_product_id[1] : $downloadable_product_id[0];  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    95
                                                                                                                                                                                                 | 
                                                            +								$downloadable_product_id = explode("__", $downloadable_product_id); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    96
                                                                                                                                                                                                 | 
                                                            +								$downloadable_product_id = isset($downloadable_product_id[1]) ? $downloadable_product_id[1] : $downloadable_product_id[0];  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    97
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    97
                                                                                                                                                                                                 | 
                                                             							}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    98
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    98
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    99
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    99
                                                                                                                                                                                                 | 
                                                             							$link = wpshop_attributes::get_attribute_option_output(  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -101,24 +101,24 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    101
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    101
                                                                                                                                                                                                 | 
                                                             								'is_downloadable_', 'file_url', $order  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    102
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    102
                                                                                                                                                                                                 | 
                                                             							);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    103
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    103
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    104
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -							if ( $link !== false ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    104
                                                                                                                                                                                                 | 
                                                            +							if ($link !== false) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    105
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    105
                                                                                                                                                                                                 | 
                                                             								$uploads = wp_upload_dir();  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    106
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    106
                                                                                                                                                                                                 | 
                                                             								$basedir = $uploads['basedir'];  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    107
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    107
                                                                                                                                                                                                 | 
                                                             								$pos = strpos($link, 'uploads');  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    108
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								$link = $basedir.substr($link,$pos+7);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    108
                                                                                                                                                                                                 | 
                                                            +								$link = $basedir . substr($link, $pos + 7);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    109
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    109
                                                                                                                                                                                                 | 
                                                             								/** If plugin is encrypted **/  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    110
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								$encrypted_plugin_path = get_post_meta( $oid, '_download_file_path_'.$oid.'_'.( ( !empty( $variation_id ) && get_post_type( $variation_id ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) ? $variation_id : $downloadable_product_id ), true);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    111
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								if ( !empty($encrypted_plugin_path) ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    112
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -									$link = WPSHOP_UPLOAD_DIR.$encrypted_plugin_path;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    110
                                                                                                                                                                                                 | 
                                                            +								$encrypted_plugin_path = get_post_meta($oid, '_download_file_path_' . $oid . '_' . ((!empty($variation_id) && get_post_type($variation_id) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) ? $variation_id : $downloadable_product_id), true);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    111
                                                                                                                                                                                                 | 
                                                            +								if (!empty($encrypted_plugin_path)) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    112
                                                                                                                                                                                                 | 
                                                            +									$link = WPSHOP_UPLOAD_DIR . $encrypted_plugin_path;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    113
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    113
                                                                                                                                                                                                 | 
                                                             									$is_encrypted = true;  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    114
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    114
                                                                                                                                                                                                 | 
                                                             								}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    115
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    115
                                                                                                                                                                                                 | 
                                                               | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    116
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								$overload_force_download = apply_filters( 'wps_download_file_overload_force_download', false );  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    117
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -								if ( !$overload_force_download ) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    116
                                                                                                                                                                                                 | 
                                                            +								$overload_force_download = apply_filters('wps_download_file_overload_force_download', false); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    117
                                                                                                                                                                                                 | 
                                                            +								if (!$overload_force_download) { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    118
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    118
                                                                                                                                                                                                 | 
                                                             									wpshop_tools::forceDownload($link, $is_encrypted);  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    119
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    119
                                                                                                                                                                                                 | 
                                                             								}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    120
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    120
                                                                                                                                                                                                 | 
                                                             								else { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    121
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -									wpshop_tools::wpshop_safe_redirect( str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $link ) );  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    121
                                                                                                                                                                                                 | 
                                                            +									wpshop_tools::wpshop_safe_redirect(str_replace(WP_CONTENT_DIR, WP_CONTENT_URL, $link));  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    122
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    122
                                                                                                                                                                                                 | 
                                                             								}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    123
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    123
                                                                                                                                                                                                 | 
                                                             							}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    124
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    124
                                                                                                                                                                                                 | 
                                                             						}  | 
                                                        
                                                                                                                                                        
                                                         | 
                                                        @@ -126,7 +126,7 @@  discard block  | 
                                                    
                                                    
                                                         | 
                                                         | 
                                                         block discarded – undo  | 
                                                    
                                                                                                                                                                                                                    
                                                            | 
                                                                                                                                    126
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    126
                                                                                                                                                                                                 | 
                                                             				}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    127
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    127
                                                                                                                                                                                                 | 
                                                             			}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    128
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    128
                                                                                                                                                                                                 | 
                                                             			else { | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    129
                                                                                                                                                                                                 | 
                                                            
                                                                                                                             | 
                                                            -				wp_redirect( get_permalink( wpshop_tools::get_page_id( get_option('wpshop_myaccount_page_id') ) ) ); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                             | 
                                                            
                                                                                                                                    129
                                                                                                                                                                                                 | 
                                                            +				wp_redirect(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')))); | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    130
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    130
                                                                                                                                                                                                 | 
                                                             			}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    131
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    131
                                                                                                                                                                                                 | 
                                                             		}  | 
                                                        
                                                                                                            
                                                            | 
                                                                                                                                    132
                                                                                                                                                                                                 | 
                                                            
                                                                                                                                    132
                                                                                                                                                                                                 | 
                                                             		echo __('Impossible to download the file you requested', 'wpshop'); |