/** Update display options of the options admin page **/
function yd_rp_plugin_update_options()
{
    $to_update = array('display_ul', 'keep_html', 'strip_sqbt', 'strip_clbt', 'use_timthumb', 'timthumb_path', 'timthumb_width', 'timthumb_height', 'skip_latest', 'disable_backlink', 'use_wpthumb', 'load_css', 'default_cutlength', 'ellipsis_string', 'image_style', 'default_image');
    if (yd_update_options('widget_yd_rp', 0, $to_update, $_GET, 'yd_rp-')) {
        clear_yd_widget_cache('widget_yd_rp_home');
        clear_yd_widget_cache('widget_yd_rp_page');
        clear_yd_widget_cache('widget_yd_rp_hometemplate1');
        // TODO? Clear other pages template cache?
    }
}
/** Widget options **/
function widget_yd_rp_control($args, $vars = array())
{
    $number = $args['number'];
    if ($number < 1) {
        $number = 1;
    }
    //echo 'debug: widget number ' . $number . '<br/>';
    $options = get_option('widget_yd_rp');
    $to_update = array('home_title', 'home_tag', 'home_showposts', 'home_datemeta', 'home_bottomtext', 'home_bottomlink', 'home_d_post_thumb', 'home_d_post_title', 'home_d_post_date', 'home_d_abstract', 'home_u_wpabstract', 'home_title_cutlength', 'home_abstract_cutlength', 'home_date_format', 'home_add_query', 'same_opages', 'opage_title', 'opage_tag', 'opage_showposts', 'opage_bottomtext', 'opage_bottomlink', 'opage_d_post_thumb', 'opage_d_post_title', 'opage_d_post_date', 'opage_d_abstract', 'opage_u_wpabstract', 'opage_title_cutlength', 'opage_abstract_cutlength', 'opage_date_format', 'opage_datemeta', 'opage_add_query', 'title_cutlength', 'abstract_cutlength', 'load_css', 'image_style', 'default_image', 'display_date', 'date_format');
    if ($_POST["yd_rp-submit-{$number}"]) {
        if (yd_update_options('widget_yd_rp', $number, $to_update, $_POST, 'yd_rp-')) {
            clear_yd_widget_cache('widget_yd_rp_home');
            clear_yd_widget_cache('widget_yd_rp_page');
            clear_yd_widget_cache('widget_yd_rp_hometemplate1');
            // TODO? Clear other pages template cache?
            $options = get_option('widget_yd_rp');
        }
    }
    foreach ($to_update as $key) {
        $v[$key] = htmlspecialchars($options[$number][$key], ENT_QUOTES);
    }
    ?>
	<div style="float: right"><a
	href="http://www.yann.com/en/wp-plugins/yd-recent-posts-widget"
	title="Help!" target="_blank">?</a></div>
	
	<?php 
    // =========================== Home options ===================================
    ?>
	
	<h5><?php 
    echo __('Home page widget options:', 'yd-recent-posts-widget');
    ?>
</h5>
	<p>
		<label for="yd_rp-home_title-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Title: <em>(optional - leave blank for no title)</em>', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			class="widefat" 
			id="yd_rp-home_title-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-home_title-<?php 
    echo "{$number}";
    ?>
" 
			type="text"
			value="<?php 
    echo $v['home_title'];
    ?>
" />
	</p>
	<p>
		<label for="yd_rp-home_tag-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Only show posts with this tag:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input 
			id="yd_rp-home_tag-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-home_tag-<?php 
    echo "{$number}";
    ?>
" 
			type="text"
			size="10"
			value="<?php 
    echo $v['home_tag'];
    ?>
" />
			<em>(
			<?php 
    echo __('optional - leave blank for all', 'yd-recent-posts-widget');
    ?>
			)</em>
	</p>
	<p>
		<label for="yd_rp-home_showposts-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('# no. of posts to show:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-home_showposts-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-home_showposts-<?php 
    echo "{$number}";
    ?>
" 
			type="text"
			size = "3"
			value="<?php 
    echo $v['home_showposts'];
    ?>
" />
	</p>
	<p>
		<label for="yd_rp-home_d_post_thumb-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Display post thumbnail:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-home_d_post_thumb-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-home_d_post_thumb-<?php 
    echo "{$number}";
    ?>
"
			type="checkbox"
			value="1"
			<?php 
    if ($v['home_d_post_thumb']) {
        echo "checked=\"checked\"";
    }
    ?>
 />
	</p>		
	<p>
		<label for="yd_rp-home_d_post_title-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Display post title:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-home_d_post_title-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-home_d_post_title-<?php 
    echo "{$number}";
    ?>
"
			type="checkbox"
			value="1"
			<?php 
    if ($v['home_d_post_title']) {
        echo "checked=\"checked\"";
    }
    ?>
 />
	</p>
	<p>
		<label for="yd_rp-home_title_cutlength-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Title cut length:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-home_title_cutlength-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-home_title_cutlength-<?php 
    echo "{$number}";
    ?>
"
			type="text"
			size="3"
			value="<?php 
    echo $v['home_title_cutlength'];
    ?>
" />
		<em>(
		<?php 
    echo __('# of characters to keep. 0 = keep all.');
    ?>
		)</em>
	</p>
	<p>
		<label for="yd_rp-home_d_post_date-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Display post date:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-home_d_post_date-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-home_d_post_date-<?php 
    echo "{$number}";
    ?>
"
			type="checkbox"
			value="1"
			<?php 
    if ($v['home_d_post_date']) {
        echo "checked=\"checked\"";
    }
    ?>
 />
	</p>
	<p>
		<label for="yd_rp-home_date_format-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Date format:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-home_date_format-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-home_date_format-<?php 
    echo "{$number}";
    ?>
"
			type="text"
			size="10"
			value="<?php 
    echo $v['home_date_format'];
    ?>
" />
			<em>(
			<?php 
    echo __('Use Php date format string', 'yd-recent-posts-widget');
    ?>
			)</em>
	</p>
	<p>
		<label for="yd_rp-home_datemeta-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Display meta:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-home_datemeta-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-home_datemeta-<?php 
    echo "{$number}";
    ?>
" 
			type="text"
			size="10"
			value="<?php 
    echo $v['home_datemeta'];
    ?>
" />
			<em>(
			<?php 
    echo __('optional - additional post meta field to display', 'yd-recent-posts-widget');
    ?>
			)</em>
	</p>
	<p>
		<label for="yd_rp-home_d_abstract-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Display post excerpt:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-home_d_abstract-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-home_d_abstract-<?php 
    echo "{$number}";
    ?>
"
			type="checkbox"
			value="1"
			<?php 
    if ($v['home_d_abstract']) {
        echo "checked=\"checked\"";
    }
    ?>
 />
	</p>
	<p>
		<label for="yd_rp-home_u_wpabstract-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Use WP excerpt field:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-home_u_wpabstract-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-home_u_wpabstract-<?php 
    echo "{$number}";
    ?>
"
			type="checkbox"
			value="1"
			<?php 
    if ($v['home_u_wpabstract']) {
        echo "checked=\"checked\"";
    }
    ?>
 />
	</p>
	<p>
		<label for="yd_rp-home_abstract_cutlength-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Excerpt cut length:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-home_abstract_cutlength-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-home_abstract_cutlength-<?php 
    echo "{$number}";
    ?>
"
			type="text"
			size="3"
			value="<?php 
    echo $v['home_abstract_cutlength'];
    ?>
" />
		<em>(
			<?php 
    echo __("# of characters to keep. 0 = cut at 'more'");
    ?>
		)</em>
	</p>
	<p>
		<label for="yd_rp-home_add_query-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Additional query parameters:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-home_add_query-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-home_add_query-<?php 
    echo "{$number}";
    ?>
"
			type="text"
			size="20"
			value="<?php 
    echo $v['home_add_query'];
    ?>
" />
		<em>(
			<?php 
    echo __("optional", 'yd-recent-posts-widget');
    ?>
		)</em>
	</p>
	<p>
		<label for="yd_rp-home_bottomtext-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Bottom text:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			class="widefat"
			id="yd_rp-home_bottomtext-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-home_bottomtext-<?php 
    echo "{$number}";
    ?>
" 
			type="text"
			value="<?php 
    echo $v['home_bottomtext'];
    ?>
" />
	</p>
	<p>
		<label for="yd_rp-home_bottomlink-<?php 
    echo "{$number}";
    ?>
">
			-
			<?php 
    echo __('link:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			class="widefat"
			id="yd_rp-home_bottomlink-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-home_bottomlink-<?php 
    echo "{$number}";
    ?>
"
			type="text"
			value="<?php 
    echo $v['home_bottomlink'];
    ?>
" />
	</p>
<hr />

	<?php 
    // =========================== Pages options ===================================
    ?>
	
	<?php 
    if ($v['same_opages']) {
        $disp_opages = 'none';
        $visi_opages = 'hidden';
    } else {
        $disp_opages = 'block';
        $visi_opages = 'visible';
    }
    ?>
	<script type="text/javascript">
	function yd_toggle_opages( ck ) {
		var dv = document.getElementById( 'yd_opages_settings-<?php 
    echo $number;
    ?>
' );
		if( ck ) {
			dv.style.display = 'none';
			dv.style.visibility = 'hidden';
		} else {
			dv.style.display = 'block';
			dv.style.visibility = 'visible';
		}
	} 
	</script>
	<p>
		<label for="yd_rp-same_opages-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Same settings on other pages:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-same_opages-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-same_opages-<?php 
    echo "{$number}";
    ?>
"
			type="checkbox"
			value="1"
			onclick="yd_toggle_opages(this.checked);"
			<?php 
    if ($v['same_opages']) {
        echo "checked=\"checked\"";
    }
    ?>
 />
	</p>
	
<div id="yd_opages_settings-<?php 
    echo $number;
    ?>
" style="display:<?php 
    echo $disp_opages;
    ?>
;visibility:<?php 
    echo $visi_opages;
    ?>
;">
	<h5><?php 
    echo __('Other pages widget options:', 'yd-recent-posts-widget');
    ?>
</h5>
	<p>
		<label for="yd_rp-opage_title-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Title: <em>(optional - leave blank for no title)</em>', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			class="widefat" 
			id="yd_rp-opage_title-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-opage_title-<?php 
    echo "{$number}";
    ?>
" 
			type="text"
			value="<?php 
    echo $v['opage_title'];
    ?>
" />
	</p>
	<p>
		<label for="yd_rp-opage_tag-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Only show posts with this tag:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-opage_tag-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-opage_tag-<?php 
    echo "{$number}";
    ?>
" 
			type="text"
			size="10"
			value="<?php 
    echo $v['opage_tag'];
    ?>
" />
			<em>(
			<?php 
    echo __('optional - leave blank for all', 'yd-recent-posts-widget');
    ?>
			)</em>
	</p>
	<p>
		<label for="yd_rp-opage_showposts-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('# no. of posts to show:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-opage_showposts-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-opage_showposts-<?php 
    echo "{$number}";
    ?>
"
			type="text"
			size="3"
			value="<?php 
    echo $v['opage_showposts'];
    ?>
" />
	</p>
	<p>
		<label for="yd_rp-opage_d_post_thumb-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Display post thumbnail:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-opage_d_post_thumb-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-opage_d_post_thumb-<?php 
    echo "{$number}";
    ?>
"
			type="checkbox"
			value="1"
			<?php 
    if ($v['opage_d_post_thumb']) {
        echo "checked=\"checked\"";
    }
    ?>
 />
	</p>		
	<p>
		<label for="yd_rp-opage_d_post_title-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Display post title:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-opage_d_post_title-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-opage_d_post_title-<?php 
    echo "{$number}";
    ?>
"
			type="checkbox"
			value="1"
			<?php 
    if ($v['opage_d_post_title']) {
        echo "checked=\"checked\"";
    }
    ?>
 />
	</p>
	<p>
		<label for="yd_rp-opage_title_cutlength-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Title cut length:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-opage_title_cutlength-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-opage_title_cutlength-<?php 
    echo "{$number}";
    ?>
"
			type="text"
			size="3"
			value="<?php 
    echo $v['opage_title_cutlength'];
    ?>
" />
		<em>(
		<?php 
    echo __('# of characters to keep. 0 = keep all.');
    ?>
		)</em>
	</p>
	<p>
		<label for="yd_rp-opage_d_post_date-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Display post date:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-opage_d_post_date-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-opage_d_post_date-<?php 
    echo "{$number}";
    ?>
"
			type="checkbox"
			value="1"
			<?php 
    if ($v['opage_d_post_date']) {
        echo "checked=\"checked\"";
    }
    ?>
 />
	</p>
	<p>
		<label for="yd_rp-opage_date_format-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Date format:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-opage_date_format-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-opage_date_format-<?php 
    echo "{$number}";
    ?>
"
			type="text"
			size="10"
			value="<?php 
    echo $v['opage_date_format'];
    ?>
" />
			<em>(
			<?php 
    echo __('Use Php date format string', 'yd-recent-posts-widget');
    ?>
			)</em>
	</p>
	<p>
		<label for="yd_rp-opage_d_abstract-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Display post excerpt:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-opage_d_abstract-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-opage_d_abstract-<?php 
    echo "{$number}";
    ?>
"
			type="checkbox"
			value="1"
			<?php 
    if ($v['opage_d_abstract']) {
        echo "checked=\"checked\"";
    }
    ?>
 />
	</p>
	<p>
		<label for="yd_rp-opage_u_wpabstract-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Use WP excerpt field:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-opage_u_wpabstract-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-opage_u_wpabstract-<?php 
    echo "{$number}";
    ?>
"
			type="checkbox"
			value="1"
			<?php 
    if ($v['opage_u_wpabstract']) {
        echo "checked=\"checked\"";
    }
    ?>
 />
	</p>
	<p>
		<label for="yd_rp-opage_abstract_cutlength-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Excerpt cut length:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-opage_abstract_cutlength-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-opage_abstract_cutlength-<?php 
    echo "{$number}";
    ?>
"
			type="text"
			size="3"
			value="<?php 
    echo $v['opage_abstract_cutlength'];
    ?>
" />
		<em>(
			<?php 
    echo __("# of characters to keep. 0 = cut at 'more'");
    ?>
		)</em>
	</p>
	<p>
		<label for="yd_rp-opage_add_query-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Additional query parameters:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			id="yd_rp-opage_add_query-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-opage_add_query-<?php 
    echo "{$number}";
    ?>
"
			type="text"
			size="20"
			value="<?php 
    echo $v['opage_add_query'];
    ?>
" />
		<em>(
			<?php 
    echo __("optional", 'yd-recent-posts-widget');
    ?>
		)</em>
	</p>
	<p>
		<label for="yd_rp-opage_bottomtext-<?php 
    echo "{$number}";
    ?>
">
			<?php 
    echo __('Bottom text:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			class="widefat"
			id="yd_rp-opage_bottomtext-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-opage_bottomtext-<?php 
    echo "{$number}";
    ?>
"
			type="text"
			value="<?php 
    echo $v['opage_bottomtext'];
    ?>
" />
	</p>
	<p>
		<label for="yd_rp-opage_bottomlink-<?php 
    echo "{$number}";
    ?>
">
			-
			<?php 
    echo __('link:', 'yd-recent-posts-widget');
    ?>
		</label>
		<input
			class="widefat"
			id="yd_rp-opage_bottomlink-<?php 
    echo "{$number}";
    ?>
"
			name="yd_rp-opage_bottomlink-<?php 
    echo "{$number}";
    ?>
"
			type="text"
			value="<?php 
    echo $v['opage_bottomlink'];
    ?>
" />
	</p>
</div>

	<?php 
    /** DEPRECATED
    	// =========================== Other options (DEPRECATED) ============================= ?>
    <hr />
    	<?php echo __('Title cut length:', 'yd-recent-posts-widget') ?>
    <input style="width: 50px;"
    	id="yd_rp-title_cutlength-<?php echo "$number"; ?>"
    	name="yd_rp-title_cutlength-<?php echo "$number"; ?>" type="text"
    	value="<?php echo $v['title_cutlength']; ?>" />
    	<?php echo __('Excerpt cut length:', 'yd-recent-posts-widget') ?>
    <input style="width: 50px;"
    	id="yd_rp-abstract_cutlength-<?php echo "$number"; ?>"
    	name="yd_rp-abstract_cutlength-<?php echo "$number"; ?>" type="text"
    	value="<?php echo $v['abstract_cutlength']; ?>" />
    <br />
    	<?php /** 
    	widget-level css inclusion deprecated since plugin v.3.0.0 ** /
    	echo __('Load CSS:', 'yd-recent-posts-widget') ?>
    <input style="width: 15px;" id="yd_rp-load_css-<?php echo "$number"; ?>"
    	name="yd_rp-load_css-<?php echo "$number"; ?>" type="checkbox"
    	value="1" <?php if( $v['load_css'] ) echo "checked=\"checked\""; ?> />
    	<?php /** ** ?>
    	<?php echo __('Image CSS Style:', 'yd-recent-posts-widget') ?>
    <input style="width: 450px;"
    	id="yd_rp-image_style-<?php echo "$number"; ?>"
    	name="yd_rp-image_style-<?php echo "$number"; ?>" type="text"
    	value="<?php echo $v['image_style']; ?>" />
    <br />
    	<?php echo __('Default image URL:', 'yd-recent-posts-widget') ?>
    <input style="width: 300px;"
    	id="yd_rp-default_image-<?php echo "$number"; ?>"
    	name="yd_rp-default_image-<?php echo "$number"; ?>" type="text"
    	value="<?php echo $v['default_image']; ?>" />
    <br />
    	<?php echo __('Display date:', 'yd-recent-posts-widget') ?>
    <input style="width: 15px;"
    	id="yd_rp-display_date-<?php echo "$number"; ?>"
    	name="yd_rp-display_date-<?php echo "$number"; ?>" type="checkbox"
    	value="1" <?php if( $v['display_date'] ) echo "checked=\"checked\""; ?> />
    	<?php echo __('Date format:', 'yd-recent-posts-widget') ?>
    <input style="width: 100px;"
    	id="yd_rp-date_format-<?php echo "$number"; ?>"
    	name="yd_rp-date_format-<?php echo "$number"; ?>" type="text"
    	value="<?php echo $v['date_format']; ?>" />
    	/** **/
    ?>
<input
	type="hidden" id="yd_rp-submit-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-submit-<?php 
    echo "{$number}";
    ?>
" value="1" />
	<?php 
}
/** Widget options **/
function widget_yd_rp_control($number)
{
    $options = get_option('widget_yd_rp');
    $to_update = array('home_title', 'home_tag', 'home_showposts', 'home_datemeta', 'home_bottomtext', 'home_bottomlink', 'opage_title', 'opage_tag', 'opage_showposts', 'opage_bottomtext', 'opage_bottomlink', 'title_cutlength', 'abstract_cutlength', 'load_css', 'image_style', 'default_image', 'display_date', 'date_format');
    if ($_POST["yd_rp-submit-{$number}"]) {
        if (yd_update_options('widget_yd_rp', $number, $to_update, $_POST, 'yd_rp-')) {
            clear_yd_widget_cache('widget_yd_rp_home');
            clear_yd_widget_cache('widget_yd_rp_page');
            clear_yd_widget_cache('widget_yd_rp_hometemplate1');
            // TODO? Clear other pages template cache?
        }
    }
    foreach ($to_update as $key) {
        $v[$key] = htmlspecialchars($options[$number][$key], ENT_QUOTES);
    }
    ?>
<div style="float: right"><a
	href="http://www.yann.com/en/wp-plugins/yd-recent-posts-widget"
	title="Help!" target="_blank">?</a></div>
<strong><?php 
    echo __('Home page widget title:', 'yd-recent-posts-widget');
    ?>
</strong>
<br />
<input
	style="width: 450px;" id="yd_rp-home_title-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-home_title-<?php 
    echo "{$number}";
    ?>
" type="text"
	value="<?php 
    echo $v['home_title'];
    ?>
" />
<br />
	<?php 
    echo __('Home page tag:', 'yd-recent-posts-widget');
    ?>
<input style="width: 100px;"
	id="yd_rp-home_tag-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-home_tag-<?php 
    echo "{$number}";
    ?>
" type="text"
	value="<?php 
    echo $v['home_tag'];
    ?>
" />
	<?php 
    echo __('Home no. of posts:', 'yd-recent-posts-widget');
    ?>
<input style="width: 50px;"
	id="yd_rp-home_showposts-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-home_showposts-<?php 
    echo "{$number}";
    ?>
" type="text"
	value="<?php 
    echo $v['home_showposts'];
    ?>
" />
<br />
	<?php 
    echo __('Use special date meta:', 'yd-recent-posts-widget');
    ?>
<input style="width: 50px;"
	id="yd_rp-home_datemeta-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-home_datemeta-<?php 
    echo "{$number}";
    ?>
" type="text"
	value="<?php 
    echo $v['home_datemeta'];
    ?>
" />
(
	<?php 
    echo __('custom field name', 'yd-recent-posts-widget');
    ?>
)
<br />
	<?php 
    echo __('Bottom text:', 'yd-recent-posts-widget');
    ?>
<input style="width: 250px;"
	id="yd_rp-home_bottomtext-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-home_bottomtext-<?php 
    echo "{$number}";
    ?>
" type="text"
	value="<?php 
    echo $v['home_bottomtext'];
    ?>
" />
<br />
-
	<?php 
    echo __('link:', 'yd-recent-posts-widget');
    ?>
<input style="width: 250px;"
	id="yd_rp-home_bottomlink-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-home_bottomlink-<?php 
    echo "{$number}";
    ?>
" type="text"
	value="<?php 
    echo $v['home_bottomlink'];
    ?>
" />
<hr />
<strong><?php 
    echo __('Other pages widget title:', 'yd-recent-posts-widget');
    ?>
</strong>
<br />
<input
	style="width: 450px;" id="yd_rp-opage_title-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-opage_title-<?php 
    echo "{$number}";
    ?>
" type="text"
	value="<?php 
    echo $v['opage_title'];
    ?>
" />
<br />
	<?php 
    echo __('Other pages tag:', 'yd-recent-posts-widget');
    ?>
<input style="width: 100px;"
	id="yd_rp-opage_tag-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-opage_tag-<?php 
    echo "{$number}";
    ?>
" type="text"
	value="<?php 
    echo $v['opage_tag'];
    ?>
" />
	<?php 
    echo __('Other no. of posts:', 'yd-recent-posts-widget');
    ?>
<input style="width: 50px;"
	id="yd_rp-opage_showposts-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-opage_showposts-<?php 
    echo "{$number}";
    ?>
" type="text"
	value="<?php 
    echo $v['opage_showposts'];
    ?>
" />
<br />
	<?php 
    echo __('Bottom text:', 'yd-recent-posts-widget');
    ?>
<input style="width: 250px;"
	id="yd_rp-opage_bottomtext-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-opage_bottomtext-<?php 
    echo "{$number}";
    ?>
" type="text"
	value="<?php 
    echo $v['opage_bottomtext'];
    ?>
" />
<br />
-
	<?php 
    echo __('link:', 'yd-recent-posts-widget');
    ?>
<input style="width: 250px;"
	id="yd_rp-opage_bottomlink-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-opage_bottomlink-<?php 
    echo "{$number}";
    ?>
" type="text"
	value="<?php 
    echo $v['opage_bottomlink'];
    ?>
" />
<hr />
	<?php 
    echo __('Title cut length:', 'yd-recent-posts-widget');
    ?>
<input style="width: 50px;"
	id="yd_rp-title_cutlength-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-title_cutlength-<?php 
    echo "{$number}";
    ?>
" type="text"
	value="<?php 
    echo $v['title_cutlength'];
    ?>
" />
	<?php 
    echo __('Abstract cut length:', 'yd-recent-posts-widget');
    ?>
<input style="width: 50px;"
	id="yd_rp-abstract_cutlength-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-abstract_cutlength-<?php 
    echo "{$number}";
    ?>
" type="text"
	value="<?php 
    echo $v['abstract_cutlength'];
    ?>
" />
<br />
	<?php 
    echo __('Load CSS:', 'yd-recent-posts-widget');
    ?>
<input style="width: 15px;" id="yd_rp-load_css-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-load_css-<?php 
    echo "{$number}";
    ?>
" type="checkbox"
	value="1" <?php 
    if ($v['load_css']) {
        echo "checked=\"checked\"";
    }
    ?>
 />
	<?php 
    echo __('Image CSS Style:', 'yd-recent-posts-widget');
    ?>
<input style="width: 450px;"
	id="yd_rp-image_style-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-image_style-<?php 
    echo "{$number}";
    ?>
" type="text"
	value="<?php 
    echo $v['image_style'];
    ?>
" />
<br />
	<?php 
    echo __('Default image URL:', 'yd-recent-posts-widget');
    ?>
<input style="width: 300px;"
	id="yd_rp-default_image-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-default_image-<?php 
    echo "{$number}";
    ?>
" type="text"
	value="<?php 
    echo $v['default_image'];
    ?>
" />
<br />
	<?php 
    echo __('Display date:', 'yd-recent-posts-widget');
    ?>
<input style="width: 15px;"
	id="yd_rp-display_date-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-display_date-<?php 
    echo "{$number}";
    ?>
" type="checkbox"
	value="1" <?php 
    if ($v['display_date']) {
        echo "checked=\"checked\"";
    }
    ?>
 />
	<?php 
    echo __('Date format:', 'yd-recent-posts-widget');
    ?>
<input style="width: 100px;"
	id="yd_rp-date_format-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-date_format-<?php 
    echo "{$number}";
    ?>
" type="text"
	value="<?php 
    echo $v['date_format'];
    ?>
" />
<input
	type="hidden" id="yd_rp-submit-<?php 
    echo "{$number}";
    ?>
"
	name="yd_rp-submit-<?php 
    echo "{$number}";
    ?>
" value="1" />
	<?php 
}