function widget($args, $instance) { extract($args); $instance = wp_parse_args((array) $instance, self::$widget_defaults); /* Our variables from the widget settings. */ $title = apply_filters('widget_title', $instance['title']); $terms = empty($instance['cats']) ? array(0) : (array) $instance['cats']; $html = ''; if ($terms) { $attachments_data = presscore_get_related_posts(array('exclude_current' => false, 'cats' => $terms, 'select' => $instance['select'], 'post_type' => 'post', 'taxonomy' => 'category', 'field' => 'term_id', 'args' => array('posts_per_page' => $instance['show'], 'orderby' => $instance['orderby'], 'order' => $instance['order']))); $list_args = array('show_images' => (bool) $instance['thumbnails'], 'image_dimensions' => $instance['images_dimensions']); $posts_list = presscore_get_posts_small_list($attachments_data, $list_args); if ($posts_list) { foreach ($posts_list as $p) { $html .= sprintf('<li>%s</li>', $p); } $html = '<ul class="recent-posts' . ($instance['round_images'] ? ' round-images' : '') . '">' . $html . '</ul>'; } } echo $before_widget; // title if ($title) { echo $before_title . $title . $after_title; } echo $html; echo $after_widget; }
public function shortcode($atts, $content = null) { extract(shortcode_atts(array('featured_images' => 'true', 'round_images' => '', 'images_width' => 60, 'images_height' => 60, 'category' => '', 'order' => '', 'orderby' => '', 'number' => 6, 'columns' => 1), $atts)); // sanitize attributes $featured_images = apply_filters('dt_sanitize_flag', $featured_images); $round_images = apply_filters('dt_sanitize_flag', $round_images); $order = apply_filters('dt_sanitize_order', $order); $orderby = apply_filters('dt_sanitize_orderby', $orderby); $number = apply_filters('dt_sanitize_posts_per_page', $number); $columns = absint($columns); $images_width = absint($images_width); $images_height = absint($images_height); if ($category) { $category = explode(',', $category); $category = array_map('trim', $category); } $related_posts_args = array('exclude_current' => false, 'post_type' => 'post', 'taxonomy' => 'category', 'field' => 'slug', 'args' => array('posts_per_page' => $number, 'orderby' => $orderby, 'order' => $order)); if (!empty($category)) { $related_posts_args['cats'] = $category; $related_posts_args['select'] = 'only'; } else { $related_posts_args['select'] = 'all'; } $attachments_data = presscore_get_related_posts($related_posts_args); $list_args = array('show_images' => $featured_images, 'image_dimensions' => array('w' => $images_width, 'h' => $images_height)); $posts_list = presscore_get_posts_small_list($attachments_data, $list_args); switch ($columns) { case 2: $column_class = 'wf-1-2'; break; case 3: $column_class = 'wf-1-3'; break; case 1: default: $column_class = 'wf-1'; } $output = ''; if ($posts_list) { foreach ($posts_list as $p) { $output .= sprintf('<div class="wf-cell %s"><div class="borders">%s</div></div>', $column_class, $p); } $section_class = 'items-grid wf-container'; if ($featured_images && $round_images) { $section_class .= ' round-images'; } $output = '<section class="' . $section_class . '">' . $output . '</section>'; } if (function_exists('vc_is_inline') && vc_is_inline()) { $terms_list = presscore_get_terms_list_by_slug(array('slugs' => $category, 'taxonomy' => 'category')); $output = ' <div class="dt_vc-shortcode_dummy dt_vc-mini_blog" style="height: 250px;"> <h5>Mini blog</h4> <p class="text-small"><strong>Display categories:</strong> ' . $terms_list . '</p> </div> '; } return $output; }
public function shortcode($atts, $content = null) { extract(shortcode_atts(array('featured_images' => 'true', 'category' => '', 'order' => '', 'orderby' => '', 'number' => '6', 'columns' => '1'), $atts)); // sanitize attributes $featured_images = in_array($featured_images, array('1', 'true', 'yes')); $order = apply_filters('dt_sanitize_order', $order); $orderby = apply_filters('dt_sanitize_orderby', $orderby); $number = apply_filters('dt_sanitize_posts_per_page', $number); $columns = in_array($columns, array('1', '2', '3')) ? absint($columns) : 1; if ($category) { $category = explode(',', $category); $category = array_map('trim', $category); } $related_posts_args = array('exclude_current' => false, 'post_type' => 'post', 'taxonomy' => 'category', 'field' => 'slug', 'args' => array('posts_per_page' => $number, 'orderby' => $orderby, 'order' => $order)); if (!empty($category)) { $related_posts_args['cats'] = $category; $related_posts_args['select'] = 'only'; } else { $related_posts_args['select'] = 'all'; } $attachments_data = presscore_get_related_posts($related_posts_args); // unset thumbnails if (!$featured_images) { foreach ($attachments_data as $k => $v) { $attachments_data[$k]['full'] = ''; } } $posts_list = presscore_get_posts_small_list($attachments_data); switch ($columns) { case 2: $column_class = 'wf-1-2'; break; case 3: $column_class = 'wf-1-3'; break; default: $column_class = 'wf-1'; } $output = ''; if ($posts_list) { foreach ($posts_list as $p) { $output .= sprintf('<div class="wf-cell %s"><div class="borders">%s</div></div>', $column_class, $p); } $output = '<section class="items-grid wf-container">' . $output . '</section>'; } return $output; }
/** * Display related posts. * */ function presscore_display_related_posts() { if (!of_get_option('general-show_rel_posts', false)) { return ''; } global $post; $html = ''; $terms = array(); switch (get_post_meta($post->ID, '_dt_post_options_related_mode', true)) { case 'custom': $terms = get_post_meta($post->ID, '_dt_post_options_related_categories', true); break; default: $terms = wp_get_object_terms($post->ID, 'category', array('fields' => 'ids')); } if ($terms && !is_wp_error($terms)) { $attachments_data = presscore_get_related_posts(array('cats' => $terms, 'post_type' => 'post', 'taxonomy' => 'category', 'args' => array('posts_per_page' => intval(of_get_option('general-rel_posts_max', 12))))); $posts_list = presscore_get_posts_small_list($attachments_data, array('image_dimensions' => array('w' => 80, 'h' => 60))); if ($posts_list) { $config = Presscore_Config::get_instance(); if ('disabled' != $config->get('sidebar_position')) { $column_class = 'wf-1-2'; } else { $column_class = 'wf-1-3'; } foreach ($posts_list as $p) { $html .= sprintf('<div class="wf-cell %s"><div class="borders">%s</div></div>', $column_class, $p); } $html = '<section class="items-grid wf-container">' . $html . '</section>'; $head_title = esc_html(of_get_option('general-rel_posts_head_title', 'Related posts')); // add title if ($head_title) { $html = '<div class="dt-fancy-separator title-left fancy-posts-title"><div class="dt-fancy-title">' . $head_title . '<span class="separator-holder separator-right"></span></div></div>' . $html; } } } echo (string) apply_filters('presscore_display_related_posts', $html); }
/** * Portfolio slider. * */ public function portfolio_slider($attributes = array()) { $config = Presscore_Config::get_instance(); $slider_class = array(); if ('disabled' == $config->get('sidebar_position')) { $slider_class[] = 'full'; } $slider_fields = array(); if ($attributes['show_title']) { $slider_fields[] = 'title'; } if ($attributes['meta_info']) { $slider_fields[] = 'meta'; } if ($attributes['show_excerpt']) { $slider_fields[] = 'description'; } if ($attributes['show_link']) { $slider_fields[] = 'link'; } if ($attributes['show_zoom']) { $slider_fields[] = 'zoom'; } if ($attributes['show_details']) { $slider_fields[] = 'details'; } $slider_style = array(); if ($attributes['margin_bottom']) { $slider_style[] = 'margin-bottom: ' . $attributes['margin_bottom']; } if ($attributes['margin_top']) { $slider_style[] = 'margin-top: ' . $attributes['margin_top']; } $slider_args = array('mode' => $attributes['appearance'], 'fields' => $slider_fields, 'class' => $slider_class, 'style' => implode(';', $slider_style), 'under_image_buttons' => $attributes['under_image_buttons'], 'hover_animation' => $attributes['hover_animation'], 'hover_bg_color' => $attributes['hover_bg_color'], 'hover_content_visibility' => $attributes['hover_content_visibility']); if ($attributes['height']) { $slider_args['height'] = $attributes['height']; } if ($attributes['width']) { $slider_args['img_width'] = $attributes['width']; } if (function_exists('vc_is_inline') && vc_is_inline()) { $terms_list = presscore_get_terms_list_by_slug(array('slugs' => $attributes['category'], 'taxonomy' => 'dt_portfolio_category')); $output = ' <div class="dt_vc-shortcode_dummy dt_vc-portfolio_scroller" style="height: ' . $slider_args['height'] . 'px;"> <h5>Portfolio scroller</h5> <p class="text-small"><strong>Display categories:</strong> ' . $terms_list . '</p> </div> '; } else { $related_posts_args = array('exclude_current' => false, 'post_type' => 'dt_portfolio', 'taxonomy' => 'dt_portfolio_category', 'field' => 'slug', 'args' => array('posts_per_page' => $attributes['number'], 'orderby' => $attributes['orderby'], 'order' => $attributes['order'])); $related_posts_args['cats'] = $attributes['category']; if (!empty($attributes['category'])) { $related_posts_args['select'] = 'only'; } else { $related_posts_args['select'] = 'all'; } $attachments_data = presscore_get_related_posts($related_posts_args); $output = presscore_get_fullwidth_slider_two_with_hovers($attachments_data, $slider_args); } return $output; }
/** * Display related projects. * */ function presscore_display_related_projects() { global $post; $html = ''; // if related projects turn on in theme options if (of_get_option('general-show_rel_projects', false)) { $terms = array(); switch (get_post_meta($post->ID, '_dt_project_options_related_mode', true)) { case 'custom': $terms = get_post_meta($post->ID, '_dt_project_options_related_categories', true); break; default: $terms = wp_get_object_terms($post->ID, 'dt_portfolio_category', array('fields' => 'ids')); } if ($terms && !is_wp_error($terms)) { $config = Presscore_Config::get_instance(); $attachments_data = presscore_get_related_posts(array('cats' => $terms, 'post_type' => 'dt_portfolio', 'taxonomy' => 'dt_portfolio_category', 'args' => array('posts_per_page' => intval(of_get_option('general-rel_projects_max', 12))))); $img_width = null; $slider_title = of_get_option('general-rel_projects_head_title', 'Related projects'); $slider_class = 'related-projects'; if ('disabled' != get_post_meta($post->ID, '_dt_sidebar_position', true)) { $height = of_get_option('general-rel_projects_height', 190); if ('fixed' == of_get_option('general-rel_projects_width_style')) { $img_width = of_get_option('general-rel_projects_width'); } } else { $height = of_get_option('general-rel_projects_fullwidth_height', 270); $slider_class .= ' full'; if ('fixed' == of_get_option('general-rel_projects_fullwidth_width_style')) { $img_width = of_get_option('general-rel_projects_fullwidth_width'); } } $slider_fields = array(); // if ( of_get_option('general-rel_projects_meta', true) ) { /*if ( of_get_option('general-rel_projects_arrows', true) ) { $slider_fields[] = 'arrows'; }*/ if (of_get_option('general-rel_projects_title', true)) { $slider_fields[] = 'title'; } if (of_get_option('general-rel_projects_meta', true)) { $slider_fields[] = 'meta'; } if (of_get_option('general-rel_projects_excerpt', true)) { $slider_fields[] = 'description'; } if (of_get_option('general-rel_projects_link', true)) { $slider_fields[] = 'link'; } if (of_get_option('general-rel_projects_details', true)) { $slider_fields[] = 'details'; } // } $html = presscore_get_fullwidth_slider_two($attachments_data, array('class' => $slider_class, 'title' => $slider_title, 'fields' => $slider_fields, 'height' => $height, 'img_width' => $img_width)); if ('disabled' != $config->get('sidebar_position')) { $html = '<div class="hr-thick"></div>' . $html; if (presscore_comments_will_be_displayed()) { $html .= '<div class="gap-10"></div><div class="hr-thick"></div><div class="gap-30"></div>'; } } } } echo (string) apply_filters('presscore_display_related_projects', $html); }
/** * Portfolio slider. * */ public function portfolio_slider($attributes = array()) { $config = Presscore_Config::get_instance(); $related_posts_args = array('exclude_current' => false, 'post_type' => 'dt_portfolio', 'taxonomy' => 'dt_portfolio_category', 'field' => 'slug', 'args' => array('posts_per_page' => $attributes['number'], 'orderby' => $attributes['orderby'], 'order' => $attributes['order'])); if (!empty($attributes['category'])) { $related_posts_args['cats'] = $attributes['category']; $related_posts_args['select'] = 'only'; } else { $related_posts_args['select'] = 'all'; } $attachments_data = presscore_get_related_posts($related_posts_args); $slider_class = array(); if ('disabled' == $config->get('sidebar_position')) { $slider_class[] = 'full'; } $slider_fields = array(); if ($attributes['show_title']) { $slider_fields[] = 'title'; } if ($attributes['meta_info']) { $slider_fields[] = 'meta'; } if ($attributes['show_excerpt']) { $slider_fields[] = 'description'; } if ($attributes['show_link']) { $slider_fields[] = 'link'; } if ($attributes['show_zoom']) { $slider_fields[] = 'zoom'; } if ($attributes['show_details']) { $slider_fields[] = 'details'; } $slider_style = array(); if ($attributes['margin_bottom']) { $slider_style[] = 'margin-bottom: ' . $attributes['margin_bottom']; } if ($attributes['margin_top']) { $slider_style[] = 'margin-top: ' . $attributes['margin_top']; } $slider_args = array('mode' => $attributes['appearance'], 'fields' => $slider_fields, 'class' => $slider_class, 'style' => implode(';', $slider_style), 'under_image_buttons' => $attributes['under_image_buttons'], 'hover_animation' => $attributes['hover_animation'], 'hover_bg_color' => $attributes['hover_bg_color'], 'hover_content_visibility' => $attributes['hover_content_visibility']); if ($attributes['height']) { $slider_args['height'] = $attributes['height']; } if ($attributes['width']) { $slider_args['img_width'] = $attributes['width']; } $output = presscore_get_fullwidth_slider_two_with_hovers($attachments_data, $slider_args); return $output; }