This commit is contained in:
2022-07-17 19:33:08 +03:00
parent 6c1eae64d7
commit 7a955031d4
3 changed files with 257 additions and 28 deletions

View File

@@ -21,7 +21,7 @@ function get_ddate($content, $format = "", $originalRequest = null) {
case "get_the_date":
case "get_the_time":
$post = get_post( $format );
if ( get_option('dtime_convert') == '1' )
if (get_option('dtime_convert'))
$standard_date = utcm5_convert(mysql2date( 'U', $post->post_date_gmt ));
else
$standard_date = getdate (mysql2date( 'U', $post->post_date ));
@@ -29,13 +29,13 @@ function get_ddate($content, $format = "", $originalRequest = null) {
case "get_comment_date":
case "get_comment_time":
$comment = get_comment( $format );
if ( get_option('dtime_convert') == '1' )
if (get_option('dtime_convert'))
$standard_date = utcm5_convert(mysql2date( 'U', $comment->comment_date_gmt ));
else
$standard_date = getdate (mysql2date( 'U', $comment->comment_date ));
break;
case "now":
if ( get_option('dtime_convert') == '1' )
if (get_option('dtime_convert'))
$standard_date = utcm5_convert(getdate()[0]);
else
$standard_date = getdate();
@@ -284,6 +284,7 @@ class Discordian_Date_Widget extends WP_Widget {
echo "<div class=\"discordian_date_func\" style=\"width:100%;text-align:center;font-size:18px;line-height:36px;padding-top:40px;padding-bottom:40px;\"> Today is ";
echo get_ddate($content, $format, "now").".";
if ($holiday) echo "<br><b>".$holiday."</b>";
if (get_option('dtime_widget')) echo "<br><h1 style=\"font-size: 255%\" id=\"dtime\">5:55:55</h1>";
echo "</div>";
$body2 = ob_get_contents();
ob_end_clean();
@@ -364,6 +365,10 @@ function ddatefunc_admin() {
update_option('dtime_convert', "1");
else
update_option('dtime_convert', "0");
if (isset($_POST['dtime_widget_checkbox']))
update_option('dtime_widget', "1");
else
update_option('dtime_widget', "0");
echo '<div id="setting-error-settings_updated" class="updated settings-error"><p><b>'.__('Settings saved.').'</b></p></div>';
}
?>
@@ -438,6 +443,19 @@ Examples<br>
</fieldset>
</td>
</tr>
<tr valign="top">
<th scope="row">Show Erisian time clock in the widget:</th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span>Erisian time in the widget</span>
</legend>
<label for="users_can_register">
<input name="dtime_widget_checkbox" id="users_can_register" type="checkbox" value="1" <?php if(get_option('dtime_widget')==1) { echo 'checked="checked"'; } ?>>
</label>
</fieldset>
</td>
</tr>
</table>
<div class="submit">
<input name="save" type="submit" class="button-primary" value="<?php echo __('Save Cganges'); ?>" />
@@ -447,12 +465,12 @@ Examples<br>
<?php
}
function ddatefunc_settings( $actions, $plugin_file ) {
if( false === strpos( $plugin_file, basename(__FILE__) ) )
function ddatefunc_settings($actions, $plugin_file) {
if (false === strpos($plugin_file, basename(__FILE__)))
return $actions;
$settings_link = '<a href="options-general.php?page=ddatefunc.php' .'">Settings</a>';
array_unshift( $actions, $settings_link );
array_unshift($actions, $settings_link);
return $actions;
}
@@ -461,27 +479,36 @@ function ddatefunc_deinstall() {
delete_option('ddatefunc_change');
delete_option('dtimefunc_change');
delete_option('dtime_convert');
delete_option('dtime_widget');
}
add_shortcode( 'today_ddate', 'return_today_ddate' );
add_action( 'widgets_init', 'register_ddatefunc_widget' );
add_option( 'ddatefunc_string', '%DD day of %DS, in the yold %DY');
add_option( 'ddatefunc_change', '1');
add_option( 'dtimefunc_change', '1');
add_option( 'dtime_convert', '1');
add_filter( 'plugin_action_links', 'ddatefunc_settings', 10, 2 );
add_action( 'admin_menu', 'ddatefunc_add_admin' );
if ( get_option('ddatefunc_change') == '1' ) {
add_filter( 'get_the_date','get_the_ddate_post' );
add_filter( 'get_comment_date','get_the_ddate_comment' );
function ddatefunc_init() {
wp_enqueue_script('dtime', plugins_url('/dtime.js', __FILE__));
}
if ( get_option('dtimefunc_change') == '1' ) {
add_filter( 'get_the_time','get_the_dtime_post' );
add_filter( 'get_comment_time','get_the_dtime_comment' );
add_shortcode('today_ddate', 'return_today_ddate');
add_action('widgets_init', 'register_ddatefunc_widget');
add_option('ddatefunc_string', '%DD day of %DS, in the yold %DY');
add_option('ddatefunc_change', '1');
add_option('dtimefunc_change', '1');
add_option('dtime_convert', '1');
add_option('dtime_widget', '1');
add_filter('plugin_action_links', 'ddatefunc_settings', 10, 2);
add_action('admin_menu', 'ddatefunc_add_admin');
if (get_option('ddatefunc_change')) {
add_filter('get_the_date','get_the_ddate_post');
add_filter('get_comment_date','get_the_ddate_comment');
}
if (get_option('dtimefunc_change')) {
add_filter('get_the_time','get_the_dtime_post');
add_filter('get_comment_time','get_the_dtime_comment');
}
if (get_option('dtime_widget'))
add_action('wp_enqueue_scripts','ddatefunc_init');
if (function_exists('register_uninstall_hook'))
register_uninstall_hook(__FILE__, 'ddatefunc_deinstall');