Skip to content

Commit

Permalink
main/wordpress: support for new wp_date filter
Browse files Browse the repository at this point in the history
  • Loading branch information
geminorum committed Jan 15, 2020
1 parent eae5176 commit c3c7f1c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion includes/wordpress.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ class gPersianDateWordPress extends gPersianDateModuleCore

protected function setup_actions()
{
add_filter( 'date_i18n', [ $this, 'date_i18n' ], 10, 4 );
if ( gPersianDateWP::isWPcompatible( '5.3.0' ) )
add_filter( 'wp_date', [ $this, 'wp_date' ], 10, 4 );
else
add_filter( 'date_i18n', [ $this, 'date_i18n' ], 10, 4 );

add_filter( 'get_the_date', [ $this, 'get_the_date' ], 10, 3 );
add_filter( 'get_the_time', [ $this, 'get_the_time' ], 10, 3 );
Expand Down Expand Up @@ -63,6 +66,12 @@ public function widgets_init()
$wp_widget_factory->widgets['WP_Widget_Calendar'] = new WP_Widget_Persian_Calendar();
}

public function wp_date( $date, $format, $timestamp, $gmt )
{
return $this->date_i18n( $date, $format, $timestamp, $gmt );
}

// applies only on prior to WP 5.3.0
public function date_i18n( $date, $format, $timestamp, $gmt )
{
if ( gPersianDateFormat::checkISO( $format ) )
Expand Down

0 comments on commit c3c7f1c

Please sign in to comment.