function reference_cell_content_callback($cell_settings) { ob_start(); ?> <?php // Display a single field ?> <p> <?php the_ddl_field('text_data'); // Get the value of the text field using the 'text_data' key. ?> </p> <?php // Display repeatable fields ?> <?php if (has_ddl_repeater('gallery')) { ?> <ul class="thumbnails"> <?php // It looks very similar to the native WordPress Loop, which you're already familiar with ?> <?php while (has_ddl_repeater('gallery')) { the_ddl_repeater('gallery'); ?> <li> <a href="#" class="thumbnail"> <?php // use the_ddl_sub_field('field-name') to display the field value or get_ddl_sub_field('field-name') to asign it to a variable ?> <img src="<?php the_ddl_sub_field('gallery_item'); ?> " alt="<?php _e('Image:', 'theme-context'); ?> <?php the_ddl_repeater_index(); // the_ddl_repeater_index() displays the loop index ?> "> </a> </li> <?php } ?> </ul> <?php } ?> <?php return ob_get_clean(); }
function slider_cell_content_callback() { $unique_id = uniqid(); $pause = ''; if (get_ddl_field('pause')) { $pause = 'data-pause="hover"'; } else { $pause = 'data-pause="false"'; } ob_start(); ?> <?php if (get_ddl_field('autoplay')) { ?> <script> jQuery(document).ready( function($) { var ddl_slider_id_string = "#slider-<?php echo $unique_id; ?> "; $(ddl_slider_id_string).carousel({ interval : <?php the_ddl_field('interval'); ?> <?php if (!get_ddl_field('pause')) { echo ', pause: "false"'; } ?> }); }); </script> <?php } ?> <style> #slider-<?php echo $unique_id; ?> .carousel-inner > .item { height: <?php the_ddl_field('slider_height'); ?> px; } </style> <div id="slider-<?php echo $unique_id; ?> " class="carousel slide ddl-slider" <?php echo $pause; ?> data-interval="<?php the_ddl_field('interval'); ?> "> <ol class="carousel-indicators"> <?php while (has_ddl_repeater('slider')) { the_ddl_repeater('slider'); ?> <li data-target="#slider-<?php echo $unique_id; ?> " data-slide-to="<?php the_ddl_repeater_index(); ?> " <?php if (get_ddl_repeater_index() == 0) { echo ' class="active"'; } ?> ></li> <?php } ddl_rewind_repeater('slider'); ?> </ol> <div class="carousel-inner"> <?php while (has_ddl_repeater('slider')) { the_ddl_repeater('slider'); ?> <div class="item <?php if (get_ddl_repeater_index() == 0) { echo ' active'; } ?> " <?php // Cover image to slide if (get_ddl_field('image_size') == 'cover') { ?> style="background: url(<?php the_ddl_sub_field('slide_url'); ?> ) no-repeat; background-size:cover;" <?php } ?> > <?php if (get_ddl_field('image_size') == '') { ?> <img src="<?php the_ddl_sub_field('slide_url'); ?> "> <?php } ?> <div class="carousel-caption"> <h4> <?php the_ddl_sub_field('slide_title'); ?> </h4> <p> <?php the_ddl_sub_field('slide_text'); ?> </p> </div> </div> <?php } ?> </div> <a class="left carousel-control" href="#slider-<?php echo $unique_id; ?> " data-slide="prev">‹</a> <a class="right carousel-control" href="#slider-<?php echo $unique_id; ?> " data-slide="next">›</a> </div> <?php return ob_get_clean(); }
function ddl_render_comments_list($comments, $post, $load_page = '') { ob_start(); ?> <div id="comments"> <?php if (post_password_required($post)) { ?> <p class="nopassword"><?php the_ddl_field('password_text'); ?> </p> </div><!-- #comments --> <?php return ob_get_clean(); } ?> <?php if (comments_open()) { $num_comments = get_comments_number(); ?> <?php if ($num_comments > 0) { ?> <h2 id="comments-title"> <?php $one_comment_text = str_replace(array('%TITLE%', '%COUNT%'), array('%2$s', '%1$s'), get_ddl_field('title_one_comment')); $two_comments_text = str_replace(array('%TITLE%', '%COUNT%'), array('%2$s', '%1$s'), get_ddl_field('title_multi_comments')); printf(_n($one_comment_text, $two_comments_text, $num_comments), number_format_i18n($num_comments), '<span>' . $post->post_title . '</span>'); ?> </h2> <?php if (get_comment_pages_count($comments) > 1 && get_option('page_comments')) { ?> <?php add_filter('previous_comments_link_attributes', 'ddl_add_previous_comments_link_data'); add_filter('next_comments_link_attributes', 'ddl_add_next_comments_link_data'); ?> <nav id="comment-nav-above"> <div class="nav-previous js-ddl-previous-link"><?php previous_comments_link(get_ddl_field('ddl_prev_link_text')); ?> </div> <div class="nav-next js-ddl-next-link"><?php next_comments_link(get_ddl_field('ddl_next_link_text')); ?> </div> </nav> <?php } // check for comment navigation ?> <?php $comments_defaults = array(); //Set comments style $comments_defaults['style'] = apply_filters('ddl_comment_cell_style', 'ul'); //Avatar Size if (get_ddl_field('avatar_size') != '') { $comments_defaults['avatar_size'] = get_ddl_field('avatar_size'); } //Reply text if (get_ddl_field('reply_text') != '') { $comments_defaults['reply_text'] = get_ddl_field('reply_text'); } if (get_comment_pages_count($comments) > 1 && get_option('page_comments')) { $comments_defaults['per_page'] = get_option('comments_per_page'); if (empty($load_page)) { if ('newest' == get_option('default_comments_page')) { $comments_defaults['page'] = get_comment_pages_count($comments); } else { $comments_defaults['page'] = 1; } } else { //Current page $comments_defaults['page'] = $load_page; } } $before_comments_list = '<ul class="commentlist">'; $after_comments_list = '</ul>'; if ($comments_defaults['style'] == 'ol') { $before_comments_list = '<ol class="commentlist">'; $after_comments_list = '</ol>'; } if ($comments_defaults['style'] == 'div') { $before_comments_list = '<div class="commentlist">'; $after_comments_list = '</div>'; } echo '<div id="comments-listing">'; echo $before_comments_list; //Generate and print comments listing wp_list_comments($comments_defaults, $comments); echo $after_comments_list; echo '</div>'; ?> <?php } ?> <?php // Generate comment form comment_form(); ?> <?php } else { ?> <p class="nocomments"><?php the_ddl_field('comments_closed_text'); ?> </p> <?php } ?> </div> <?php return ob_get_clean(); }
function video_cell_content_callback() { $video_url = get_ddl_field('video_url'); $filter = '#^(?:https?://)?(?:www\\.)?(?:youtu\\.be/|youtube\\.com(?:/embed/|/v/|/watch\\?v=|/watch\\?.+&v=))([\\w-]{11})(?:.+)?$#x'; preg_match($filter, $video_url, $matches); if (isset($matches[1])) { $video_id = $matches[1]; } else { $video_id = null; } ob_start(); ?> <style> .video-container iframe { width: 100%; } </style> <?php if ($video_id === null) { ?> <div class="video-container"> <?php echo WPDDL_Messages::display_message(WPDDL_Messages::$message_warning, sprintf(__('The URL %s is not a valid YouTube URL.', 'ddl-layouts'), $video_url)); ?> </div> <?php } else { ?> <div class="video-container"> <iframe height="<?php the_ddl_field('video_height'); ?> " src="//www.youtube.com/embed/<?php echo $video_id; ?> " frameborder="0" ></iframe> </div> <?php } ?> <?php return ob_get_clean(); }
function imagebox_cell_content_callback() { ob_start(); $title = get_ddl_field('box_title'); $content = get_ddl_field('box_content'); ?> <?php if (!get_ddl_field('disable_bootstrap_thumbnail')) { ?> <div class="thumbnail"> <?php } ?> <img src="<?php the_ddl_field('box_image'); ?> "> <?php if ($title || $content) { ?> <div class="caption text-center"> <?php if ($title) { ?> <h3> <?php echo $title; ?> </h3> <?php } ?> <?php if ($content) { ?> <p> <?php echo $content; ?> </p> <?php } ?> </div> <?php } ?> <?php if (!get_ddl_field('disable_bootstrap_thumbnail')) { ?> </div> <?php } ?> <?php return ob_get_clean(); }