ID ) ) { $data = isset( $_POST[$field_id] ) && !empty( $_POST[$field_id] ) ? $_POST[$field_id] : ''; $data_org = get_post_meta( $post->ID, $field_id ); if( $field_id === 'change-canonical' ) { if( $data === wp_get_canonical_url() || $data === get_post_permalink() ) $data = ''; } if( !empty( $data ) && empty( $data_org ) ) { /* 保存 */ add_post_meta( $post->ID, $field_id, $data, true ); } elseif( !empty( $data ) && $data !== $data_org ) { /* 更新 */ update_post_meta( $post->ID, $field_id, $data ); } else { /* 削除 */ delete_post_meta( $post->ID, $field_id ); } } }); } endif; /*--------------------------------------------------------------------------- * addhead *---------------------------------------------------------------------------*/ /* 投稿画面に表示するフォーム */ if( function_exists( 'og_image_meta_box' ) === false ): function addhead_meta_box() { global $post; $addhead = get_post_meta( $post->ID, 'addhead', true ); ?>

ID, 'change-description', true ); ?>

ID, 'add-keywords', true ); ?>

ID, 'change-canonical', true ); if( empty( $change_url ) ) { if( get_post_status( $post->ID ) === 'publish') { $change_url = wp_get_canonical_url(); } else { $change_url = get_post_permalink(); } } ?>

ID, 'amp-custom', true ); ?>

ID, 'og_img', true ); $post_thumbnail = has_post_thumbnail(); $cont = $post->post_content; $preg = '//i'; if( !empty( $og_image ) ) { $image = get_post_meta( $post->ID, 'og_img', true ); } elseif( !empty( $post_thumbnail ) ) { $img_id = get_post_thumbnail_id(); $img_arr = wp_get_attachment_image_src( $img_id, 'full'); $image = $img_arr[0]; } elseif( preg_match( $preg, $cont, $img_url ) ) { $image = $img_url[2]; } ?>