????

Your IP : 216.73.216.174


Current Path : /home2/morganrand/www/wp-content/plugins/pinwheel-slider/includes/addons/
Upload File :
Current File : /home2/morganrand/www/wp-content/plugins/pinwheel-slider/includes/addons/attachments.php

<?php /* Post Attachments Template tag and Shortcode */
//For displaying all the attachments of a particular post in Pinwheel Slider
function pinwheel_carousel_posts_on_slider_attachments($max_posts='5', $offset=0, $out_echo = '1', $set='',$id,$data=array() ) {
	$r_array=array();
	$default_pinwheel_slider_settings=get_pinwheel_slider_default_settings();
	$pinwheel_slider_options='pinwheel_slider_options'.$set;
	$pinwheel_slider_curr=get_option($pinwheel_slider_options);
	$pinwheel_slider = get_option('pinwheel_slider_options');
	if(!isset($pinwheel_slider_curr) or !is_array($pinwheel_slider_curr) or empty($pinwheel_slider_curr)){$pinwheel_slider_curr=$pinwheel_slider;$set='';}
	$pinwheel_slider_curr = populate_pinwheel_current($pinwheel_slider_curr);
		
	global $wpdb, $table_prefix;
	
	$rand = $pinwheel_slider_curr['rand'];
	if(isset($rand) and $rand=='1'){
	  $orderby = '&orderby=rand';
	}
	else {
	  $orderby = 'menu_order ID';
	}
	$args=array(
		'post_type'	=> 'attachment',
		'numberposts'	=> $max_posts,
		'offset'    	=> $offset,
		'orderby'	=> $orderby,
		'post_status'	=> null,
		'post_parent'	=> $id
		) ;
	//filter hook
	$args=apply_filters('pinwheel_svattachments_args',$args);
	$attachments = get_posts( $args	);
	foreach($attachments as $attachment){
		$attachment->slide_url=wp_get_attachment_url( $attachment->ID );
		//filter hook
		$attachment->slide_url=apply_filters('pinwheel_svattachments_slide_url',$attachment->slide_url);
	}
	$r_array=pinwheel_global_posts_processor( $attachments, $pinwheel_slider_curr, $out_echo,$set,$data );
	return $r_array;
}

function get_pinwheel_slider_attachments($args='') {
    $defaults=array('set'=>'', 'offset'=>0, 'id'=>'','data'=>array() );
	$args = wp_parse_args( $args, $defaults );
	extract( $args );
	$default_pinwheel_slider_settings=get_pinwheel_slider_default_settings();
	// If setting set is 1 then set to blank	
	if($set == '1') $set = '';
	$pinwheel_slider_options='pinwheel_slider_options'.$set;
	$pinwheel_slider_curr=get_option($pinwheel_slider_options);
	$pinwheel_slider = get_option('pinwheel_slider_options');
	if(!isset($pinwheel_slider_curr) or !is_array($pinwheel_slider_curr) or empty($pinwheel_slider_curr)){$pinwheel_slider_curr=$pinwheel_slider;$set='';}
	$pinwheel_slider_curr= populate_pinwheel_current($pinwheel_slider_curr);
	global $post;
	$id=(int) $id;
	if( empty($id) or $id==0 or !$id) $id=$post->ID;
	$slider_handle='pinwheel_slider_'.$id;
	$data['slider_handle']=$slider_handle;
	$r_array = pinwheel_carousel_posts_on_slider_attachments($pinwheel_slider_curr['no_posts'], $offset, '0', $set, $id,$data); 
	get_global_pinwheel_slider($slider_handle,$r_array,$pinwheel_slider_curr,$set,$echo='1',$data);

} 

function return_pinwheel_slider_attachments($set='', $offset=0, $id,$data=array()) {
	$slider_html='';
	$default_pinwheel_slider_settings=get_pinwheel_slider_default_settings();
	// If setting set is 1 then set to blank	
	if($set == '1') $set = ''; 
	$pinwheel_slider_options='pinwheel_slider_options'.$set;
	$pinwheel_slider_curr=get_option($pinwheel_slider_options);
	$pinwheel_slider = get_option('pinwheel_slider_options');
	if(!isset($pinwheel_slider_curr) or !is_array($pinwheel_slider_curr) or empty($pinwheel_slider_curr)){$pinwheel_slider_curr=$pinwheel_slider;$set='';}
	$pinwheel_slider_curr= populate_pinwheel_current($pinwheel_slider_curr);
	global $post;
	$id=(int) $id;
	if( empty($id) or $id==0 or !$id) $id=$post->ID;
	$slider_handle='pinwheel_slider_'.$id;
	$data['slider_handle']=$slider_handle;
	$r_array = pinwheel_carousel_posts_on_slider_attachments($pinwheel_slider_curr['no_posts'], $offset, '0', $set,$id,$data); 
	//get slider 
	$slider_html=return_global_pinwheel_slider($slider_handle,$r_array,$pinwheel_slider_curr,$set,$echo='0',$data);
	return $slider_html;
}

function pinwheel_slider_attachments_shortcode($atts) {
	extract(shortcode_atts(array(
		'set' => '',
		'offset'=>'0',
		'id'=>'',
	), $atts));

	return return_pinwheel_slider_attachments($set,$offset,$id);
}
add_shortcode('pinwheelattachments', 'pinwheel_slider_attachments_shortcode');
?>