function cc_list_posts($atts, $content = null) { global $cap, $post, $cc_js; $cc_page_options = cc_get_page_meta(); $tmp = ''; extract(shortcode_atts(array('amount' => '12', 'is_home_last_posts' => false, 'category__in' => array(), 'category_name' => '0', 'img_position' => 'mouse_over', 'height' => 'auto', 'page_id' => '', 'post_type' => 'post', 'orderby' => '', 'order' => '', 'year' => '', 'tag' => '', 'monthnum' => '', 'author' => ''), $atts)); switch ($img_position) { case 'left': $img_position = 'posts-img-left-content-right'; break; case 'right': $img_position = 'posts-img-right-content-left'; break; case 'over': $img_position = 'posts-img-over-content'; break; case 'under': $img_position = 'posts-img-under-content'; break; case 'mouse_over': $img_position = 'boxgrid'; break; } if (!is_array($category__in)) { $category__in = explode(',', $category__in); } if ($page_id != '') { $page_id = explode(',', $page_id); } $paged = get_query_var('paged') ? get_query_var('paged') : 1; $args = array('orderby' => $orderby, 'order' => $order, 'post_type' => $post_type, 'post__in' => $page_id, 'year' => $year, 'monthnum' => $monthnum, 'category__in' => $category__in, 'category_name' => $category_name, 'posts_per_page' => $amount, 'tag' => $tag, 'paged' => $paged, 'author' => $author); if (($cap->default_homepage_last_posts == 'show' || $cap->default_homepage_last_posts == __('show', 'cc')) && !$is_home_last_posts) { $args['offset'] = 3; } remove_all_filters('posts_orderby'); query_posts($args); if (have_posts()) { $thePath = array(); $pattern = "/(?<=src=['|\"])[^'|\"]*?(?=['|\"])/i"; archive_post_order($query_string); while (have_posts()) { the_post(); // magazine style and on pages if ($cc_page_options['cc_page_template_on'] == 1 || $cap->posts_lists_style_taxonomy == 'magazine' || is_page_for_posts() && $cap->posts_lists_style_home == 'magazine' || $is_home_last_posts) { if ($img_position == 'boxgrid') { $thumb = get_the_post_thumbnail($post->ID, 'post-thumbnail', __('List post image', 'cc')); preg_match($pattern, $thumb, $thePath); if (!isset($thePath[0])) { $thePath[0] = get_template_directory_uri() . '/images/slideshow/noftrdimg-222x160.jpg'; } $tmp .= '<div class="boxgrid captionfull" style="background: transparent url(' . $thePath[0] . ') repeat scroll 0 0; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; " title="' . get_the_title() . '">'; $tmp .= '<a href="' . get_permalink() . '" title="' . get_the_title() . '"><img src="' . $thePath[0] . '" /></a>'; $tmp .= '<div class="cover boxcaption">'; $tmp .= '<h3><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a></h3>'; $tmp .= '<p class="hidden-phone"><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_excerpt() . '...</a></p>'; $tmp .= '</div>'; $tmp .= '</div>'; } else { $tmp .= '<div class="listposts ' . $img_position . '">'; if ($img_position != 'posts-img-under-content') { $tmp .= '<a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_post_thumbnail($post->ID, 'post-thumbnail', array('alt' => get_the_title())) . '</a>'; } $tmp .= '<h3><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a></h3>'; if ($height != 'auto') { $height = str_replace('px', '', $height) . 'px'; } $tmp .= '<p style="height:' . $height . ';">' . get_the_excerpt() . '</p>'; if ($img_position == 'posts-img-under-content') { $tmp .= '<a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_post_thumbnail($post->ID, 'post-thumbnail', array('alt' => get_the_title())) . '</a>'; } $tmp .= '</div>'; if ($img_position == 'posts-img-left-content-right' || $img_position == 'posts-img-right-content-left') { $tmp .= '<div class="clear"></div>'; } } // blog } else { ?> <div id="post-<?php the_ID(); ?> " <?php post_class(); ?> > <?php if ($cap->posts_lists_hide_avatar == 'show' && !is_page_for_posts() || is_page_for_posts() && $cap->default_homepage_hide_avatar == 'show') { ?> <div class="author-box visible-desktop"> <?php echo get_avatar(get_the_author_meta('user_email'), '50'); ?> <?php if (defined('BP_VERSION')) { ?> <p><?php printf(__('by %s', 'cc'), bp_core_get_userlink($post->post_author)); ?> </p> <?php } ?> </div> <?php } ?> <div class="post-content span11"> <span class="marker visible-desktop"></span> <h2 class="posttitle"><a href="<?php the_permalink(); ?> " rel="bookmark" title="<?php _e('Permanent Link to', 'cc'); ?> <?php the_title_attribute(); ?> "><?php the_title(); ?> </a></h2> <?php if ($cap->posts_lists_hide_date == 'show' && !is_page_for_posts() || is_page_for_posts() && $cap->default_homepage_hide_date == 'show') { ?> <p class="date"><?php the_time('F j, Y'); ?> <em><?php _e('in', 'cc'); ?> <?php the_category(', '); if (defined('BP_VERSION')) { printf(__(' by %s', 'cc'), bp_core_get_userlink($post->post_author)); } ?> </em></p> <?php } ?> <div class="entry"> <?php do_action('blog_post_entry'); ?> </div> <?php $tags = get_the_tags(); if ($tags) { ?> <p class="postmetadata"><span class="tags"><?php the_tags(__('Tags: ', 'cc'), ', ', '<br />'); ?> </span> <span class="comments"><?php comments_popup_link(__('No Comments »', 'cc'), __('1 Comment »', 'cc'), __('% Comments »', 'cc')); ?> </span></p> <?php } else { ?> <p class="postmetadata"><span class="comments"><?php comments_popup_link(__('No Comments »', 'cc'), __('1 Comment »', 'cc'), __('% Comments »', 'cc')); ?> </span></p> <?php } ?> </div> </div> <?php } } } $tmp .= '<div class="clear"></div>'; if ($img_position == 'boxgrid') { $cc_js['list_posts'] = true; } wp_reset_query(); return '<div class="list-posts-all phone-hidden">' . $tmp . '</div> '; }
function cc_page_metabox() { global $cap; $args = array('echo' => '0', 'hide_empty' => '0'); $categories = get_categories($args); $option = array(); $i = 0; foreach ($categories as $category) { $option[$i]['name'] = $category->name; $option[$i]['id'] = $category->term_id; $i++; } $option_categories = $option; $yes_no_options = array(__('no', 'cc'), __('yes', 'cc')); $is_allowed_direct_link = __('no', 'cc'); $is_title_hidden = $cap->show_titles_all_pages == __('yes', 'cc') ? __('no', 'cc') : __('yes', 'cc'); $is_title_centered = $cap->titles_center == __('yes', 'cc') ? __('yes', 'cc') : __('no', 'cc'); $cc_page_options = cc_get_page_meta(); if ($cc_page_options['cc_page_slider_on'] == 1) { $checked_slider = 'checked="checked"'; } else { $checked_slider = ""; } if ($cc_page_options['cc_page_slider_caption'] == 1) { $checked_caption = "checked"; } else { $checked_caption = ""; } $cc_page_slider_time = $cc_page_options['cc_page_slider_time']; $cc_page_slider_orderby = $cc_page_options['cc_page_slider_orderby']; $cc_page_slider_amount = $cc_page_options['cc_page_slider_amount']; $cc_page_slider_post_type = $cc_page_options['cc_page_slider_post_type']; $cc_page_slider_show_page = $cc_page_options['cc_page_slider_show_page']; if ($cc_page_options['cc_page_template_on'] == 1) { $checked_page_template = "checked"; } else { $checked_page_template = ""; } if (!empty($cc_page_options['cc_page_allow_direct_link']) && $cc_page_options['cc_page_allow_direct_link'] == __('yes', 'cc')) { $is_allowed_direct_link = __('yes', 'cc'); } if (!empty($cc_page_options['cc_hide_title']) && $cc_page_options['cc_hide_title'] == __('yes', 'cc')) { $is_title_hidden = __('yes', 'cc'); } if (!empty($cc_page_options['cc_center_title']) && $cc_page_options['cc_center_title'] == __('yes', 'cc')) { $is_title_centered = __('yes', 'cc'); } $cc_page_template_amount = $cc_page_options['cc_page_template_amount']; $option_post_templates[0] = "img-mouse-over"; $option_post_templates[1] = "img-left-content-right"; $option_post_templates[2] = "img-right-content-left"; $option_post_templates[3] = "img-over-content"; $option_post_templates[4] = "img-under-content"; $option_styles[0] = "default"; $option_styles[1] = "full-width-image"; ?> <div id="cc_page_metabox" class="postbox"> <div class="handlediv" title="<?php _e('click', 'cc'); ?> "> <br /> </div> <h3 class="hndle"><?php _e('Custom Community settings', 'cc'); ?> </h3> <div class="inside"> <p> <div id="categories-set"> <b><?php _e('Slideshow', 'cc'); ?> </b><br /> <label for="cc_page_slider"><?php _e('Slideshow on', 'cc'); ?> :</label> <input name="cc_page_slider_on" id="cc_page_slider_on" type="checkbox" <?php echo $checked_slider; ?> value="1" /> <?php _e('Select a category to display in slideshow:', 'cc'); ?> <?php foreach ($option_categories as $option) { ?> <label> <input type="checkbox" name="cc_page_slider_cat[]" <?php echo is_array($cc_page_options['cc_page_slider_cat']) && in_array($option['id'], $cc_page_options['cc_page_slider_cat']) ? 'checked' : ''; ?> value="<?php echo $option['id']; ?> " /><?php echo $option['name']; ?> </label> <?php } ?> </div> <br /> <label for="cc_page_slider_post_type"><?php _e('Use Post Type: for Pages write "page"', 'cc'); ?> :</label> <input type="text" name="cc_page_slider_post_type" id="cc_page_slider_post_type" value="<?php echo $cc_page_slider_post_type; ?> " /> <label for="cc_page_slider_show_page"><?php _e('post/page ids comma separated', 'cc'); ?> :</label> <input type="text" name="cc_page_slider_show_page" id="cc_page_slider_show_page" value="<?php echo $cc_page_slider_show_page; ?> " /> <br /><?php _e('Select a slideshow style:', 'cc'); ?> <select id="cc_page_slider_style" name="cc_page_slider_style"> <?php foreach ($option_styles as $option_style) { ?> <option <?php if (trim($cc_page_options['cc_page_slider_style']) == trim($option_style)) { ?> selected="selected"<?php } ?> ><?php echo $option_style; ?> </option> <?php } ?> </select> <br /><label for="cc_page_slider_caption"><?php _e('Caption off', 'cc'); ?> :</label> <input name="cc_page_slider_caption" id="cc_page_slider_caption" type="checkbox" <?php echo $checked_caption; ?> value="1" /> <br /><label for="cc_page_slider_time"><?php _e('Define the sliding time in ms', 'cc'); ?> :</label> <input type="text" name="cc_page_slider_time" id="cc_page_slider_time" value="<?php echo $cc_page_slider_time; ?> " /> <label for="cc_page_slider_orderby"><?php _e('Order By', 'cc'); ?> :</label> <input type="text" name="cc_page_slider_orderby" id="cc_page_slider_orderby" value="<?php echo $cc_page_slider_orderby; ?> " /> <label for="cc_page_slider_amount"><?php _e('Amount', 'cc'); ?> :</label> <input type="text" name="cc_page_slider_amount" id="cc_page_slider_amount" value="<?php echo $cc_page_slider_amount; ?> " /> <br /><br /><b><?php _e('Lists Posts under this Page', 'cc'); ?> </b> <p><?php _e('You can show your posts in a predefined template', 'cc'); ?> :<br /> <label for="cc_page_template"><?php _e('Post template on', 'cc'); ?> :</label> <input name="cc_page_template_on" id="cc_page_template_on" type="checkbox" <?php echo $checked_page_template; ?> value="1" /> <?php _e('Select a template to use:', 'cc'); ?> <select id="cc_posts_on_page_type" name="cc_posts_on_page_type"> <?php foreach ($option_post_templates as $option_template) { ?> <option <?php if ($cc_page_options['cc_posts_on_page_type'] == $option_template) { ?> selected="selected"<?php } ?> ><?php echo $option_template; ?> </option> <?php } ?> </select> <?php _e('Select a category to display', 'cc'); ?> : <?php foreach ($option_categories as $option) { ?> <label> <input type="checkbox" name="cc_page_template_cat[]" <?php echo is_array($cc_page_options['cc_page_template_cat']) && in_array($option['id'], $cc_page_options['cc_page_template_cat']) ? 'checked' : ''; ?> value="<?php echo $option['id']; ?> " /><?php echo $option['name']; ?> </label> <?php } ?> <?php _e('How many posts to display?', 'cc'); ?> <input type="text" name="cc_page_template_amount" id="cc_page_template_amount" value="<?php echo $cc_page_template_amount; ?> " /> </p> <p><?php _e('Allow direct post access', 'cc'); ?> <br /> <select id="cc_allow_direct_link" name="cc_page_allow_direct_link"> <?php foreach ($yes_no_options as $allow_direct_link) { ?> <option value="<?php echo $allow_direct_link; ?> " <?php selected($allow_direct_link, $is_allowed_direct_link); ?> ><?php echo $allow_direct_link; ?> </option> <?php } ?> </select> </p> <p> <b><?php _e('Additional Settings', 'cc'); ?> </b><br /> <p><?php _e('Hide the title?', 'cc'); ?> <br /> <select id="cc_hide_title" name="cc_hide_title"> <?php foreach ($yes_no_options as $option) { ?> <option value="<?php echo $option; ?> " <?php selected($option, $is_title_hidden); ?> ><?php echo $option; ?> </option> <?php } ?> </select> </p> <p><?php _e('Center the title?', 'cc'); ?> <br /> <select id="cc_center_title" name="cc_center_title"> <?php foreach ($yes_no_options as $option) { ?> <option value="<?php echo $option; ?> " <?php selected($option, $is_title_centered); ?> ><?php echo $option; ?> </option> <?php } ?> </select> </p> </p> </p> </div> </div> <?php }
/** * load the array for the list posts depending on the page settings or theme settings * * @package Custom Community * @since 1.8.3 */ function cc_list_posts_on_page() { $cc_page_options = cc_get_page_meta(); if (isset($cc_page_options) && isset($cc_page_options['cc_page_template_on']) && $cc_page_options['cc_page_template_on'] == 1) { $atts = array('amount' => $cc_page_options['cc_page_template_amount'], 'category__in' => $cc_page_options['cc_page_template_cat']); switch ($cc_page_options['cc_posts_on_page_type']) { case 'img-mouse-over': $atts['img_position'] = 'mouse_over'; break; case 'img-left-content-right': $atts['img_position'] = 'left'; break; case 'img-right-content-left': $atts['img_position'] = 'right'; break; case 'img-over-content': $atts['img_position'] = 'over'; break; case 'img-under-content': $atts['img_position'] = 'under'; break; } echo cc_list_posts($atts, $content = null); } }
/** * header: add the top slider to the homepage, all pages, or just on specific pages * * !!! this function needs to be rewritten !!! * * located: header.php do_action( 'bp_after_header' ) * * @package Custom Community * @since 1.8.3 */ function slideshow_home() { global $cap; $cc_page_options = cc_get_page_meta(); if (defined('BP_VERSION')) { if ($cap->enable_slideshow_home == 'all' || $cap->enable_slideshow_home == __('all', 'cc') || ($cap->enable_slideshow_home == 'home' || $cap->enable_slideshow_home == __('home', 'cc')) && is_front_page() || ($cap->enable_slideshow_home == 'home' || $cap->enable_slideshow_home == __('home', 'cc')) && bp_is_component_front_page('activity') || is_page() && isset($cc_page_options) && isset($cc_page_options['cc_page_slider_on']) && $cc_page_options['cc_page_slider_on'] == 1) { echo cc_slidertop(); // located under wp/templatetags } } elseif ($cap->enable_slideshow_home == 'all' || $cap->enable_slideshow_home == __('all', 'cc') || ($cap->enable_slideshow_home == 'home' || $cap->enable_slideshow_home == __('home', 'cc')) && is_front_page() || is_page() && isset($cc_page_options) && $cc_page_options['cc_page_slider_on'] == 1) { echo cc_slidertop(); // located under wp/templatetags } }