function smooth_slider_wpmu_carousel_posts($max_posts, $offset = 0) { global $smooth_slider; global $wpdb, $table_prefix, $blog_id; $html = ''; $smooth_sldr_k = 0; $blogs = $wpdb->get_results($wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs} WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered ASC", $wpdb->siteid), ARRAY_A); foreach ($blogs as $details) { switch_to_blog($details['blog_id']); global $table_prefix; $table_name = $table_prefix . SLIDER_TABLE; $post_table = $table_prefix . "posts"; if (smooth_slider_table_exists($table_name, DB_NAME)) { $myposts = $wpdb->get_results("SELECT a.post_id, a.date FROM \r\r\n\t {$table_name} a LEFT OUTER JOIN {$post_table} b \r\r\n\t\t\t\t\t\t\t\t ON a.post_id = b.ID \r\r\n\t\t\t\t\t\t\t\t WHERE b.post_status = 'publish' OR (b.post_type='attachment' AND b.post_status = 'inherit') \r\r\n\t ORDER BY a.slide_order ASC, a.date DESC LIMIT {$offset}, {$max_posts}", OBJECT); foreach ($myposts as $mypost) { $posts_table = $table_prefix . "posts"; $id = $mypost->post_id; $post = $wpdb->get_row("SELECT * FROM {$posts_table} WHERE ID = {$id}", OBJECT); $post_title = stripslashes($post->post_title); $post_title = str_replace('"', '', $post_title); $slider_content = $post->post_content; // $permalink = get_permalink($post->ID); $post_id = $post->ID; //2.1 changes start $slide_redirect_url = get_post_meta($post_id, 'slide_redirect_url', true); $sslider_nolink = get_post_meta($post_id, 'sslider_nolink', true); trim($slide_redirect_url); if (!empty($slide_redirect_url) and isset($slide_redirect_url)) { $permalink = $slide_redirect_url; } else { $permalink = get_permalink($post_id); } if ($sslider_nolink == '1') { $permalink = ''; } //2.1 changes end $smooth_sldr_k++; $html .= '<div class="smooth_slideri"> <!-- smooth_slideri -->'; $thumbnail = get_post_meta($post_id, 'slider_thumbnail', true); $image_control = get_post_meta($post_id, 'slider_image_control', true); if ($smooth_slider['content_from'] == "slider_content") { $slider_content = get_post_meta($post_id, 'slider_content', true); } if ($smooth_slider['content_from'] == "excerpt") { $slider_content = $post->post_excerpt; } $slider_content = stripslashes($slider_content); $slider_content = str_replace(']]>', ']]>', $slider_content); $slider_content = str_replace("\n", "<br />", $slider_content); $slider_content = strip_tags($slider_content, $smooth_slider['allowable_tags']); if ($smooth_slider['img_pick'][0] == '1') { $custom_key = array($smooth_slider['img_pick'][0]); } else { $custom_key = ''; } if ($smooth_slider['img_pick'][2] == '1') { $the_post_thumbnail = true; } else { $the_post_thumbnail = false; } if ($smooth_slider['img_pick'][3] == '1') { $attachment = true; $order_of_image = $smooth_slider['img_pick'][4]; } else { $attachment = false; $order_of_image = '1'; } if ($smooth_slider['img_pick'][5] == '1') { $image_scan = true; } else { $image_scan = false; } if ($smooth_slider['img_size'] == '1') { $gti_width = false; } else { $gti_width = $smooth_slider['img_width']; } if ($smooth_slider['crop'] == '0') { $extract_size = 'full'; } elseif ($smooth_slider['crop'] == '1') { $extract_size = 'large'; } elseif ($smooth_slider['crop'] == '2') { $extract_size = 'medium'; } else { $extract_size = 'thumbnail'; } $img_args = array('custom_key' => $custom_key, 'attachment' => $attachment, 'size' => $extract_size, 'the_post_thumbnail' => $the_post_thumbnail, 'default_image' => false, 'order_of_image' => $order_of_image, 'link_to_post' => false, 'image_class' => 'smooth_slider_thumbnail', 'image_scan' => $image_scan, 'width' => $gti_width, 'height' => false, 'echo' => false, 'permalink' => $permalink); $html .= sslider_get_the_image($img_args); if (!$smooth_slider['content_limit'] or $smooth_slider['content_limit'] == '' or $smooth_slider['content_limit'] == ' ') { $slider_excerpt = substr($slider_content, 0, $smooth_slider['content_chars']); } else { $slider_excerpt = smooth_slider_word_limiter($slider_content, $limit = $smooth_slider['content_limit']); } if ($smooth_slider['image_only'] == '1') { $html .= '<!-- /smooth_slideri --> </div>'; } else { if ($permalink != '') { $html .= '<h2 ><a href="' . $permalink . '">' . $post_title . '</a></h2><span> ' . $slider_excerpt . '</span> <p class="more"><a href="' . $permalink . '">' . $smooth_slider['more'] . '</a></p> <!-- /smooth_slideri --> </div>'; } else { $html .= '<h2 >' . $post_title . '</h2><span> ' . $slider_excerpt . '</span> <!-- /smooth_slideri --> </div>'; } } if ($smooth_sldr_k >= $max_posts) { break; } } if ($smooth_sldr_k >= $max_posts) { break; } } //smooth slider table exists } restore_current_blog(); echo $html; return $smooth_sldr_k; }
function smooth_global_posts_processor( $posts, $smooth_slider,$out_echo ){ global $smooth_slider; $smooth_slider_css = smooth_get_inline_css(); $html = ''; $smooth_sldr_j = 0; foreach($posts as $post) { $post_id = $post->ID; $post_title = stripslashes($post->post_title); $post_title = str_replace('"', '', $post_title); //filter hook $post_title=apply_filters('smooth_post_title',$post_title,$post_id,$smooth_slider,$smooth_slider_css); $slider_content = $post->post_content; //2.1 changes start $slide_redirect_url = get_post_meta($post_id, 'slide_redirect_url', true); $sslider_nolink = get_post_meta($post_id,'sslider_nolink',true); trim($slide_redirect_url); if(!empty($slide_redirect_url) and isset($slide_redirect_url)) { $permalink = $slide_redirect_url; } else{ $permalink = get_permalink($post_id); } if($sslider_nolink=='1'){ $permalink=''; } //filter hook $permalink=apply_filters('smooth_permalink',$permalink,$post_id,$smooth_slider,$smooth_slider_css); //2.1 changes end $smooth_sldr_j++; $html .= '<div class="smooth_slideri" '.$smooth_slider_css['smooth_slideri'].'> <!-- smooth_slideri -->'; $thumbnail = get_post_meta($post_id, $smooth_slider['img_pick'][1], true); //$image_control = get_post_meta($post_id, 'slider_image_control', true); if ($smooth_slider['content_from'] == "slider_content") { $slider_content = get_post_meta($post_id, 'slider_content', true); } if ($smooth_slider['content_from'] == "excerpt") { $slider_content = $post->post_excerpt; } $slider_content = strip_shortcodes( $slider_content ); $slider_content = stripslashes($slider_content); $slider_content = str_replace(']]>', ']]>', $slider_content); $slider_content = str_replace("\n","<br />",$slider_content); $slider_content = strip_tags($slider_content, $smooth_slider['allowable_tags']); //filter hook $slider_content=apply_filters('smooth_slide_excerpt',$slider_content,$post_id,$smooth_slider,$smooth_slider_css); if($smooth_slider['img_pick'][0] == '1'){ $custom_key = array($smooth_slider['img_pick'][1]); } else { $custom_key = ''; } if($smooth_slider['img_pick'][2] == '1'){ $the_post_thumbnail = true; } else { $the_post_thumbnail = false; } if($smooth_slider['img_pick'][3] == '1'){ $attachment = true; $order_of_image = $smooth_slider['img_pick'][4]; } else{ $attachment = false; $order_of_image = '1'; } if($smooth_slider['img_pick'][5] == '1'){ $image_scan = true; } else { $image_scan = false; } if($smooth_slider['img_size'] == '1'){ $gti_width = $smooth_slider['img_width']; } else { $gti_width = false; } if($smooth_slider['crop'] == '0'){ $extract_size = 'full'; } elseif($smooth_slider['crop'] == '1'){ $extract_size = 'large'; } elseif($smooth_slider['crop'] == '2'){ $extract_size = 'medium'; } else{ $extract_size = 'thumbnail'; } $img_args = array( 'custom_key' => $custom_key, 'post_id' => $post_id, 'attachment' => $attachment, 'size' => $extract_size, 'the_post_thumbnail' => $the_post_thumbnail, 'default_image' => false, 'order_of_image' => $order_of_image, 'link_to_post' => false, 'image_class' => 'smooth_slider_thumbnail', 'image_scan' => $image_scan, 'width' => $gti_width, 'height' => false, 'echo' => false, 'permalink' => $permalink, 'style'=> $smooth_slider_css['smooth_slider_thumbnail'] ); $smooth_slide_image=smooth_sslider_get_the_image($img_args); //filter hook $smooth_slide_image=apply_filters('smooth_slide_image',$smooth_slide_image,$post_id,$smooth_slider,$smooth_slider_css); $html .= $smooth_slide_image; if(!$smooth_slider['content_limit'] or $smooth_slider['content_limit'] == '' or $smooth_slider['content_limit'] == ' ') $slider_excerpt = substr($slider_content,0,$smooth_slider['content_chars']); else $slider_excerpt = smooth_slider_word_limiter( $slider_content, $limit = $smooth_slider['content_limit'] ); if ($smooth_slider['image_only'] == '1') { $html .= '<!-- /smooth_slideri --> </div>'; } else { if($permalink!='') { $html .= '<h2 '.$smooth_slider_css['smooth_slider_h2'].'><a '.$smooth_slider_css['smooth_slider_h2_a'].' href="'.$permalink.'">'.$post_title.'</a></h2><span '.$smooth_slider_css['smooth_slider_span'].'> '.$slider_excerpt.'</span> <p class="smooth_more"><a href="'.$permalink.'" '.$smooth_slider_css['smooth_slider_p_more'].'>'.$smooth_slider['more'].'</a></p> <!-- /smooth_slideri --> </div>'; } else{ $html .= '<h2 '.$smooth_slider_css['smooth_slider_h2'].'>'.$post_title.'</h2><span '.$smooth_slider_css['smooth_slider_span'].'> '.$slider_excerpt.'</span> <!-- /smooth_slideri --> </div>'; } } } if($out_echo == '1') { echo $html; } $r_array = array( $smooth_sldr_j, $html); $r_array=apply_filters('smooth_r_array',$r_array,$posts, $smooth_slider); return $r_array; }
function smooth_data_processor_default($slides, $smooth_slider, $out_echo) { $skin = 'default'; global $smooth_slider, $data, $default_slider; $smooth_slider_css = smooth_get_inline_css(); $html = ''; $smooth_sldr_j = 0; $i = 0; if (is_array($data)) { extract($data, EXTR_PREFIX_ALL, 'data'); } foreach ($default_slider as $key => $value) { if (!isset($smooth_slider[$key])) { $smooth_slider[$key] = ''; } } $slider_handle = ''; if (!empty($data_slider_handle)) { $slider_handle = $data_slider_handle; } foreach ($slides as $slide) { $id = $post_id = ''; if (isset($slide->ID)) { $id = $post_id = $slide->ID; } $post_title = stripslashes($slide->post_title); $post_title = str_replace('"', '', $post_title); //filter hook if (isset($id)) { $post_title = apply_filters('smooth_post_title', $post_title, $id, $smooth_slider, $smooth_slider_css); } $slider_content = $slide->post_content; $smooth_slide_redirect_url = $slide->redirect_url; $smooth_sslider_nolink = $slide->nolink; trim($smooth_slide_redirect_url); if (!empty($smooth_slide_redirect_url) and isset($smooth_slide_redirect_url)) { $permalink = $smooth_slide_redirect_url; } else { $permalink = $slide->url; } if ($smooth_sslider_nolink == '1') { $permalink = ''; } $smooth_sldr_j++; $html .= '<div class="smooth_slideri" ' . $smooth_slider_css['smooth_slideri'] . '> <!-- smooth_slideri -->'; if ($smooth_slider['content_from'] == "slider_content") { $slider_content = $slide->post_content; } if ($smooth_slider['content_from'] == "excerpt") { $slider_content = $slide->post_excerpt; } $slider_content = stripslashes($slider_content); $slider_content = str_replace(']]>', ']]>', $slider_content); $slider_content = str_replace("\n", "<br />", $slider_content); $slider_content = strip_tags($slider_content, $smooth_slider['allowable_tags']); $content_limit = $smooth_slider['content_limit']; $content_chars = $smooth_slider['content_chars']; if (empty($content_limit) && !empty($content_chars)) { $slider_excerpt = substr($slider_content, 0, $content_chars); } else { $slider_excerpt = smooth_slider_word_limiter($slider_content, $limit = $content_limit); } if (!isset($slider_excerpt)) { $slider_excerpt = ''; } $slider_excerpt = apply_filters('smooth_slide_excerpt', $slider_excerpt, $post_id, $smooth_slider, $smooth_slider_css); $slider_excerpt = '<span ' . $smooth_slider_css['smooth_slider_span'] . '> ' . $slider_excerpt . '</span>'; //filter hook $slider_excerpt = apply_filters('smooth_slide_excerpt_html', $slider_excerpt, $post_id, $smooth_slider, $smooth_slider_css); //For media images if (isset($slide->media)) { $smooth_media = $slide->media; } if (isset($slide->media_image)) { $smooth_media_image = $slide->media_image; } $data_image_class = !empty($data_image_class) ? $data_image_class : ''; $data_default_image = !empty($data_default_image) ? $data_default_image : ''; if ((empty($smooth_media) or $smooth_media == '' or !$smooth_media) and (empty($smooth_media_image) or $smooth_media_image == '' or !$smooth_media_image) or $data_media != '1') { $width = $smooth_slider['img_width']; $height = $smooth_slider['img_height']; if ($smooth_slider['crop'] == '0') { $extract_size = 'full'; } elseif ($smooth_slider['crop'] == '1') { $extract_size = 'large'; } elseif ($smooth_slider['crop'] == '2') { $extract_size = 'medium'; } else { $extract_size = 'thumbnail'; } $classes[] = $extract_size; $classes[] = 'smooth_slider_thumbnail'; $classes[] = $data_image_class; $class = join(' ', array_unique($classes)); preg_match_all('|<img.*?src=[\'"](.*?)[\'"].*?>|i', $slide->content_for_image, $matches); $img_url = $data_default_image; /* If there is a match for the image, return its URL. */ $order_of_image = ''; if (isset($data_order)) { $order_of_image = $data_order; } if ($order_of_image > 0) { $order_of_image = $order_of_image; } else { $order_of_image = 0; } if (isset($matches) && count($matches[1]) <= $order_of_image) { $order_of_image = count($matches[1]); } if (isset($matches) && $matches[1][$order_of_image]) { $img_url = $matches[1][$order_of_image]; } $width = $width ? ' width="' . esc_attr($width) . '"' : ''; $height = $height ? ' height="' . esc_attr($height) . '"' : ''; $img_html = '<img src="' . $img_url . '" class="' . esc_attr($class) . '"' . $width . $height . $smooth_slider_css['smooth_slider_thumbnail'] . ' />'; $smooth_large_image = $img_html; } else { $width = $smooth_slider['img_width']; $height = $smooth_slider['img_height']; $width = $width ? ' width="' . esc_attr($width) . '"' : ''; $height = $height ? ' height="' . esc_attr($height) . '"' : ''; if ($smooth_slider['crop'] == '0') { $extract_size = 'full'; } elseif ($smooth_slider['crop'] == '1') { $extract_size = 'large'; } elseif ($smooth_slider['crop'] == '2') { $extract_size = 'medium'; } else { $extract_size = 'thumbnail'; } $classes[] = $extract_size; $classes[] = 'smooth_slider_thumbnail'; $classes[] = $data_image_class; $class = join(' ', array_unique($classes)); if (!empty($smooth_media_image)) { $smooth_large_image = '<img src="' . $smooth_media_image . '" class="' . esc_attr($class) . '"' . $width . $height . '/>'; $img_url = $smooth_media_image; } else { $smooth_large_image = '<img src="' . $data_default_image . '" class="' . esc_attr($class) . '"' . $width . $height . '/>'; $img_url = $data_default_image; } } if ($permalink != '') { $smooth_large_image = '<a href="' . $permalink . '" title="' . $post_title . '">' . $smooth_large_image . '</a>'; } //filter hook $smooth_large_image = apply_filters('smooth_large_image', $smooth_large_image, $post_id, $smooth_slider, $smooth_slider_css); $html .= $smooth_large_image; if ($smooth_slider['image_only'] == '1') { $html .= '<!-- /smooth_slideri --> </div>'; } else { if ($permalink != '') { $html .= '<h2 ' . $smooth_slider_css['smooth_slider_h2'] . '><a ' . $smooth_slider_css['smooth_slider_h2_a'] . ' href="' . $permalink . '">' . $post_title . '</a></h2><span ' . $smooth_slider_css['smooth_slider_span'] . '> ' . $slider_excerpt . '</span> <p class="smooth_more"><a href="' . $permalink . '" ' . $smooth_slider_css['smooth_slider_p_more'] . '>' . $smooth_slider['more'] . '</a></p> <!-- /smooth_slideri --> </div>'; } else { $html .= '<h2 ' . $smooth_slider_css['smooth_slider_h2'] . '>' . $post_title . '</h2><span ' . $smooth_slider_css['smooth_slider_span'] . '> ' . $slider_excerpt . '</span> <!-- /smooth_slideri --> </div>'; } } } if ($out_echo == '1') { echo $html; } $r_array = array($smooth_sldr_j, $html); $r_array = apply_filters('smooth_r_array', $r_array, $slides, $smooth_slider); return $r_array; }
function carousel_posts_on_slider_category($max_posts = '5', $catg_slug = '', $offset = 0, $out_echo = '1') { global $smooth_slider; global $wpdb, $table_prefix; if (!empty($catg_slug)) { $category = get_category_by_slug($catg_slug); $slider_cat = $category->term_id; } else { $category = get_the_category(); $slider_cat = $category[0]->cat_ID; } $posts = get_posts('numberposts=' . $max_posts . '&offset=' . $offset . '&category=' . $slider_cat); $html = ''; $smooth_sldr_a = 0; foreach ($posts as $post) { $id = $post->ID; $post_title = stripslashes($post->post_title); $post_title = str_replace('"', '', $post_title); $slider_content = $post->post_content; //2.3 changes // $permalink = get_permalink($post->ID); $post_id = $post->ID; //2.1 changes start $slide_redirect_url = get_post_meta($post_id, 'slide_redirect_url', true); $sslider_nolink = get_post_meta($post_id, 'sslider_nolink', true); trim($slide_redirect_url); if (!empty($slide_redirect_url) and isset($slide_redirect_url)) { $permalink = $slide_redirect_url; } else { $permalink = get_permalink($post_id); } if ($sslider_nolink == '1') { $permalink = ''; } //2.1 changes end $smooth_sldr_a++; $html .= '<li class="smooth_slideri"><div> <!-- smooth_slideri -->'; $thumbnail = get_post_meta($post_id, $smooth_slider['img_pick'][1], true); //$image_control = get_post_meta($post_id, 'slider_image_control', true); if ($smooth_slider['content_from'] == "slider_content") { $slider_content = get_post_meta($post_id, 'slider_content', true); } if ($smooth_slider['content_from'] == "excerpt") { $slider_content = $post->post_excerpt; } $slider_content = strip_shortcodes($slider_content); $slider_content = stripslashes($slider_content); $slider_content = str_replace(']]>', ']]>', $slider_content); $slider_content = str_replace("\n", "<br />", $slider_content); $slider_content = strip_tags($slider_content, $smooth_slider['allowable_tags']); if ($smooth_slider['img_pick'][0] == '1') { $custom_key = array($smooth_slider['img_pick'][1]); } else { $custom_key = ''; } if ($smooth_slider['img_pick'][2] == '1') { $the_post_thumbnail = true; } else { $the_post_thumbnail = false; } if ($smooth_slider['img_pick'][3] == '1') { $attachment = true; $order_of_image = $smooth_slider['img_pick'][4]; } else { $attachment = false; $order_of_image = '1'; } if ($smooth_slider['img_pick'][5] == '1') { $image_scan = true; } else { $image_scan = false; } if ($smooth_slider['img_size'] == '1') { $gti_width = $smooth_slider['img_width']; } else { $gti_width = false; } if ($smooth_slider['crop'] == '0') { $extract_size = 'full'; } elseif ($smooth_slider['crop'] == '1') { $extract_size = 'large'; } elseif ($smooth_slider['crop'] == '2') { $extract_size = 'medium'; } else { $extract_size = 'thumbnail'; } $img_args = array('custom_key' => $custom_key, 'post_id' => $post_id, 'attachment' => $attachment, 'size' => $extract_size, 'the_post_thumbnail' => $the_post_thumbnail, 'default_image' => false, 'order_of_image' => $order_of_image, 'link_to_post' => false, 'image_class' => 'smooth_slider_thumbnail', 'image_scan' => $image_scan, 'width' => $gti_width, 'height' => false, 'echo' => false, 'permalink' => $permalink); $html .= sslider_get_the_image($img_args); if (!$smooth_slider['content_limit'] or $smooth_slider['content_limit'] == '' or $smooth_slider['content_limit'] == ' ') { $slider_excerpt = substr($slider_content, 0, $smooth_slider['content_chars']); } else { $slider_excerpt = smooth_slider_word_limiter($slider_content, $limit = $smooth_slider['content_limit']); } if ($smooth_slider['image_only'] == '1') { $html .= '<!-- /smooth_slideri --> </div></li>'; } else { if ($permalink != '') { $html .= '<h2 ><a href="' . $permalink . '">' . $post_title . '</a></h2><span> ' . $slider_excerpt . '</span> <p class="more"><a href="' . $permalink . '">' . $smooth_slider['more'] . '</a></p> <!-- /smooth_slideri --> </div></li>'; } else { $html .= '<h2 >' . $post_title . '</h2><span> ' . $slider_excerpt . '</span> <!-- /smooth_slideri --> </div></li>'; } } } if ($out_echo == '1') { echo $html; } $r_array = array($smooth_sldr_a, $html); return $r_array; }