public static function build_sections_field($sections, $post_id)
{
// Make sure we have sections
if (empty($sections)) {
return '';
}
// Get current sections and determine if the article was previously published
$apple_news_sections = get_post_meta($post_id, 'apple_news_sections', true);
// Iterate over the list of sections.
foreach ($sections as $section) {
?>
<div class="section">
<input id="apple-news-section-<?php
echo esc_attr($section->id);
?>
" name="apple_news_sections[]" type="checkbox" value="<?php
echo esc_attr($section->links->self);
?>
" <?php
checked(self::section_is_checked($apple_news_sections, $section->links->self, $section->isDefault));
?>
>
<label for="apple-news-section-<?php
echo esc_attr($section->id);
?>
"><?php
echo esc_html($section->name);
?>
</label>
</div>
<?php
}
}