当前位置: 首页>>代码示例>>PHP>>正文


PHP wc_get_filename_from_url函数代码示例

本文整理汇总了PHP中wc_get_filename_from_url函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_get_filename_from_url函数的具体用法?PHP wc_get_filename_from_url怎么用?PHP wc_get_filename_from_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wc_get_filename_from_url函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_wc_get_filename_from_url

 /**
  * Test wc_get_filename_from_url().
  *
  * @since 2.2
  */
 public function test_wc_get_filename_from_url()
 {
     $this->assertEquals('woocommerce.pdf', wc_get_filename_from_url('https://woocommerce.com/woocommerce.pdf'));
     $this->assertEmpty(wc_get_filename_from_url('ftp://wc'));
     $this->assertEmpty(wc_get_filename_from_url('http://www.skyverge.com'));
     $this->assertEquals('woocommerce', wc_get_filename_from_url('https://woocommerce.com/woocommerce'));
 }
开发者ID:jimlove7273,项目名称:woocommerce,代码行数:12,代码来源:functions.php

示例2: get_files

 /**
  * Gets an array of downloadable files for this product.
  *
  * @since 2.1.0
  *
  * @return array
  */
 public function get_files()
 {
     $downloadable_files = array_filter(isset($this->downloadable_files) ? (array) maybe_unserialize($this->downloadable_files) : array());
     if ($downloadable_files) {
         foreach ($downloadable_files as $key => $file) {
             if (!is_array($file)) {
                 $downloadable_files[$key] = array('file' => $file, 'name' => '');
             }
             // Set default name
             if (empty($file['name'])) {
                 $downloadable_files[$key]['name'] = wc_get_filename_from_url($file['file']);
             }
             // Filter URL
             $downloadable_files[$key]['file'] = apply_filters('woocommerce_file_download_path', $downloadable_files[$key]['file'], $this, $key);
         }
     }
     return apply_filters('woocommerce_product_files', $downloadable_files, $this);
 }
开发者ID:nathanielks,项目名称:woocommerce,代码行数:25,代码来源:abstract-wc-product.php

