function ac_quote_render($image_id, $excerpt, $author = '', $author_url = '', $img_border_shape = 'circle-border', $image_caption = '', $img_align = 'right', $bg_color = false) { // Pass some values to the template $template_params = compact('image_id', 'excerpt', 'author', 'author_url', 'img_border_shape', 'image_caption', 'img_align', 'bg_color'); // We need to return the content so buffer ob_start(); ac_load_component_content('ac_block_quote', $template_params); $content = ob_get_contents(); ob_end_clean(); return $content; }
function widget($args, $instance) { global $post; extract($args, EXTR_SKIP); echo $before_widget; $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); if (!empty($title)) { echo $before_title . $title . $after_title; } // Get the latest Portfolio $args = array('post_type' => 'ac_portfolio', 'posts_per_page' => 1, 'orderby' => 'date'); $posts = get_posts($args); if (!empty($posts)) { foreach ($posts as $post) { setup_postdata($post); // Display as a Grid Col // Pass some values to the template $show_title = true; $show_excerpt = true; $column_count = 3; $post_category = 'portfolio-category'; $cols_class = ' col-log-3 '; $cols = 3; $excerpt_length = ''; $post_type = 'ac_portfolio'; $show_read_more = true; $image_aspect_ratio = AC_IMAGE_RATIO_SQUARE; $template_params = compact('show_title', 'show_excerpt', 'column_count', 'post_category', 'cols_class', 'cols', 'excerpt_length', 'post_type', 'show_read_more', 'image_aspect_ratio'); // Load the template ac_load_component_content('ac_grid', $template_params); ?> <?php } wp_reset_postdata(); } echo $after_widget; }
protected function get_showcase($atts) { global $post, $product; // Merge in the options $defaults = array('posts_per_page' => 4, 'meta_key' => '_thumbnail_id'); $args = wp_parse_args($atts, $defaults); // Showcase is always 4 $args['posts_per_page'] = 4; // Prepare args ac_prepare_args_for_get_posts($args); // Extract the args extract($args); // Clean up the bool values. Might be "true" $show_title = filter_var($show_title, FILTER_VALIDATE_BOOLEAN); // Calc item width, avoid div by zero if ($column_count == 0) { $item_width = '100%'; } else { $item_width = floor(100 / $posts_per_page); $item_width = $item_width . "%;"; } // Pass some values to the template $template_params = compact('item_width', 'show_title', 'column_count'); // Get the posts $posts = get_posts($args); // Post type specifics if ($post_type == 'product') { $items = '<div class="woocommerce ac-showcase">'; $items = '<ul class="products">'; } else { $items = '<div class="ac-showcase">'; } // Render the items foreach ($posts as $post) { setup_postdata($post); // We need to return the content so buffer ob_start(); ac_load_component_content('ac_showcase', $template_params); $items .= ob_get_contents(); ob_end_clean(); } wp_reset_postdata(); if ($post_type == 'product') { $items .= '</ul>'; } $items .= '</div>'; return $items; }
function ac_posts_tile($args, $posts = null) { // Define the defaults $defaults = array('post_type' => 'post', 'posts_per_page' => 12, 'column_count' => 4, 'cat' => '', 'ac_order' => 'order_date_desc', 'show_title' => true, 'show_excerpt' => true, 'excerpt_length' => '', 'meta_key' => '_thumbnail_id', 'link_to_lightbox' => false, 'show_cat_filter' => false, 'post_category' => '', 'layout' => 'posts'); // Merge in the options $args = wp_parse_args($args, $defaults); // Prepare args ac_prepare_args_for_get_posts($args); // Params to variables extract($args); // Generate our posts if not passed in if ($posts == null) { // Get our posts $posts = get_posts($args); } // Calculate the span of each column for desktop if ($column_count != 0) { $cols = 12 / $column_count; } else { $cols = 12; } // Lets set the columns. Ensure the small screens don't have more columns than the larger screens $cols_class = ' col-lg-' . $cols; $cols_class .= ' col-md-' . max($cols, 3); $cols_class .= ' col-sm-' . max($cols, 4); $cols_class .= ' col-xs-' . max($cols, 12); // Grid classes $grid_css = " ac-{$layout} "; // Terms $show_terms = true; // Clean up the bool values. Might be "true" $show_title = filter_var($show_title, FILTER_VALIDATE_BOOLEAN); $show_excerpt = filter_var($show_excerpt, FILTER_VALIDATE_BOOLEAN); $show_cat_filter = filter_var($show_cat_filter, FILTER_VALIDATE_BOOLEAN); // Render the output ob_start(); // Get the terms for these posts // Get all od the term ids for these posts $term_ids = ac_get_terms_for_posts($posts, $post_category); if ($post_category && $show_cat_filter) { echo ac_grids_get_category_filter($post_category, $term_ids); } ?> <?php // NOTE; Bootstrap row not required as tile cols don't have padding ?> <div class='ac-tile-posts ac-filter-target <?php echo $grid_css; ?> ' data-cols='<?php echo $column_count; ?> '> <?php global $post; // Pass some values to the template $template_params = compact('show_title', 'show_excerpt', 'post_category', 'cols_class', 'cols', 'column_count', 'show_terms', 'layout'); foreach ($posts as $post) { setup_postdata($post); // Load the template ac_load_component_content('ac_tile', $template_params); } wp_reset_postdata(); ?> </div> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }