/**
 * Show the Expiration Date options page
 */
function postExpiratorMenuGeneral()
{
    if (isset($_POST['expirationdateSave']) && $_POST['expirationdateSave']) {
        update_option('expirationdateExpiredPostStatus', $_POST['expired-post-status']);
        update_option('expirationdateExpiredPageStatus', $_POST['expired-page-status']);
        update_option('expirationdateDefaultDateFormat', $_POST['expired-default-date-format']);
        update_option('expirationdateDefaultTimeFormat', $_POST['expired-default-time-format']);
        update_option('expirationdateDisplayFooter', $_POST['expired-display-footer']);
        update_option('expirationdateFooterContents', $_POST['expired-footer-contents']);
        update_option('expirationdateFooterStyle', $_POST['expired-footer-style']);
        update_option('expirationdateCategory', $_POST['expired-category']);
        update_option('expirationdateCategoryDefaults', $_POST['expirationdate_category']);
        update_option('expirationdateCronSchedule', $_POST['expired-default-cron-schedule']);
        update_option('expirationdateDefaultDate', $_POST['expired-default-expiration-date']);
        if ($_POST['expired-custom-expiration-date']) {
            update_option('expirationdateDefaultDateCustom', $_POST['expired-custom-expiration-date']);
        }
        postExpiratorResetCronEvent();
        echo "<div id='message' class='updated fade'><p>";
        _e('Saved Options!', 'post-expirator');
        echo "</p></div>";
    }
    postExpiratorTimezoneSetup();
    // Get Option
    $expirationdateExpiredPostStatus = get_option('expirationdateExpiredPostStatus', POSTEXPIRATOR_POSTSTATUS);
    $expirationdateExpiredPageStatus = get_option('expirationdateExpiredPageStatus', POSTEXPIRATOR_PAGESTATUS);
    $expirationdateDefaultDateFormat = get_option('expirationdateDefaultDateFormat', POSTEXPIRATOR_DATEFORMAT);
    $expirationdateDefaultTimeFormat = get_option('expirationdateDefaultTimeFormat', POSTEXPIRATOR_TIMEFORMAT);
    $expiredcategory = get_option('expirationdateCategory', POSTEXPIRATOR_CATEGORY);
    $expireddisplayfooter = get_option('expirationdateDisplayFooter', POSTEXPIRATOR_FOOTERDISPLAY);
    $expirationdateFooterContents = get_option('expirationdateFooterContents', POSTEXPIRATOR_FOOTERCONTENTS);
    $expirationdateFooterStyle = get_option('expirationdateFooterStyle', POSTEXPIRATOR_FOOTERSTYLE);
    $expirationdateCronSchedule = get_option('expirationdateCronSchedule', POSTEXPIRATOR_CRONSCHEDULE);
    $expirationdateDefaultDate = get_option('expirationdateDefaultDate', POSTEXPIRATOR_EXPIREDEFAULT);
    $expirationdateDefaultDateCustom = get_option('expirationdateDefaultDateCustom');
    $categories = get_option('expirationdateCategoryDefaults');
    $expireddisplayfooterenabled = '';
    $expireddisplayfooterdisabled = '';
    if ($expireddisplayfooter == 0) {
        $expireddisplayfooterdisabled = 'checked="checked"';
    } else {
        if ($expireddisplayfooter == 1) {
            $expireddisplayfooterenabled = 'checked="checked"';
        }
    }
    $expiredcategorydisabled = '';
    $expiredcategoryenabled = '';
    if ($expiredcategory == 0) {
        $expiredcategorydisabled = 'checked="checked"';
    } else {
        if ($expiredcategory == 1) {
            $expiredcategoryenabled = 'checked="checked"';
        }
    }
    ?>
	<p>
	<?php 
    _e('The post expirator plugin sets a custom meta value, and then optionally allows you to select if you want the post changed to a draft status or deleted when it expires.', 'post-expirator');
    ?>
	</p>
	<p>
	<?php 
    _e('Valid [postexpirator] attributes:', 'post-expirator');
    ?>
	<ul>
		<li><?php 
    _e('type - defaults to full - valid options are full,date,time', 'post-expirator');
    ?>
</li>
		<li><?php 
    _e('dateformat - format set here will override the value set on the settings page', 'post-expirator');
    ?>
</li>
		<li><?php 
    _e('timeformat - format set here will override the value set on the settings page', 'post-expirator');
    ?>
</li>
	</ul>
	</p>
	<form method="post" id="expirationdate_save_options">
		<h3><?php 
    _e('Defaults', 'post-expirator');
    ?>
</h3>
		<table class="form-table">
			<tr valign-"top">
				<th scope="row"><label for="expired-post-status"><?php 
    _e('Set Post To:', 'post-expirator');
    ?>
</label></th>
				<td>
					<select name="expired-post-status" id="expired-post-status">
					<option <?php 
    if ($expirationdateExpiredPostStatus == 'Draft') {
        echo 'selected="selected"';
    }
    ?>
 value="Draft"><?php 
    _e('Draft', 'post-expirator');
    ?>
</option>
					<option <?php 
    if ($expirationdateExpiredPostStatus == 'Delete') {
        echo 'selected="selected"';
    }
    ?>
 value="Delete"><?php 
    _e('Delete', 'post-expirator');
    ?>
</option>
					</select>	
					<br/>
					<?php 
    _e('Select whether the post should be deleted or changed to a draft at expiration time.', 'post-expirator');
    ?>
				</td>
			</tr>
			<tr valign-"top">
				<th scope="row"><label for="expired-page-status"><?php 
    _e('Set Page To:', 'post-expirator');
    ?>
</label></th>
				<td>
					<select name="expired-page-status" id="expired-page-status">
					<option<?php 
    if ($expirationdateExpiredPageStatus == 'Draft') {
        echo ' selected="selected"';
    }
    ?>
 value="Draft"><?php 
    _e('Draft', 'post-expirator');
    ?>
</option>
					<option<?php 
    if ($expirationdateExpiredPageStatus == 'Delete') {
        echo ' selected="selected"';
    }
    ?>
 value="Delete"><?php 
    _e('Delete', 'post-expirator');
    ?>
</option>
					</select>	
					<br/>
					<?php 
    _e('Select whether the page should be deleted or changed to a draft at expiration time.', 'post-expirator');
    ?>
				</td>
			</tr>
			<tr valign-"top">
				<th scope="row"><label for="expired-default-date-format"><?php 
    _e('Date Format:', 'post-expirator');
    ?>
</label></th>
				<td>
					<input type="text" name="expired-default-date-format" id="expired-default-date-format" value="<?php 
    echo $expirationdateDefaultDateFormat;
    ?>
" size="25" /> (<?php 
    echo date_i18n("{$expirationdateDefaultDateFormat}");
    ?>
)
					<br/>
					<?php 
    _e('The default format to use when displaying the expiration date within a post using the [postexpirator] shortcode or within the footer.  For information on valid formatting options, see: <a href="http://us2.php.net/manual/en/function.date.php" target="_blank">PHP Date Function</a>.', 'post-expirator');
    ?>
				</td>
			</tr>
			<tr valign-"top">
				<th scope="row"><label for="expired-default-time-format"><?php 
    _e('Time Format:', 'post-expirator');
    ?>
