Location: PHPKode > scripts > Photospace Gallery > photospace theme download/photospace/functions.php
<?php

// Photospace options

class photospace_options {

	function getOptions() {
		$options = get_option('pb_options');
		
		if (!is_array($options)) {
			
			$options['theme'] = 1;
			
			$options['show_captions'] = 1;	
			
			$options['caption_space'] = '40';
			
			$options['use_logo'] = true;
			
			$options['use_dropdown'] = false;
			
			$options['num_thumb'] = '8';		
			
			$options['thumbnail_width'] = 80;
			$options['thumbnail_height'] = 80;
			$options['thumbnail_crop_ratio'] = '1:1';	
			
			
			$options['category_post_id'] = '';
			$options['news_post_id'] = '';
		
			$options['author'] = false;
		
			$options['exclude_pages'] = '';
			
			update_option('pb_options', $options);
		}
		return $options;
	}

	function update() {
		if(isset($_POST['pb_save'])) {
			$options = photospace_options::getOptions();
			
			if ($_POST['theme'] == 1) {
				$options['theme'] = 1;
			} else {
				$options['theme'] = 2;
			}
			

			if ($_POST['use_logo']) {
				$options['use_logo'] = (bool)true;
			} else {
				$options['use_logo'] = (bool)false;
			}
			
			if ($_POST['show_captions']) {
				$options['show_captions'] = (bool)true;
			} else {
				$options['show_captions'] = (bool)false;
			}			
			
			$options['caption_space'] = stripslashes($_POST['caption_space']);			
			
			$options['num_thumb'] = stripslashes($_POST['num_thumb']);			
			$options['thumbnail_width'] = stripslashes($_POST['thumbnail_width']);
			$options['thumbnail_height'] = stripslashes($_POST['thumbnail_height']);			
			$options['thumbnail_crop_ratio'] = stripslashes($_POST['thumbnail_crop_ratio']);
			
			if ($_POST['use_dropdown']) {
				$options['use_dropdown'] = (bool)true;
			} else {
				$options['use_dropdown'] = (bool)false;
			}		
			
			$options['category_post_id'] = stripslashes($_POST['category_post_id']);			
			$options['news_post_id'] = stripslashes($_POST['news_post_id']);
			
			$options['exclude_pages'] = stripslashes($_POST['exclude_pages']);

			if ($_POST['author']) {
				$options['author'] = (bool)true;
			} else {
				$options['author'] = (bool)false;
			}

			$options['page_navi_type'] = stripslashes($_POST['page_navi_type']);		

			update_option('pb_options', $options);

		} else {
			photospace_options::getOptions();
		}

		add_theme_page('Photospace options', 'Photospace Theme Options', 'edit_themes', basename(__FILE__), array('photospace_options', 'display'));
	}

