デジタルアーカイブ公開システム(8)
メタデータを管理する「Advanced Custom Fields」がバージョンアップしました(V5へ)。新しいバージョンは前バージョンと互換性がないので、公開システムの修正が必要となった。
特にグループデータ関係に問題が出たので、次のように修正した。
// acf グループ データ取得 v5用
function da_getlabel( ) {
global $da_acf_g;
$options = array();
$target_label = array();
$field_groups = acf_get_field_groups();
foreach ( $field_groups as $group ) {
// DO NOT USE here: $fields = acf_get_fields($group['key']);
// because it causes repeater field bugs and returns "trashed" fields
if( $group['title'] == $da_acf_g ) {
$fields = get_posts(array(
'posts_per_page' => -1,
'post_type' => 'acf-field',
));
foreach ( $fields as $field ) {
$target_label[]=array('name' => $field->post_excerpt,'label' => $field->post_title);
}
break;
}
}
return $target_label;
}
/*
acf グループのメタデータ取得 v5用
*/
if ( ! function_exists( 'da_getacffield' ) ):
function da_getacffield( $acfgroup, $name ) {
$target_field = array();
$meta = array();
$field_groups = acf_get_field_groups();
foreach ( $field_groups as $group ) {
// DO NOT USE here: $fields = acf_get_fields($group['key']);
// because it causes repeater field bugs and returns "trashed" fields
if( $group['title'] == $acfgroup ) {
$fields = get_posts(array(
'posts_per_page' => -1,
'post_type' => 'acf-field',
));
foreach( $fields as $f ) {
$meta = unserialize($f->post_content);
$meta['name']=$f->post_excerpt;
$meta['label']=$f->post_title;
if( $meta['name'] == $name ) {
$target_field = $meta;
break;
}
}
}
}
return $target_field;
}
endif;
また、lightbox機能を「Luminous」を使って実現した。

そろそろプラグインの配布をすることにした。