</label></th>
				<td>
					<input type="text" name="expired-default-time-format" id="expired-default-time-format" value="<?php 
    echo $expirationdateDefaultTimeFormat;
    ?>
" size="25" /> (<?php 
    echo date_i18n("{$expirationdateDefaultTimeFormat}");
    ?>
)
					<br/>
					<?php 
    _e('The default format to use when displaying the expiration time within a post using the [postexpirator] shortcode or within the footer.  For information on valid formatting options, see: <a href="http://us2.php.net/manual/en/function.date.php" target="_blank">PHP Date Function</a>.', 'post-expirator');
    ?>
				</td>
			</tr>
			<tr valign-"top">
				<th scope="row"><label for="expired-default-cron-schedule"><?php 
    _e('Cron Schedule:', 'post-expirator');
    ?>
</label></th>
				<td>
					<select name="expired-default-cron-schedule" id="expired-default-cron-schedule">
					<?php 
    $schedules = wp_get_schedules();
    foreach ($schedules as $key => $value) {
        $selected = $key == $expirationdateCronSchedule ? ' selected="selected"' : '';
        echo '<option value="' . $key . '"' . $selected . '>' . $value['display'] . ' (' . $key . ') </option>';
    }
    ?>
					</select>
					<br/>
					<?php 
    _e('By default set to "postexpiratorminute" which fires every minute.', 'post-expirator');
    ?>
				</td>
			</tr>
			<tr valign-"top">
				<th scope="row"><label for="expired-default-expiration-date"><?php 
    _e('Default Date/Time Duration:', 'post-expirator');
    ?>