示例3: do_export

 /**
  * Product Exporter Tool
  */
 public static function do_export($post_type = 'product')
 {
     global $wpdb;
     $export_limit = !empty($_POST['limit']) ? intval($_POST['limit']) : 999999999;
     $export_count = 0;
     $limit = 100;
     $current_offset = !empty($_POST['offset']) ? intval($_POST['offset']) : 0;
     $csv_columns = $post_type == 'product' ? include 'data/data-post-columns.php' : (include 'data/data-variation-columns.php');
     $product_taxonomies = get_object_taxonomies($post_type, 'name');
     $export_columns = !empty($_POST['columns']) ? $_POST['columns'] : '';
     $include_hidden_meta = !empty($_POST['include_hidden_meta']) ? true : false;
     $product_limit = !empty($_POST['product_limit']) ? sanitize_text_field($_POST['product_limit']) : '';
     $exclude_hidden_meta_columns = (include 'data/data-hidden-meta-columns.php');
     if ($limit > $export_limit) {
         $limit = $export_limit;
     }
     $wpdb->hide_errors();
     @set_time_limit(0);
     // Disable GZIP
     if (function_exists('apache_setenv')) {
         @apache_setenv('no-gzip', 1);
     }
     @ini_set('zlib.output_compression', 'Off');
     @ini_set('output_buffering', 'Off');
     @ini_set('output_handler', '');
     $filename_suffix = 'woocommerce-product-export';
     if ('product_variation' === $post_type) {
         $filename_suffix = 'woocommerce-product-variations-export';
     }
     $filename = sprintf('%s-%s.csv', $filename_suffix, date_i18n('Y_m_d_H_i_s', current_time('timestamp')));
     header('Content-Type: text/csv; charset=UTF-8');
     header('Content-Disposition: attachment; filename=' . $filename);
     header('Pragma: no-cache');
     header('Expires: 0');
     $fp = fopen('php://output', 'w');
     // Headers
     $all_meta_keys = self::get_all_metakeys($post_type);
     $found_attributes = self::get_all_product_attributes($post_type);
     // Loop products and load meta data
     $found_product_meta = array();
     // Some of the values may not be usable (e.g. arrays of arrays) but the worse
     // that can happen is we get an empty column.
     foreach ($all_meta_keys as $meta) {
         if (!$meta) {
             continue;
         }
         if (!$include_hidden_meta && !in_array($meta, array_keys($csv_columns)) && substr($meta, 0, 1) == '_') {
             continue;
         }
         if ($include_hidden_meta && (in_array($meta, $exclude_hidden_meta_columns) || in_array($meta, array_keys($csv_columns)))) {
             continue;
         }
         $found_product_meta[] = $meta;
     }
     $found_product_meta = array_diff($found_product_meta, array_keys($csv_columns));
     // Variable to hold the CSV data we're exporting
     $row = array();
     if ($post_type == 'product_variation') {
         $row[] = 'Parent';
         $row[] = 'parent_sku';
     }
     // Export header rows
     foreach ($csv_columns as $column => $value) {
         if (!$export_columns || in_array($column, $export_columns)) {
             $row[] = esc_attr($value);
         }
     }
     // Handle special fields like taxonomies
     if (!$export_columns || in_array('images', $export_columns)) {
         $row[] = 'images';
     }
     if (!$export_columns || in_array('file_paths', $export_columns)) {
         if (function_exists('wc_get_filename_from_url')) {
             $row[] = 'downloadable_files';
         } else {
             $row[] = 'file_paths';
         }
     }
     if (!$export_columns || in_array('taxonomies', $export_columns)) {
         foreach ($product_taxonomies as $taxonomy) {
             if (strstr($taxonomy->name, 'pa_')) {
                 continue;
             }
             // Skip attributes
             $row[] = 'tax:' . self::format_data($taxonomy->name);
         }
     }
     if (!$export_columns || in_array('meta', $export_columns)) {
         foreach ($found_product_meta as $product_meta) {
             $row[] = 'meta:' . self::format_data($product_meta);
         }
     }
     if (!$export_columns || in_array('attributes', $export_columns)) {
         foreach ($found_attributes as $attribute) {
             $row[] = 'attribute:' . self::format_data($attribute);
             $row[] = 'attribute_data:' . self::format_data($attribute);
             $row[] = 'attribute_default:' . self::format_data($attribute);
//.........这里部分代码省略.........
开发者ID:arobbins,项目名称:spellestate,代码行数:101,代码来源:class-wc-pcsvis-exporter.php

示例4: woocommerce_get_filename_from_url

/**
 * @deprecated
 */
function woocommerce_get_filename_from_url($file_url)
{
    return wc_get_filename_from_url($file_url);
}
开发者ID:nayemDevs,项目名称:woocommerce,代码行数:7,代码来源:wc-deprecated-functions.php

示例5: read_downloads

 /**
  * Read downloads from post meta.
  *
  * @param WC_Product
  * @since 2.7.0
  */
 protected function read_downloads(&$product)
 {
     $meta_values = array_filter((array) maybe_unserialize(get_post_meta($product->get_id(), '_downloadable_files', true)));
     if ($meta_values) {
         $downloads = array();
         foreach ($meta_values as $key => $value) {
             $download = new WC_Product_Download();
             $download->set_id($key);
             $download->set_name($value['name'] ? $value['name'] : wc_get_filename_from_url($value['file']));
             $download->set_file(apply_filters('woocommerce_file_download_path', $value['file'], $product, $key));
             $downloads[] = $download;
         }
         $product->set_downloads($downloads);
     }
 }
开发者ID:shivapoudel,项目名称:woocommerce,代码行数:21,代码来源:class-wc-product-data-store-cpt.php

示例6: save_downloadable_files

 /**
  * Save downloadable files.
  *
  * @param WC_Product $product    Product instance.
  * @param array      $downloads  Downloads data.
  * @param int        $deprecated Deprecated since 2.7.
  * @return WC_Product
  */
 private function save_downloadable_files($product, $downloads, $deprecated = 0)
 {
     if ($deprecated) {
         wc_deprecated_argument('variation_id', '2.7', 'save_downloadable_files() not requires a variation_id anymore.');
     }
     $files = array();
     foreach ($downloads as $key => $file) {
         if (empty($file['file'])) {
             continue;
         }
         $download = new WC_Product_Download();
         $download->set_id($key);
         $download->set_name($file['name'] ? $file['name'] : wc_get_filename_from_url($file['file']));
         $download->set_file(apply_filters('woocommerce_file_download_path', $file['file'], $product, $key));
         $files[] = $download;
     }
     $product->set_downloads($files);
     return $product;
 }
开发者ID:shivapoudel,项目名称:woocommerce,代码行数:27,代码来源:class-wc-rest-products-controller.php

示例7: esc_attr

echo esc_attr($download->get_id());
?>
" rel="<?php 
echo esc_attr($download->get_product_id()) . ',' . esc_attr($download->get_download_id());
?>
" class="revoke_access button"><?php 
_e('Revoke access', 'woocommerce');
?>
</button>
		<div class="handlediv" aria-label="<?php 
esc_attr_e('Click to toggle', 'woocommerce');
?>
"></div>
		<strong>
			<?php 
echo '#' . esc_html($product->get_id()) . ' &mdash; ' . apply_filters('woocommerce_admin_download_permissions_title', $product->get_name(), $download->get_product_id(), $download->get_order_id(), $download->get_order_key(), $download->get_download_id()) . ' &mdash; ' . esc_html($file_count) . ': ' . wc_get_filename_from_url($product->get_file_download_path($download->get_download_id())) . ' &mdash; ' . sprintf(_n('Downloaded %s time', 'Downloaded %s times', $download->get_download_count(), 'woocommerce'), $download->get_download_count());
?>
		</strong>
	</h3>
	<table cellpadding="0" cellspacing="0" class="wc-metabox-content">
		<tbody>
			<tr>
				<td>
					<label><?php 
_e('Downloads remaining', 'woocommerce');
?>
</label>
					<input type="hidden" name="permission_id[<?php 
echo $loop;
?>
]" value="<?php 
开发者ID:woocommerce,项目名称:woocommerce,代码行数:31,代码来源:html-order-download-permission.php

示例8: wc_update_210_file_paths

function wc_update_210_file_paths()
{
    global $wpdb;
    // Upgrade file paths to support multiple file paths + names etc
    $existing_file_paths = $wpdb->get_results("SELECT * FROM {$wpdb->postmeta} WHERE meta_key = '_file_paths' AND meta_value != '';");
    if ($existing_file_paths) {
        foreach ($existing_file_paths as $existing_file_path) {
            $needs_update = false;
            $new_value = array();
            $value = maybe_unserialize(trim($existing_file_path->meta_value));
            if ($value) {
                foreach ($value as $key => $file) {
                    if (!is_array($file)) {
                        $needs_update = true;
                        $new_value[$key] = array('file' => $file, 'name' => wc_get_filename_from_url($file));
                    } else {
                        $new_value[$key] = $file;
                    }
                }
                if ($needs_update) {
                    $new_value = serialize($new_value);
                    $wpdb->query($wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_key = %s, meta_value = %s WHERE meta_id = %d", '_downloadable_files', $new_value, $existing_file_path->meta_id));
                }
            }
        }
    }
}
开发者ID:Korkey128k,项目名称:woocommerce,代码行数:27,代码来源:wc-update-functions.php

示例9: wp_trash_post

global $wpdb, $woocommerce;
// Pages no longer used
wp_trash_post(get_option('woocommerce_pay_page_id'));
wp_trash_post(get_option('woocommerce_thanks_page_id'));
wp_trash_post(get_option('woocommerce_view_order_page_id'));
wp_trash_post(get_option('woocommerce_change_password_page_id'));
wp_trash_post(get_option('woocommerce_edit_address_page_id'));
wp_trash_post(get_option('woocommerce_lost_password_page_id'));
// Upgrade file paths to support multiple file paths + names etc
$existing_file_paths = $wpdb->get_results("SELECT * FROM {$wpdb->postmeta} WHERE meta_key = '_file_paths' AND meta_value != '';");
if ($existing_file_paths) {
    foreach ($existing_file_paths as $existing_file_path) {
        $needs_update = false;
        $new_value = array();
        $value = maybe_unserialize(trim($existing_file_path->meta_value));
        if ($value) {
            foreach ($value as $key => $file) {
                if (!is_array($file)) {
                    $needs_update = true;
                    $new_value[$key] = array('file' => $file, 'name' => wc_get_filename_from_url($file));
                } else {
                    $new_value[$key] = $file;
                }
            }
            if ($needs_update) {
                $new_value = serialize($new_value);
                $wpdb->query($wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_key = %s, meta_value = %s WHERE meta_id = %d", '_downloadable_files', $new_value, $existing_file_path->meta_id));
            }
        }
    }
}
开发者ID:slavic18,项目名称:cats,代码行数:31,代码来源:woocommerce-update-2.1.php

示例10: absint

<div class="wc-metabox closed">
	<h3 class="fixed">
		<button type="button" rel="<?php 
echo absint($download->product_id) . ',' . esc_attr($download->download_id);
?>
" class="revoke_access button"><?php 
_e('Revoke Access', 'woocommerce');
?>
</button>
		<div class="handlediv" title="<?php 
esc_attr_e('Click to toggle', 'woocommerce');
?>
"></div>
		<strong>
			<?php 
echo '#' . absint($product->id) . ' &mdash; ' . apply_filters('woocommerce_admin_download_permissions_title', $product->get_title(), $download->product_id, $download->order_id, $download->order_key, $download->download_id) . ' &mdash; ' . sprintf(__('%s: %s', 'woocommerce'), $file_count, wc_get_filename_from_url($product->get_file_download_path($download->download_id))) . ' &mdash; ' . sprintf(_n('Downloaded %s time', 'Downloaded %s times', absint($download->download_count), 'woocommerce'), absint($download->download_count));
?>
		</strong>
	</h3>
	<table cellpadding="0" cellspacing="0" class="wc-metabox-content">
		<tbody>
			<tr>
				<td>
					<label><?php 
_e('Downloads Remaining', 'woocommerce');
?>
:</label>
					<input type="hidden" name="product_id[<?php 
echo $loop;
?>
]" value="<?php 
开发者ID:slavic18,项目名称:cats,代码行数:31,代码来源:html-order-download-permission.php

示例11: parse_product


//.........这里部分代码省略.........
     }
     // Format post status
     if (!empty($product['post_status'])) {
         $product['post_status'] = strtolower($product['post_status']);
         if ('product' === $this->post_type) {
             if (!in_array($product['post_status'], array('publish', 'private', 'draft', 'pending', 'future', 'inherit', 'trash'))) {
                 $product['post_status'] = 'publish';
             }
         } else {
             if (!in_array($product['post_status'], array('private', 'publish'))) {
                 $product['post_status'] = 'publish';
             }
         }
     }
     // Put set core product postmeta into product array
     foreach ($postmeta as $key => $value) {
         $product['postmeta'][] = array('key' => '_' . esc_attr($key), 'value' => $value);
     }
     /**
      * Handle other columns
      */
     foreach ($item as $key => $value) {
         if ($this->post_type == 'product' && !$merge_empty_cells && $value == "") {
             continue;
         }
         /**
          * File path handling
          */
         if ($key == 'file_paths' || $key == 'downloadable_files') {
             $file_paths = explode('|', $value);
             $_file_paths = array();
             foreach ($file_paths as $file_path) {
                 // 2.1
                 if (function_exists('wc_get_filename_from_url')) {
                     $file_path = array_map('trim', explode('::', $file_path));
                     if (sizeof($file_path) === 2) {
                         $file_name = $file_path[0];
                         $file_path = $file_path[1];
                     } else {
                         $file_name = wc_get_filename_from_url($file_path[0]);
                         $file_path = $file_path[0];
                     }
                     $_file_paths[md5($file_path)] = array('name' => $file_name, 'file' => $file_path);
                 } else {
                     $file_path = trim($file_path);
                     $_file_paths[md5($file_path)] = $file_path;
                 }
             }
             $value = $_file_paths;
             $product['postmeta'][] = array('key' => '_' . esc_attr($key), 'value' => $value);
         } elseif (strstr($key, 'meta:attribute_pa_')) {
             // Get meta key name
             $meta_key = isset($WC_CSV_Product_Import->raw_headers[$key]) ? $WC_CSV_Product_Import->raw_headers[$key] : $key;
             $meta_key = trim(str_replace('meta:', '', $meta_key));
             // Convert to slug
             $value = sanitize_title($value);
             // Add to postmeta array
             $product['postmeta'][] = array('key' => esc_attr($meta_key), 'value' => $value);
         } elseif (strstr($key, 'meta:')) {
             // Get meta key name
             $meta_key = isset($WC_CSV_Product_Import->raw_headers[$key]) ? $WC_CSV_Product_Import->raw_headers[$key] : $key;
             $meta_key = trim(str_replace('meta:', '', $meta_key));
             // Decode JSON
             $json = json_decode($value, true);
             if (is_array($json) || is_object($json)) {
                 $value = (array) $json;
开发者ID:arobbins,项目名称:spellestate,代码行数:67,代码来源:class-wc-csv-parser.php


注:本文中的wc_get_filename_from_url函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。