تابع wc_update_210_file_paths بروزرسانی مسیر فایل های ووکامرس به نسخه 2.1.0

تابع ووکامرسی wc_update_210_file_paths – بروزرسانی مسیر فایل های ووکامرس به نسخه 2.1.0
Syntax – سینتکس
wc_update_210_file_paths();
Usage – نحوه استفاده
if ( !function_exists( 'wc_update_210_file_paths' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-update-functions.php';
}
// NOTICE! Understand what this does before running.
$result = wc_update_210_file_paths();
Defined – محل تعریف
/includes/wc-update-functions.php
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 meta_value, meta_id 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 ) );
}
}
}
}
}
versions – نسخه ها
از نسخه : 3.0.2
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر