function mtm_options_page() { if (false !== mtm_acf_check()) { acf_add_options_page(array('page_title' => 'Theme General Settings', 'menu_title' => 'Theme Settings', 'menu_slug' => 'theme-general-settings', 'capability' => 'edit_posts', 'redirect' => true)); acf_add_options_sub_page(array('page_title' => 'Theme Header Settings', 'menu_title' => 'Header', 'parent_slug' => 'theme-general-settings')); acf_add_options_sub_page(array('page_title' => 'Theme Default Settings', 'menu_title' => 'Defaults', 'parent_slug' => 'theme-general-settings')); acf_add_options_sub_page(array('page_title' => 'Theme Footer Settings', 'menu_title' => 'Footer', 'parent_slug' => 'theme-general-settings')); } }
function the_mtm_post_thumbnail_inline($post_ID = '', $size = 'full', $class = '', $link = true, $attr = '') { $attachments = get_children('post_parent=' . $post_ID . '&post_type=attachment&post_mime_type=image'); if (false !== mtm_acf_check()) { if (has_post_thumbnail()) { // is there a post thumbnail? if ($link) { ?> <a href="<?php the_permalink(); ?> "> <?php } ?> <figure class="post--thumbnail <?php echo $class; ?> "> <?php the_post_thumbnail($size, $attr); ?> </figure> <?php if ($link) { ?> </a> <?php } } elseif ($attachments) { // is there an inline image? $keys = array_reverse(array_keys($attachments)); $image = wp_get_attachment_image($keys[0], $size, true); if ($link) { ?> <a href="<?php the_permalink(); ?> "> <?php } ?> <figure class="post--thumbnail <?php echo $class; ?> "> <?php echo $image; ?> </figure> <?php if ($link) { ?> </a> <?php } } elseif (get_field('mtm_default_featured_image', 'option')) { // make sure field value exists $image = get_field('mtm_default_featured_image', 'option'); $thumb = $image['sizes'][$size]; $alt = $image['alt']; if ($link) { ?> <a href="<?php the_permalink(); ?> "> <?php } ?> <figure class="post--thumbnail default-thumbnail <?php echo $class; ?> "><img src="<?php echo esc_url($thumb); ?> " alt="<?php echo esc_html($alt); ?> " /></figure> <?php if ($link) { ?> </a> <?php } } } }