</label></th>
				<td>
					<select name="expired-default-expiration-date" id="expired-default-expiration-date" onchange="expirationdate_toggle_defaultdate(this)">
						<option value="null" <?php 
    echo $expirationdateDefaultDate == 'null' ? ' selected="selected"' : '';
    ?>
><?php 
    _e('None', 'post-expirator');
    ?>
</option>
						<option value="custom" <?php 
    echo $expirationdateDefaultDate == 'custom' ? ' selected="selected"' : '';
    ?>
><?php 
    _e('Custom', 'post-expirator');
    ?>
</option>
						<option value="publish" <?php 
    echo $expirationdateDefaultDate == 'publish' ? ' selected="selected"' : '';
    ?>
><?php 
    _e('Post/Page Publish Time', 'post-expirator');
    ?>
</option>
					</select>
					<br/>
					<?php 
    _e('Set the default expiration date to be used when creating new posts and pages.  Defaults to none.', 'post-expirator');
    ?>
					<?php 
    $show = $expirationdateDefaultDate == 'custom' ? 'block' : 'none';
    ?>
					<div id="expired-custom-container" style="display: <?php 
    echo $show;
    ?>
;">
					<br/><label for="expired-custom-expiration-date">Custom:</label> <input type="text" value="<?php 
    echo $expirationdateDefaultDateCustom;
    ?>
" name="expired-custom-expiration-date" id="expired-custom-expiration-date" />
					<br/>
					<?php 
    _e('Set the custom value to use for the default expiration date.  For information on formatting, see <a href="http://php.net/manual/en/function.strtotime.php">PHP strtotime function</a>.', 'post-expirator');
    ?>
					</div>
				</td>
			</tr>
		</table>
		<h3><?php 
    _e('Category Expiration', 'post-expirator');
    ?>
</h3>
		<table class="form-table">
			<tr valign-"top">
				<th scope="row"><?php 
    _e('Enable Post Expiration to Category?', 'post-expirator');
    ?>
</th>
				<td>
					<input type="radio" name="expired-category" id="expired-category-true" value="1" <?php 
    echo $expiredcategoryenabled;
    ?>
/> <label for="expired-category-true"><?php 
    _e('Enabled', 'post-expirator');
    ?>
</label> 
					<input type="radio" name="expired-category" id="expired-category-false" value="0" <?php 
    echo $expiredcategorydisabled;
    ?>
/> <label for="expired-category-false"><?php 
    _e('Disabled', 'post-expirator');
    ?>
</label>
					<br/>
					<?php 
    _e('This will enable or disable the ability to expire a post to a category.', 'post-expirator');
    ?>
				</td>
			</tr>
			<tr valign-"top">
				<th scope="row"><?php 
    _e('Default Expiration Category', 'post-expirator');
    ?>
:</th>
				<td>
		<?php 
    echo '<div class="wp-tab-panel" id="post-expirator-cat-list">';
    echo '<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">';
    $walker = new Walker_PostExpirator_Category_Checklist();
    wp_terms_checklist(0, array('taxonomy' => 'category', 'walker' => $walker, 'selected_cats' => $categories, 'checked_ontop' => false));
    echo '</ul>';
    echo '</div>';
    ?>
					<br/>
					<?php 
    _e("Set's the default expiration category for the post.", 'post-expirator');
    ?>
				</td>
			</tr>
		</table>

		<h3><?php 
    _e('Post Footer Display', 'post-expirator');
    ?>
</h3>
		<p><?php 
    _e('Enabling this below will display the expiration date automatically at the end of any post which is set to expire.', 'post-expirator');
    ?>
</p>
		<table class="form-table">
			<tr valign-"top">
				<th scope="row"><?php 
    _e('Show in post footer?', 'post-expirator');
    ?>
</th>
				<td>
					<input type="radio" name="expired-display-footer" id="expired-display-footer-true" value="1" <?php 
    echo $expireddisplayfooterenabled;
    ?>
/> <label for="expired-display-footer-true"><?php 
    _e('Enabled', 'post-expirator');
    ?>
</label> 
					<input type="radio" name="expired-display-footer" id="expired-display-footer-false" value="0" <?php 
    echo $expireddisplayfooterdisabled;
    ?>
