<?php
/**
 * Plugin Name: Custom Content Type
 * Plugin URI: http://mioplugin.com
 * Description: A custom content plugin built for example
 * Version: 1.0
 * Author: Andrea Ferracani
 * Author URI: http://www.micc.unifi.it/ferracani
 */

function register_custom_post(){
	
	$args = array(
		'label' => 'Custom Post',
		'hierarchical' => false,
		'description' => 'Custom Post Type',
		'supports' => array('title', 'editor', 'custom-fields'),
		'public' => true,
		'show_ui' => true,
		'menu_icon' => 'http://placehold.it/20x20',
		'publicly_queryable' => true,
		'exclude_from_search' => false,
		'has_archive' => true,
		'query_var' => true,
		'can_export' => true,
		'rewrite' => true,
		'capability_type' => 'post'	
	);
	
	register_post_type('custom_post', $args);
}

add_action('init', 'register_custom_post');


class CustomGallery {
	
	function CustomGallery(){
		$this -> addHeadFiles();
	}
	
	function addHeadFiles(){
		wp_enqueue_script("jquery");
		wp_enqueue_script(
							"slider", 
							WP_PLUGIN_URL . "/gallery/jquery.slider.js", 
							array("jquery"),
							"1.0",
							0
						);
		wp_enqueue_script(
		"initialize",
		WP_PLUGIN_URL . "/gallery/initialize.js",
		array("slider", "jquery"),
		"1.0",
		0
		);	
		
		$initArray = array($this, "displayPostID");
		add_shortcode('custom-gallery', $initArray);
	}
	
	function displayPostID(){
		global $post;
		$postID = $post->ID;
		
		echo '<ul class="gallery">';
		
		$meta = get_post_meta($postID, 'img');
		
		for ($i = 0; $i < count($meta); $i++) {
			echo '<li><img src="' . $meta[$i] . '" /></li>';
		}
		
		echo '</ul>';
	}
	
}

$CustomGallery = new CustomGallery();

add_filter('request', 'pu_specific_post_type_custom_feed');

function pu_specific_post_type_custom_feed($vars) {
	$post_type_list = array('custom_post');
	
	if(isset($vars['feed']) AND !isset($vars['post_type'])) {
		$vars['post_type'] = $post_type_list;
	}
	
	return $vars;
}


?>