	function display() {
		$options = photospace_options::getOptions();
		
		?>
		
		<div class="wrap">
		
			<h2>Photospace Options</h2>
			
			<form method="post" action="#" enctype="multipart/form-data">
			
				<h3>Choose your theme</h3>
				<p>
				<input name="theme" type="radio" value="1" <?php if($options['theme'] == 1) echo "checked='checked'"; ?> /> Use white theme <br />
				<input name="theme" type="radio" value="2" <?php if($options['theme'] == 2) echo "checked='checked'"; ?> /> Use black theme
				</p>
				<br />
				
				<h3>Show captions?</h3>
				<p><input name="show_captions" type="checkbox" value="checkbox" <?php if($options['show_captions']) echo "checked='checked'"; ?> /> Yes </p>
				<br />
				
				<h3>Space for captions</h3>
				<p><input type="text" name="caption_space" value="<?php echo($options['caption_space']); ?>" /></p>
				<br />
				
				
				<h3>Number of thumbnails in gallery</h3>
				<p><input type="text" name="num_thumb" value="<?php echo($options['num_thumb']); ?>" /></p>
				<br />
				
				
				<h3>Use the portfolio dropdown selector</h3>
				<p><input name="use_dropdown" type="checkbox" value="checkbox" <?php if($options['use_dropdown']) echo "checked='checked'"; ?> /> Yes </p>
				<br />
				
				<h3>Thumbnail Width</h3>
				<p><input type="text" name="thumbnail_width" value="<?php echo($options['thumbnail_width']); ?>" /></p>
				<br />
				
				<h3>Thumbnail Height</h3>
				<p><input type="text" name="thumbnail_height" value="<?php echo($options['thumbnail_height']); ?>" /></p>
				<br />
				
				<h3>Crop Ratio</h3>
				<p><input type="text" name="thumbnail_crop_ratio" value="<?php echo($options['thumbnail_crop_ratio']); ?>" /></p>
				<br />
				
				<h3>Portfolio category post ID</h3>
				<p><input type="text" name="category_post_id" value="<?php echo($options['category_post_id']); ?>" /></p>
				<br />
				
				<h3>Blog / News category post ID</h3>
				<p><input type="text" name="news_post_id" value="<?php echo($options['news_post_id']); ?>" /></p>
				<br />
				
				<h3>Select if you would like to use an image for your logo (should be less than 70px high)</h3>
				<p>	Replace your original image with photospace / img / logo.png </p>	
				
				<p>
				<input name="use_logo" type="checkbox" value="checkbox" <?php if($options['use_logo']) echo "checked='checked'"; ?> /> Yes <br />
				</p>
				<br />
				
				<h3>Exclude Pages</h3>
				<p>	(Page ID's that you don't want displayed in your main navigation. Use a comma-delimited list, eg. 1,2,3)</p>
				<p><input type="text" name="exclude_pages" value="<?php echo($options['exclude_pages']); ?>" /></p>
				<br />
				
				<h3>Page navi type</h3>
				<p>
				<input name="page_navi_type" type="radio" value="pager" <?php if($options['page_navi_type'] != 'normal') echo "checked='checked'"; ?> /> Use Pager. <br />
				<input name="page_navi_type" type="radio" value="normal" <?php if($options['page_navi_type'] == 'normal') echo "checked='checked'"; ?> /> Use normal style next-previous link.
				</p>
				<br />
				
				<h3>Show author</h3>
				<p><input name="author" type="checkbox" value="checkbox" <?php if($options['author']) echo "checked='checked'"; ?> /> <?php _e('Yes', 'piano-black'); ?></p>
				<br />
				
				<p><input class="button-primary" type="submit" name="pb_save" value="Save Changes" /></p>
			
			</form>
	
		</div>

		<?php
	}
}


function getOption($option) {
    global $mytheme;
    return $mytheme->option[$option];
}


// register functions
add_action('admin_menu', array('photospace_options', 'update'));


// Sidebar widget
if ( function_exists('register_sidebar') ) {
    register_sidebar(array(
        'before_widget' => '<div class="side-box" id="%1$s">'."\n",
        'after_widget' => "</div>\n",
        'before_title' => '<h3 class="side-title">',
        'after_title' => "</h3>\n",
        'name' => 'page side column'
    ));

	
	register_sidebar(array(
        'before_widget' => '<div class="side-box" id="%1$s">'."\n",
        'after_widget' => "</div>\n",
        'before_title' => '<h3 class="side-title">',
        'after_title' => "</h3>\n",
        'name' => 'blog side column'
    ));
		
    register_sidebar(array(
        'before_widget' => '<div class="footer-box" id="%1$s">'."\n",
        'after_widget' => "</div>\n",
        'before_title' => '<h3 class="side-title">',
        'after_title' => "</h3>\n",
        'name' => 'footer left'
    ));
	
    register_sidebar(array(
        'before_widget' => '<div class="footer-box" id="%1$s">'."\n",
        'after_widget' => "</div>\n",
        'before_title' => '<h3 class="side-title">',
        'after_title' => "</h3>\n",
        'name' => 'footer right'
    ));
	
	register_sidebar(array(
        'before_widget' => '<div class="contact_form" id="%1$s">'."\n",
        'after_widget' => "</div>\n",
        'before_title' => '<h2>',
        'after_title' => "</h2><p></p>\n",
        'name' => 'contact form'
    ));
   
}

