تابع wc_update_240_api_keys بروزرسانی کلید های api ووکامرس به نسخه 2.4.0
تابع ووکامرسی wc_update_240_api_keys – بروزرسانی کلید های api ووکامرس به نسخه 2.4.0
Syntax – سینتکس
wc_update_240_api_keys();
Usage – نحوه استفاده
if ( !function_exists( 'wc_update_240_api_keys' ) ) { require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-update-functions.php'; } // NOTICE! Understand what this does before running. $result = wc_update_240_api_keys();
Defined – محل تعریف
/includes/wc-update-functions.php
function wc_update_240_api_keys() { global $wpdb; /** * Update the old user API keys to the new Apps keys. */ $api_users = $wpdb->get_results( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'woocommerce_api_consumer_key'" ); $apps_keys = array(); // Get user data foreach ( $api_users as $_user ) { $user = get_userdata( $_user->user_id ); $apps_keys[] = array( 'user_id' => $user->ID, 'permissions' => $user->woocommerce_api_key_permissions, 'consumer_key' => wc_api_hash( $user->woocommerce_api_consumer_key ), 'consumer_secret' => $user->woocommerce_api_consumer_secret, 'truncated_key' => substr( $user->woocommerce_api_consumer_secret, -7 ), ); } if ( ! empty( $apps_keys ) ) { // Create new apps foreach ( $apps_keys as $app ) { $wpdb->insert( $wpdb->prefix . 'woocommerce_api_keys', $app, array( '%d', '%s', '%s', '%s', '%s', ) ); } // Delete old user keys from usermeta foreach ( $api_users as $_user ) { $user_id = intval( $_user->user_id ); delete_user_meta( $user_id, 'woocommerce_api_consumer_key' ); delete_user_meta( $user_id, 'woocommerce_api_consumer_secret' ); delete_user_meta( $user_id, 'woocommerce_api_key_permissions' ); } } }
versions – نسخه ها
از نسخه : 3.0.2
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر