Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DateTimeZone setup: fall back to gmt_offset; php notice fixes #32

Merged
merged 2 commits into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions includes/functions/plugins/article-export.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function get_export_status( $article_id ) {


$zone = new \DateTimeZone( Core\get_timezone() );

$export_datetime = new \DateTime( 'now', $zone );
$export_datetime->setTimestamp( $timestamp );

Expand Down Expand Up @@ -516,6 +516,10 @@ function get_first_author_name() {

$author = $authors[0];

if ( ! $author ) {
return '';
}

if ( $author->last_name ) {
return $author->last_name;
}
Expand Down Expand Up @@ -674,7 +678,7 @@ function html_to_xml( $dom ) {
foreach ( $content->childNodes as $el ) {
$content_element->appendChild( $xml_document->importNode( $el, true ) );
}

$article_xml = new \stdClass;
$article_xml->xml_document = $xml_document;
$article_xml->root_element = $article_element;
Expand Down Expand Up @@ -730,7 +734,14 @@ function __construct( $issue_title, $files = [] ) {
* @return string The zip file name
*/
function get_zip_file_name( ) {
$date = new \DateTime( 'now', new \DateTimeZone( get_option( 'timezone_string' ) ) );
$timezone_string = get_option( 'timezone_string' );
if ( empty( $timezone_string ) ) {
$offset = get_option( 'gmt_offset' );
$hours = (int) $offset;
$minutes = abs( ( $offset - (int) $offset ) * 60 );
$timezone_string = sprintf( '%+03d:%02d', $hours, $minutes );
}
$date = new \DateTime( 'now', new \DateTimeZone( $timezone_string ) );
return 'Issue ' . $this->issue_title . ' exported on ' . $date->format( 'm-d-y' ) . ' at ' . $date->format( 'h:ia' );
}

Expand Down
2 changes: 1 addition & 1 deletion includes/functions/plugins/issue-status.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function add_issue_status_filters() {
echo '<select name="' . esc_attr( $tax_slug ) . '" id="' . esc_attr( $tax_slug ) . '" class="postform">';
echo '<option value="">' . sprintf( esc_html_x( 'Show All %s', 'Select option for filtering all issue statuses', 'eight-day-week' ) , esc_html( $tax_name ) ) . '</option>';
foreach ( $terms as $term ) {
echo '<option value="' . esc_attr( $term->slug ) . '"' . selected( $_GET[ $tax_slug ], $term->slug ) . '>' . esc_html( $term->name ) . '</option>';
echo '<option value="' . esc_attr( $term->slug ) . '"' . selected( isset( $_GET[ $tax_slug ] ) && $_GET[ $tax_slug ], $term->slug ) . '>' . esc_html( $term->name ) . '</option>';
helen marked this conversation as resolved.
Show resolved Hide resolved
}
echo '</select>';
}
Expand Down