<?php

class Intense_Siblings extends Intense_Shortcode {

	function __construct() {
        parent::__construct();

		global $intense_visions_options;
		global $post;

		$this->title = __( 'Siblings', 'intense' );
		$this->description = __( 'Add a list of sibling pages using the siblings shortcode. Sibling pages are pages that have the same parent WordPress page. Choose how deep to go when listing sibling pages. You can se the title to show at the top of the list. Also set the parent to start from or use the current page.', 'intense' );
		$this->category = __( 'Elements', 'intense' );
		$this->show_preview = true;
	}

	function shortcode( $atts, $content = null ) {
		global $intense_visions_options;
		extract( shortcode_atts( $this->get_shortcode_defaults( null, $atts ), $atts ) );

		global $post;

		$walker = new Intense_List_Pages_Walker();

		if ( empty( $parent ) && isset( $post) ) {			
			$parent = $post->post_parent;
		}

		if ( empty( $post_type ) ) {
			$post_type = $post->post_type;
		}

 		$pages = wp_list_pages( array(
			'authors'      => '',
			'child_of'     => !empty( $parent ) ? $parent : 0,
			'date_format'  => get_option('date_format'),
			'depth'        => !empty( $depth ) ? $depth : 0,
			'echo'         => 0,
			'exclude'      => $parent,
			'include'      => '',
			'link_after'   => '',
			'link_before'  => '',
			'post_type'    => $post_type,
			'post_status'  => 'publish',
			'show_date'    => '',
			'sort_column'  => 'menu_order, post_title',
			'title_li'     => $title,
			'walker' => $walker,
			'template' => $template,
			'template_path' => '/siblings/'
		) );
		
 		if ( empty( $id ) ) $id = "siblings_" . rand();

		return '<ul id="' . $id . '" class="intense siblings' . ( !empty( $class ) ? ' ' . $class : '' ) . '">' . $pages . '</ul>';
	}
}