/> <label for="expired-display-footer-false"><?php 
    _e('Disabled', 'post-expirator');
    ?>
</label>
					<br/>
					<?php 
    _e('This will enable or disable displaying the post expiration date in the post footer.', 'post-expirator');
    ?>
				</td>
			</tr>
			<tr valign-"top">
				<th scope="row"><label for="expired-footer-contents"><?php 
    _e('Footer Contents:', 'post-expirator');
    ?>
</label></th>
				<td>
					<textarea id="expired-footer-contents" name="expired-footer-contents" rows="3" cols="50"><?php 
    echo $expirationdateFooterContents;
    ?>
</textarea>
					<br/>
					<?php 
    _e('Enter the text you would like to appear at the bottom of every post that will expire.  The following placeholders will be replaced with the post expiration date in the following format:', 'post-expirator');
    ?>
					<ul>
						<li>EXPIRATIONFULL -> <?php 
    echo date_i18n("{$expirationdateDefaultDateFormat} {$expirationdateDefaultTimeFormat}");
    ?>
</li>
						<li>EXPIRATIONDATE -> <?php 
    echo date_i18n("{$expirationdateDefaultDateFormat}");
    ?>
</li>
						<li>EXPIRATIONTIME -> <?php 
    echo date_i18n("{$expirationdateDefaultTimeFormat}");
    ?>
</li>
					</ul>
				</td>
			</tr>
			<tr valign-"top">
				<th scope="row"><label for="expired-footer-style"><?php 
    _e('Footer Style:', 'post-expirator');
    ?>
</label></th>
				<td>
					<input type="text" name="expired-footer-style" id="expired-footer-style" value="<?php 
    echo $expirationdateFooterStyle;
    ?>
" size="25" />
					(<span style="<?php 
    echo $expirationdateFooterStyle;
    ?>
"><?php 
    _e('This post will expire on', 'post-expirator');
    ?>
 <?php 
    echo date_i18n("{$expirationdateDefaultDateFormat} {$expirationdateDefaultTimeFormat}");
    ?>
</span>)
					<br/>
					<?php 
    _e('The inline css which will be used to style the footer text.', 'post-expirator');
    ?>
				</td>
			</tr>
		</table>
		<p class="submit">
			<input type="submit" name="expirationdateSave" class="button-primary" value="<?php 
    _e('Save Changes', 'post-expirator');
    ?>
