コード例 #1
0
                        if (get_post_type($downloadable_product_id) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
                            $parent_def = wpshop_products::get_parent_variation($downloadable_product_id);
                            if (!empty($parent_def) && !empty($parent_def['parent_post'])) {
                                $parent_post = $parent_def['parent_post'];
                                $variation_id = $downloadable_product_id;
                                $downloadable_product_id = $parent_post->ID;
                            }
                        }
                        $link = wpshop_attributes::get_attribute_option_output(array('item_id' => $downloadable_product_id, 'item_is_downloadable_' => 'yes'), 'is_downloadable_', 'file_url', $order);
                        if ($link !== false) {
                            $uploads = wp_upload_dir();
                            $basedir = $uploads['basedir'];
                            $pos = strpos($link, 'uploads');
                            $link = $basedir . substr($link, $pos + 7);
                            /** If plugin is encrypted **/
                            $encrypted_plugin_path = get_post_meta($_GET['oid'], '_download_file_path_' . $_GET['oid'] . '_' . (!empty($variation_id) && get_post_type($variation_id) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ? $variation_id : $downloadable_product_id), true);
                            if (!empty($encrypted_plugin_path)) {
                                $link = WPSHOP_UPLOAD_DIR . $encrypted_plugin_path;
                                $is_encrypted = true;
                            }
                            wpshop_tools::forceDownload($link, $is_encrypted);
                        }
                    }
                }
            }
        }
    } else {
        wp_redirect(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))));
    }
}
echo __('Impossible to download the file you requested', 'wpshop');