if (function_exists('wp_list_comments')) {
	
	add_filter('get_comments_number', 'comment_count', 0);
	function comment_count( $commentcount ) {
		global $id;
		$_commnets = get_comments('post_id=' . $id);
		$comments_by_type = &separate_comments($_commnets);
		return count($comments_by_type['comment']);
	}
}

function custom_comments($comment, $args, $depth) {
	$GLOBALS['comment'] = $comment;
	global $commentcount;
	if(!$commentcount) {
		$commentcount = 0;
	}
?>

	<li class="comment <?php if($comment->comment_author_email == get_the_author_email()) {echo 'admin-comment';} else {echo 'guest-comment';} ?>" id="comment-<?php comment_ID() ?>">
	
	<div class="comment-meta">
		<div class="comment-meta-left clearfix">
			<?php if (function_exists('get_avatar') && get_option('show_avatars')) { echo get_avatar($comment, 35); } ?>
			
			<ul class="comment-name-date">
				<li class="comment-name">
				<?php if (get_comment_author_url()) : ?>
				<a id="commentauthor-<?php comment_ID() ?>" class="url <?php if($comment->comment_author_email == get_the_author_email()) {echo 'admin-url';} else {echo 'guest-url';} ?>" href="<?php comment_author_url() ?>" rel="external nofollow">
				<?php else : ?>
				<span id="commentauthor-<?php comment_ID(); ?>" >
				<?php endif; ?>
				
				<?php comment_author(); ?>
				
				<?php if(get_comment_author_url()) : ?>
				</a>
				<?php else : ?>
				</span> 
				<?php endif; ?>
				</li>
				<li class="comment-date"><?php echo get_comment_time('F jS, Y'); ?></li>
			</ul>
		</div>
		
		<ul class="comment-act">
			<?php if (function_exists('comment_reply_link')) { 
			if ( get_option('thread_comments') == '1' ) { ?>
			<li class="comment-reply"><?php comment_reply_link(array_merge( $args, array('add_below' => 'comment-content', 'depth' => $depth, 'max_depth' => $args['max_depth'], 'reply_text' => '<span><span> REPLY </span></span>' . $my_comment_count))) ?></li>
			<?php   } else { ?>
			<li class="comment-reply"><a href="javascript:void(0);" onclick="MGJS_CMT.reply('commentauthor-<?php comment_ID() ?>', 'comment-<?php comment_ID() ?>', 'comment');">REPLY </a></li>
			<?php   }
			} else { ?>
			<li class="comment-reply"><a href="javascript:void(0);" onclick="MGJS_CMT.reply('commentauthor-<?php comment_ID() ?>', 'comment-<?php comment_ID() ?>', 'comment');">REPLY </a></li>
			<?php } ?>
			<li class="comment-quote"><a href="javascript:void(0);" onclick="MGJS_CMT.quote('commentauthor-<?php comment_ID() ?>', 'comment-<?php comment_ID() ?>', 'comment-content-<?php comment_ID() ?>', 'comment');">QUOTE </a></li>
			<?php edit_comment_link('EDIT', '<li class="comment-edit">', '</li>'); ?>
		</ul>
		
	</div>
	
	
	<div class="comment-content" id="comment-content-<?php comment_ID() ?>">
		<?php if ($comment->comment_approved == '0') : ?>
		<span class="comment-note">Your comment is awaiting moderation.</span>
		<?php endif; ?>
		<?php comment_text(); ?>
	</div>
	
	<?php } ?>
Return current item: Photospace Gallery