內容簡介
當從其他系統(例如 Drupal)遷移時,WordPress 可能需要解序列化當前的數據,然後存儲在其自己的 WordPress 專用表格/列中。此外掛能夠查找此類數據,並根據外掛設置進行解序列化和存儲。
此外掛一次只處理一個(可配置的)導入字段,因此所有導入的序列化數據需要存儲在單個字段中。該字段中的每個密鑰均可映射到任何列,並存儲在如下所示的wp_postmeta 或 wp_posts 中:
`
if ( $maps[$key][‘wp_table’] === ‘wp_postmeta’ && $value != ” && $value != NULL ) {
add_post_meta( $post_id, $maps[$key][‘wp_column’], $value, $maps[$key][‘unique’] );
} else if ( $maps[$key][‘wp_table’] === ‘wp_posts’ && $value != ” && $value != NULL ) {
$post = array(
‘ID’ => $post_id,
$maps[$key][‘wp_column’] => $value
);
wp_update_post( $post );
}
`
使用 wp_schedule_event 方法解序列化數據並將其放入適當的字段中,可以在任何可配置的時間間隔內運行(您選擇一個數字,然後選擇時間單位)。
外掛標籤
開發者團隊
原文外掛簡介
When migrating from another system (i.e. Drupal), WordPress can require data that is currently serialized to be unserialized and stored in its own WordPress-specific tables/columns. This plugin can look for such data, and deserialize and store it, based on the plugin settings.
This plugin handles one (configurable) imported field at a time, so all imported, serialized data needs to be stored in that single field. Each key in that field can be mapped to any column, and stored in either wp_postmeta or wp_posts, as shown below:
`
if ( $maps[$key][‘wp_table’] === ‘wp_postmeta’ && $value != ” && $value != NULL ) {
add_post_meta( $post_id, $maps[$key][‘wp_column’], $value, $maps[$key][‘unique’] );
} else if ( $maps[$key][‘wp_table’] === ‘wp_posts’ && $value != ” && $value != NULL ) {
$post = array(
‘ID’ => $post_id,
$maps[$key][‘wp_column’] => $value
);
wp_update_post( $post );
}
`
The wp_schedule_event method is used to deserialize the data and place it into its appropriate fields, and it can run at any configurable interval (you pick a number, and then a unit of time).
