Version Description
- Change date based on WordPress language (Persian/Farsi)
- Compatible with WP Multilingual plugin (WPML)
Download this release
Release Info
Developer | parselearn |
Plugin | Parsi Date |
Version | 2.3.2 |
Comparing to | |
See all releases |
Code changes from version 2.3.1 to 2.3.2
- includes/fixes-dates.php +1 -1
- includes/fixes-misc.php +42 -40
- includes/fixes-permalinks.php +311 -307
- readme.txt +5 -1
- wp-parsidate.php +1 -1
includes/fixes-dates.php
CHANGED
@@ -9,7 +9,7 @@
|
|
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 );
|
9 |
|
10 |
global $wpp_settings;
|
11 |
|
12 |
+
if ( get_locale() == 'fa_IR' && $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 );
|
includes/fixes-misc.php
CHANGED
@@ -8,43 +8,45 @@
|
|
8 |
* @subpackage Fixes/NumbersAndArabic
|
9 |
*/
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
8 |
* @subpackage Fixes/NumbersAndArabic
|
9 |
*/
|
10 |
|
11 |
+
if (get_locale() == 'fa_IR') {
|
12 |
+
global $wpp_settings;
|
13 |
+
|
14 |
+
if (isset($wpp_settings['conv_page_title']) && $wpp_settings['conv_page_title'] != 'disable') {
|
15 |
+
add_filter('wp_title', 'fixnumber', 1000);
|
16 |
+
add_filter('pre_get_document_title', 'fixnumber', 1000); // WP 4.4+
|
17 |
+
}
|
18 |
+
|
19 |
+
if (isset($wpp_settings['conv_title']) && $wpp_settings['conv_title'] != 'disable') {
|
20 |
+
add_filter('the_title', 'fixnumber', 1000);
|
21 |
+
}
|
22 |
+
|
23 |
+
if (isset($wpp_settings['conv_contents']) && $wpp_settings['conv_contents'] != 'disable') {
|
24 |
+
add_filter('the_content', 'fixnumber', 1000);
|
25 |
+
}
|
26 |
+
|
27 |
+
if (isset($wpp_settings['conv_excerpt']) && $wpp_settings['conv_excerpt'] != 'disable') {
|
28 |
+
add_filter('the_excerpt', 'fixnumber', 1000);
|
29 |
+
}
|
30 |
+
|
31 |
+
if (isset($wpp_settings['conv_comments']) && $wpp_settings['conv_comments'] != 'disable') {
|
32 |
+
add_filter('comment_text', 'fixnumber', 1000);
|
33 |
+
}
|
34 |
+
|
35 |
+
if (isset($wpp_settings['conv_comment_count']) && $wpp_settings['conv_comment_count'] != 'disable') {
|
36 |
+
add_filter('comments_number', 'fixnumber', 1000);
|
37 |
+
}
|
38 |
+
|
39 |
+
if (isset($wpp_settings['conv_cats']) && $wpp_settings['conv_cats'] != 'disable') {
|
40 |
+
add_filter('wp_list_categories', 'fixnumber', 1000);
|
41 |
+
}
|
42 |
+
|
43 |
+
if (isset($wpp_settings['conv_arabic']) && $wpp_settings['conv_arabic'] != 'disable') {
|
44 |
+
add_filter('the_content', 'fixarabic', 1000);
|
45 |
+
add_filter('the_title', 'fixarabic', 1000);
|
46 |
+
add_filter('comment_text', 'fixarabic', 1000);
|
47 |
+
add_filter('wp_list_categories', 'fixarabic', 1000);
|
48 |
+
add_filter('the_excerpt', 'fixarabic', 1000);
|
49 |
+
add_filter('wp_title', 'fixarabic', 1000);
|
50 |
+
add_filter('pre_get_document_title', 'fixarabic', 1000); // WP 4.4+
|
51 |
+
}
|
52 |
+
}
|
includes/fixes-permalinks.php
CHANGED
@@ -8,128 +8,130 @@
|
|
8 |
*/
|
9 |
global $wpp_settings;
|
10 |
|
11 |
-
if (
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
}
|
16 |
|
17 |
/**
|
18 |
* Converts post date pointer to Jalali pointer
|
19 |
*
|
20 |
* @param string $where
|
|
|
21 |
*
|
22 |
* @return string
|
23 |
*/
|
24 |
-
function wpp_posts_where(
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
133 |
}
|
134 |
|
135 |
/**
|
@@ -139,113 +141,114 @@ function wpp_posts_where( $where ) {
|
|
139 |
*
|
140 |
* @return mixed
|
141 |
*/
|
142 |
-
function wpp_pre_get_posts(
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
|
|
249 |
|
250 |
}
|
251 |
|
@@ -258,91 +261,92 @@ function wpp_pre_get_posts( $query ) {
|
|
258 |
*
|
259 |
* @return string New permalink
|
260 |
*/
|
261 |
-
function wpp_permalink(
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
|
|
348 |
}
|
8 |
*/
|
9 |
global $wpp_settings;
|
10 |
|
11 |
+
if ($wpp_settings['conv_permalinks'] == 'enable') {
|
12 |
+
add_filter('posts_where', 'wpp_posts_where', 10, 2);
|
13 |
+
add_action('pre_get_posts', 'wpp_pre_get_posts');
|
14 |
+
add_filter('post_link', 'wpp_permalink', 10, 3);
|
15 |
}
|
16 |
|
17 |
/**
|
18 |
* Converts post date pointer to Jalali pointer
|
19 |
*
|
20 |
* @param string $where
|
21 |
+
* @param string $wp_query
|
22 |
*
|
23 |
* @return string
|
24 |
*/
|
25 |
+
function wpp_posts_where($where, $wp_query)
|
26 |
+
{
|
27 |
+
global $wpdb;
|
28 |
+
if (!$wp_query->is_main_query() || empty($wp_query->query_vars)) {
|
29 |
+
return $where;
|
30 |
+
}
|
31 |
+
|
32 |
+
$pd = bn_parsidate::getInstance();
|
33 |
+
|
34 |
+
$m = (isset($wp_query->query_vars['m'])) ? $wp_query->query_vars['m'] : '';
|
35 |
+
$hour = (isset($wp_query->query_vars['hour'])) ? $wp_query->query_vars['hour'] : '';
|
36 |
+
$minute = (isset($wp_query->query_vars['minute'])) ? $wp_query->query_vars['minute'] : '';
|
37 |
+
$second = (isset($wp_query->query_vars['second'])) ? $wp_query->query_vars['second'] : '';
|
38 |
+
$year = (isset($wp_query->query_vars['year'])) ? $wp_query->query_vars['year'] : '';
|
39 |
+
$month = (isset($wp_query->query_vars['month'])) ? $wp_query->query_vars['month'] : '';
|
40 |
+
$day = (isset($wp_query->query_vars['day'])) ? $wp_query->query_vars['day'] : '';
|
41 |
+
|
42 |
+
if (!empty($m)) {
|
43 |
+
$len = strlen($m);
|
44 |
+
$year = substr($m, 0, 4);
|
45 |
+
if ($len > 5) {
|
46 |
+
$month = substr($m, 4, 2);
|
47 |
+
}
|
48 |
+
if ($len > 7) {
|
49 |
+
$day = substr($m, 6, 2);
|
50 |
+
}
|
51 |
+
if ($len > 9) {
|
52 |
+
$hour = substr($m, 8, 2);
|
53 |
+
}
|
54 |
+
if ($len > 11) {
|
55 |
+
$minute = substr($m, 10, 2);
|
56 |
+
}
|
57 |
+
if ($len > 13) {
|
58 |
+
$second = substr($m, 12, 2);
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
if (empty($year) || $year > 1700) {
|
63 |
+
return $where;
|
64 |
+
}
|
65 |
+
|
66 |
+
$stamon = 1;
|
67 |
+
$staday = 1;
|
68 |
+
$stahou = '00';
|
69 |
+
$stamin = '00';
|
70 |
+
$stasec = '00';
|
71 |
+
$endmon = 1;
|
72 |
+
$endday = 1;
|
73 |
+
$endhou = '00';
|
74 |
+
$endmin = '00';
|
75 |
+
$endsec = '00';
|
76 |
+
|
77 |
+
$stayear = $year;
|
78 |
+
$endyear = $year + 1;
|
79 |
+
|
80 |
+
if ($month != '') {
|
81 |
+
$stamon = $month;
|
82 |
+
$endmon = ($month == 12 ? 1 : $month + 1);
|
83 |
+
$endyear = ($endmon == 1 ? $stayear + 1 : $stayear);
|
84 |
+
}
|
85 |
+
|
86 |
+
if ($day != '') {
|
87 |
+
$staday = $day;
|
88 |
+
$endday = ($day == $pd->j_days_in_month[(int)$month - 1] ? 1 : $day + 1);
|
89 |
+
$endmon = ($endday == 1 ? $stamon + 1 : $stamon);
|
90 |
+
}
|
91 |
+
|
92 |
+
if ($hour != '') {
|
93 |
+
$stahou = $hour;
|
94 |
+
$endhou = ($hour == 24 ? '00' : $hour + 1);
|
95 |
+
$endday = ($endhou == '00' ? $staday + 1 : $staday);
|
96 |
+
}
|
97 |
+
|
98 |
+
if ($minute != '') {
|
99 |
+
$stamin = $minute;
|
100 |
+
$endmin = ($minute == 59 ? '00' : $minute + 1);
|
101 |
+
$endhou = ($endmin == '00' ? $stahou + 1 : $stahou);
|
102 |
+
}
|
103 |
+
|
104 |
+
if ($second != '') {
|
105 |
+
$stasec = $second;
|
106 |
+
$endsec = ($second == 59 ? '00' : $second + 1);
|
107 |
+
$endmin = ($endsec == '00' ? $stamin + 1 : $stamin);
|
108 |
+
}
|
109 |
+
|
110 |
+
$stadate = "$stayear-$stamon-$staday";
|
111 |
+
$enddate = "$endyear-$endmon-$endday";
|
112 |
+
$stadate = gregdate('Y-m-d', $stadate);
|
113 |
+
$enddate = gregdate('Y-m-d', $enddate);
|
114 |
+
$stadate .= " $stahou:$stamin:$stasec";
|
115 |
+
$enddate .= " $endhou:$endmin:$endsec";
|
116 |
+
|
117 |
+
$patterns = array(
|
118 |
+
'/YEAR\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
|
119 |
+
'/DAYOFMONTH\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
|
120 |
+
'/MONTH\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
|
121 |
+
'/HOUR\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
|
122 |
+
'/MINUTE\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
|
123 |
+
'/SECOND\((.*?)post_date\s*\)\s*=\s*[0-9\']*/'
|
124 |
+
);
|
125 |
+
foreach ($patterns as $pattern) {
|
126 |
+
$where = preg_replace($pattern, '1=1', $where);
|
127 |
+
}
|
128 |
+
|
129 |
+
$prefixp = "{$wpdb->posts}.";
|
130 |
+
$prefixp = (strpos($where, $prefixp) == false) ? '' : $prefixp;
|
131 |
+
|
132 |
+
$where .= " AND {$prefixp}post_date >= '$stadate' AND {$prefixp}post_date < '$enddate' ";
|
133 |
+
|
134 |
+
return $where;
|
135 |
}
|
136 |
|
137 |
/**
|
141 |
*
|
142 |
* @return mixed
|
143 |
*/
|
144 |
+
function wpp_pre_get_posts($query)
|
145 |
+
{
|
146 |
+
global $wpdb;
|
147 |
+
|
148 |
+
$permalink = $query->query;
|
149 |
+
$year = '';
|
150 |
+
$monthnum = '';
|
151 |
+
$day = '';//start
|
152 |
+
|
153 |
+
if (isset($permalink['year'])) {
|
154 |
+
$year = $permalink['year'];
|
155 |
+
}
|
156 |
+
if (isset($permalink['monthnum'])) {
|
157 |
+
$monthnum = $permalink['monthnum'];
|
158 |
+
}
|
159 |
+
if (isset($permalink['day'])) {
|
160 |
+
$day = $permalink['day'];
|
161 |
+
}
|
162 |
+
if ($year > 1700) {
|
163 |
+
return $query;
|
164 |
+
}
|
165 |
+
|
166 |
+
$out = false;
|
167 |
+
$pd = bn_parsidate::getInstance();
|
168 |
+
if (isset($permalink['name'])) {
|
169 |
+
$var = $wpdb->get_var("SELECT post_date FROM {$wpdb->prefix}posts WHERE post_name='{$permalink['name']}' ORDER BY id");
|
170 |
+
$per = parsidate('Y-m-d', $var, 'eng');
|
171 |
+
//update_option('options', $per );
|
172 |
+
$per = explode('-', $per);
|
173 |
+
$out = true;
|
174 |
+
|
175 |
+
if ($year != $per[0]) {
|
176 |
+
$out = false;
|
177 |
+
}
|
178 |
+
if ($out && $monthnum != $per[1]) {
|
179 |
+
$out = false;
|
180 |
+
}
|
181 |
+
if ($out && $day != $per[2]) {
|
182 |
+
$out = false;
|
183 |
+
}
|
184 |
+
|
185 |
+
} elseif (isset($permalink['post_id'])) {
|
186 |
+
$out = true;
|
187 |
+
$var = $wpdb->get_var("SELECT post_date FROM {$wpdb->prefix}posts WHERE ID={$permalink['post_id']}");
|
188 |
+
} elseif (!empty($year) && !empty($monthnum) && !empty($day)) {
|
189 |
+
$out = true;
|
190 |
+
$var = gregdate('Y-m-d', "$year-$monthnum-$day");
|
191 |
+
} elseif (!empty($year) && !empty($monthnum)) {
|
192 |
+
$stadate = $pd->persian_to_gregorian($year, $monthnum, 1);
|
193 |
+
$enddate = $pd->persian_to_gregorian($year, $monthnum, $pd->j_days_in_month[($monthnum - 1)]);
|
194 |
+
$date_query = array(
|
195 |
+
array(
|
196 |
+
'after' => array(
|
197 |
+
'year' => $stadate[0],
|
198 |
+
'month' => $stadate[1],
|
199 |
+
'day' => $stadate[2] - 1,
|
200 |
+
),
|
201 |
+
'before' => array(
|
202 |
+
'year' => $enddate[0],
|
203 |
+
'month' => $enddate[1],
|
204 |
+
'day' => $enddate[2] + 1,
|
205 |
+
),
|
206 |
+
'inclusive' => true,
|
207 |
+
),
|
208 |
+
);
|
209 |
+
$query->set('date_query', $date_query);
|
210 |
+
|
211 |
+
// commented for get year & month in calander widget
|
212 |
+
// $query->set('year', '');
|
213 |
+
// $query->set('monthnum', '');
|
214 |
+
$out = false;
|
215 |
+
|
216 |
+
} elseif (!empty($year)) {
|
217 |
+
$stadate = $pd->persian_to_gregorian($year, 1, 1);
|
218 |
+
$enddate = $pd->persian_to_gregorian(($year + 1), 1, 1);
|
219 |
+
$date_query = array(
|
220 |
+
array(
|
221 |
+
'after' => array(
|
222 |
+
'year' => $stadate[0],
|
223 |
+
'month' => $stadate[1],
|
224 |
+
'day' => $stadate[2] - 1,
|
225 |
+
),
|
226 |
+
'before' => array(
|
227 |
+
'year' => $enddate[0],
|
228 |
+
'month' => $enddate[1],
|
229 |
+
'day' => $enddate[2],
|
230 |
+
),
|
231 |
+
'inclusive' => true,
|
232 |
+
),
|
233 |
+
);
|
234 |
+
$query->set('date_query', $date_query);
|
235 |
+
// $query->set('year', '');
|
236 |
+
$out = false;
|
237 |
+
}
|
238 |
+
|
239 |
+
if ($out) {
|
240 |
+
preg_match_all('!\d+!', $var, $matches);
|
241 |
+
$var = $matches[0];
|
242 |
+
|
243 |
+
$query->set('year', $var[0]);
|
244 |
+
$query->set('monthnum', $var[1]);
|
245 |
+
$query->set('day', $var[2]);
|
246 |
+
}
|
247 |
+
|
248 |
+
$query->is_404 = false;
|
249 |
+
$query->query_vars['error'] = '';
|
250 |
+
|
251 |
+
return $query;
|
252 |
|
253 |
}
|
254 |
|
261 |
*
|
262 |
* @return string New permalink
|
263 |
*/
|
264 |
+
function wpp_permalink($perma, $post, $leavename = false)
|
265 |
+
{
|
266 |
+
if (empty($post->ID)) {
|
267 |
+
return false;
|
268 |
+
}
|
269 |
+
if ($post->post_type == 'page' || $post->post_status == 'static') {
|
270 |
+
return get_page_link($post->ID);
|
271 |
+
} elseif ($post->post_type == 'attachment') {
|
272 |
+
return get_attachment_link($post->ID);
|
273 |
+
} elseif (in_array($post->post_type, get_post_types(array('_builtin' => false)))) {
|
274 |
+
return get_post_permalink($post->ID);
|
275 |
+
}
|
276 |
+
|
277 |
+
$permalink = get_option('permalink_structure');
|
278 |
+
preg_match_all('/%([^\/]*)%/', $permalink, $rewritecode);
|
279 |
+
$rewritecode = $rewritecode[0];
|
280 |
+
if ('' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft'))) {
|
281 |
+
if ($leavename) {
|
282 |
+
$rewritecode = array_diff($rewritecode, array('%postname%', '%pagename%'));
|
283 |
+
}
|
284 |
+
|
285 |
+
$date = explode(' ', parsidate('Y m d H i s', $post->post_date, 'eng'));
|
286 |
+
$out = array();
|
287 |
+
|
288 |
+
foreach ($rewritecode as $rewrite) {
|
289 |
+
switch ($rewrite) {
|
290 |
+
case '%year%':
|
291 |
+
$out[] = $date[0];
|
292 |
+
break;
|
293 |
+
case '%monthnum%':
|
294 |
+
$out[] = $date[1];
|
295 |
+
break;
|
296 |
+
case '%day%':
|
297 |
+
$out[] = $date[2];
|
298 |
+
break;
|
299 |
+
case '%hour%':
|
300 |
+
$out[] = $date[3];
|
301 |
+
break;
|
302 |
+
case '%minute%':
|
303 |
+
$out[] = $date[4];
|
304 |
+
break;
|
305 |
+
case '%second%':
|
306 |
+
$out[] = $date[5];
|
307 |
+
break;
|
308 |
+
case '%post_id%':
|
309 |
+
$out[] = $post->ID;
|
310 |
+
break;
|
311 |
+
case '%postname%':
|
312 |
+
$out[] = $post->post_name;
|
313 |
+
break;
|
314 |
+
case '%category%':
|
315 |
+
$category = '';
|
316 |
+
$cats = get_the_category($post->ID);
|
317 |
+
if ($cats) {
|
318 |
+
usort($cats, '_usort_terms_by_ID');
|
319 |
+
$category = $cats[0]->slug;
|
320 |
+
if ($parent = $cats[0]->parent) {
|
321 |
+
$category = get_category_parents($parent, false, '/', true);
|
322 |
+
}
|
323 |
+
|
324 |
+
if ($cats[0]->parent != 0) {
|
325 |
+
$category .= $cats[0]->slug;
|
326 |
+
}
|
327 |
+
}
|
328 |
+
if (empty($category)) {
|
329 |
+
$default_category = get_term(get_option('default_category'), 'category');
|
330 |
+
$category = is_wp_error($default_category) ? '' : $default_category->slug;
|
331 |
+
}
|
332 |
+
$out[] = $category;
|
333 |
+
break;
|
334 |
+
case '%author%':
|
335 |
+
$authordata = get_userdata($post->post_author);
|
336 |
+
$out[] = $authordata->user_nicename;
|
337 |
+
break;
|
338 |
+
case '%pagename%':
|
339 |
+
$out[] = $post->post_name;
|
340 |
+
break;
|
341 |
+
default:
|
342 |
+
unset($rewritecode[array_search($rewrite, $rewritecode)]);
|
343 |
+
break;
|
344 |
+
}
|
345 |
+
}
|
346 |
+
$permalink = home_url(str_replace($rewritecode, $out, $permalink));
|
347 |
+
|
348 |
+
return user_trailingslashit($permalink, 'single');
|
349 |
+
} else {
|
350 |
+
return home_url("?p=$post->ID");
|
351 |
+
}
|
352 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://forum.wp-parsi.com/
|
|
4 |
Tags: shamsi, wp-parsi, wpparsi, persian, parsi, farsi, jalali, date, calendar, i18n, l10n, Iran, Iranian, parsidate, rtl
|
5 |
Requires at least: 3.6
|
6 |
Tested up to: 4.8
|
7 |
-
Stable tag: 2.3.
|
8 |
|
9 |
Persian date support for WordPress
|
10 |
|
@@ -41,6 +41,10 @@ List of some features:
|
|
41 |
4. 'Jalali Date Calender' in action
|
42 |
|
43 |
== Changelog ==
|
|
|
|
|
|
|
|
|
44 |
= 2.3.1 =
|
45 |
* Fix date picker's month dropdown bug in admin edit post. [#issue](https://github.com/wordpress-parsi/wp-parsidate/issues/5)
|
46 |
|
4 |
Tags: shamsi, wp-parsi, wpparsi, persian, parsi, farsi, jalali, date, calendar, i18n, l10n, Iran, Iranian, parsidate, rtl
|
5 |
Requires at least: 3.6
|
6 |
Tested up to: 4.8
|
7 |
+
Stable tag: 2.3.2
|
8 |
|
9 |
Persian date support for WordPress
|
10 |
|
41 |
4. 'Jalali Date Calender' in action
|
42 |
|
43 |
== Changelog ==
|
44 |
+
= 2.3.2 =
|
45 |
+
* Change date based on WordPress language (Persian/Farsi)
|
46 |
+
* Compatible with WP Multilingual plugin (WPML)
|
47 |
+
|
48 |
= 2.3.1 =
|
49 |
* Fix date picker's month dropdown bug in admin edit post. [#issue](https://github.com/wordpress-parsi/wp-parsidate/issues/5)
|
50 |
|
wp-parsidate.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: WP-Parsidate
|
4 |
-
* Version: 2.3.
|
5 |
* Plugin URI: http://forum.wp-parsi.com/
|
6 |
* Description: Persian package for WordPress, Adds full RTL and Shamsi (Jalali) support for: posts, comments, pages, archives, search, categories, permalinks and all admin sections and TinyMce editor, lists, quick editor. This package has Jalali archive widget.
|
7 |
* Author: WP-Parsi Team
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: WP-Parsidate
|
4 |
+
* Version: 2.3.2
|
5 |
* Plugin URI: http://forum.wp-parsi.com/
|
6 |
* Description: Persian package for WordPress, Adds full RTL and Shamsi (Jalali) support for: posts, comments, pages, archives, search, categories, permalinks and all admin sections and TinyMce editor, lists, quick editor. This package has Jalali archive widget.
|
7 |
* Author: WP-Parsi Team
|