/** * 添付データのIDを返す * 過去バージョンでの不具合でアップロードファイルを示すメタデータが空になっていることがあるのでその場合の代替処理 * * @param WP_Post $post * @param int $meta_key * @return int */ public static function get_multimedia_id__fallback($post, $meta_key) { $Contact_Data_Setting = new MW_WP_Form_Contact_Data_Setting($post->ID); $key = $Contact_Data_Setting->get_key_in_upload_file_keys($post, $meta_key); $attachments = get_posts(array('post_type' => 'attachment', 'post_parent' => $post->ID, 'posts_per_page' => 1, 'offset' => $key)); if (isset($attachments[0])) { return $attachments[0]->ID; } }