froger-me / wp-packages-update-server

WP Packages Update Server - Run Your Own Update Server for Plugins and Themes
GNU General Public License v3.0
141 stars 39 forks source link

Possible incorrect use of the function **date_i18n** #29

Closed mbsouth closed 10 months ago

mbsouth commented 3 years ago

WP Plugin Update Server Version: 1.4.14 WP Version: 5.8

Possible incorrect use of the function date_i18n in wp-plugin-update-server/wp-plugin-update-server/integration-examples/dummy-theme/lib/wp-package-updater/ on line 445

Expected behavior: Outputs a message on WP Admin Dashboard that a license has expired. This message should include the expiration date.

Actual behavior: Outputs the current date of the day instead of the expiration date.

The use of date_i18n in /wp-package-updater/class-wp-package-updater.php on line 445:

date_i18n( get_option( 'date_format' ), $license_data->date_expiry )

is incorrect. According to WP code reference, the second parameter can´t be a date (string) but only int|bool:

date_i18n( 
    string $format, 
    int|bool $timestamp_with_offset = false, 
    bool $gmt = false )

Possible solution: 445: date_format( date_create( $license_data->date_expiry ), get_option( 'date_format' ) ) shows the correct expiration date.

froger-me commented 10 months ago

Thanks for the contribution, merged with your repo! https://github.com/froger-me/wp-plugin-update-server/pull/38