" />
		</p>
	</form>
	<?php 
}
示例#2
0
function postExpiratorMenuDiagnostics()
{
    if (isset($_POST['reset-cron-event'])) {
        postExpiratorResetCronEvent();
        echo "<div id='message' class='updated fade'><p>";
        _e('Cron Events Reset! (Reload page to remove warning)', 'post-expirator');
        echo "</p></div>";
    } elseif (isset($_POST['debugging-disable'])) {
        update_option('expirationdateDebug', 0);
        echo "<div id='message' class='updated fade'><p>";
        _e('Debugging Disabled', 'post-expirator');
        echo "</p></div>";
    } elseif (isset($_POST['debugging-enable'])) {
        update_option('expirationdateDebug', 1);
        echo "<div id='message' class='updated fade'><p>";
        _e('Debugging Enabled', 'post-expirator');
        echo "</p></div>";
    } elseif (isset($_POST['purge-debug'])) {
        require_once plugin_dir_path(__FILE__) . 'post-expirator-debug.php';
        $debug = new postExpiratorDebug();
        $debug->purge();
        echo "<div id='message' class='updated fade'><p>";
        _e('Debugging Table Emptied', 'post-expirator');
        echo "</p></div>";
    }
    $status = postExpiratorCronEventStatus();
    if ($status) {
        $cronstatus = '<span style="color:green">' . __('OK', 'post-expirator') . '</span>';
    } else {
        $cronstatus = '<span style="color:red">' . __('RESET NEEDED', 'post-expirator') . '</span>';
    }
    $schedule = postExpiratorCronScheduleStatus();
    if ($schedule) {
        $cronschedulestatus = '<span style="color:green">' . __('OK', 'post-expirator') . '</span>';
    } else {
        $cronschedulestatus = '<span style="color:red">' . __('ERROR WITH FILTER', 'post-expirator') . '</span>';
    }
    $debug = postExpiratorDebugEnabled();
    ?>
        <form method="post" id="postExpiratorMenuUpgrade">
                <h3><?php 
    _e('Cron Settings', 'post-expirator');
    ?>
</h3>
                <table class="form-table">
                        <tr valign-"top">
                                <th scope="row"><label for="reset-cron-event"><?php 
    _e('Reset Cron Event:', 'post-expirator');
    ?>
</label></th>
                                <td>
					<input type="submit" name="reset-cron-event" id="reset-cron-event" value="<?php 
    _e('Reset', 'post-expirator');
    ?>
" />
					<?php 
    _e('Status:', 'post-expirator');
    ?>
 <?php 
    echo $cronstatus;
    ?>
                                        <br/>
					<?php 
    _e('Resets the cron event and removes any old or stray entries.', 'post-expirator');
    ?>
                                </td>
                        </tr>
                        <tr valign-"top">
                                <th scope="row"><label for="reset-cron-schedule"><?php 
    _e('Reset Cron Schedule:', 'post-expirator');
    ?>
</label></th>
                                <td>
					<?php 
    _e('Status:', 'post-expirator');
    ?>
 <?php 
    echo $cronschedulestatus;
    ?>
                                        <br/>
					<?php 
    _e('Displays the cron minute schedule status for post expirator.', 'post-expirator');
    ?>
                                </td>
                        </tr>
		</table>

                <h3><?php 
    _e('Advanced Diagnostics', 'post-expirator');
    ?>
</h3>
                <table class="form-table">		
                        <tr valign-"top">
                                <th scope="row"><label for="postexpirator-log"><?php 
    _e('Post Expirator Debug Logging:', 'post-expirator');
    ?>
</label></th>
                                <td>
					<?php 
    if ($debug) {
        echo __('Status: Enabled', 'post-expirator') . '<br/>';
        echo '<input type="submit" name="debugging-disable" id="debugging-disable" value="' . __('Disable Debugging', 'post-expirator') . '" />';
    } else {
        echo __('Status: Disabled', 'post-expirator') . '<br/>';
        echo '<input type="submit" name="debugging-enable" id="debugging-enable" value="' . __('Enable Debugging', 'post-expirator') . '" />';
    }
    ?>
                                        <br/>
					<a href="<?php 
    echo admin_url('options-general.php?page=post-expirator.php&tab=viewdebug');
    ?>
">View Debug Logs</a>
                                </td>
                        </tr>
                        <tr valign-"top">
                                <th scope="row"><?php 
    _e('Purge Debug Log:', 'post-expirator');
    ?>
</th>
                                <td>
					<input type="submit" name="purge-debug" id="purge-debug" value="<?php 
    _e('Purge Debug Log', 'post-expirator');
    ?>
" />
				</td>
			</tr/>
                        <tr valign-"top">
                                <th scope="row"><label for="cron-schedule"><?php 
    _e('Current Cron Schedule:', 'post-expirator');
    ?>
</label></th>
                                <td>
					<?php 
    _e('The below table will show all currently scheduled cron events with the next run time.', 'post-expirator');
    ?>
<br/>
					<?php 
    _e('Single site (non multisite) users should see an event named expirationdate_delete with a schedule of postexpiratorminute.', 'post-expirator');
    ?>
<br/>
					<?php 
    if (postExpirator_is_wpmu()) {
        _e('Multisite users should see an event named expirationdate_delete_blogid (where the blogid is replaced with the numeric id of the blog) with a schedule of postexpiratorminute', 'post-expirator');
    }
    ?>
					<table>
						<tr>
							<th><?php 
    _e('Date', 'post-expirator');
    ?>
</th>
							<th><?php 
    _e('Event', 'post-expirator');
    ?>
</th>
							<th><?php 
    _e('Schedule', 'post-expirator');
    ?>
</th>
							<th><?php 
    _e('Interval (seconds)', 'post-expirator');
    ?>
</th>
						</tr>
					<?php 
    $cron = _get_cron_array();
    foreach ($cron as $key => $value) {
        foreach ($value as $eventkey => $eventvalue) {
            print '<tr>';
            print '<td>' . date_i18n('r', $key) . '</td>';
            print '<td>' . $eventkey . '</td>';
            $arrkey = array_keys($eventvalue);
            print '<td>' . $eventvalue[$arrkey[0]]['schedule'] . '</td>';
            print '<td>' . $eventvalue[$arrkey[0]]['interval'] . '</td>';
            print '</tr>';
        }
    }
    ?>
					</table>
                                </td>
                        </tr>
                </table>
        </form>
	<?php 
}