Skip to content

Commit

Permalink
Merge pull request #10 from tarosky/bugfix/wrong-month-selector
Browse files Browse the repository at this point in the history
Bugfix/wrong month selector
  • Loading branch information
fumikito authored Jan 31, 2025
2 parents 1403401 + 0206d7c commit d1c2aaf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .wp-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
".",
"https://downloads.wordpress.org/plugin/classic-editor.latest-stable.zip",
"https://downloads.wordpress.org/plugin/taro-ad-fields.latest-stable.zip",
"https://downloads.wordpress.org/plugin/query-monitor.latest-stable.zip"
"https://downloads.wordpress.org/plugin/query-monitor.latest-stable.zip",
"https://downloads.wordpress.org/plugin/localhost2host-docker-internal.latest-stable.zip"
],
"themes": [
"https://downloads.wordpress.org/theme/twentytwenty.latest-stable.zip"
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ add_filter( 'tscp_cron_interval', function() {

## Changelog

### 1.2.6

* Fix month string error in Clasic editor's meta box. This happened on Any 31st day in a month.

### 1.2.2

* Fix deploy script to avoid incorrect versioning.
Expand Down
8 changes: 4 additions & 4 deletions includes/meta-box.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
wp_nonce_field( 'tscp_date', '_tscpnonce', false );
$date_time = get_post_meta( $post->ID, '_tscp_expires', true );
if ( ! $date_time ) {
$now = new DateTime();
$now->add( new DateInterval( sprintf( 'P1MT%sH', get_option( 'gmt_offset' ) ) ) );
$now = new DateTime( 'now', wp_timezone() );
$now->add( new DateInterval( 'P1M' ) );
$one_month_later = $now->format( 'Y-m-d H:i:s' );
$date_time = apply_filters( 'tspc_default_expires', $one_month_later, $post );
}
Expand All @@ -37,9 +37,9 @@
$year_input = sprintf( '<input type="text" name="tscp-year" class="tscp-long" value="%s" />', esc_attr( $year ) );
$month_input = '<select name="tscp-month" class="tscp-month">';
for ( $i = 1; $i <= 12; $i++ ) {
$month_str = mysql2date( 'M', str_replace( '-00-', sprintf( '-%02d-', $i ), date_i18n( 'Y-00-d' ) ) );
$month_str = mysql2date( 'M', date_i18n( 'Y-' . sprintf( '%02d', $i ) . '-01' ) );
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
$month_input .= sprintf( '<option value="%02d" %s>%s</option>', $i, selected( $i, $month, false ), $month_str );
$month_input .= sprintf( '<option value="%02d" %s>%s</option>', $i, selected( $i, (int) $month, false ), $month_str );
}
$month_input .= '</select>';
$day_input = sprintf( '<input type="text" name="tscp-day" class="tscp-short" value="%s" />', esc_attr( $day ) );
Expand Down

0 comments on commit d1c2aaf

Please sign in to comment.