PluginProbe ʕ •ᴥ•ʔ
پارسی دیت – Parsi Date / 2.1.6
پارسی دیت – Parsi Date v2.1.6
6.1 5.1.6 5.1.7 5.1.8 5.1.8.2 6.0 trunk 1.0 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.0.0-alpha 2.1 2.1.1 2.1.2 2.1.3 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0.1 2.3.0.2 2.3.1 2.3.2 2.3.3 2.3.4 3.0.1 3.0.2 3.0.3 4.0.0 4.0.1 4.0.2 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5
wp-parsidate / includes / fixes-dates.php
wp-parsidate / includes Last commit date
admin 10 years ago plugins 11 years ago widget 10 years ago fixes-archive.php 11 years ago fixes-dates.php 11 years ago fixes-get_archives.php 11 years ago fixes-get_calendar.php 11 years ago fixes-misc.php 11 years ago fixes-permalinks.php 11 years ago general.php 10 years ago install.php 11 years ago parsidate.php 11 years ago settings.php 10 years ago
fixes-dates.php
119 lines
1 <?php
2 /**
3 * Fixes dates and convert them to Jalali date.
4 *
5 * @author Mobin Ghasempoor
6 * @package WP-Parsidate
7 * @subpackage Fixes/Dates
8 */
9
10 global $wpp_settings;
11
12 if ( $wpp_settings['persian_date'] != 'disable' ) {
13 add_filter( 'the_time', 'wpp_fix_post_time', 10, 2 );
14 add_filter( 'the_date', 'wpp_fix_post_date', 10, 2 );
15 add_filter( 'get_comment_time', 'wpp_fix_comment_time', 10, 2 );
16 add_filter( 'get_comment_date', 'wpp_fix_comment_date', 10, 2 );
17 add_action( 'date_i18n', 'wpp_fix_i18n', 10, 3 );
18 }
19
20 /**
21 * Fixes post date and returns in Jalali format
22 *
23 * @param string $time Post time
24 * @param string $format Date format
25 * @return string Formatted date
26 */
27 function wpp_fix_post_date( $time, $format = '' ) {
28 global $post, $wpp_settings;
29 if ( empty( $format ) )
30 $format = get_option( 'date_format' );
31
32 if ( $wpp_settings['conv_dates'] == 'disable' )
33 return parsidate( $format, $post->post_date, 'eng' );
34 else
35 return parsidate( $format, $post->post_date );
36 }
37
38 /**
39 * Fixes post time and returns in Jalali format
40 *
41 * @param string $time Post time
42 * @param string $format Date format
43 * @return string Formatted date
44 */
45 function wpp_fix_post_time( $time, $format = '' ) {
46 global $post, $wpp_settings;
47 if ( empty( $format ) )
48 $format = get_option( 'time_format' );
49
50 if ( $wpp_settings['conv_dates'] == 'disable' )
51 return parsidate( $format, $post->post_date, 'eng' );
52 else
53 return parsidate( $format, $post->post_date );
54 }
55
56 /**
57 * Fixes comment time and returns in Jalali format
58 *
59 * @param string $time Comment time
60 * @param string $fomat Date format
61 * @return string Formatted date
62 */
63 function wpp_fix_comment_time( $time, $format = '' ) {
64 global $comment, $wpp_settings;
65 if ( empty( $format ) )
66 $format = get_option( 'time_format' );
67
68 if ( $wpp_settings['conv_dates'] == 'disable' )
69 return parsidate( $format, $comment->comment_date, 'eng' );
70 else
71 return parsidate( $format, $comment->comment_date );
72 }
73
74 /**
75 * Fixes comment date and returns in Jalali format
76 *
77 * @param string $time Comment time
78 * @param string $fomat Date format
79 * @return string Formatted date
80 */
81 function wpp_fix_comment_date( $time, $format = '' ) {
82 global $comment, $wpp_settings;
83 if ( empty( $format ) )
84 $format = get_option( 'date_format' );
85
86 if ( $wpp_settings['conv_dates'] == 'disable' )
87 return parsidate( $format, $comment->comment_date, 'eng' );
88 else
89 return parsidate( $format, $comment->comment_date );
90 }
91
92 /**
93 * Fixes i18n date formatting and convert them to Jalali
94 *
95 * @param string $format_string Date format
96 * @param string $timestamp Unix timestamp
97 * @param string $gmt GMT timestamp
98 * @return string Formatted time
99 */
100 function wpp_fix_i18n( $format_string, $timestamp, $gmt ) {
101 global $wpp_settings;
102
103 if(function_exists('debug_backtrace')) {
104 $callers = debug_backtrace();
105
106 // WordPress SEO OpenGraph Dates fix
107 if (isset($callers[6]['class']) && $callers[6]['class'] == 'WPSEO_OpenGraph') return $format_string;
108 if (isset($callers[6]['function']) && $callers[6]['function'] == 'get_the_modified_date') return $format_string;
109
110 // WooCommerce order detail fix
111 if(isset($callers['4']['class']) && $callers['4']['class']=='WC_Meta_Box_Order_Data') return $format_string;
112 }
113
114 if ( $wpp_settings['conv_dates'] == 'disable' )
115 return parsidate( $timestamp, $gmt, 'eng' );
116 else
117 return parsidate( $timestamp, $gmt );
118 }
119