/** * */ function testimonials_grid($atts = null, $content = null) { if ($atts == 'generator') { $option = array('name' => __('Testimonials Grid', MYSITE_ADMIN_TEXTDOMAIN), 'value' => 'testimonials_grid', 'options' => array(array('name' => __('Number of Testimonials', MYSITE_ADMIN_TEXTDOMAIN), 'desc' => __('Select the number of testimonials you wish to have displayed on each page.', MYSITE_ADMIN_TEXTDOMAIN), 'id' => 'show', 'options' => array_combine(range(1, 40), array_values(range(1, 40))), 'type' => 'select'), array('name' => __('Number of Columns', MYSITE_ADMIN_TEXTDOMAIN), 'desc' => __('Select the number of columns you would like your testimonials to display in.', MYSITE_ADMIN_TEXTDOMAIN), 'id' => 'column', 'default' => '', 'options' => array('1' => __('One Column', MYSITE_ADMIN_TEXTDOMAIN), '2' => __('Two Column', MYSITE_ADMIN_TEXTDOMAIN), '3' => __('Three Column', MYSITE_ADMIN_TEXTDOMAIN), '4' => __('Four Column', MYSITE_ADMIN_TEXTDOMAIN)), 'type' => 'select'), array('name' => __('Style', MYSITE_ADMIN_TEXTDOMAIN), 'desc' => __('Select the style you would like your testimonials to display in.', MYSITE_ADMIN_TEXTDOMAIN), 'id' => 'style', 'default' => '', 'options' => array('pullquote1' => __('Pullquote 1', MYSITE_ADMIN_TEXTDOMAIN), 'pullquote2' => __('Pullquote 2', MYSITE_ADMIN_TEXTDOMAIN), 'pullquote3' => __('Pullquote 3', MYSITE_ADMIN_TEXTDOMAIN), 'pullquote4' => __('Pullquote 4', MYSITE_ADMIN_TEXTDOMAIN), 'blockquote' => __('Blockquotes', MYSITE_ADMIN_TEXTDOMAIN)), 'type' => 'select'), array('name' => __('Testimonials Categories <small>(optional)</small>', MYSITE_ADMIN_TEXTDOMAIN), 'desc' => __('If you want testimonials from specific categories to display then you may choose them here.', MYSITE_ADMIN_TEXTDOMAIN), 'id' => 'cat', 'default' => array(), 'target' => 'cat_testimonial', 'type' => 'multidropdown'), array('name' => __('Show Testimonials Pagination <small>(optional)</small>', MYSITE_ADMIN_TEXTDOMAIN), 'desc' => __('Checking this will show pagination at the bottom so the reader can go to the next page.', MYSITE_ADMIN_TEXTDOMAIN), 'id' => 'pagination', 'options' => array('true' => 'Show Post Pagination'), 'type' => 'checkbox'), 'shortcode_has_atts' => true)); return $option; } extract(shortcode_atts(array('show' => '4', 'column' => '2', 'style' => 'blockquote', 'cat' => '', 'pagination' => ''), $atts)); $out = ''; # Testimonal query options $show = trim($show); $column = trim($column); $style = trim($style); $pagination = trim($pagination); $query = array('post_type' => 'testimonial'); if ($pagination == 'true') { $query['posts_per_page'] = $show; $query['paged'] = mysite_get_page_query(); } else { $query['showposts'] = $show; $query['nopaging'] = 0; } if (!empty($cat)) { $query['tax_query'] = array('relation' => 'IN', array('taxonomy' => 'testimonial_category', 'field' => 'slug', 'terms' => explode(',', $cat))); } # Query testimonials $testimonials_query = new WP_Query($query); # Check to see testimonials have be added if ($testimonials_query->have_posts()) { while ($testimonials_query->have_posts()) { $testimonials_query->the_post(); # Loop through and get all testimonial custom fields $post_id = get_the_ID(); $custom_fields = get_post_custom($post_id); foreach ($custom_fields as $key => $value) { $testimonial[$post_id][$key] = $value[0]; } } # End testimonials_query loop # Define column classes switch ($column) { case 1: $main_class = 'testimonial_grid one_column_testimonial'; break; case 2: $main_class = 'testimonial_grid two_column_testimonial'; $column_class = 'one_half'; break; case 3: $main_class = 'testimonial_grid three_column_testimonial'; $column_class = 'one_third'; break; case 4: $main_class = 'testimonial_grid four_column_testimonial'; $column_class = 'one_fourth'; break; } $out .= '<div class="' . $main_class . '">'; # Loop through all testimonial custom fields and output testimonials $i = 1; foreach ($testimonial as $key => $value) { $out .= $column != 1 ? '<div class="' . ($i % $column == 0 ? $column_class . ' last' : $column_class) . '">' : ''; if (!empty($value['_testimonial'])) { # Pullquote1 style $quote = '[' . $style . ' raw="false" testimonial_sc="true"'; if (!empty($value['_name'])) { $quote .= ' cite_sc="' . $value['_name'] . '"'; } if (!empty($value['_website_url'])) { $quote .= ' citelink="' . $value['_website_url'] . '"'; } if (!empty($value['_website_name'])) { $quote .= ' citename="' . $value['_website_name'] . '"'; } if (isset($value['_image']) && $value['_image'] == 'upload_picture' && !empty($value['_custom_image'])) { $quote .= ' citeimgcustom="' . $value['_custom_image'] . '"'; } if (isset($value['_image']) && $value['_image'] == 'use_gravatar') { $value['_email'] = isset($value['_email']) ? $value['_email'] : '*****@*****.**'; $quote .= ' citeimgavatar="' . $value['_email'] . '"'; } $quote .= ']' . $value['_testimonial']; $quote .= '[/' . $style . ']'; $out .= do_shortcode($quote); } $out .= $column != 1 ? '</div>' : ''; if ($i % $column == 0) { $out .= '<div class="clearboth"></div>'; } $i++; } $out .= '</div>'; $out .= $pagination == 'true' ? mysite_pagenavi('', '', $testimonials_query) : ''; } else { $out .= __('No testimonials were found', MYSITE_TEXTDOMAIN); if (current_user_can('edit_post')) { $out .= '<p><a href="' . esc_url(admin_url('post-new.php?post_type=testimonial')) . '">' . __('Click here to add testimonials', MYSITE_TEXTDOMAIN) . '</a></p>'; } } wp_reset_query(); return $out; }
/** * */ function portfolio_list($atts) { if ($atts == 'generator') { $option = array('name' => __('Portfolio List', MYSITE_ADMIN_TEXTDOMAIN), 'value' => 'portfolio_list', 'options' => array(array('name' => __('Select Thumbnail Size', MYSITE_ADMIN_TEXTDOMAIN), 'desc' => __('Select the size of thumbnails that you wish to have displayed.<br /><br />This is a thumbnail of the "Featured Image" in each of your posts.', MYSITE_ADMIN_TEXTDOMAIN), 'id' => 'thumb', 'default' => '', 'options' => array('small' => __('Small', MYSITE_ADMIN_TEXTDOMAIN), 'medium' => __('Medium', MYSITE_ADMIN_TEXTDOMAIN), 'large' => __('Large', MYSITE_ADMIN_TEXTDOMAIN)), 'type' => 'select'), array('name' => __('Number of Portfolio Posts', MYSITE_ADMIN_TEXTDOMAIN), 'desc' => __('Select the number of posts you would like to display on each page.', MYSITE_ADMIN_TEXTDOMAIN), 'id' => 'showposts', 'default' => '', 'options' => array_combine(range(1, 40), array_values(range(1, 40))), 'type' => 'select'), array('name' => __('Portfolio Categories <small>(optional)</small>', MYSITE_ADMIN_TEXTDOMAIN), 'desc' => __('Select which portfolio categories you would like to display.', MYSITE_ADMIN_TEXTDOMAIN), 'id' => 'cat', 'default' => array(), 'target' => 'portfolio_category', 'type' => 'multidropdown'), array('name' => __('Offset Portfolio Posts <small>(optional)</small>', MYSITE_ADMIN_TEXTDOMAIN), 'desc' => __('This will skip a number of posts at the beginning.<br /><br />Useful if you are using multiple portfolio shortcodes on the same page.', MYSITE_ADMIN_TEXTDOMAIN), 'id' => 'offset', 'default' => '', 'options' => array_combine(range(1, 10), array_values(range(1, 10))), 'type' => 'select'), array('name' => __('Disable Portfolio Elements <small>(optional)</small>', MYSITE_ADMIN_TEXTDOMAIN), 'desc' => __('You can hide certain elements from displaying here.', MYSITE_ADMIN_TEXTDOMAIN), 'id' => 'disable', 'options' => array('image' => __('Disable Post Image', MYSITE_ADMIN_TEXTDOMAIN), 'title' => __('Disable Post Title', MYSITE_ADMIN_TEXTDOMAIN), 'excerpt' => __('Disable Post Excerpt', MYSITE_ADMIN_TEXTDOMAIN), 'date' => __('Disable Date', MYSITE_ADMIN_TEXTDOMAIN), 'more' => __('Disable Read More', MYSITE_ADMIN_TEXTDOMAIN), 'visit' => __('Disable Visit Site', MYSITE_ADMIN_TEXTDOMAIN), 'pagination' => __('Disable Pagination', MYSITE_ADMIN_TEXTDOMAIN)), 'default' => '', 'type' => 'checkbox'), 'shortcode_has_atts' => true)); return $option; } extract(shortcode_atts(array('thumb' => 'large', 'showposts' => '3', 'cat' => '', 'offset' => '', 'disable' => ''), $atts)); $out = ''; $portfolio_query = new WP_Query(); global $post, $wp_rewrite, $wp_query, $mysite; $thumb = trim($thumb); $showposts = trim($showposts); $cat = trim($cat); $offset = trim($offset); if (is_front_page()) { $_layout = mysite_get_setting('homepage_layout'); $images = $_layout == 'full_width' ? 'images' : ($_layout == 'left_sidebar' ? 'small_sidebar_images' : 'big_sidebar_images'); } else { $post_obj = $wp_query->get_queried_object(); $_layout = get_post_meta($post_obj->ID, '_layout', true); $_layout = empty($_layout) ? 'full_width' : $_layout; $images = $_layout == 'full_width' ? 'images' : ($_layout == 'left_sidebar' ? 'small_sidebar_images' : 'big_sidebar_images'); } $paged = mysite_get_page_query(); $gallery_post = $post->post_name; if ($post->post_parent) { $parent_query = get_post($post->post_parent); $gallery_parent = $parent_query->ID; } if (is_numeric($offset) && strpos($disable, 'pagination') === false) { $mysite->offset = $offset; $mysite->posts_per_page = $showposts; add_filter('post_limits', 'my_post_limit'); } if (strpos($disable, 'pagination') === false) { if (!empty($cat)) { $portfolio_query->query(array('post_type' => 'portfolio', 'posts_per_page' => $showposts, 'tax_query' => array('relation' => 'IN', array('taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => explode(',', $cat))), 'offset' => $offset, 'paged' => $paged)); } else { $portfolio_query->query(array('post_type' => 'portfolio', 'posts_per_page' => $showposts, 'offset' => $offset, 'paged' => $paged)); } } else { if (!empty($cat)) { $portfolio_query->query(array('post_type' => 'portfolio', 'posts_per_page' => $showposts, 'tax_query' => array('relation' => 'IN', array('taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => explode(',', $cat))), 'offset' => $offset, 'nopaging' => 0)); } else { $portfolio_query->query(array('post_type' => 'portfolio', 'posts_per_page' => $showposts, 'offset' => $offset, 'nopaging' => 0)); } } if ($portfolio_query->have_posts()) { $img_sizes = $mysite->layout[$images]; $img_group = 'portfolio_img_group_' . rand(1, 1000); $width = ''; $height = ''; switch ($thumb) { case 'small': $main_class = 'post_list small_post_list'; $width = $img_sizes['small_post_list'][0]; $height = $img_sizes['small_post_list'][1]; break; case 'medium': $main_class = 'post_list medium_post_list'; $width = $img_sizes['medium_post_list'][0]; $height = $img_sizes['medium_post_list'][1]; break; case 'large': $main_class = 'post_list large_post_list'; $width = $img_sizes['large_post_list'][0]; $height = $img_sizes['large_post_list'][1]; break; } $out .= '<ul class="portfolio_gallery ' . $main_class . '">'; $i = 1; while ($portfolio_query->have_posts()) { $portfolio_query->the_post(); $id = get_the_ID(); $image_id = get_post_thumbnail_id(); $custom_fields = get_post_custom($id); foreach ($custom_fields as $key => $value) { ${$key}[$id] = $value[0]; if (is_serialized(${$key}[$id])) { ${$key}[$id] = unserialize(${$key}[$id]); } } if (has_post_thumbnail() || !empty($_image[$id]) || !empty($_featured_video[$id])) { if (has_post_thumbnail()) { $img = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'full', true); } else { $img[0] = !empty($_image[$id]) ? $_image[$id] : ''; } if ($wp_rewrite->using_permalinks()) { $url = empty($_custom_link[$id]) ? home_url('/') . 'portfolio/' . $post->post_name . '/gallery/' . $gallery_post . '/' : $_custom_link[$id]; } else { $url = htmlspecialchars(add_query_arg(array('gallery' => $gallery_post), get_permalink($id))); } $link_to = empty($_post[$id][0]) ? empty($_featured_video[$id]) ? empty($_image[$id]) ? $img[0] : $_image[$id] : $_featured_video[$id] : $url; $out .= '<li class="' . join(' ', get_post_class('post_list_module', get_the_ID())) . '">'; if (strpos($disable, 'image') === false) { $offset = $mysite->layout['images']['image_padding']; $load_width = $width + $offset; $load_height = $height + $offset; $out .= '<div class="post_list_image" style="width:' . $load_width . 'px;">'; if ($thumb != 'small') { ob_start(); mysite_portfolio_image_begin(); $out .= ob_get_clean(); } if (empty($img[0]) && !empty($_featured_video[$id])) { $video_check = mysite_video($args = array('url' => $_featured_video[$id], 'parse' => true, 'width' => $width, 'height' => $height)); } else { $video_check = false; } if (!empty($video_check)) { $out .= $video_check; } else { $image_tags = mysite_post_image_tags($image_id, $id); $out .= mysite_display_image(array('src' => $img[0], 'alt' => $image_tags['alt'], 'title' => $image_tags['title'], 'height' => $height, 'width' => $width, 'class' => 'hover_fade_js', 'link_to' => $link_to, 'link_class' => 'portfolio_img_load', 'prettyphoto' => empty($_post[$id][0]) ? true : false, 'group' => $img_group, 'preload' => isset($mysite->mobile) ? false : true)); } if ($thumb != 'small') { ob_start(); mysite_portfolio_image_end(array('thumb' => $thumb, 'disable' => $disable, 'more' => !empty($_more[$id][0]) ? $_more[$id][0] : '', 'link' => !empty($_link[$id]) ? $_link[$id] : '', 'url' => $url, 'date' => !empty($_date[$id]) ? $_date[$id] : '')); $out .= ob_get_clean(); } $out .= '</div>'; } $out .= '<div class="post_list_content">'; $out .= apply_filters('mysite_portfolio_date_top', '', array('thumb' => $thumb, 'date' => !empty($_date[$id]) ? $_date[$id] : '', 'disable' => $disable)); if (strpos($disable, 'title') === false) { $title = empty($_more[$id][0]) ? '<a href="' . esc_url($url) . '">' . get_the_title($id) . '</a>' : get_the_title($id); if ($thumb == 'small') { $out .= '<p class="post_title">' . $title . '</p>'; } else { $out .= '<h2 class="post_title">' . $title . '</h2>'; } } if (!empty($_date[$id]) && strpos($disable, 'date') === false) { $out .= apply_filters('mysite_portfolio_date', '<p class="date">' . $_date[$id] . '</p>', array('thumb' => $thumb)); } if (empty($_more[$id][0]) || !empty($_link[$id]) || !empty($_teaser[$id])) { $out .= '<div class="post_excerpt">'; $out .= !empty($_teaser[$id]) && strpos($disable, 'excerpt') === false ? '<p>' . do_shortcode($_teaser[$id]) . '</p>' : ''; if (empty($_more[$id][0]) || !empty($_link[$id])) { $out .= '<p>'; if (empty($_more[$id][0]) && strpos($disable, 'more') === false) { $read_more = '<a href="' . esc_url($url) . '" class="post_more_link">' . __('Read More', MYSITE_TEXTDOMAIN) . '</a> '; $out .= apply_filters('mysite_portfolio_read_more', $read_more, esc_url($url)); } if (!empty($_link[$id]) && strpos($disable, 'visit') === false) { $visit_site = '<a href="' . esc_url($_link[$id]) . '" class="post_more_link">' . __('Visit Site', MYSITE_TEXTDOMAIN) . '</a>'; $out .= apply_filters('mysite_portfolio_visit_site', $visit_site, esc_url($_link[$id])); } $out .= '</p>'; } $out .= '</div>'; } $out .= '</div>'; $out .= '</li>'; } } $out .= '</ul>'; $out .= strpos($disable, 'pagination') === false ? mysite_pagenavi('', '', $portfolio_query) : ''; } else { $out .= __('No portfolio posts were found for the category selected.', MYSITE_TEXTDOMAIN); } if (is_numeric($offset) && strpos($disable, 'pagination') === false) { remove_filter('post_limits', 'my_post_limit'); } wp_reset_query(); return $out; }
function _blog_shortcode($args = array()) { global $post, $wp_rewrite, $wp_query, $mysite; extract($args['atts']); $out = ''; $showposts = trim($showposts); $column = !empty($column) ? trim($column) : '3'; $thumb = !empty($thumb) ? trim($thumb) : 'medium'; $offset = isset($offset) ? trim($offset) : ''; $post_in = !empty($post_in) ? explode(",", trim($post_in)) : ''; $category_in = !empty($category_in) ? explode(",", trim($category_in)) : ''; $tag_in = !empty($tag_in) ? explode(",", trim($tag_in)) : ''; if (is_front_page()) { $_layout = mysite_get_setting('homepage_layout'); $images = $_layout == 'full_width' ? 'images' : ($_layout == 'left_sidebar' ? 'small_sidebar_images' : 'big_sidebar_images'); } else { $post_obj = $wp_query->get_queried_object(); $_layout = get_post_meta($post_obj->ID, '_layout', true); $template = get_post_meta($post_obj->ID, '_wp_page_template', true); $images = $_layout == 'full_width' ? 'images' : ($_layout == 'left_sidebar' || $template == 'template-featuretour.php' ? 'small_sidebar_images' : 'big_sidebar_images'); } $post_img = ''; $blog_query = new WP_Query(); if (trim($pagination) == 'true') { if (is_numeric($offset)) { $mysite->offset = $offset; $mysite->posts_per_page = $showposts; add_filter('post_limits', 'my_post_limit'); } $paged = mysite_get_page_query(); $blog_query->query(array('post__in' => $post_in, 'category__in' => $category_in, 'tag__in' => $tag_in, 'post_type' => 'post', 'posts_per_page' => $showposts, 'paged' => $paged, 'offset' => $offset, 'ignore_sticky_posts' => 1)); } else { $blog_query->query(array('post__in' => $post_in, 'category__in' => $category_in, 'tag__in' => $tag_in, 'post_type' => 'post', 'showposts' => $showposts, 'nopaging' => 0, 'offset' => $offset, 'ignore_sticky_posts' => 1)); } if ($blog_query->have_posts()) { $img_sizes = $mysite->layout[$images]; $width = ''; $height = ''; if ($args['type'] == 'blog_grid') { switch ($column) { case 1: $main_class = 'post_grid one_column_blog'; $post_class = 'post_grid_module'; $content_class = 'post_grid_content'; $img_class = 'post_grid_image'; $excerpt_lenth = 400; $width = $img_sizes['one_column_blog'][0]; $height = $img_sizes['one_column_blog'][1]; break; case 2: $main_class = 'post_grid two_column_blog'; $post_class = 'post_grid_module'; $content_class = 'post_grid_content'; $img_class = 'post_grid_image'; $column_class = 'one_half'; $excerpt_lenth = 150; $width = $img_sizes['two_column_blog'][0]; $height = $img_sizes['two_column_blog'][1]; break; case 3: $main_class = 'post_grid three_column_blog'; $post_class = 'post_grid_module'; $content_class = 'post_grid_content'; $img_class = 'post_grid_image'; $column_class = 'one_third'; $excerpt_lenth = 75; $width = $img_sizes['three_column_blog'][0]; $height = $img_sizes['three_column_blog'][1]; break; case 4: $main_class = 'post_grid four_column_blog'; $post_class = 'post_grid_module'; $content_class = 'post_grid_content'; $img_class = 'post_grid_image'; $column_class = 'one_fourth'; $excerpt_lenth = 50; $width = $img_sizes['four_column_blog'][0]; $height = $img_sizes['four_column_blog'][1]; break; } } else { if ($args['type'] == 'blog_list') { switch ($thumb) { case 'small': $main_class = 'post_list small_post_list'; $post_class = 'post_list_module'; $content_class = 'post_list_content'; $img_class = 'post_list_image'; $excerpt_lenth = 180; $width = $img_sizes['small_post_list'][0]; $height = $img_sizes['small_post_list'][1]; break; case 'medium': $main_class = 'post_list medium_post_list'; $post_class = 'post_list_module'; $content_class = 'post_list_content'; $img_class = 'post_list_image'; $excerpt_lenth = 180; $width = $img_sizes['medium_post_list'][0]; $height = $img_sizes['medium_post_list'][1]; break; case 'large': $main_class = 'post_list large_post_list'; $post_class = 'post_list_module'; $content_class = 'post_list_content'; $img_class = 'post_list_image'; $excerpt_lenth = 180; $width = $img_sizes['large_post_list'][0]; $height = $img_sizes['large_post_list'][1]; break; } } } $filter_args = array('width' => $width, 'height' => $height, 'img_class' => $img_class, 'link_class' => 'blog_sc_image_load', 'preload' => isset($mysite->mobile) ? false : true, 'post_content' => $post_content, 'disable' => $disable, 'column' => $column, 'thumb' => $thumb, 'type' => $args['type'], 'shortcode' => true, 'echo' => false); $out .= $args['type'] == 'blog_grid' ? '<div class="' . $main_class . '">' : '<ul class="' . $main_class . '">'; $i = 1; while ($blog_query->have_posts()) { $blog_query->the_post(); $post_id = get_the_ID(); $video = get_post_meta($post_id, '_featured_video', true); if (!empty($video)) { $filter_args = array_merge(array('video' => $video), $filter_args); } $out .= $args['type'] == 'blog_list' ? '' : ($column != 1 ? '<div class="' . ($i % $column == 0 ? $column_class . ' last' : $column_class) . '">' : ''); $out .= $args['type'] == 'blog_grid' ? '<div class="' . join(' ', get_post_class($post_class, $post_id)) . '">' : '<li class="' . join(' ', get_post_class($post_class, $post_id)) . '">'; $out .= mysite_before_post_sc($filter_args); $out .= '<div class="' . $content_class . '">'; $out .= mysite_before_entry_sc($filter_args); $out .= '<div class="post_excerpt">'; if (strpos($disable, 'content') === false) { ob_start(); mysite_post_content($filter_args); $out .= ob_get_clean(); } $out .= '</div>'; $out .= mysite_after_entry_sc($filter_args); $out .= '</div>'; $out .= $args['type'] == 'blog_grid' ? '</div>' : '</li>'; $out .= $args['type'] == 'blog_list' ? '' : ($column != 1 ? '</div>' : ''); if ($args['type'] == 'blog_grid') { if ($i % $column == 0) { $out .= '<div class="clearboth"></div>'; } } $i++; } $out .= $args['type'] == 'blog_grid' ? '</div>' : '</ul>'; if ($pagination == 'true') { $out .= mysite_pagenavi('', '', $blog_query); } } if (is_numeric($offset) && trim($pagination) == 'true') { remove_filter('post_limits', 'my_post_limit'); } wp_reset_query(); return $out; }