Version Description
Download this release
Release Info
Developer | parselearn |
Plugin | Parsi Date |
Version | 2.3.0.1 |
Comparing to | |
See all releases |
Code changes from version 2.2.3 to 2.3.0.1
- README.md +1 -0
- assets/css/admin-fix.css +4 -4
- assets/css/admin-fonts.css +13 -11
- assets/css/admin-styles.css +3 -10
- assets/css/editor-font-rtl.css +3 -3
- assets/css/editor-rtl.css +14 -12
- assets/css/editor.css +9 -8
- assets/js/admin.js +161 -133
- includes/admin/lists-fix.php +96 -96
- includes/admin/other-fix.php +0 -50
- includes/admin/styles-fix.php +57 -57
- includes/admin/widgets.php +51 -0
- includes/fixes-archive.php +44 -39
- includes/fixes-archives.php +112 -107
- includes/fixes-calendar.php +112 -118
- includes/fixes-dates.php +142 -130
- includes/fixes-misc.php +50 -40
- includes/fixes-permalinks.php +348 -325
- includes/general.php +171 -171
- includes/install.php +20 -31
- includes/parsidate.php +409 -366
- includes/plugins/edd.php +31 -34
- includes/plugins/woocommerce.php +71 -73
- includes/settings.php +621 -627
- includes/widget/widget_archive.php +88 -68
- includes/widget/widget_calendar.php +30 -22
- {parsi-languages → languages}/common-strings.php +3 -3
- languages/fa_IR.mo +0 -0
- {parsi-languages → languages}/fa_IR.po +83 -72
- parsi-languages/fa_IR.mo +0 -0
- readme.txt +7 -2
- wp-parsidate.php +52 -47
README.md
CHANGED
@@ -7,6 +7,7 @@ This package is made by Persian developers to bring so much better experience of
|
|
7 |
|
8 |
List of some features:
|
9 |
|
|
|
10 |
- Shamsi (Jalali) date in Posts, comments, pages, archives, search, categories
|
11 |
- Shamsi (Jalali) date in Permalinks
|
12 |
- Shamsi (Jalali) date in admin sections such as posts lists, comments lists, pages lists
|
7 |
|
8 |
List of some features:
|
9 |
|
10 |
+
- [WP-Planet.ir](http://wp-planet.ir) Widget
|
11 |
- Shamsi (Jalali) date in Posts, comments, pages, archives, search, categories
|
12 |
- Shamsi (Jalali) date in Permalinks
|
13 |
- Shamsi (Jalali) date in admin sections such as posts lists, comments lists, pages lists
|
assets/css/admin-fix.css
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
.wrap #template textarea{
|
2 |
-
direction: ltr;
|
3 |
-
text-align: left;
|
4 |
-
}
|
1 |
+
.wrap #template textarea {
|
2 |
+
direction: ltr;
|
3 |
+
text-align: left;
|
4 |
+
}
|
assets/css/admin-fonts.css
CHANGED
@@ -11,22 +11,24 @@
|
|
11 |
* - Licensed under Apache License
|
12 |
*/
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
}
|
|
|
18 |
@font-face {
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
}
|
23 |
|
24 |
@font-face {
|
25 |
-
|
26 |
-
|
27 |
}
|
|
|
28 |
@font-face {
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
}
|
11 |
* - Licensed under Apache License
|
12 |
*/
|
13 |
|
14 |
+
@font-face {
|
15 |
+
font-family: 'DroidNaskh';
|
16 |
+
src: url('../fonts/DroidNaskh-Regular.woff2') format('woff2');
|
17 |
}
|
18 |
+
|
19 |
@font-face {
|
20 |
+
font-family: 'DroidNaskh';
|
21 |
+
src: url('../fonts/DroidNaskh-Bold.woff2') format('woff2');
|
22 |
+
font-weight: bold;
|
23 |
}
|
24 |
|
25 |
@font-face {
|
26 |
+
font-family: 'Roboto';
|
27 |
+
src: url('../fonts/Roboto-Regular.woff') format('woff');
|
28 |
}
|
29 |
+
|
30 |
@font-face {
|
31 |
+
font-family: 'Roboto';
|
32 |
+
src: url('../fonts/Roboto-Bold.woff') format('woff');
|
33 |
+
font-weight: bold;
|
34 |
}
|
assets/css/admin-styles.css
CHANGED
@@ -1,14 +1,7 @@
|
|
1 |
-
body.rtl,
|
2 |
-
|
3 |
-
h2,
|
4 |
-
h3,
|
5 |
-
h4,
|
6 |
-
h5,
|
7 |
-
h6,
|
8 |
-
#wpadminbar a {
|
9 |
-
font-family: 'DroidNaskh', 'Roboto', tahoma, sans-serif !important;
|
10 |
}
|
11 |
|
12 |
.rtl #wpadminbar {
|
13 |
-
|
14 |
}
|
1 |
+
body.rtl, h1, h2, h3, h4, h5, h6, #wpadminbar a {
|
2 |
+
font-family: 'DroidNaskh', 'Roboto', tahoma, sans-serif !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
}
|
4 |
|
5 |
.rtl #wpadminbar {
|
6 |
+
font-family: 'DroidNaskh', 'Roboto', tahoma, sans-serif;
|
7 |
}
|
assets/css/editor-font-rtl.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
@import url(
|
2 |
|
3 |
body {
|
4 |
-
|
5 |
-
|
6 |
}
|
1 |
+
@import url('admin-fonts.css');
|
2 |
|
3 |
body {
|
4 |
+
font-family: 'DroidNaskh', 'Roboto', tahoma, sans-serif !important;
|
5 |
+
font-size: 15px !important;
|
6 |
}
|
assets/css/editor-rtl.css
CHANGED
@@ -1,13 +1,15 @@
|
|
1 |
-
body, #tinymce {
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
}
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
13 |
}
|
1 |
+
body, #tinymce {
|
2 |
+
font-family: tahoma, sans-serif;
|
3 |
+
font-size: 13px;
|
4 |
+
direction: rtl;
|
5 |
+
}
|
6 |
+
|
7 |
+
p {
|
8 |
+
margin-top: 13px;
|
9 |
+
margin-bottom: 13px;
|
10 |
+
}
|
11 |
+
|
12 |
+
h1, h2, h3, h4, h5, h6 {
|
13 |
+
margin-top: 15px;
|
14 |
+
margin-bottom: 15px;
|
15 |
}
|
assets/css/editor.css
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
-
body{
|
2 |
-
font-family:tahoma;
|
3 |
-
font-size:12px;
|
4 |
-
}
|
5 |
-
|
6 |
-
|
7 |
-
font-
|
8 |
-
|
|
1 |
+
body {
|
2 |
+
font-family: tahoma, sans-serif;
|
3 |
+
font-size: 12px;
|
4 |
+
}
|
5 |
+
|
6 |
+
#tinymce {
|
7 |
+
font-family: tahoma, sans-serif;
|
8 |
+
font-size: 12px;
|
9 |
+
}
|
assets/js/admin.js
CHANGED
@@ -1,133 +1,161 @@
|
|
1 |
-
jQuery(document).ready(function(){
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
else
|
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 |
-
jQuery(
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
jQuery('
|
101 |
-
|
102 |
-
|
103 |
-
function
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
var
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
jQuery('#
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
jQuery('
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(document).ready(function () {
|
2 |
+
var persian_month_names = ['', 'فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'];
|
3 |
+
|
4 |
+
jQuery('.wp-editor-wrap.html-active #content').css("direction", "ltr");
|
5 |
+
|
6 |
+
function IsLeapYear(year) {
|
7 |
+
if (((year % 4) === 0 && (year % 100) !== 0) || (year % 400) === 0 && (year % 100) === 0)
|
8 |
+
return true;
|
9 |
+
else
|
10 |
+
return false;
|
11 |
+
}
|
12 |
+
|
13 |
+
function persian_to_gregorian(jy, jm, jd) {
|
14 |
+
var j_days_sum_month = [0, 0, 31, 62, 93, 124, 155, 186, 216, 246, 276, 306, 336, 365];
|
15 |
+
var g_days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
16 |
+
var g_days_leap_month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
17 |
+
var gd = j_days_sum_month[parseInt(jm)] + parseInt(jd), gm, gy = parseInt(jy) + 621;
|
18 |
+
if (gd > 286) gy++;
|
19 |
+
if (IsLeapYear(gy - 1) && 286 < gd) gd--;
|
20 |
+
if (gd > 286) gd -= 286; else gd += 79;
|
21 |
+
if (IsLeapYear(gy)) {
|
22 |
+
for (gm = 0; gd > g_days_leap_month[gm]; gm++) {
|
23 |
+
gd -= g_days_leap_month[gm];
|
24 |
+
}
|
25 |
+
} else {
|
26 |
+
for (gm = 0; gd > g_days_in_month[gm]; gm++)gd -= g_days_in_month[gm];
|
27 |
+
}
|
28 |
+
gm++;
|
29 |
+
if (gm < 10) gm = '0' + gm;
|
30 |
+
return [gy, gm, gd];
|
31 |
+
}
|
32 |
+
|
33 |
+
function gregorian_to_persian(gy, gm, gd) {
|
34 |
+
var j_days_in_month = [31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29];
|
35 |
+
var g_days_sum_month = [0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365];
|
36 |
+
var day_of_year = g_days_sum_month[parseInt(gm)] + parseInt(gd);
|
37 |
+
var leab = IsLeapYear(gy);
|
38 |
+
var leap = IsLeapYear(gy - 1);
|
39 |
+
var jd, jm, jy, i;
|
40 |
+
if (day_of_year > 79) {
|
41 |
+
jd = (leab ? day_of_year - 78 : day_of_year - 79);
|
42 |
+
jy = gy - 621;
|
43 |
+
for (i = 0; jd > j_days_in_month[i]; i++)jd -= j_days_in_month[i];
|
44 |
+
} else {
|
45 |
+
jd = ((leap || (leab && gm > 2)) ? 287 + day_of_year : 286 + day_of_year);
|
46 |
+
jy = gy - 622;
|
47 |
+
if (leap === false && jd === 366)return [jy, 12, 30];
|
48 |
+
for (i = 0; jd > j_days_in_month[i]; i++)jd -= j_days_in_month[i];
|
49 |
+
}
|
50 |
+
jm = ++i;
|
51 |
+
jm = (jm < 10 ? jm = '0' + jm : jm);
|
52 |
+
return [jy, jm, jd];
|
53 |
+
}
|
54 |
+
|
55 |
+
/*
|
56 |
+
* Edit inline
|
57 |
+
*/
|
58 |
+
function create_stampdiv(year, mon, day, hour, minu) {
|
59 |
+
var div = '<div class="timestamp-wrap persian">' +
|
60 |
+
'<select id="mma" name="mma">';
|
61 |
+
for (var i = 1; i < 13; i++) {
|
62 |
+
if (i === mon)
|
63 |
+
div += '<option value="' + i + '" selected="selected">' + persian_month_names[i] + '</option>';
|
64 |
+
else
|
65 |
+
div += '<option value="' + i + '">' + persian_month_names[i] + '</option>';
|
66 |
+
}
|
67 |
+
div += '</select>' +
|
68 |
+
'<input type="text" id="jja" name="jja" value="' + day + '" size="2" maxlength="2" autocomplete="off" />,' +
|
69 |
+
'<input type="text" id="aaa" name="aaa" value="' + year + '" size="4" maxlength="4" autocomplete="off" /> @' +
|
70 |
+
'<input type="text" id="hha" name="hha" value="' + hour + '" size="2" maxlength="2" autocomplete="off" /> : ' +
|
71 |
+
'<input type="text" id="mna" name="mna" value="' + minu + '" size="2" maxlength="2" autocomplete="off" />' +
|
72 |
+
'</div>';
|
73 |
+
return div;
|
74 |
+
}
|
75 |
+
|
76 |
+
jQuery('a.edit-timestamp').on('click', function () {
|
77 |
+
jQuery('.persian').remove();
|
78 |
+
var date = gregorian_to_persian(jQuery('#aa').val(), jQuery('#mm').val(), jQuery('#jj').val());
|
79 |
+
var div = create_stampdiv(date[0], date[1], date[2], jQuery('#hh').val(), jQuery('#mn').val());
|
80 |
+
jQuery('#timestampdiv').prepend(div);
|
81 |
+
jQuery('#timestampdiv .timestamp-wrap:eq(1)').hide();
|
82 |
+
});
|
83 |
+
|
84 |
+
jQuery('#the-list').on('click', '.editinline', function () {
|
85 |
+
var tr = jQuery(this).closest('td');
|
86 |
+
var year = tr.find('.aa').html();
|
87 |
+
if (year > 1400) {
|
88 |
+
var month = tr.find('.mm').html();
|
89 |
+
var day = tr.find('.jj').html();
|
90 |
+
var hour = tr.find('.hh').html();
|
91 |
+
var minu = tr.find('.mn').html();
|
92 |
+
var date = gregorian_to_persian(year, month, day);
|
93 |
+
jQuery('.persian').remove();
|
94 |
+
jQuery('.inline-edit-date').prepend(create_stampdiv(date[0], date[1], date[2], hour, minu));
|
95 |
+
jQuery('.inline-edit-date div:eq(1)').hide();
|
96 |
+
}
|
97 |
+
});
|
98 |
+
|
99 |
+
|
100 |
+
jQuery('#timestampdiv,.inline-edit-date').on('keyup', '#hha', function () {
|
101 |
+
jQuery('input[name=hh]').val(jQuery(this).val());
|
102 |
+
|
103 |
+
}).on('keyup', '#mna', function () {
|
104 |
+
jQuery('input[name=mn]').val(jQuery(this).val());
|
105 |
+
|
106 |
+
}).on('keyup', '#aaa , #jja', function () {
|
107 |
+
var year = jQuery('#aaa').val();
|
108 |
+
var mon = jQuery('#mma').val();
|
109 |
+
var day = jQuery('#jja').val();
|
110 |
+
date = persian_to_gregorian(year, mon, day);
|
111 |
+
jQuery('input[name=aa]').val(date[0]);
|
112 |
+
jQuery('select[name=mm]').val(date[1]);
|
113 |
+
jQuery('input[name=jj]').val(date[2]);
|
114 |
+
|
115 |
+
}).on('change', '#mma', function () {
|
116 |
+
var year = jQuery('#aaa').val();
|
117 |
+
var mon = jQuery('#mma').val();
|
118 |
+
var day = jQuery('#jja').val();
|
119 |
+
date = persian_to_gregorian(year, mon, day);
|
120 |
+
jQuery('input[name=aa]').val(date[0]);
|
121 |
+
jQuery('select[name=mm]').val(date[1]);
|
122 |
+
jQuery('input[name=jj]').val(date[2]);
|
123 |
+
});
|
124 |
+
|
125 |
+
|
126 |
+
/*
|
127 |
+
* Filter on post screen dates
|
128 |
+
*/
|
129 |
+
jQuery('select[name=m]').hide()
|
130 |
+
var timer;
|
131 |
+
|
132 |
+
function change_date() {
|
133 |
+
var old = jQuery('#timestamp b').text();
|
134 |
+
var info = jQuery('#mma option:selected').text() + ' ' + jQuery('#jja').val() + ', ' + jQuery('#aaa').val() + '@ ' + jQuery('#hha').val() + ':' + jQuery('#mna').val();
|
135 |
+
info = info.replace(/\d+/g, function (digit) {
|
136 |
+
var ret = '';
|
137 |
+
for (var i = 0, len = digit.length; i < len; i++) {
|
138 |
+
ret += String.fromCharCode(digit.charCodeAt(i) + 1728);
|
139 |
+
}
|
140 |
+
return ret;
|
141 |
+
});
|
142 |
+
if (old != info) {
|
143 |
+
jQuery('#timestamp b').html(info);
|
144 |
+
clearInterval(timer);
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
jQuery('#timestampdiv').on('keypress', function (e) {
|
149 |
+
if (e.which == 13)
|
150 |
+
timer = setInterval(function () {
|
151 |
+
change_date();
|
152 |
+
}, 50);
|
153 |
+
});
|
154 |
+
|
155 |
+
jQuery('.save-timestamp , .cancel-timestamp , #publish').on('click', function () {
|
156 |
+
if (jQuery('#aaa').length)
|
157 |
+
timer = setInterval(function () {
|
158 |
+
change_date();
|
159 |
+
}, 50);
|
160 |
+
});
|
161 |
+
});
|
includes/admin/lists-fix.php
CHANGED
@@ -1,97 +1,97 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Fixes admin lists for dates
|
4 |
-
*
|
5 |
-
* @author Mobin Ghasempoor
|
6 |
-
* @package WP-Parsidate
|
7 |
-
* @subpackage Admin/Lists
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Enqueues admin scripts
|
12 |
-
*
|
13 |
-
* @author Ehsaan
|
14 |
-
* @return void
|
15 |
-
*/
|
16 |
-
function wpp_enqueue_admin_scripts()
|
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 |
-
|
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 |
-
$m
|
80 |
-
$predate = '';
|
81 |
-
|
82 |
-
echo '<select name="mfa">';
|
83 |
-
echo '<option ' . selected($m, 0, false) . ' value="0">' . __('Show All Dates', 'wp-parsidate') . '</option>' . PHP_EOL;
|
84 |
-
foreach ($list as $date) {
|
85 |
-
$date
|
86 |
-
$year
|
87 |
-
$month = substr($date, 4, 2);
|
88 |
-
$month = $persian_month_names[intval($month)];
|
89 |
-
|
90 |
-
if ($predate != $date) {
|
91 |
-
echo sprintf('<option %s value="%s">%s</option>', selected($m, $date, false), $date, $month . ' ' . fixnumber($year));
|
92 |
-
}
|
93 |
-
|
94 |
-
$predate = $date;
|
95 |
-
}
|
96 |
-
echo '</select>';
|
97 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fixes admin lists for dates
|
4 |
+
*
|
5 |
+
* @author Mobin Ghasempoor
|
6 |
+
* @package WP-Parsidate
|
7 |
+
* @subpackage Admin/Lists
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Enqueues admin scripts
|
12 |
+
*
|
13 |
+
* @author Ehsaan
|
14 |
+
* @return void
|
15 |
+
*/
|
16 |
+
function wpp_enqueue_admin_scripts() {
|
17 |
+
wp_register_script( 'wpp_admin', WP_PARSI_URL . 'assets/js/admin.js', false, WP_PARSI_VER );
|
18 |
+
wp_enqueue_script( 'wpp_admin' );
|
19 |
+
}
|
20 |
+
|
21 |
+
add_action( 'admin_enqueue_scripts', 'wpp_enqueue_admin_scripts' );
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Hooks admin functions for restrict posts in edit pages
|
25 |
+
*
|
26 |
+
* @return void
|
27 |
+
*/
|
28 |
+
function wpp_backend_init() {
|
29 |
+
add_action( 'restrict_manage_posts', 'wpp_restrict_posts' );
|
30 |
+
add_filter( 'posts_where', 'wpp_admin_posts_where' );
|
31 |
+
}
|
32 |
+
|
33 |
+
add_action( 'load-edit.php', 'wpp_backend_init' );
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Limits posts to a certain date, if date setted
|
37 |
+
*
|
38 |
+
* @param string $where Query pointer
|
39 |
+
*
|
40 |
+
* @return string New Pointer
|
41 |
+
*/
|
42 |
+
function wpp_admin_posts_where( $where ) {
|
43 |
+
global $wp_query;
|
44 |
+
if ( isset( $_GET['mfa'] ) && $_GET['mfa'] != '0' ) {
|
45 |
+
$wp_query->query_vars['m'] = $_GET['mfa'];
|
46 |
+
$where = wpp_posts_where( $where );
|
47 |
+
}
|
48 |
+
|
49 |
+
return $where;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Restrict posts to given date
|
54 |
+
* @author Mobin Ghasempoor
|
55 |
+
* @author Parsa Kafi
|
56 |
+
* @return void
|
57 |
+
*/
|
58 |
+
function wpp_restrict_posts() {
|
59 |
+
global $post_type, $post_status, $wpdb, $persian_month_names;
|
60 |
+
|
61 |
+
$post_status_w = "AND post_status <> 'auto-draft'";
|
62 |
+
if ( $post_status != "" ) {
|
63 |
+
if ( is_string( $post_status ) ) {
|
64 |
+
$post_status_w .= " AND post_status = '$post_status'";
|
65 |
+
}
|
66 |
+
} else {
|
67 |
+
$post_status_w .= " AND post_status <> 'trash'";
|
68 |
+
}
|
69 |
+
|
70 |
+
$sql = "SELECT DISTINCT date( post_date ) AS date
|
71 |
+
FROM $wpdb->posts
|
72 |
+
WHERE post_type='$post_type' {$post_status_w} AND date( post_date ) <> '0000-00-00'
|
73 |
+
ORDER BY post_date";
|
74 |
+
$list = $wpdb->get_col( $sql );
|
75 |
+
if ( empty( $list ) ) {
|
76 |
+
return;
|
77 |
+
}
|
78 |
+
|
79 |
+
$m = isset( $_GET['mfa'] ) ? (int) $_GET['mfa'] : 0;
|
80 |
+
$predate = '';
|
81 |
+
|
82 |
+
echo '<select name="mfa">';
|
83 |
+
echo '<option ' . selected( $m, 0, false ) . ' value="0">' . __( 'Show All Dates', 'wp-parsidate' ) . '</option>' . PHP_EOL;
|
84 |
+
foreach ( $list as $date ) {
|
85 |
+
$date = parsidate( 'Ym', $date, 'eng' );
|
86 |
+
$year = substr( $date, 0, 4 );
|
87 |
+
$month = substr( $date, 4, 2 );
|
88 |
+
$month = $persian_month_names[ intval( $month ) ];
|
89 |
+
|
90 |
+
if ( $predate != $date ) {
|
91 |
+
echo sprintf( '<option %s value="%s">%s</option>', selected( $m, $date, false ), $date, $month . ' ' . fixnumber( $year ) );
|
92 |
+
}
|
93 |
+
|
94 |
+
$predate = $date;
|
95 |
+
}
|
96 |
+
echo '</select>';
|
97 |
}
|
includes/admin/other-fix.php
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Other Fix Function
|
4 |
-
*
|
5 |
-
* @package WP-Parsidate
|
6 |
-
* @subpackage Admin/Other
|
7 |
-
*/
|
8 |
-
|
9 |
-
if (!defined('ABSPATH')) exit; // No direct access allowed
|
10 |
-
|
11 |
-
if (is_admin()) {
|
12 |
-
/**
|
13 |
-
* Fix Broken Plugins Update Link
|
14 |
-
*
|
15 |
-
* @author Parsa Kafi
|
16 |
-
* @parms string $buffer admin page
|
17 |
-
* @return string
|
18 |
-
*/
|
19 |
-
function wpp_plugins_update_link_fix($buffer)
|
20 |
-
{
|
21 |
-
if (get_locale() == 'fa_IR') {
|
22 |
-
if (preg_match_all('(صورت <a.*?>خودکار بهروز کنید<\/a>)', $buffer, $update_links)) {
|
23 |
-
foreach ($update_links[0] as $link) {
|
24 |
-
preg_match('/<a href="(.+)">/', $link, $href);
|
25 |
-
if (!wp_http_validate_url($href[1])) {
|
26 |
-
preg_match('!https?://\S+!', $link, $url);
|
27 |
-
$link_f = ' صورت ' . '<a href="' . $url[0] . '"> خودکار بهروز کنید</a>';
|
28 |
-
$buffer = str_replace($link, $link_f, $buffer);
|
29 |
-
}
|
30 |
-
}
|
31 |
-
}
|
32 |
-
}
|
33 |
-
|
34 |
-
return $buffer;
|
35 |
-
}
|
36 |
-
|
37 |
-
add_action('init', 'wpp_admin_buffer_start');
|
38 |
-
add_action('admin_footer', 'wpp_admin_buffer_end');
|
39 |
-
function wpp_admin_buffer_start()
|
40 |
-
{
|
41 |
-
global $pagenow;
|
42 |
-
if ($pagenow == 'plugins.php')
|
43 |
-
ob_start("wpp_plugins_update_link_fix");
|
44 |
-
}
|
45 |
-
|
46 |
-
function wpp_admin_buffer_end()
|
47 |
-
{
|
48 |
-
ob_end_flush();
|
49 |
-
}
|
50 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/admin/styles-fix.php
CHANGED
@@ -1,58 +1,58 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Fix admin styles & TinyMCE editor
|
4 |
-
*
|
5 |
-
* @author Mobin Ghasempoor
|
6 |
-
* @package WP-Parsidate
|
7 |
-
* @subpackage Admin/Styles
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Fixes themes and plugins RTL style, they should be LTR
|
12 |
-
*
|
13 |
-
* @since 2.0
|
14 |
-
* @return void
|
15 |
-
*/
|
16 |
-
function wpp_fix_editor_rtl()
|
17 |
-
{
|
18 |
-
wp_enqueue_style('functions', WP_PARSI_URL . 'assets/css/admin-fix.css', false, WP_PARSI_VER, 'all');
|
19 |
-
}
|
20 |
-
|
21 |
-
add_action('admin_print_styles-plugin-editor.php', 'wpp_fix_editor_rtl', 10);
|
22 |
-
add_action('admin_print_styles-theme-editor.php', 'wpp_fix_editor_rtl', 10);
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Fixes TinyMCE font
|
26 |
-
*
|
27 |
-
* @since 2.0
|
28 |
-
* @return void
|
29 |
-
*/
|
30 |
-
function wpp_fix_tinymce_font()
|
31 |
-
{
|
32 |
-
global $wpp_settings;
|
33 |
-
|
34 |
-
add_editor_style(WP_PARSI_URL . 'assets/css/editor.css');
|
35 |
-
if (!isset($wpp_settings['droidsans_editor']) || $wpp_settings['droidsans_editor'] != 'disable') {
|
36 |
-
add_editor_style(WP_PARSI_URL . 'assets/css/editor-font.css');
|
37 |
-
}
|
38 |
-
}
|
39 |
-
|
40 |
-
add_filter('init', 'wpp_fix_tinymce_font', 9);
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Style for whole Admin side
|
44 |
-
*
|
45 |
-
* @since 2.1.5
|
46 |
-
* @return void
|
47 |
-
*/
|
48 |
-
function wpp_enqueue_admin()
|
49 |
-
{
|
50 |
-
global $wpp_settings;
|
51 |
-
|
52 |
-
if (!isset($wpp_settings['droidsans_admin']) || $wpp_settings['droidsans_admin'] != 'disable') {
|
53 |
-
wp_enqueue_style('wp-parsi-fonts', WP_PARSI_URL . 'assets/css/admin-fonts.css', false, WP_PARSI_VER, 'all');
|
54 |
-
wp_enqueue_style('wp-parsi-admin', WP_PARSI_URL . 'assets/css/admin-styles.css', false, WP_PARSI_VER, 'all');
|
55 |
-
}
|
56 |
-
}
|
57 |
-
|
58 |
add_action('admin_enqueue_scripts', 'wpp_enqueue_admin');
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fix admin styles & TinyMCE editor
|
4 |
+
*
|
5 |
+
* @author Mobin Ghasempoor
|
6 |
+
* @package WP-Parsidate
|
7 |
+
* @subpackage Admin/Styles
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Fixes themes and plugins RTL style, they should be LTR
|
12 |
+
*
|
13 |
+
* @since 2.0
|
14 |
+
* @return void
|
15 |
+
*/
|
16 |
+
function wpp_fix_editor_rtl()
|
17 |
+
{
|
18 |
+
wp_enqueue_style('functions', WP_PARSI_URL . 'assets/css/admin-fix.css', false, WP_PARSI_VER, 'all');
|
19 |
+
}
|
20 |
+
|
21 |
+
add_action('admin_print_styles-plugin-editor.php', 'wpp_fix_editor_rtl', 10);
|
22 |
+
add_action('admin_print_styles-theme-editor.php', 'wpp_fix_editor_rtl', 10);
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Fixes TinyMCE font
|
26 |
+
*
|
27 |
+
* @since 2.0
|
28 |
+
* @return void
|
29 |
+
*/
|
30 |
+
function wpp_fix_tinymce_font()
|
31 |
+
{
|
32 |
+
global $wpp_settings;
|
33 |
+
|
34 |
+
add_editor_style(WP_PARSI_URL . 'assets/css/editor.css');
|
35 |
+
if (!isset($wpp_settings['droidsans_editor']) || $wpp_settings['droidsans_editor'] != 'disable') {
|
36 |
+
add_editor_style(WP_PARSI_URL . 'assets/css/editor-font.css');
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
add_filter('init', 'wpp_fix_tinymce_font', 9);
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Style for whole Admin side
|
44 |
+
*
|
45 |
+
* @since 2.1.5
|
46 |
+
* @return void
|
47 |
+
*/
|
48 |
+
function wpp_enqueue_admin()
|
49 |
+
{
|
50 |
+
global $wpp_settings;
|
51 |
+
|
52 |
+
if (!isset($wpp_settings['droidsans_admin']) || $wpp_settings['droidsans_admin'] != 'disable') {
|
53 |
+
wp_enqueue_style('wp-parsi-fonts', WP_PARSI_URL . 'assets/css/admin-fonts.css', false, WP_PARSI_VER, 'all');
|
54 |
+
wp_enqueue_style('wp-parsi-admin', WP_PARSI_URL . 'assets/css/admin-styles.css', false, WP_PARSI_VER, 'all');
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
add_action('admin_enqueue_scripts', 'wpp_enqueue_admin');
|
includes/admin/widgets.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP-Parsidate Admin Widget
|
4 |
+
*
|
5 |
+
* @author Parsa Kafi
|
6 |
+
* @package WP-Parsidate
|
7 |
+
* @subpackage Core/General
|
8 |
+
*/
|
9 |
+
|
10 |
+
function wpp_add_dashboard_widgets() {
|
11 |
+
wp_add_dashboard_widget(
|
12 |
+
'wpp_planet_widget',
|
13 |
+
__( 'WordPress Planet', 'wp-parsidate' ),
|
14 |
+
'wpp_planet_widget_function'
|
15 |
+
);
|
16 |
+
}
|
17 |
+
|
18 |
+
function wpp_planet_widget_function() {
|
19 |
+
$rss = fetch_feed( 'http://wp-planet.ir/feed' );
|
20 |
+
|
21 |
+
$max_items = $rss_items = 0;
|
22 |
+
|
23 |
+
if ( ! is_wp_error( $rss ) ) {
|
24 |
+
$max_items = $rss->get_item_quantity( 5 );
|
25 |
+
$rss_items = $rss->get_items( 0, $max_items );
|
26 |
+
}
|
27 |
+
?>
|
28 |
+
<div class="rss-widget">
|
29 |
+
<ul>
|
30 |
+
<?php if ( $max_items == 0 ) {
|
31 |
+
echo "<li>" . __( 'No items', 'wp-parsidate' ) . "</li>";
|
32 |
+
} else {
|
33 |
+
$date_format = get_option( 'date_format' );
|
34 |
+
foreach ( $rss_items as $item ) {
|
35 |
+
?>
|
36 |
+
<li>
|
37 |
+
<a href="<?php echo esc_url( $item->get_permalink() ); ?>" target="_blank"
|
38 |
+
title="<?php echo esc_html( parsidate( "Y F d H:i:s", $item->get_date( "Y-m-d H:i:s" ) ) ); ?>">
|
39 |
+
<?php echo esc_html( $item->get_title() ); ?>
|
40 |
+
</a>
|
41 |
+
<span class="rss-date"><?php echo esc_html( parsidate( $date_format, $item->get_date( "Y-m-d H:i:s" ) ) ); ?></span>
|
42 |
+
<div class="rssSummary">
|
43 |
+
<?php //echo esc_url( $item->get_description() ); ?>
|
44 |
+
</div>
|
45 |
+
</li>
|
46 |
+
<?php }
|
47 |
+
} ?>
|
48 |
+
</ul>
|
49 |
+
</div>
|
50 |
+
<?php
|
51 |
+
}
|
includes/fixes-archive.php
CHANGED
@@ -1,39 +1,44 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Fixes archives and make them compatible with Shamsi date
|
4 |
-
*
|
5 |
-
* @package WP-Parsidate
|
6 |
-
* @subpackage Fixes/Archives
|
7 |
-
* @author Mobin Ghasempoor
|
8 |
-
*/
|
9 |
-
|
10 |
-
add_filter('wp_title', 'wpp_fix_title');
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @param string $
|
17 |
-
* @param string $
|
18 |
-
* @
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
$
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
$title =
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fixes archives and make them compatible with Shamsi date
|
4 |
+
*
|
5 |
+
* @package WP-Parsidate
|
6 |
+
* @subpackage Fixes/Archives
|
7 |
+
* @author Mobin Ghasempoor
|
8 |
+
*/
|
9 |
+
|
10 |
+
add_filter( 'wp_title', 'wpp_fix_title', 10000, 2 );
|
11 |
+
add_filter( 'pre_get_document_title', 'wpp_fix_title', 10000 ); // WP 4.4+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Fixes titles for archives
|
15 |
+
*
|
16 |
+
* @param string $title Archive title
|
17 |
+
* @param string $sep Separator
|
18 |
+
* @param string $sep_location Separator location
|
19 |
+
*
|
20 |
+
* @return string New archive title
|
21 |
+
*/
|
22 |
+
function wpp_fix_title( $title, $sep = '-', $sep_location = 'right' ) {
|
23 |
+
global $persian_month_names, $wp_query, $wpp_settings;
|
24 |
+
$query = $wp_query->query;
|
25 |
+
|
26 |
+
if ( ! is_archive() || $wpp_settings['persian_date'] == 'disable' ) {
|
27 |
+
return $title;
|
28 |
+
}
|
29 |
+
|
30 |
+
if ( $sep_location == 'right' ) {
|
31 |
+
$query = array_reverse( $query );
|
32 |
+
}
|
33 |
+
|
34 |
+
if ( isset( $query['monthnum'] ) ) {
|
35 |
+
$query['monthnum'] = $persian_month_names[ intval( $query['monthnum'] ) ];
|
36 |
+
$title = implode( " ", $query ) . " $sep " . get_bloginfo( "name" );
|
37 |
+
}
|
38 |
+
|
39 |
+
if ( $wpp_settings['conv_page_title'] != 'disable' ) {
|
40 |
+
$title = fixnumber( $title );
|
41 |
+
}
|
42 |
+
|
43 |
+
return $title;
|
44 |
+
}
|
includes/fixes-archives.php
CHANGED
@@ -4,151 +4,156 @@
|
|
4 |
* Create Persian Archives
|
5 |
*
|
6 |
* @param string $args
|
|
|
7 |
* @return string
|
8 |
*/
|
9 |
-
function wpp_get_archives($args = '')
|
10 |
-
|
11 |
-
global $wpdb, $wp_locale, $persian_month_names;
|
12 |
$defaults = array(
|
13 |
-
'type'
|
14 |
-
'
|
15 |
-
'
|
16 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
$
|
19 |
-
extract($r, EXTR_SKIP);
|
20 |
-
$archive_link_m = home_url("'?m='");
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
$
|
26 |
-
$count
|
27 |
-
$
|
28 |
-
|
29 |
-
$
|
30 |
-
|
31 |
-
if ($date == $old_date)
|
32 |
$count += $dt->count;
|
33 |
-
else {
|
34 |
-
echo_yarchive($old_date, $format, $before, $count, $show_post_count);
|
35 |
$old_date = $date;
|
36 |
-
$count
|
37 |
}
|
38 |
}
|
39 |
-
echo_yarchive($old_date, $format, $before, $count, $show_post_count);
|
40 |
-
} elseif ($type == 'monthly') {
|
41 |
-
$old_date = parsidate('Ym', $results[0]->date, 'eng');
|
42 |
-
$count
|
43 |
-
$c
|
44 |
-
for ($i = 1; $i < $c; $i++) {
|
45 |
-
$dt
|
46 |
-
$date = parsidate('Ym', $dt->date, 'eng');
|
47 |
-
if ($date == $old_date)
|
48 |
$count += $dt->count;
|
49 |
-
else {
|
50 |
-
echo_marchive($old_date, $format, $before, $count, $show_post_count);
|
51 |
$old_date = $date;
|
52 |
-
$count
|
53 |
}
|
54 |
}
|
55 |
-
echo_marchive($old_date, $format, $before, $count, $show_post_count);
|
56 |
-
} elseif ($type == 'daily') {
|
57 |
-
foreach ($results as $row) {
|
58 |
-
$date = parsidate('Y,m,d', $row->date, 'eng');
|
59 |
-
$date = explode(',', $date);
|
60 |
-
if ($show_post_count)
|
61 |
-
$count = ' (' . fixnumber($row->count) . ')';
|
62 |
-
else
|
63 |
$count = '';
|
64 |
-
|
65 |
-
|
|
|
66 |
}
|
67 |
}
|
68 |
}
|
69 |
}
|
70 |
|
71 |
-
function echo_yarchive($year, $format, $before, $count, $show_post_count)
|
72 |
-
{
|
73 |
-
|
74 |
-
|
75 |
-
else
|
76 |
$count = '';
|
77 |
-
|
|
|
78 |
}
|
79 |
|
80 |
-
function echo_marchive($old_date, $format, $before, $count, $show_post_count)
|
81 |
-
{
|
82 |
global $persian_month_names;
|
83 |
-
$year
|
84 |
-
$month = substr($old_date, 4, 2);
|
85 |
-
if ($show_post_count)
|
86 |
-
$count = ' (' . fixnumber($count) . ')';
|
87 |
-
else
|
88 |
$count = '';
|
89 |
-
|
|
|
90 |
}
|
91 |
|
92 |
-
function wp_get_parchives($args = '')
|
93 |
-
|
94 |
-
global $wpdb, $wp_locale, $persian_month_names;
|
95 |
$defaults = array(
|
96 |
-
'type'
|
97 |
-
'
|
98 |
-
'
|
99 |
-
'
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
-
$r = wp_parse_args($args, $defaults);
|
102 |
-
extract($r, EXTR_SKIP);
|
103 |
-
$archive_link_m = home_url("'?m='");
|
104 |
|
105 |
-
$results = $wpdb->get_results("SELECT date( post_date )as date,count(ID)as count FROM $wpdb->posts WHERE post_date < NOW() AND post_type = 'post' AND post_status = 'publish' group by date ORDER BY post_date DESC");
|
106 |
-
if (!empty($results)) {
|
107 |
-
if ($type == 'yearly') {
|
108 |
-
$old_date = parsidate('Y', $results[0]->date, 'eng');
|
109 |
-
$count
|
110 |
-
$c
|
111 |
-
for ($i = 1; $i < $c; $i++) {
|
112 |
-
$dt
|
113 |
-
$date = parsidate('Y', $dt->date, 'eng');
|
114 |
-
if ($date
|
115 |
$count += $dt->count;
|
116 |
-
else {
|
117 |
-
echo_yarchive($old_date, $format, $before, $count, $show_post_count);
|
118 |
$old_date = $date;
|
119 |
-
$count
|
120 |
}
|
121 |
}
|
122 |
-
echo_yarchive($old_date
|
123 |
-
} elseif ($type == 'monthly') {
|
124 |
-
$old_date = parsidate('Ym', $results[0]->date, 'eng');
|
125 |
-
$count
|
126 |
-
$c
|
127 |
-
for ($i = 1; $i < $c; $i++) {
|
128 |
-
$dt
|
129 |
-
$date = parsidate('Ym', $dt->date, 'eng');
|
130 |
-
if ($date
|
131 |
$count += $dt->count;
|
132 |
-
else {
|
133 |
-
echo_marchive($old_date, $format, $before, $count, $show_post_count);
|
134 |
$old_date = $date;
|
135 |
-
$count
|
136 |
}
|
137 |
}
|
138 |
-
echo_marchive($old_date, $format, $before, $count, $show_post_count);
|
139 |
-
} elseif ($type == 'daily') {
|
140 |
-
foreach ($results as $row) {
|
141 |
-
$date = parsidate('Y,m,d', $row->date, 'eng');
|
142 |
-
$date = explode(',', $date);
|
143 |
-
if ($show_post_count)
|
144 |
-
$count = ' (' . fixnumber($row->count) . ')';
|
145 |
-
else
|
146 |
$count = '';
|
147 |
-
|
148 |
-
|
|
|
149 |
}
|
150 |
}
|
151 |
}
|
152 |
-
}
|
153 |
-
|
154 |
-
?>
|
4 |
* Create Persian Archives
|
5 |
*
|
6 |
* @param string $args
|
7 |
+
*
|
8 |
* @return string
|
9 |
*/
|
10 |
+
function wpp_get_archives( $args = '' ) {
|
11 |
+
global $wpdb, $persian_month_names;
|
|
|
12 |
$defaults = array(
|
13 |
+
'type' => 'monthly',
|
14 |
+
'limit' => '',
|
15 |
+
'format' => 'html',
|
16 |
+
'before' => '',
|
17 |
+
'after' => '',
|
18 |
+
'show_post_count' => false,
|
19 |
+
'echo' => 1,
|
20 |
+
'order' => 'DESC'
|
21 |
+
);
|
22 |
+
$r = wp_parse_args( $args, $defaults );
|
23 |
|
24 |
+
$results = $wpdb->get_results( "SELECT date( post_date )as date,count(ID)as count FROM $wpdb->posts WHERE post_date < NOW() AND post_type = 'post' AND post_status = 'publish' group by date ORDER BY post_date DESC" );
|
|
|
|
|
25 |
|
26 |
+
if ( ! empty( $results ) ) {
|
27 |
+
if ( $r['type'] == 'yearly' ) {
|
28 |
+
$old_date = parsidate( 'Y', $results[0]->date, 'eng' );
|
29 |
+
$count = $results[0]->count;
|
30 |
+
$c = count( $results );
|
31 |
+
for ( $i = 1; $i < $c; $i ++ ) {
|
32 |
+
$dt = $results[ $i ];
|
33 |
+
$date = parsidate( 'Y', $dt->date, 'eng' );
|
34 |
+
if ( $date === $old_date ) {
|
|
|
35 |
$count += $dt->count;
|
36 |
+
} else {
|
37 |
+
echo_yarchive( $old_date, $r['format'], $r['before'], $count, $r['show_post_count'] );
|
38 |
$old_date = $date;
|
39 |
+
$count = $dt->count;
|
40 |
}
|
41 |
}
|
42 |
+
echo_yarchive( $old_date, $r['format'], $r['before'], $count, $r['show_post_count'] );
|
43 |
+
} elseif ( $r['type'] == 'monthly' ) {
|
44 |
+
$old_date = parsidate( 'Ym', $results[0]->date, 'eng' );
|
45 |
+
$count = $results[0]->count;
|
46 |
+
$c = count( $results );
|
47 |
+
for ( $i = 1; $i < $c; $i ++ ) {
|
48 |
+
$dt = $results[ $i ];
|
49 |
+
$date = parsidate( 'Ym', $dt->date, 'eng' );
|
50 |
+
if ( $date == $old_date ) {
|
51 |
$count += $dt->count;
|
52 |
+
} else {
|
53 |
+
echo_marchive( $old_date, $r['format'], $r['before'], $count, $r['show_post_count'] );
|
54 |
$old_date = $date;
|
55 |
+
$count = $dt->count;
|
56 |
}
|
57 |
}
|
58 |
+
echo_marchive( $old_date, $r['format'], $r['before'], $count, $r['show_post_count'] );
|
59 |
+
} elseif ( $r['type'] == 'daily' ) {
|
60 |
+
foreach ( $results as $row ) {
|
61 |
+
$date = parsidate( 'Y,m,d', $row->date, 'eng' );
|
62 |
+
$date = explode( ',', $date );
|
63 |
+
if ( $r['show_post_count'] ) {
|
64 |
+
$count = ' (' . fixnumber( $row->count ) . ')';
|
65 |
+
} else {
|
66 |
$count = '';
|
67 |
+
}
|
68 |
+
$text = fixnumber( $date[2] ) . ' ' . $persian_month_names[ intval( $date[1] ) ] . ' ' . fixnumber( $date[0] );
|
69 |
+
echo get_archives_link( get_day_link( $date[0], $date[1], $date[2] ), $text, $r['format'], $r['before'], $count );
|
70 |
}
|
71 |
}
|
72 |
}
|
73 |
}
|
74 |
|
75 |
+
function echo_yarchive( $year, $format, $before, $count, $show_post_count ) {
|
76 |
+
if ( $show_post_count ) {
|
77 |
+
$count = ' (' . fixnumber( $count ) . ')';
|
78 |
+
} else {
|
|
|
79 |
$count = '';
|
80 |
+
}
|
81 |
+
echo get_archives_link( get_year_link( $year ), fixnumber( $year ), $format, $before, $count );
|
82 |
}
|
83 |
|
84 |
+
function echo_marchive( $old_date, $format, $before, $count, $show_post_count ) {
|
|
|
85 |
global $persian_month_names;
|
86 |
+
$year = substr( $old_date, 0, 4 );
|
87 |
+
$month = substr( $old_date, 4, 2 );
|
88 |
+
if ( $show_post_count ) {
|
89 |
+
$count = ' (' . fixnumber( $count ) . ')';
|
90 |
+
} else {
|
91 |
$count = '';
|
92 |
+
}
|
93 |
+
echo get_archives_link( get_month_link( $year, $month ), $persian_month_names[ intval( $month ) ] . ' ' . fixnumber( $year ), $format, $before, $count );
|
94 |
}
|
95 |
|
96 |
+
function wp_get_parchives( $args = '' ) {
|
97 |
+
global $wpdb, $persian_month_names;
|
|
|
98 |
$defaults = array(
|
99 |
+
'type' => 'monthly',
|
100 |
+
'limit' => '',
|
101 |
+
'format' => 'html',
|
102 |
+
'before' => '',
|
103 |
+
'after' => '',
|
104 |
+
'show_post_count' => false,
|
105 |
+
'echo' => 1,
|
106 |
+
'order' => 'DESC'
|
107 |
+
);
|
108 |
|
109 |
+
$r = wp_parse_args( $args, $defaults );
|
|
|
|
|
110 |
|
111 |
+
$results = $wpdb->get_results( "SELECT date( post_date )as date,count(ID)as count FROM $wpdb->posts WHERE post_date < NOW() AND post_type = 'post' AND post_status = 'publish' group by date ORDER BY post_date DESC" );
|
112 |
+
if ( ! empty( $results ) ) {
|
113 |
+
if ( $r['type'] == 'yearly' ) {
|
114 |
+
$old_date = parsidate( 'Y', $results[0]->date, 'eng' );
|
115 |
+
$count = $results[0]->count;
|
116 |
+
$c = count( $results );
|
117 |
+
for ( $i = 1; $i < $c; $i ++ ) {
|
118 |
+
$dt = $results[ $i ];
|
119 |
+
$date = parsidate( 'Y', $dt->date, 'eng' );
|
120 |
+
if ( $date === $old_date ) {
|
121 |
$count += $dt->count;
|
122 |
+
} else {
|
123 |
+
echo_yarchive( $old_date, $r['format'], $r['before'], $count, $r['show_post_count'] );
|
124 |
$old_date = $date;
|
125 |
+
$count = $dt->count;
|
126 |
}
|
127 |
}
|
128 |
+
echo_yarchive( $old_date,$r['format'], $r['before'], $count, $r['show_post_count'] );
|
129 |
+
} elseif ( $r['type'] == 'monthly' ) {
|
130 |
+
$old_date = parsidate( 'Ym', $results[0]->date, 'eng' );
|
131 |
+
$count = $results[0]->count;
|
132 |
+
$c = count( $results );
|
133 |
+
for ( $i = 1; $i < $c; $i ++ ) {
|
134 |
+
$dt = $results[ $i ];
|
135 |
+
$date = parsidate( 'Ym', $dt->date, 'eng' );
|
136 |
+
if ( $date === $old_date ) {
|
137 |
$count += $dt->count;
|
138 |
+
} else {
|
139 |
+
echo_marchive( $old_date, $r['format'], $r['before'], $count, $r['show_post_count']);
|
140 |
$old_date = $date;
|
141 |
+
$count = $dt->count;
|
142 |
}
|
143 |
}
|
144 |
+
echo_marchive( $old_date, $r['format'], $r['before'], $count, $r['show_post_count'] );
|
145 |
+
} elseif ( $r['type'] == 'daily' ) {
|
146 |
+
foreach ( $results as $row ) {
|
147 |
+
$date = parsidate( 'Y,m,d', $row->date, 'eng' );
|
148 |
+
$date = explode( ',', $date );
|
149 |
+
if ( $r['show_post_count'] ) {
|
150 |
+
$count = ' (' . fixnumber( $row->count ) . ')';
|
151 |
+
} else {
|
152 |
$count = '';
|
153 |
+
}
|
154 |
+
$text = fixnumber( $date[2] ) . ' ' . $persian_month_names[ intval( $date[1] ) ] . ' ' . fixnumber( $date[0] );
|
155 |
+
echo get_archives_link( get_day_link( $date[0], $date[1], $date[2] ), $text, $r['format'], $r['before'], $count );
|
156 |
}
|
157 |
}
|
158 |
}
|
159 |
+
}
|
|
|
|
includes/fixes-calendar.php
CHANGED
@@ -3,109 +3,110 @@
|
|
3 |
/**
|
4 |
* Create Persian Calendar
|
5 |
*
|
6 |
-
* @param string $args
|
7 |
* @author Mobin Ghasempoor
|
8 |
* @author Parsa Kafi
|
9 |
* @return string
|
10 |
*/
|
11 |
-
function wpp_get_calendar(
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
$pd = bn_parsidate::getInstance();
|
16 |
$jm = $monthnum;
|
17 |
-
if ($m != '') {
|
18 |
-
$m
|
19 |
-
$jy = substr($m, 0, 4);
|
20 |
-
} elseif ($year !== '') {
|
21 |
$jy = $year;
|
22 |
}
|
23 |
|
24 |
-
if ($jy > 1500)
|
25 |
-
list($jy, $jm, $jd) = $pd->gregorian_to_persian($year, $monthnum, $day);
|
|
|
26 |
|
27 |
-
if (
|
28 |
-
$gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
|
29 |
-
if (
|
30 |
return;
|
|
|
31 |
}
|
32 |
|
33 |
-
$week_begins
|
34 |
-
$w
|
35 |
$is_gregorian = false;
|
36 |
|
37 |
-
if (!empty($jm) && !empty($jy)) {
|
38 |
-
$thismonth = '' . zeroise(intval($jm), 2);
|
39 |
-
$thisyear
|
40 |
|
41 |
-
} elseif (!empty($w)) {
|
42 |
-
$thisyear
|
43 |
-
$d
|
44 |
-
$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
|
45 |
|
46 |
-
} elseif (!empty($m)) {
|
47 |
-
$thisyear = '' . intval(substr($m, 0, 4));
|
48 |
-
if (strlen($m) < 6)
|
49 |
$thismonth = '01';
|
50 |
-
else
|
51 |
-
$thismonth = '' . zeroise(intval(substr($m, 4, 2)), 2);
|
|
|
52 |
|
53 |
} else {
|
54 |
$is_gregorian = true;
|
55 |
-
$thisyear
|
56 |
-
$thismonth
|
57 |
-
$thisday
|
58 |
}
|
59 |
|
60 |
//print_r($wp_query->query_vars);
|
61 |
|
62 |
-
if ($is_gregorian) {
|
63 |
-
list($jthisyear, $jthismonth, $jthisday) = $pd->gregorian_to_persian($thisyear, $thismonth, $thisday);
|
64 |
-
$unixmonth = $pd->gregurian_date('Y-m-d 00:00:00', "$jthisyear-$jthismonth-01");
|
65 |
} else {
|
66 |
-
$gdate
|
67 |
-
$unixmonth
|
68 |
-
$jthisyear
|
69 |
$jthismonth = $thismonth;
|
70 |
}
|
71 |
|
72 |
$jnextmonth = $jthismonth + 1;
|
73 |
-
$jnextyear
|
74 |
|
75 |
|
76 |
-
if ($jnextmonth > 12) {
|
77 |
$jnextmonth = 1;
|
78 |
-
$jnextyear++;
|
79 |
}
|
80 |
|
81 |
-
$start = $pd->gregurian_date('Y-m-d 00:00:00', "$jthisyear-$jthismonth-01");
|
82 |
-
$end
|
83 |
|
84 |
//echo "Start Date: ".$start.", End Date: ".$end."<br>";
|
85 |
|
86 |
-
$previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
87 |
FROM $wpdb->posts
|
88 |
WHERE post_date < '$start'
|
89 |
AND post_type = 'post' AND post_status = 'publish'
|
90 |
ORDER BY post_date DESC
|
91 |
-
LIMIT 1");
|
92 |
-
$next
|
93 |
FROM $wpdb->posts
|
94 |
WHERE post_date >= '$end'
|
95 |
AND post_type = 'post' AND post_status = 'publish'
|
96 |
ORDER BY post_date ASC
|
97 |
-
LIMIT 1");
|
98 |
|
99 |
$calendar_output = '<table id="wp-calendar" style="direction: rtl" class="widget_calendar">
|
100 |
-
<caption>' . $pd->persian_month_names[(int)$jthismonth] . ' ' . $pd->persian_date('Y', $unixmonth) . '</caption>
|
101 |
<thead>
|
102 |
<tr>';
|
103 |
-
$myweek
|
104 |
-
for ($wdcount = 0; $wdcount <= 6; $wdcount++) {
|
105 |
-
$myweek[] = $pd->persian_day_small[($wdcount + $week_begins) % 7];
|
106 |
}
|
107 |
|
108 |
-
foreach ($myweek as $wd) {
|
109 |
$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$wd</th>";
|
110 |
}
|
111 |
|
@@ -116,31 +117,31 @@ function wpp_get_calendar($args = '')
|
|
116 |
<tfoot>
|
117 |
<tr>';
|
118 |
|
119 |
-
if ($previous) {
|
120 |
$previous_month = $jthismonth - 1;
|
121 |
-
$previous_year
|
122 |
-
if ($previous_month == 0) {
|
123 |
$previous_month = 12;
|
124 |
-
$previous_year--;
|
125 |
}
|
126 |
|
127 |
-
$calendar_output .= "\n\t\t" . '<td colspan="3" id="prev"><a href="' . get_month_link($previous_year, $previous_month) .
|
128 |
-
|
129 |
} else {
|
130 |
$calendar_output .= "\n\t\t" . '<td colspan="3" id="prev" class="pad"> </td>';
|
131 |
}
|
132 |
|
133 |
$calendar_output .= "\n\t\t" . '<td class="pad"> </td>';
|
134 |
|
135 |
-
if ($next) {
|
136 |
$next_month = $jthismonth + 1;
|
137 |
-
$next_year
|
138 |
-
if ($next_month == 13) {
|
139 |
$next_month = 1;
|
140 |
-
$next_year++;
|
141 |
}
|
142 |
-
$calendar_output .= "\n\t\t" . '<td colspan="3" id="next"><a href="' . get_month_link($next_year, $next_month) .
|
143 |
-
|
144 |
} else {
|
145 |
$calendar_output .= "\n\t\t" . '<td colspan="3" id="next" class="pad"> </td>';
|
146 |
}
|
@@ -154,99 +155,92 @@ function wpp_get_calendar($args = '')
|
|
154 |
|
155 |
//____________________________________________________________________________________________________________________________________
|
156 |
|
157 |
-
$sql
|
158 |
FROM $wpdb->posts
|
159 |
WHERE post_date > '$start' AND post_date < '$end'
|
160 |
AND post_type = 'post'
|
161 |
AND post_status = 'publish'";
|
162 |
-
$dayswithposts = $wpdb->get_results($sql, ARRAY_N);
|
163 |
|
164 |
-
if ($dayswithposts) {
|
165 |
-
foreach ($dayswithposts as $daywith) {
|
166 |
-
$daywithpost[] = $pd->persian_date('j', "$daywith[2]-$daywith[1]-$daywith[0]", 'eng');
|
167 |
}
|
168 |
|
169 |
} else {
|
170 |
$daywithpost = array();
|
171 |
}
|
172 |
|
173 |
-
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
|
174 |
$ak_title_separator = "\n";
|
175 |
-
else
|
176 |
$ak_title_separator = ', ';
|
|
|
177 |
|
178 |
$ak_titles_for_day = array();
|
179 |
-
$ak_post_titles
|
180 |
FROM $wpdb->posts WHERE post_date >= '$start'
|
181 |
AND post_date <= '$end'
|
182 |
-
AND post_type = 'post' AND post_status = 'publish'");
|
183 |
|
184 |
-
if ($ak_post_titles) {
|
185 |
-
foreach ($ak_post_titles as $ak_post_title) {
|
186 |
/** This filter is documented in wp-includes/post-template.php */
|
187 |
-
$post_title
|
188 |
-
$ak_post_title->dom = $pd->persian_date('j', "$ak_post_title->year-$ak_post_title->month-$ak_post_title->dom", 'eng');
|
189 |
-
|
190 |
-
if (empty($ak_titles_for_day['day_' . $ak_post_title->dom]))
|
191 |
-
$ak_titles_for_day['day_' . $ak_post_title->dom] = '';
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
$ak_titles_for_day[$ak_post_title->dom]
|
|
|
|
|
|
|
196 |
}
|
197 |
}
|
198 |
|
199 |
-
|
200 |
-
|
201 |
-
$pad = wppd_get_pad($jthisyear . "-" . $jthismonth);
|
202 |
-
//echo "<br />begin=$week_begins<br />pad=$pad<br />";
|
203 |
|
204 |
-
if (0 != $pad)
|
205 |
$calendar_output .= "\n\t\t" . '<td colspan="' . $pad . '" class="pad"> </td>';
|
|
|
206 |
|
207 |
-
$daysinmonth = intval($pd->persian_date('t', $unixmonth, 'eng'));
|
208 |
|
209 |
-
for ($day = 1; $day <= $daysinmonth;
|
210 |
-
list($thiyear, $thismonth, $thisday) = $pd->persian_to_gregorian($jthisyear, $jthismonth, $day);
|
211 |
-
if (isset($newrow) && $newrow)
|
212 |
$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
|
|
|
213 |
$newrow = false;
|
214 |
|
215 |
-
if ($thisday == gmdate('j', (time() + (get_option('gmt_offset') * 3600))) && $thismonth == gmdate('m', time() + (get_option('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time() + (get_option('gmt_offset') * 3600)))
|
216 |
$calendar_output .= '<td id="today">';
|
217 |
-
else
|
218 |
$calendar_output .= '<td>';
|
|
|
219 |
|
220 |
-
$p_day = (empty($val['sep_datesnum']) ? $day : per_number($day));
|
221 |
|
222 |
-
if (in_array($day, $daywithpost)) // any posts today?
|
223 |
-
|
224 |
-
|
|
|
225 |
$calendar_output .= $p_day;
|
|
|
226 |
$calendar_output .= '</td>';
|
227 |
|
228 |
-
if (6 == calendar_week_mod($pd->gregurian_date('w', "$jthisyear-$jthismonth-$day") - $week_begins))
|
229 |
$newrow = true;
|
|
|
230 |
}
|
231 |
-
$pad = 7 - calendar_week_mod($pd->gregurian_date('w', "$jthisyear-$jthismonth-$day", 'eng') - $week_begins);
|
232 |
-
if ($pad != 0 && $pad != 7)
|
233 |
$calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . $pad . '"> </td>';
|
|
|
234 |
|
235 |
echo $calendar_output . "\n\t</tr>\n\t</tbody>\n\t</table>";
|
236 |
-
}
|
237 |
-
|
238 |
-
/**
|
239 |
-
* Get Pad
|
240 |
-
* @author Parsa Kafi
|
241 |
-
* @param string $date
|
242 |
-
* @return int
|
243 |
-
*/
|
244 |
-
function wppd_get_pad($date)
|
245 |
-
{
|
246 |
-
$pd = bn_parsidate::getInstance();
|
247 |
-
$p = $pd->persian_date("w", $pd->gregurian_date("Y-m-d", $date . "-01"), "eng");
|
248 |
-
|
249 |
-
return $p;
|
250 |
-
}
|
251 |
-
|
252 |
-
?>
|
3 |
/**
|
4 |
* Create Persian Calendar
|
5 |
*
|
|
|
6 |
* @author Mobin Ghasempoor
|
7 |
* @author Parsa Kafi
|
8 |
* @return string
|
9 |
*/
|
10 |
+
function wpp_get_calendar() {
|
11 |
+
global $wpdb, $m, $monthnum, $year, $day, $posts;
|
12 |
+
$jy = 0;
|
|
|
13 |
$pd = bn_parsidate::getInstance();
|
14 |
$jm = $monthnum;
|
15 |
+
if ( $m != '' ) {
|
16 |
+
$m = preg_replace( "/[^0-9]/", "", $m );
|
17 |
+
$jy = substr( $m, 0, 4 );
|
18 |
+
} elseif ( $year !== '' ) {
|
19 |
$jy = $year;
|
20 |
}
|
21 |
|
22 |
+
if ( $jy > 1500 ) {
|
23 |
+
list( $jy, $jm, $jd ) = $pd->gregorian_to_persian( $year, $monthnum, $day );
|
24 |
+
}
|
25 |
|
26 |
+
if ( ! $posts ) {
|
27 |
+
$gotsome = $wpdb->get_var( "SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1" );
|
28 |
+
if ( ! $gotsome ) {
|
29 |
return;
|
30 |
+
}
|
31 |
}
|
32 |
|
33 |
+
$week_begins = intval( get_option( 'start_of_week' ) );
|
34 |
+
$w = isset( $_GET['w'] ) ? intval( $_GET['w'] ) : '';
|
35 |
$is_gregorian = false;
|
36 |
|
37 |
+
if ( ! empty( $jm ) && ! empty( $jy ) ) {
|
38 |
+
$thismonth = '' . zeroise( intval( $jm ), 2 );
|
39 |
+
$thisyear = '' . intval( $jy );
|
40 |
|
41 |
+
} elseif ( ! empty( $w ) ) {
|
42 |
+
$thisyear = '' . intval( substr( $m, 0, 4 ) );
|
43 |
+
$d = ( ( $w - 1 ) * 7 ) + 6; //it seems MySQL's weeks disagree with PHP's
|
44 |
+
$thismonth = $wpdb->get_var( "SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')" );
|
45 |
|
46 |
+
} elseif ( ! empty( $m ) ) {
|
47 |
+
$thisyear = '' . intval( substr( $m, 0, 4 ) );
|
48 |
+
if ( strlen( $m ) < 6 ) {
|
49 |
$thismonth = '01';
|
50 |
+
} else {
|
51 |
+
$thismonth = '' . zeroise( intval( substr( $m, 4, 2 ) ), 2 );
|
52 |
+
}
|
53 |
|
54 |
} else {
|
55 |
$is_gregorian = true;
|
56 |
+
$thisyear = gmdate( 'Y', current_time( 'timestamp' ) + get_option( 'gmt_offset' ) * 3600 );
|
57 |
+
$thismonth = gmdate( 'm', current_time( 'timestamp' ) + get_option( 'gmt_offset' ) * 3600 );
|
58 |
+
$thisday = gmdate( 'd', current_time( 'timestamp' ) + get_option( 'gmt_offset' ) * 3600 );
|
59 |
}
|
60 |
|
61 |
//print_r($wp_query->query_vars);
|
62 |
|
63 |
+
if ( $is_gregorian ) {
|
64 |
+
list( $jthisyear, $jthismonth, $jthisday ) = $pd->gregorian_to_persian( $thisyear, $thismonth, $thisday );
|
65 |
+
$unixmonth = $pd->gregurian_date( 'Y-m-d 00:00:00', "$jthisyear-$jthismonth-01" );
|
66 |
} else {
|
67 |
+
$gdate = $pd->persian_to_gregorian( $thisyear, $thismonth, 1 );
|
68 |
+
$unixmonth = mktime( 0, 0, 0, $gdate[1], 1, $gdate[0] );
|
69 |
+
$jthisyear = $thisyear;
|
70 |
$jthismonth = $thismonth;
|
71 |
}
|
72 |
|
73 |
$jnextmonth = $jthismonth + 1;
|
74 |
+
$jnextyear = $jthisyear;
|
75 |
|
76 |
|
77 |
+
if ( $jnextmonth > 12 ) {
|
78 |
$jnextmonth = 1;
|
79 |
+
$jnextyear ++;
|
80 |
}
|
81 |
|
82 |
+
$start = $pd->gregurian_date( 'Y-m-d 00:00:00', "$jthisyear-$jthismonth-01" );
|
83 |
+
$end = $pd->gregurian_date( 'Y-m-d 23:59:59', "$jnextyear-$jthismonth-" . $pd->j_days_in_month[ $jthismonth - 1 ] );
|
84 |
|
85 |
//echo "Start Date: ".$start.", End Date: ".$end."<br>";
|
86 |
|
87 |
+
$previous = $wpdb->get_row( "SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
88 |
FROM $wpdb->posts
|
89 |
WHERE post_date < '$start'
|
90 |
AND post_type = 'post' AND post_status = 'publish'
|
91 |
ORDER BY post_date DESC
|
92 |
+
LIMIT 1" );
|
93 |
+
$next = $wpdb->get_row( "SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
94 |
FROM $wpdb->posts
|
95 |
WHERE post_date >= '$end'
|
96 |
AND post_type = 'post' AND post_status = 'publish'
|
97 |
ORDER BY post_date ASC
|
98 |
+
LIMIT 1" );
|
99 |
|
100 |
$calendar_output = '<table id="wp-calendar" style="direction: rtl" class="widget_calendar">
|
101 |
+
<caption>' . $pd->persian_month_names[ (int) $jthismonth ] . ' ' . $pd->persian_date( 'Y', $unixmonth ) . '</caption>
|
102 |
<thead>
|
103 |
<tr>';
|
104 |
+
$myweek = array();
|
105 |
+
for ( $wdcount = 0; $wdcount <= 6; $wdcount ++ ) {
|
106 |
+
$myweek[] = $pd->persian_day_small[ ( $wdcount + $week_begins ) % 7 ];
|
107 |
}
|
108 |
|
109 |
+
foreach ( $myweek as $wd ) {
|
110 |
$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$wd</th>";
|
111 |
}
|
112 |
|
117 |
<tfoot>
|
118 |
<tr>';
|
119 |
|
120 |
+
if ( $previous ) {
|
121 |
$previous_month = $jthismonth - 1;
|
122 |
+
$previous_year = $jthisyear;
|
123 |
+
if ( $previous_month == 0 ) {
|
124 |
$previous_month = 12;
|
125 |
+
$previous_year --;
|
126 |
}
|
127 |
|
128 |
+
$calendar_output .= "\n\t\t" . '<td colspan="3" id="prev"><a href="' . get_month_link( $previous_year, $previous_month ) .
|
129 |
+
'">« ' . $pd->persian_month_names[ $previous_month ] . '</a></td>';
|
130 |
} else {
|
131 |
$calendar_output .= "\n\t\t" . '<td colspan="3" id="prev" class="pad"> </td>';
|
132 |
}
|
133 |
|
134 |
$calendar_output .= "\n\t\t" . '<td class="pad"> </td>';
|
135 |
|
136 |
+
if ( $next ) {
|
137 |
$next_month = $jthismonth + 1;
|
138 |
+
$next_year = $jthisyear;
|
139 |
+
if ( $next_month == 13 ) {
|
140 |
$next_month = 1;
|
141 |
+
$next_year ++;
|
142 |
}
|
143 |
+
$calendar_output .= "\n\t\t" . '<td colspan="3" id="next"><a href="' . get_month_link( $next_year, $next_month ) .
|
144 |
+
'">' . $pd->persian_month_names[ $next_month ] . ' »</a></td>';
|
145 |
} else {
|
146 |
$calendar_output .= "\n\t\t" . '<td colspan="3" id="next" class="pad"> </td>';
|
147 |
}
|
155 |
|
156 |
//____________________________________________________________________________________________________________________________________
|
157 |
|
158 |
+
$sql = "SELECT DISTINCT DAYOFMONTH(post_date),MONTH(post_date),YEAR(post_date)
|
159 |
FROM $wpdb->posts
|
160 |
WHERE post_date > '$start' AND post_date < '$end'
|
161 |
AND post_type = 'post'
|
162 |
AND post_status = 'publish'";
|
163 |
+
$dayswithposts = $wpdb->get_results( $sql, ARRAY_N );
|
164 |
|
165 |
+
if ( $dayswithposts ) {
|
166 |
+
foreach ( $dayswithposts as $daywith ) {
|
167 |
+
$daywithpost[] = $pd->persian_date( 'j', "$daywith[2]-$daywith[1]-$daywith[0]", 'eng' );
|
168 |
}
|
169 |
|
170 |
} else {
|
171 |
$daywithpost = array();
|
172 |
}
|
173 |
|
174 |
+
if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false || stripos( $_SERVER['HTTP_USER_AGENT'], 'camino' ) !== false || stripos( $_SERVER['HTTP_USER_AGENT'], 'safari' ) !== false ) {
|
175 |
$ak_title_separator = "\n";
|
176 |
+
} else {
|
177 |
$ak_title_separator = ', ';
|
178 |
+
}
|
179 |
|
180 |
$ak_titles_for_day = array();
|
181 |
+
$ak_post_titles = $wpdb->get_results( "SELECT ID, post_title, DAYOFMONTH(post_date) as dom, MONTH(post_date) as month, YEAR(post_date) as year
|
182 |
FROM $wpdb->posts WHERE post_date >= '$start'
|
183 |
AND post_date <= '$end'
|
184 |
+
AND post_type = 'post' AND post_status = 'publish'" );
|
185 |
|
186 |
+
if ( $ak_post_titles ) {
|
187 |
+
foreach ( $ak_post_titles as $ak_post_title ) {
|
188 |
/** This filter is documented in wp-includes/post-template.php */
|
189 |
+
$post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) );
|
190 |
+
$ak_post_title->dom = $pd->persian_date( 'j', "$ak_post_title->year-$ak_post_title->month-$ak_post_title->dom", 'eng' );
|
191 |
+
|
192 |
+
if ( empty( $ak_titles_for_day[ 'day_' . $ak_post_title->dom ] ) ) {
|
193 |
+
$ak_titles_for_day[ 'day_' . $ak_post_title->dom ] = '';
|
194 |
+
}
|
195 |
+
if ( empty( $ak_titles_for_day[ $ak_post_title->dom ] ) ) // first one
|
196 |
+
{
|
197 |
+
$ak_titles_for_day[ $ak_post_title->dom ] = $post_title;
|
198 |
+
} else {
|
199 |
+
$ak_titles_for_day[ $ak_post_title->dom ] .= $ak_title_separator . $post_title;
|
200 |
+
}
|
201 |
}
|
202 |
}
|
203 |
|
204 |
+
$pd = bn_parsidate::getInstance();
|
205 |
+
$pad = $pd->persian_date( "w", $pd->gregurian_date( "Y-m-d", $jthisyear . "-" . $jthismonth . "-01" ), "eng" );
|
|
|
|
|
206 |
|
207 |
+
if ( 0 != $pad ) {
|
208 |
$calendar_output .= "\n\t\t" . '<td colspan="' . $pad . '" class="pad"> </td>';
|
209 |
+
}
|
210 |
|
211 |
+
$daysinmonth = intval( $pd->persian_date( 't', $unixmonth, 'eng' ) );
|
212 |
|
213 |
+
for ( $day = 1; $day <= $daysinmonth; ++ $day ) {
|
214 |
+
list( $thiyear, $thismonth, $thisday ) = $pd->persian_to_gregorian( $jthisyear, $jthismonth, $day );
|
215 |
+
if ( isset( $newrow ) && $newrow ) {
|
216 |
$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
|
217 |
+
}
|
218 |
$newrow = false;
|
219 |
|
220 |
+
if ( $thisday == gmdate( 'j', ( time() + ( get_option( 'gmt_offset' ) * 3600 ) ) ) && $thismonth == gmdate( 'm', time() + ( get_option( 'gmt_offset' ) * 3600 ) ) && $thisyear == gmdate( 'Y', time() + ( get_option( 'gmt_offset' ) * 3600 ) ) ) {
|
221 |
$calendar_output .= '<td id="today">';
|
222 |
+
} else {
|
223 |
$calendar_output .= '<td>';
|
224 |
+
}
|
225 |
|
226 |
+
$p_day = ( empty( $val['sep_datesnum'] ) ? $day : per_number( $day ) );
|
227 |
|
228 |
+
if ( in_array( $day, $daywithpost ) ) // any posts today?
|
229 |
+
{
|
230 |
+
$calendar_output .= '<a href="' . get_day_link( $jthisyear, $jthismonth, $day ) . "\" title=\"$ak_titles_for_day[$day]\">$p_day</a>";
|
231 |
+
} else {
|
232 |
$calendar_output .= $p_day;
|
233 |
+
}
|
234 |
$calendar_output .= '</td>';
|
235 |
|
236 |
+
if ( 6 == calendar_week_mod( $pd->gregurian_date( 'w', "$jthisyear-$jthismonth-$day" ) - $week_begins ) ) {
|
237 |
$newrow = true;
|
238 |
+
}
|
239 |
}
|
240 |
+
$pad = 7 - calendar_week_mod( $pd->gregurian_date( 'w', "$jthisyear-$jthismonth-$day", 'eng' ) - $week_begins );
|
241 |
+
if ( $pad != 0 && $pad != 7 ) {
|
242 |
$calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . $pad . '"> </td>';
|
243 |
+
}
|
244 |
|
245 |
echo $calendar_output . "\n\t</tr>\n\t</tbody>\n\t</table>";
|
246 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/fixes-dates.php
CHANGED
@@ -1,130 +1,142 @@
|
|
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_filter('get_post_modified_time', 'wpp_fix_post_date', 10, 2);
|
18 |
-
|
19 |
-
add_action('date_i18n', 'wpp_fix_i18n', 10, 3);
|
20 |
-
}
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Fixes post date and returns in Jalali format
|
24 |
-
*
|
25 |
-
* @param string $time Post time
|
26 |
-
* @param string $format Date format
|
27 |
-
*
|
28 |
-
|
29 |
-
|
30 |
-
{
|
31 |
-
global $post, $wpp_settings;
|
32 |
-
|
33 |
-
// It's seems some plugin like acf does not exits $post.
|
34 |
-
if (empty($post))
|
35 |
-
return $time;
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
*
|
48 |
-
*
|
49 |
-
* @param string $
|
50 |
-
*
|
51 |
-
* @return string Formatted date
|
52 |
-
*/
|
53 |
-
function wpp_fix_post_time($time, $format = '')
|
54 |
-
|
55 |
-
|
56 |
-
if (empty($
|
57 |
-
$
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
*
|
69 |
-
*
|
70 |
-
* @
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
if ($
|
79 |
-
return
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_filter( 'get_post_modified_time', 'wpp_fix_post_date', 10, 2 );
|
18 |
+
|
19 |
+
add_action( 'date_i18n', 'wpp_fix_i18n', 10, 3 );
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Fixes post date and returns in Jalali format
|
24 |
+
*
|
25 |
+
* @param string $time Post time
|
26 |
+
* @param string $format Date format
|
27 |
+
*
|
28 |
+
* @return string Formatted date
|
29 |
+
*/
|
30 |
+
function wpp_fix_post_date( $time, $format = '' ) {
|
31 |
+
global $post, $wpp_settings;
|
32 |
+
|
33 |
+
// It's seems some plugin like acf does not exits $post.
|
34 |
+
if ( empty( $post ) ) {
|
35 |
+
return $time;
|
36 |
+
}
|
37 |
+
|
38 |
+
if ( empty( $format ) ) {
|
39 |
+
$format = get_option( 'date_format' );
|
40 |
+
}
|
41 |
+
|
42 |
+
return parsidate( $format, $post->post_date, $wpp_settings['conv_dates'] == 'disable' ? 'eng' : 'per' );
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Fixes post time and returns in Jalali format
|
47 |
+
*
|
48 |
+
* @param string $time Post time
|
49 |
+
* @param string $format Date format
|
50 |
+
*
|
51 |
+
* @return string Formatted date
|
52 |
+
*/
|
53 |
+
function wpp_fix_post_time( $time, $format = '' ) {
|
54 |
+
global $post, $wpp_settings;
|
55 |
+
|
56 |
+
if ( empty( $post ) ) {
|
57 |
+
return $time;
|
58 |
+
}
|
59 |
+
|
60 |
+
if ( empty( $format ) ) {
|
61 |
+
$format = get_option( 'time_format' );
|
62 |
+
}
|
63 |
+
|
64 |
+
return parsidate( $format, $post->post_date, $wpp_settings['conv_dates'] == 'disable' ? 'eng' : 'per' );
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Fixes comment time and returns in Jalali format
|
69 |
+
*
|
70 |
+
* @param string $time Comment time
|
71 |
+
* @param string $fomat Date format
|
72 |
+
*
|
73 |
+
* @return string Formatted date
|
74 |
+
*/
|
75 |
+
function wpp_fix_comment_time( $time, $format = '' ) {
|
76 |
+
global $comment, $wpp_settings;
|
77 |
+
|
78 |
+
if ( empty( $comment ) ) {
|
79 |
+
return $time;
|
80 |
+
}
|
81 |
+
|
82 |
+
if ( empty( $format ) ) {
|
83 |
+
$format = get_option( 'time_format' );
|
84 |
+
}
|
85 |
+
|
86 |
+
return parsidate( $format, $comment->comment_date, $wpp_settings['conv_dates'] == 'disable' ? 'eng' : 'per' );
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Fixes comment date and returns in Jalali format
|
91 |
+
*
|
92 |
+
* @param string $time Comment time
|
93 |
+
* @param string $format Date format
|
94 |
+
*
|
95 |
+
* @return string Formatted date
|
96 |
+
*/
|
97 |
+
function wpp_fix_comment_date( $time, $format = '' ) {
|
98 |
+
global $comment, $wpp_settings;
|
99 |
+
|
100 |
+
if ( empty( $comment ) ) {
|
101 |
+
return $time;
|
102 |
+
}
|
103 |
+
|
104 |
+
if ( empty( $format ) ) {
|
105 |
+
$format = get_option( 'date_format' );
|
106 |
+
}
|
107 |
+
|
108 |
+
return parsidate( $format, $comment->comment_date, $wpp_settings['conv_dates'] == 'disable' ? 'eng' : 'per' );
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Fixes i18n date formatting and convert them to Jalali
|
113 |
+
*
|
114 |
+
* @param string $format_string Date format
|
115 |
+
* @param string $timestamp Unix timestamp
|
116 |
+
* @param string $gmt GMT timestamp
|
117 |
+
*
|
118 |
+
* @return string Formatted time
|
119 |
+
*/
|
120 |
+
function wpp_fix_i18n( $format_string, $timestamp, $gmt ) {
|
121 |
+
global $wpp_settings;
|
122 |
+
|
123 |
+
if ( function_exists( 'debug_backtrace' ) ) {
|
124 |
+
$callers = debug_backtrace();
|
125 |
+
|
126 |
+
// WordPress SEO OpenGraph Dates fix
|
127 |
+
if ( isset( $callers[6]['class'] ) && $callers[6]['class'] == 'WPSEO_OpenGraph' ) {
|
128 |
+
return $format_string;
|
129 |
+
}
|
130 |
+
|
131 |
+
if ( isset( $callers[6]['function'] ) && $callers[6]['function'] == 'get_the_modified_date' ) {
|
132 |
+
return $format_string;
|
133 |
+
}
|
134 |
+
|
135 |
+
// WooCommerce order detail fix
|
136 |
+
if ( isset( $callers['4']['class'] ) && $callers['4']['class'] == 'WC_Meta_Box_Order_Data' ) {
|
137 |
+
return $format_string;
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
return parsidate( $timestamp, $gmt, $wpp_settings['conv_dates'] == 'disable' ? 'eng' : 'per' );
|
142 |
+
}
|
includes/fixes-misc.php
CHANGED
@@ -1,40 +1,50 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Fixes numbers in selected options
|
4 |
-
*
|
5 |
-
* @author Mobin Ghasempoor
|
6 |
-
* @author Ehsaan
|
7 |
-
* @package WP-Parsidate
|
8 |
-
* @subpackage Fixes/NumbersAndArabic
|
9 |
-
*/
|
10 |
-
|
11 |
-
global $wpp_settings;
|
12 |
-
|
13 |
-
if (isset($wpp_settings['conv_page_title']) && $wpp_settings['conv_page_title'] != 'disable')
|
14 |
-
add_filter('wp_title', 'fixnumber',
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
if (isset($wpp_settings['
|
23 |
-
add_filter('
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
if (isset($wpp_settings['
|
35 |
-
add_filter('
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
add_filter('
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fixes numbers in selected options
|
4 |
+
*
|
5 |
+
* @author Mobin Ghasempoor
|
6 |
+
* @author Ehsaan
|
7 |
+
* @package WP-Parsidate
|
8 |
+
* @subpackage Fixes/NumbersAndArabic
|
9 |
+
*/
|
10 |
+
|
11 |
+
global $wpp_settings;
|
12 |
+
|
13 |
+
if ( isset( $wpp_settings['conv_page_title'] ) && $wpp_settings['conv_page_title'] != 'disable' ) {
|
14 |
+
add_filter( 'wp_title', 'fixnumber', 1000 );
|
15 |
+
add_filter( 'pre_get_document_title', 'fixnumber', 1000 ); // WP 4.4+
|
16 |
+
}
|
17 |
+
|
18 |
+
if ( isset( $wpp_settings['conv_title'] ) && $wpp_settings['conv_title'] != 'disable' ) {
|
19 |
+
add_filter( 'the_title', 'fixnumber', 1000 );
|
20 |
+
}
|
21 |
+
|
22 |
+
if ( isset( $wpp_settings['conv_contents'] ) && $wpp_settings['conv_contents'] != 'disable' ) {
|
23 |
+
add_filter( 'the_content', 'fixnumber', 1000 );
|
24 |
+
}
|
25 |
+
|
26 |
+
if ( isset( $wpp_settings['conv_excerpt'] ) && $wpp_settings['conv_excerpt'] != 'disable' ) {
|
27 |
+
add_filter( 'the_excerpt', 'fixnumber', 1000 );
|
28 |
+
}
|
29 |
+
|
30 |
+
if ( isset( $wpp_settings['conv_comments'] ) && $wpp_settings['conv_comments'] != 'disable' ) {
|
31 |
+
add_filter( 'comment_text', 'fixnumber', 1000 );
|
32 |
+
}
|
33 |
+
|
34 |
+
if ( isset( $wpp_settings['conv_comment_count'] ) && $wpp_settings['conv_comment_count'] != 'disable' ) {
|
35 |
+
add_filter( 'comments_number', 'fixnumber', 1000 );
|
36 |
+
}
|
37 |
+
|
38 |
+
if ( isset( $wpp_settings['conv_cats'] ) && $wpp_settings['conv_cats'] != 'disable' ) {
|
39 |
+
add_filter( 'wp_list_categories', 'fixnumber', 1000 );
|
40 |
+
}
|
41 |
+
|
42 |
+
if ( isset( $wpp_settings['conv_arabic'] ) && $wpp_settings['conv_arabic'] != 'disable' ) {
|
43 |
+
add_filter( 'the_content', 'fixarabic' ,1000);
|
44 |
+
add_filter( 'the_title', 'fixarabic' ,1000);
|
45 |
+
add_filter( 'comment_text', 'fixarabic',1000 );
|
46 |
+
add_filter( 'wp_list_categories', 'fixarabic',1000 );
|
47 |
+
add_filter( 'the_excerpt', 'fixarabic' ,1000);
|
48 |
+
add_filter( 'wp_title', 'fixarabic', 1000 );
|
49 |
+
add_filter( 'pre_get_document_title', 'fixarabic', 1000 ); // WP 4.4+
|
50 |
+
}
|
includes/fixes-permalinks.php
CHANGED
@@ -1,325 +1,348 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Fixes and converts permalinks date to Jalali
|
4 |
-
*
|
5 |
-
* @author Mobin Ghasempoor
|
6 |
-
* @package WP-Parsidate
|
7 |
-
* @subpackage Fixes/Permalinks
|
8 |
-
*/
|
9 |
-
global $wpp_settings;
|
10 |
-
|
11 |
-
if ($wpp_settings['conv_permalinks'] == 'enable') {
|
12 |
-
add_filter('posts_where', 'wpp_posts_where');
|
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 |
-
*
|
22 |
-
|
23 |
-
|
24 |
-
{
|
25 |
-
global $wp_query, $wpdb;
|
26 |
-
if (empty($wp_query->query_vars))
|
27 |
-
return $where;
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
$
|
33 |
-
$
|
34 |
-
$
|
35 |
-
$
|
36 |
-
$
|
37 |
-
$
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
$
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
if ($len >
|
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 |
-
$endmon
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
$
|
86 |
-
$endday = ($
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
$
|
92 |
-
$endhou = ($
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
$
|
98 |
-
$endmin = ($
|
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 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
$
|
149 |
-
|
150 |
-
if (isset($permalink['
|
151 |
-
$
|
152 |
-
|
153 |
-
|
154 |
-
$
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
$var = $wpdb->get_var("SELECT post_date FROM {$wpdb->prefix}posts WHERE
|
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 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
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 |
-
$out[] = $
|
309 |
-
break;
|
310 |
-
case '%
|
311 |
-
$
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
}
|
324 |
-
|
325 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fixes and converts permalinks date to Jalali
|
4 |
+
*
|
5 |
+
* @author Mobin Ghasempoor
|
6 |
+
* @package WP-Parsidate
|
7 |
+
* @subpackage Fixes/Permalinks
|
8 |
+
*/
|
9 |
+
global $wpp_settings;
|
10 |
+
|
11 |
+
if ( $wpp_settings['conv_permalinks'] == 'enable' ) {
|
12 |
+
add_filter( 'posts_where', 'wpp_posts_where' );
|
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 |
+
*
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
function wpp_posts_where( $where ) {
|
25 |
+
global $wp_query, $wpdb;
|
26 |
+
if ( empty( $wp_query->query_vars ) ) {
|
27 |
+
return $where;
|
28 |
+
}
|
29 |
+
|
30 |
+
$pd = bn_parsidate::getInstance();
|
31 |
+
|
32 |
+
$m = ( isset( $wp_query->query_vars['m'] ) ) ? $wp_query->query_vars['m'] : '';
|
33 |
+
$hour = ( isset( $wp_query->query_vars['hour'] ) ) ? $wp_query->query_vars['hour'] : '';
|
34 |
+
$minute = ( isset( $wp_query->query_vars['minute'] ) ) ? $wp_query->query_vars['minute'] : '';
|
35 |
+
$second = ( isset( $wp_query->query_vars['second'] ) ) ? $wp_query->query_vars['second'] : '';
|
36 |
+
$year = ( isset( $wp_query->query_vars['year'] ) ) ? $wp_query->query_vars['year'] : '';
|
37 |
+
$month = ( isset( $wp_query->query_vars['month'] ) ) ? $wp_query->query_vars['month'] : '';
|
38 |
+
$day = ( isset( $wp_query->query_vars['day'] ) ) ? $wp_query->query_vars['day'] : '';
|
39 |
+
|
40 |
+
if ( ! empty( $m ) ) {
|
41 |
+
$len = strlen( $m );
|
42 |
+
$year = substr( $m, 0, 4 );
|
43 |
+
if ( $len > 5 ) {
|
44 |
+
$month = substr( $m, 4, 2 );
|
45 |
+
}
|
46 |
+
if ( $len > 7 ) {
|
47 |
+
$day = substr( $m, 6, 2 );
|
48 |
+
}
|
49 |
+
if ( $len > 9 ) {
|
50 |
+
$hour = substr( $m, 8, 2 );
|
51 |
+
}
|
52 |
+
if ( $len > 11 ) {
|
53 |
+
$minute = substr( $m, 10, 2 );
|
54 |
+
}
|
55 |
+
if ( $len > 13 ) {
|
56 |
+
$second = substr( $m, 12, 2 );
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
if ( empty( $year ) || $year > 1700 ) {
|
61 |
+
return $where;
|
62 |
+
}
|
63 |
+
|
64 |
+
$stamon = 1;
|
65 |
+
$staday = 1;
|
66 |
+
$stahou = '00';
|
67 |
+
$stamin = '00';
|
68 |
+
$stasec = '00';
|
69 |
+
$endmon = 1;
|
70 |
+
$endday = 1;
|
71 |
+
$endhou = '00';
|
72 |
+
$endmin = '00';
|
73 |
+
$endsec = '00';
|
74 |
+
|
75 |
+
$stayear = $year;
|
76 |
+
$endyear = $year + 1;
|
77 |
+
|
78 |
+
if ( $month != '' ) {
|
79 |
+
$stamon = $month;
|
80 |
+
$endmon = ( $month == 12 ? 1 : $month + 1 );
|
81 |
+
$endyear = ( $endmon == 1 ? $stayear + 1 : $stayear );
|
82 |
+
}
|
83 |
+
|
84 |
+
if ( $day != '' ) {
|
85 |
+
$staday = $day;
|
86 |
+
$endday = ( $day == $pd->j_days_in_month[ (int) $month - 1 ] ? 1 : $day + 1 );
|
87 |
+
$endmon = ( $endday == 1 ? $stamon + 1 : $stamon );
|
88 |
+
}
|
89 |
+
|
90 |
+
if ( $hour != '' ) {
|
91 |
+
$stahou = $hour;
|
92 |
+
$endhou = ( $hour == 24 ? '00' : $hour + 1 );
|
93 |
+
$endday = ( $endhou == '00' ? $staday + 1 : $staday );
|
94 |
+
}
|
95 |
+
|
96 |
+
if ( $minute != '' ) {
|
97 |
+
$stamin = $minute;
|
98 |
+
$endmin = ( $minute == 59 ? '00' : $minute + 1 );
|
99 |
+
$endhou = ( $endmin == '00' ? $stahou + 1 : $stahou );
|
100 |
+
}
|
101 |
+
|
102 |
+
if ( $second != '' ) {
|
103 |
+
$stasec = $second;
|
104 |
+
$endsec = ( $second == 59 ? '00' : $second + 1 );
|
105 |
+
$endmin = ( $endsec == '00' ? $stamin + 1 : $stamin );
|
106 |
+
}
|
107 |
+
|
108 |
+
$stadate = "$stayear-$stamon-$staday";
|
109 |
+
$enddate = "$endyear-$endmon-$endday";
|
110 |
+
$stadate = gregdate( 'Y-m-d', $stadate );
|
111 |
+
$enddate = gregdate( 'Y-m-d', $enddate );
|
112 |
+
$stadate .= " $stahou:$stamin:$stasec";
|
113 |
+
$enddate .= " $endhou:$endmin:$endsec";
|
114 |
+
|
115 |
+
$patterns = array(
|
116 |
+
'/YEAR\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
|
117 |
+
'/DAYOFMONTH\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
|
118 |
+
'/MONTH\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
|
119 |
+
'/HOUR\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
|
120 |
+
'/MINUTE\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
|
121 |
+
'/SECOND\((.*?)post_date\s*\)\s*=\s*[0-9\']*/'
|
122 |
+
);
|
123 |
+
foreach ( $patterns as $pattern ) {
|
124 |
+
$where = preg_replace( $pattern, '1=1', $where );
|
125 |
+
}
|
126 |
+
|
127 |
+
$prefixp = "{$wpdb->posts}.";
|
128 |
+
$prefixp = ( strpos( $where, $prefixp ) == false ) ? '' : $prefixp;
|
129 |
+
|
130 |
+
$where .= " AND {$prefixp}post_date >= '$stadate' AND {$prefixp}post_date < '$enddate' ";
|
131 |
+
|
132 |
+
return $where;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Converts post dates to Georgian dates for preventing errors
|
137 |
+
*
|
138 |
+
* @param WP_Query $query
|
139 |
+
*
|
140 |
+
* @return mixed
|
141 |
+
*/
|
142 |
+
function wpp_pre_get_posts( $query ) {
|
143 |
+
global $wpdb;
|
144 |
+
|
145 |
+
$permalink = $query->query;
|
146 |
+
$year = '';
|
147 |
+
$monthnum = '';
|
148 |
+
$day = '';//start
|
149 |
+
|
150 |
+
if ( isset( $permalink['year'] ) ) {
|
151 |
+
$year = $permalink['year'];
|
152 |
+
}
|
153 |
+
if ( isset( $permalink['monthnum'] ) ) {
|
154 |
+
$monthnum = $permalink['monthnum'];
|
155 |
+
}
|
156 |
+
if ( isset( $permalink['day'] ) ) {
|
157 |
+
$day = $permalink['day'];
|
158 |
+
}
|
159 |
+
if ( $year > 1700 ) {
|
160 |
+
return $query;
|
161 |
+
}
|
162 |
+
|
163 |
+
$out = false;
|
164 |
+
$pd = bn_parsidate::getInstance();
|
165 |
+
if ( isset( $permalink['name'] ) ) {
|
166 |
+
$var = $wpdb->get_var( "SELECT post_date FROM {$wpdb->prefix}posts WHERE post_name='{$permalink['name']}' ORDER BY id" );
|
167 |
+
$per = parsidate( 'Y-m-d', $var, 'eng' );
|
168 |
+
//update_option('options', $per );
|
169 |
+
$per = explode( '-', $per );
|
170 |
+
$out = true;
|
171 |
+
|
172 |
+
if ( $year != $per[0] ) {
|
173 |
+
$out = false;
|
174 |
+
}
|
175 |
+
if ( $out && $monthnum != $per[1] ) {
|
176 |
+
$out = false;
|
177 |
+
}
|
178 |
+
if ( $out && $day != $per[2] ) {
|
179 |
+
$out = false;
|
180 |
+
}
|
181 |
+
|
182 |
+
} elseif ( isset( $permalink['post_id'] ) ) {
|
183 |
+
$out = true;
|
184 |
+
$var = $wpdb->get_var( "SELECT post_date FROM {$wpdb->prefix}posts WHERE ID={$permalink['post_id']}" );
|
185 |
+
} elseif ( ! empty( $year ) && ! empty( $monthnum ) && ! empty( $day ) ) {
|
186 |
+
$out = true;
|
187 |
+
$var = gregdate( 'Y-m-d', "$year-$monthnum-$day" );
|
188 |
+
} elseif ( ! empty( $year ) && ! empty( $monthnum ) ) {
|
189 |
+
$stadate = $pd->persian_to_gregorian( $year, $monthnum, 1 );
|
190 |
+
$enddate = $pd->persian_to_gregorian( $year, $monthnum, $pd->j_days_in_month[ ( $monthnum - 1 ) ] );
|
191 |
+
$date_query = array(
|
192 |
+
array(
|
193 |
+
'after' => array(
|
194 |
+
'year' => $stadate[0],
|
195 |
+
'month' => $stadate[1],
|
196 |
+
'day' => $stadate[2] - 1,
|
197 |
+
),
|
198 |
+
'before' => array(
|
199 |
+
'year' => $enddate[0],
|
200 |
+
'month' => $enddate[1],
|
201 |
+
'day' => $enddate[2] + 1,
|
202 |
+
),
|
203 |
+
'inclusive' => true,
|
204 |
+
),
|
205 |
+
);
|
206 |
+
$query->set( 'date_query', $date_query );
|
207 |
+
|
208 |
+
// commented for get year & month in calander widget
|
209 |
+
// $query->set('year', '');
|
210 |
+
// $query->set('monthnum', '');
|
211 |
+
$out = false;
|
212 |
+
|
213 |
+
} elseif ( ! empty( $year ) ) {
|
214 |
+
$stadate = $pd->persian_to_gregorian( $year, 1, 1 );
|
215 |
+
$enddate = $pd->persian_to_gregorian( ( $year + 1 ), 1, 1 );
|
216 |
+
$date_query = array(
|
217 |
+
array(
|
218 |
+
'after' => array(
|
219 |
+
'year' => $stadate[0],
|
220 |
+
'month' => $stadate[1],
|
221 |
+
'day' => $stadate[2] - 1,
|
222 |
+
),
|
223 |
+
'before' => array(
|
224 |
+
'year' => $enddate[0],
|
225 |
+
'month' => $enddate[1],
|
226 |
+
'day' => $enddate[2],
|
227 |
+
),
|
228 |
+
'inclusive' => true,
|
229 |
+
),
|
230 |
+
);
|
231 |
+
$query->set( 'date_query', $date_query );
|
232 |
+
// $query->set('year', '');
|
233 |
+
$out = false;
|
234 |
+
}
|
235 |
+
|
236 |
+
if ( $out ) {
|
237 |
+
preg_match_all( '!\d+!', $var, $matches );
|
238 |
+
$var = $matches[0];
|
239 |
+
|
240 |
+
$query->set( 'year', $var[0] );
|
241 |
+
$query->set( 'monthnum', $var[1] );
|
242 |
+
$query->set( 'day', $var[2] );
|
243 |
+
}
|
244 |
+
|
245 |
+
$query->is_404 = false;
|
246 |
+
$query->query_vars['error'] = '';
|
247 |
+
|
248 |
+
return $query;
|
249 |
+
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Convert permalink structure to Jalali format
|
254 |
+
*
|
255 |
+
* @param mixed $perma
|
256 |
+
* @param WP_Post $post
|
257 |
+
* @param bool $leavename
|
258 |
+
*
|
259 |
+
* @return string New permalink
|
260 |
+
*/
|
261 |
+
function wpp_permalink( $perma, $post, $leavename = false ) {
|
262 |
+
if ( empty( $post->ID ) ) {
|
263 |
+
return false;
|
264 |
+
}
|
265 |
+
if ( $post->post_type == 'page' || $post->post_status == 'static' ) {
|
266 |
+
return get_page_link( $post->ID );
|
267 |
+
} elseif ( $post->post_type == 'attachment' ) {
|
268 |
+
return get_attachment_link( $post->ID );
|
269 |
+
} elseif ( in_array( $post->post_type, get_post_types( array( '_builtin' => false ) ) ) ) {
|
270 |
+
return get_post_permalink( $post->ID );
|
271 |
+
}
|
272 |
+
|
273 |
+
$permalink = get_option( 'permalink_structure' );
|
274 |
+
preg_match_all( '/%([^\/]*)%/', $permalink, $rewritecode );
|
275 |
+
$rewritecode = $rewritecode[0];
|
276 |
+
if ( '' != $permalink && ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) {
|
277 |
+
if ( $leavename ) {
|
278 |
+
$rewritecode = array_diff( $rewritecode, array( '%postname%', '%pagename%' ) );
|
279 |
+
}
|
280 |
+
|
281 |
+
$date = explode( ' ', parsidate( 'Y m d H i s', $post->post_date, 'eng' ) );
|
282 |
+
$out = array();
|
283 |
+
|
284 |
+
foreach ( $rewritecode as $rewrite ) {
|
285 |
+
switch ( $rewrite ) {
|
286 |
+
case '%year%':
|
287 |
+
$out[] = $date[0];
|
288 |
+
break;
|
289 |
+
case '%monthnum%':
|
290 |
+
$out[] = $date[1];
|
291 |
+
break;
|
292 |
+
case '%day%':
|
293 |
+
$out[] = $date[2];
|
294 |
+
break;
|
295 |
+
case '%hour%':
|
296 |
+
$out[] = $date[3];
|
297 |
+
break;
|
298 |
+
case '%minute%':
|
299 |
+
$out[] = $date[4];
|
300 |
+
break;
|
301 |
+
case '%second%':
|
302 |
+
$out[] = $date[5];
|
303 |
+
break;
|
304 |
+
case '%post_id%':
|
305 |
+
$out[] = $post->ID;
|
306 |
+
break;
|
307 |
+
case '%postname%':
|
308 |
+
$out[] = $post->post_name;
|
309 |
+
break;
|
310 |
+
case '%category%':
|
311 |
+
$category = '';
|
312 |
+
$cats = get_the_category( $post->ID );
|
313 |
+
if ( $cats ) {
|
314 |
+
usort( $cats, '_usort_terms_by_ID' );
|
315 |
+
$category = $cats[0]->slug;
|
316 |
+
if ( $parent = $cats[0]->parent ) {
|
317 |
+
$category = get_category_parents( $parent, false, '/', true );
|
318 |
+
}
|
319 |
+
|
320 |
+
if ( $cats[0]->parent != 0 ) {
|
321 |
+
$category .= $cats[0]->slug;
|
322 |
+
}
|
323 |
+
}
|
324 |
+
if ( empty( $category ) ) {
|
325 |
+
$default_category = get_term( get_option( 'default_category' ), 'category' );
|
326 |
+
$category = is_wp_error( $default_category ) ? '' : $default_category->slug;
|
327 |
+
}
|
328 |
+
$out[] = $category;
|
329 |
+
break;
|
330 |
+
case '%author%':
|
331 |
+
$authordata = get_userdata( $post->post_author );
|
332 |
+
$out[] = $authordata->user_nicename;
|
333 |
+
break;
|
334 |
+
case '%pagename%':
|
335 |
+
$out[] = $post->post_name;
|
336 |
+
break;
|
337 |
+
default:
|
338 |
+
unset( $rewritecode[ array_search( $rewrite, $rewritecode ) ] );
|
339 |
+
break;
|
340 |
+
}
|
341 |
+
}
|
342 |
+
$permalink = home_url( str_replace( $rewritecode, $out, $permalink ) );
|
343 |
+
|
344 |
+
return user_trailingslashit( $permalink, 'single' );
|
345 |
+
} else {
|
346 |
+
return home_url( "?p=$post->ID" );
|
347 |
+
}
|
348 |
+
}
|
includes/general.php
CHANGED
@@ -1,172 +1,172 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WP-Parsidate general functions
|
4 |
-
*
|
5 |
-
* @author Mobin Ghasempoor
|
6 |
-
* @author Ehsaan
|
7 |
-
* @package WP-Parsidate
|
8 |
-
* @subpackage Core/General
|
9 |
-
*/
|
10 |
-
global $wpp_settings;
|
11 |
-
|
12 |
-
add_filter('login_headerurl', 'wpp_login_headerurl', 10, 2);
|
13 |
-
add_filter('locale', 'wp_parsi_set_locale');
|
14 |
-
add_action('admin_notices', 'wpp_activation_notice');
|
15 |
-
add_action('admin_init', 'wpp_dismiss_notice_action');
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Change Locale WordPress Admin and Front-end user
|
19 |
-
* @author
|
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 |
-
|
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 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
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 |
-
if (isset($_GET['wpp-action']) && $_GET['wpp-action'] == 'dismiss-notice') {
|
170 |
-
update_option('wpp_dismissed', true);
|
171 |
-
}
|
172 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP-Parsidate general functions
|
4 |
+
*
|
5 |
+
* @author Mobin Ghasempoor
|
6 |
+
* @author Ehsaan
|
7 |
+
* @package WP-Parsidate
|
8 |
+
* @subpackage Core/General
|
9 |
+
*/
|
10 |
+
global $wpp_settings;
|
11 |
+
|
12 |
+
add_filter( 'login_headerurl', 'wpp_login_headerurl', 10, 2 );
|
13 |
+
add_filter( 'locale', 'wp_parsi_set_locale' );
|
14 |
+
add_action( 'admin_notices', 'wpp_activation_notice' );
|
15 |
+
add_action( 'admin_init', 'wpp_dismiss_notice_action' );
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Change Locale WordPress Admin and Front-end user
|
19 |
+
* @author
|
20 |
+
*
|
21 |
+
* @param String $locale
|
22 |
+
*
|
23 |
+
* @return String
|
24 |
+
*/
|
25 |
+
function wp_parsi_set_locale( $locale ) {
|
26 |
+
$settings = get_option( 'wpp_settings' );
|
27 |
+
if ( $settings['admin_lang'] == 'enable' ) {
|
28 |
+
$admin_locale = "fa_IR";
|
29 |
+
} elseif ( $settings['admin_lang'] == 'disable' ) {
|
30 |
+
$admin_locale = "en_US";
|
31 |
+
}
|
32 |
+
if ( $settings['user_lang'] == 'enable' ) {
|
33 |
+
$user_locale = "fa_IR";
|
34 |
+
} elseif ( $settings['user_lang'] == 'disable' ) {
|
35 |
+
$user_locale = "en_US";
|
36 |
+
}
|
37 |
+
|
38 |
+
$locale_s = ( is_admin() ) ? $admin_locale : $user_locale;
|
39 |
+
|
40 |
+
if ( ! empty( $locale_s ) ) {
|
41 |
+
$locale = $locale_s;
|
42 |
+
}
|
43 |
+
|
44 |
+
setlocale( LC_ALL, $locale );
|
45 |
+
|
46 |
+
return $locale;
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Detects current page is feed or not
|
52 |
+
*
|
53 |
+
* @since 1.0
|
54 |
+
* @return bool True when page is feed, false when page isn't feed
|
55 |
+
*/
|
56 |
+
function wpp_is_feed() {
|
57 |
+
if ( is_feed() ) {
|
58 |
+
return true;
|
59 |
+
}
|
60 |
+
|
61 |
+
$path = $_SERVER['REQUEST_URI'];
|
62 |
+
$exts = array( 'xml', 'gz', 'xsl' );
|
63 |
+
$ext = pathinfo( $path, PATHINFO_EXTENSION );
|
64 |
+
|
65 |
+
return in_array( $ext, $exts );
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Converts English digits to Persian digits
|
70 |
+
*
|
71 |
+
* @param string $number Numbers
|
72 |
+
*
|
73 |
+
* @return string Formatted numbers
|
74 |
+
*/
|
75 |
+
function per_number( $number ) {
|
76 |
+
return str_replace(
|
77 |
+
range( 0, 9 ),
|
78 |
+
array( '۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹' ),
|
79 |
+
$number
|
80 |
+
);
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Converts Persian digits to English digits
|
85 |
+
*
|
86 |
+
* @param string $number Numbers
|
87 |
+
*
|
88 |
+
* @return string Formatted numbers
|
89 |
+
*/
|
90 |
+
function eng_number( $number ) {
|
91 |
+
return str_replace(
|
92 |
+
array( '۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹' ),
|
93 |
+
range( 0, 9 ),
|
94 |
+
$number
|
95 |
+
);
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Converts English numbers to Persian numbers in post contents
|
100 |
+
*
|
101 |
+
* @param string $content Post content
|
102 |
+
*
|
103 |
+
* @return string Formatted content
|
104 |
+
*/
|
105 |
+
function persian_number( $content ) {
|
106 |
+
return (
|
107 |
+
isset( $content[1] ) ? per_number( $content[1] ) : $content[0]
|
108 |
+
);
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Fix numbers and convert them to Persian digits style
|
113 |
+
*
|
114 |
+
* @param string $content
|
115 |
+
*
|
116 |
+
* @return mixed
|
117 |
+
*/
|
118 |
+
function fixnumber( $content ) {
|
119 |
+
return preg_replace_callback( '/(?:&#\d{2,4};)|(?:[0]?[a-z][\x20-\x3B=\x3F-\x7F]*)|(\d+[\.\d]*)|<\s*[^>]+>/i', 'persian_number', $content );
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Fix arabic foreign characters
|
124 |
+
*
|
125 |
+
* @param string $content
|
126 |
+
*
|
127 |
+
* @return mixed
|
128 |
+
*/
|
129 |
+
function fixarabic( $content ) {
|
130 |
+
return str_replace( array( 'ي', 'ك', '٤', '٥', '٦', 'ة' ), array( 'ی', 'ک', '۴', '۵', '۶', 'ه' ), $content );
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Change login header url in wp-login.php
|
135 |
+
*
|
136 |
+
* @return string
|
137 |
+
*/
|
138 |
+
function wpp_login_headerurl() {
|
139 |
+
return 'http://wp-parsi.com';
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Notice for the activation.
|
144 |
+
* Added dismiss feature.
|
145 |
+
*
|
146 |
+
* @author Ehsaan
|
147 |
+
* @return void
|
148 |
+
*/
|
149 |
+
function wpp_activation_notice() {
|
150 |
+
$dismissed = get_option( 'wpp_dismissed', false );
|
151 |
+
|
152 |
+
if ( ! $dismissed ) {
|
153 |
+
global $wpp_settings;
|
154 |
+
|
155 |
+
if ( $wpp_settings['persian_date'] != 'enable' ) {
|
156 |
+
$output = sprintf( __( '<div class="updated wpp-message"><p>ParsiDate activated, you may need to configure it to work properly. <a href="%s">Go to configuartion page</a> – <a href="%s">Dismiss</a></p></div>', 'wp-parsidate' ), admin_url( 'admin.php?page=wp-parsi-settings' ), add_query_arg( 'wpp-action', 'dismiss-notice' ) );
|
157 |
+
echo $output;
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Dismiss the notice action
|
164 |
+
*
|
165 |
+
* @author Ehsaan
|
166 |
+
* @return void
|
167 |
+
*/
|
168 |
+
function wpp_dismiss_notice_action() {
|
169 |
+
if ( isset( $_GET['wpp-action'] ) && $_GET['wpp-action'] == 'dismiss-notice' ) {
|
170 |
+
update_option( 'wpp_dismissed', true );
|
171 |
+
}
|
172 |
}
|
includes/install.php
CHANGED
@@ -1,32 +1,21 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Plugin installer helper
|
4 |
-
*
|
5 |
-
* @author Mobin Ghasempoor
|
6 |
-
* @package WP-Parsidate
|
7 |
-
* @subpackage Core/Install
|
8 |
-
*/
|
9 |
-
|
10 |
-
register_activation_hook(WP_PARSI_ROOT, 'wpp_install');
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Copys files from plugin languages folder to global languages folder
|
14 |
-
*
|
15 |
-
* @since 1.0
|
16 |
-
* @return void
|
17 |
-
*/
|
18 |
-
function wpp_install()
|
19 |
-
{
|
20 |
-
|
21 |
-
/*if ( ! is_dir( WP_CONTENT_DIR . '/languages' ) )
|
22 |
-
mkdir( WP_CONTENT_DIR . '/languages/' );
|
23 |
-
|
24 |
-
$source = WP_PARSI_DIR . 'languages/*';
|
25 |
-
$destination = WP_CONTENT_DIR . '/languages/';
|
26 |
-
$files = glob( $source );
|
27 |
-
|
28 |
-
foreach( $files as $file )
|
29 |
-
@ copy( $file, $destination . basename( $file ) );*/
|
30 |
-
|
31 |
-
update_option('wpp_settings', array());
|
32 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin installer helper
|
4 |
+
*
|
5 |
+
* @author Mobin Ghasempoor
|
6 |
+
* @package WP-Parsidate
|
7 |
+
* @subpackage Core/Install
|
8 |
+
*/
|
9 |
+
|
10 |
+
register_activation_hook(WP_PARSI_ROOT, 'wpp_install');
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Copys files from plugin languages folder to global languages folder
|
14 |
+
*
|
15 |
+
* @since 1.0
|
16 |
+
* @return void
|
17 |
+
*/
|
18 |
+
function wpp_install()
|
19 |
+
{
|
20 |
+
update_option('wpp_settings', array());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
}
|
includes/parsidate.php
CHANGED
@@ -1,366 +1,409 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Parsi date main conversation class
|
4 |
-
*
|
5 |
-
* @author Mobin Ghasempoor
|
6 |
-
* @package WP-Parsidate
|
7 |
-
* @subpackage DateConversation
|
8 |
-
*/
|
9 |
-
/*Special thanks to :
|
10 |
-
Reza Gholampanahi for convert function*/
|
11 |
-
|
12 |
-
class bn_parsidate
|
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 |
-
|
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 |
-
case'
|
103 |
-
$
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
$out
|
127 |
-
break;
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
case'
|
150 |
-
$out .= ($date['
|
151 |
-
break;
|
152 |
-
case'
|
153 |
-
$out .= ($date['
|
154 |
-
break;
|
155 |
-
case'
|
156 |
-
$out .=
|
157 |
-
break;
|
158 |
-
case'
|
159 |
-
$out .=
|
160 |
-
break;
|
161 |
-
case'
|
162 |
-
$out .= $date['
|
163 |
-
break;
|
164 |
-
|
165 |
-
|
166 |
-
$out .= ($
|
167 |
-
break;
|
168 |
-
case'
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
case'
|
189 |
-
|
190 |
-
|
191 |
-
case'
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
case'
|
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 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
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 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Parsi date main conversation class
|
4 |
+
*
|
5 |
+
* @author Mobin Ghasempoor
|
6 |
+
* @package WP-Parsidate
|
7 |
+
* @subpackage DateConversation
|
8 |
+
*/
|
9 |
+
/*Special thanks to :
|
10 |
+
Reza Gholampanahi for convert function*/
|
11 |
+
|
12 |
+
class bn_parsidate {
|
13 |
+
protected static $instance;
|
14 |
+
public $persian_month_names = array(
|
15 |
+
'',
|
16 |
+
'فروردین',
|
17 |
+
'اردیبهشت',
|
18 |
+
'خرداد',
|
19 |
+
'تیر',
|
20 |
+
'مرداد',
|
21 |
+
'شهریور',
|
22 |
+
'مهر',
|
23 |
+
'آبان',
|
24 |
+
'آذر',
|
25 |
+
'دی',
|
26 |
+
'بهمن',
|
27 |
+
'اسفند'
|
28 |
+
);
|
29 |
+
public $persian_short_month_names = array(
|
30 |
+
'',
|
31 |
+
'فرو',
|
32 |
+
'ارد',
|
33 |
+
'خرد',
|
34 |
+
'تیر',
|
35 |
+
'مرد',
|
36 |
+
'شهر',
|
37 |
+
'مهر',
|
38 |
+
'آبا',
|
39 |
+
'آذر',
|
40 |
+
'دی',
|
41 |
+
'بهم',
|
42 |
+
'اسف'
|
43 |
+
);
|
44 |
+
public $sesson = array( 'بهار', 'تابستان', 'پاییز', 'زمستان' );
|
45 |
+
|
46 |
+
public $persian_day_names = array( 'یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه' );
|
47 |
+
public $persian_day_small = array( 'ی', 'د', 'س', 'چ', 'پ', 'ج', 'ش' );
|
48 |
+
|
49 |
+
public $j_days_in_month = array( 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29 );
|
50 |
+
private $j_days_sum_month = array( 0, 0, 31, 62, 93, 124, 155, 186, 216, 246, 276, 306, 336 );
|
51 |
+
|
52 |
+
private $g_days_sum_month = array( 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 );
|
53 |
+
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Constructor
|
57 |
+
*/
|
58 |
+
function __construct() {
|
59 |
+
if ( $this->IsLeapYear( $this->persian_date( "Y", time(), "eng" ) ) ) {
|
60 |
+
$this->j_days_in_month[11] = 30;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* bn_parsidate::IsLeapYear()
|
66 |
+
* check year is leap
|
67 |
+
*
|
68 |
+
* @param mixed $year
|
69 |
+
*
|
70 |
+
* @return boolean
|
71 |
+
*/
|
72 |
+
private function IsLeapYear( $year ) {
|
73 |
+
if ( ( ( $year % 4 ) == 0 && ( $year % 100 ) != 0 ) || ( ( $year % 400 ) == 0 ) && ( $year % 100 ) == 0 ) {
|
74 |
+
return true;
|
75 |
+
} else {
|
76 |
+
return false;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* bn_parsidate::persian_date()
|
82 |
+
* convert gregorian datetime to persian datetime
|
83 |
+
*
|
84 |
+
* @param mixed $format
|
85 |
+
* @param string $date
|
86 |
+
* @param string $lang
|
87 |
+
*
|
88 |
+
* @return datetime
|
89 |
+
*/
|
90 |
+
public function persian_date( $format, $date = 'now', $lang = 'per' ) {
|
91 |
+
$j_days_in_month = array( 31, 62, 93, 124, 155, 186, 216, 246, 276, 306, 336, 365 );
|
92 |
+
$timestamp = is_numeric( $date ) && (int) $date == $date ? $date : strtotime( $date );
|
93 |
+
|
94 |
+
$date = getdate( $timestamp );
|
95 |
+
list( $date['year'], $date['mon'], $date['mday'] ) = self::gregorian_to_persian( $date['year'], $date['mon'], $date['mday'] );
|
96 |
+
$date['mon'] = (int) $date['mon'];
|
97 |
+
$date['mday'] = (int) $date['mday'];
|
98 |
+
$out = '';
|
99 |
+
for ( $i = 0; $i < strlen( $format ); $i ++ ) {
|
100 |
+
Switch ( $format[ $i ] ) {
|
101 |
+
//day
|
102 |
+
case 'd':
|
103 |
+
$out .= ( $date['mday'] < 10 ) ? '0' . $date['mday'] : $date['mday'];
|
104 |
+
break;
|
105 |
+
case 'D':
|
106 |
+
$out .= $this->persian_day_small[ $date['wday'] ];
|
107 |
+
break;
|
108 |
+
case'l':
|
109 |
+
$out .= $this->persian_day_names[ $date['wday'] ];
|
110 |
+
break;
|
111 |
+
case 'j':
|
112 |
+
$out .= $date['mday'];
|
113 |
+
break;
|
114 |
+
case'N':
|
115 |
+
$out .= $this->week_day( $date['wday'] ) + 1;
|
116 |
+
break;
|
117 |
+
case'w':
|
118 |
+
$out .= $this->week_day( $date['wday'] );
|
119 |
+
break;
|
120 |
+
case'z':
|
121 |
+
$out .= $this->j_days_in_month[ $date['mon'] ] + $date['mday'];
|
122 |
+
break;
|
123 |
+
//week
|
124 |
+
case'W':
|
125 |
+
$yday = $this->j_days_sum_month[ $date['mon'] - 1 ] + $date['mday'];
|
126 |
+
$out .= intval( $yday / 7 );
|
127 |
+
break;
|
128 |
+
//month
|
129 |
+
case'f':
|
130 |
+
$mon = $date['mon'];
|
131 |
+
switch ( $mon ) {
|
132 |
+
case( $mon < 4 ):
|
133 |
+
$out .= $this->sesson[0];
|
134 |
+
break;
|
135 |
+
case( $mon < 7 ):
|
136 |
+
$out .= $this->sesson[1];
|
137 |
+
break;
|
138 |
+
case( $mon < 10 ):
|
139 |
+
$out .= $this->sesson[2];
|
140 |
+
break;
|
141 |
+
case( $mon > 9 ):
|
142 |
+
$out .= $this->sesson[3];
|
143 |
+
break;
|
144 |
+
}
|
145 |
+
break;
|
146 |
+
case'F':
|
147 |
+
$out .= $this->persian_month_names[ (int) $date['mon'] ];
|
148 |
+
break;
|
149 |
+
case'm':
|
150 |
+
$out .= ( $date['mon'] < 10 ) ? '0' . $date['mon'] : $date['mon'];
|
151 |
+
break;
|
152 |
+
case'M':
|
153 |
+
$out .= $this->persian_short_month_names[ (int) $date['mon'] ];
|
154 |
+
break;
|
155 |
+
case'n':
|
156 |
+
$out .= $date['mon'];
|
157 |
+
break;
|
158 |
+
case'S':
|
159 |
+
$out .= 'ام';
|
160 |
+
break;
|
161 |
+
case't':
|
162 |
+
$out .= $this->j_days_in_month[ (int) $date['mon'] - 1 ];
|
163 |
+
break;
|
164 |
+
//year
|
165 |
+
case'L':
|
166 |
+
$out .= ( ( $date['year'] % 4 ) == 0 ) ? 1 : 0;
|
167 |
+
break;
|
168 |
+
case'o':
|
169 |
+
case'Y':
|
170 |
+
$out .= $date['year'];
|
171 |
+
break;
|
172 |
+
case'y':
|
173 |
+
$out .= substr( $date['year'], 2, 2 );
|
174 |
+
break;
|
175 |
+
//time
|
176 |
+
case'a':
|
177 |
+
$out .= ( $date['hours'] < 12 ) ? 'ق.ظ' : 'ب.ظ';
|
178 |
+
break;
|
179 |
+
case'A':
|
180 |
+
$out .= ( $date['hours'] < 12 ) ? 'قبل از ظهر' : 'بعد از ظهر';
|
181 |
+
break;
|
182 |
+
case'B':
|
183 |
+
$out .= (int) ( 1 + ( $date['mon'] / 3 ) );
|
184 |
+
break;
|
185 |
+
case'g':
|
186 |
+
$out .= ( $date['hours'] > 12 ) ? $date['hours'] - 12 : $date['hours'];
|
187 |
+
break;
|
188 |
+
case'G':
|
189 |
+
$out .= $date['hours'];
|
190 |
+
break;
|
191 |
+
case'h':
|
192 |
+
$hour = ( $date['hours'] > 12 ) ? $date['hours'] - 12 : $date['hours'];
|
193 |
+
$out .= ( $hour < 10 ) ? '0' . $hour : $hour;
|
194 |
+
break;
|
195 |
+
case'H':
|
196 |
+
$out .= ( $date['hours'] < 10 ) ? '0' . $date['hours'] : $date['hours'];
|
197 |
+
break;
|
198 |
+
case'i':
|
199 |
+
$out .= ( $date['minutes'] < 10 ) ? '0' . $date['minutes'] : $date['minutes'];
|
200 |
+
break;
|
201 |
+
case's':
|
202 |
+
$out .= ( $date['seconds'] < 10 ) ? '0' . $date['seconds'] : $date['seconds'];
|
203 |
+
break;
|
204 |
+
//full date time
|
205 |
+
case'c':
|
206 |
+
$out = $date['year'] . '/' . $date['mon'] . '/' . $date['mday'] . ' ' . $date['hours'] . ':' . ( ( $date['minutes'] < 10 ) ? '0' . $date['minutes'] : $date['minutes'] ) . ':' . ( ( $date['seconds'] < 10 ) ? '0' . $date['seconds'] : $date['seconds'] );//2004-02-12T15:19:21+00:00
|
207 |
+
break;
|
208 |
+
case'r':
|
209 |
+
$out = $this->persian_day_names[ $date['wday'] ] . ',' . $date['mday'] . ' ' . $this->persian_month_names[ (int) $date['mon'] ] . ' ' . $date['year'] . ' ' . $date['hours'] . ':' . ( ( $date['minutes'] < 10 ) ? '0' . $date['minutes'] : $date['minutes'] ) . ':' . ( ( $date['seconds'] < 10 ) ? '0' . $date['seconds'] : $date['seconds'] );//Thu, 21 Dec 2000 16:01:07
|
210 |
+
break;
|
211 |
+
case'U':
|
212 |
+
$out = $timestamp;
|
213 |
+
break;
|
214 |
+
//others
|
215 |
+
case'e':
|
216 |
+
case'I':
|
217 |
+
case'i':
|
218 |
+
case'O':
|
219 |
+
case'P':
|
220 |
+
case'T':
|
221 |
+
case'Z':
|
222 |
+
case'u':
|
223 |
+
break;
|
224 |
+
default:
|
225 |
+
$out .= $format[ $i ];
|
226 |
+
}
|
227 |
+
}
|
228 |
+
if ( $lang == 'per' ) {
|
229 |
+
return self::trim_number( $out );
|
230 |
+
} else {
|
231 |
+
return $out;
|
232 |
+
}
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* bn_parsidate::gregorian_to_persian()
|
237 |
+
* convert gregorian date to persian date
|
238 |
+
*
|
239 |
+
* @param mixed $gy
|
240 |
+
* @param mixed $gm
|
241 |
+
* @param mixed $gd
|
242 |
+
*
|
243 |
+
* @return array
|
244 |
+
*/
|
245 |
+
function gregorian_to_persian( $gy, $gm, $gd ) {
|
246 |
+
$dayofyear = $this->g_days_sum_month[ (int) $gm ] + $gd;
|
247 |
+
if ( self::IsLeapYear( $gy ) and $gm > 2 ) {
|
248 |
+
$dayofyear ++;
|
249 |
+
}
|
250 |
+
$d_33 = (int) ( ( ( $gy - 16 ) % 132 ) * 0.0305 );
|
251 |
+
$leap = $gy % 4;
|
252 |
+
$a = ( ( $d_33 == 1 or $d_33 == 2 ) and ( $d_33 == $leap or $leap == 1 ) ) ? 78 : ( ( $d_33 == 3 and $leap == 0 ) ? 80 : 79 );
|
253 |
+
$b = ( $d_33 == 3 or $d_33 < ( $leap - 1 ) or $leap == 0 ) ? 286 : 287;
|
254 |
+
if ( (int) ( ( $gy - 10 ) / 63 ) == 30 ) {
|
255 |
+
$b --;
|
256 |
+
$a ++;
|
257 |
+
}
|
258 |
+
if ( $dayofyear > $a ) {
|
259 |
+
$jy = $gy - 621;
|
260 |
+
$jd = $dayofyear - $a;
|
261 |
+
} else {
|
262 |
+
$jy = $gy - 622;
|
263 |
+
$jd = $dayofyear + $b;
|
264 |
+
}
|
265 |
+
for ( $i = 0; $i < 11 and $jd > $this->j_days_in_month[ $i ]; $i ++ ) {
|
266 |
+
$jd -= $this->j_days_in_month[ $i ];
|
267 |
+
}
|
268 |
+
$jm = ++ $i;
|
269 |
+
|
270 |
+
return array( $jy, strlen( $jm ) == 1 ? '0' . $jm : $jm, strlen( $jd ) == 1 ? '0' . $jd : $jd );
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Get day of the week shamsi/jalali
|
275 |
+
* @author Parsa Kafi
|
276 |
+
*
|
277 |
+
* @param int $wday
|
278 |
+
*
|
279 |
+
* @return int
|
280 |
+
*/
|
281 |
+
private function week_day( $wday ) {
|
282 |
+
if ( $wday == 6 ) {
|
283 |
+
return 0;
|
284 |
+
} else {
|
285 |
+
return ++ $wday;
|
286 |
+
}
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* bn_parsidate::trim_number()
|
291 |
+
* convert english number to persian number
|
292 |
+
*
|
293 |
+
* @param mixed $num
|
294 |
+
* @param string $sp
|
295 |
+
*
|
296 |
+
* @return string
|
297 |
+
*/
|
298 |
+
public function trim_number( $num, $sp = '٫' ) {
|
299 |
+
$eng = array( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.' );
|
300 |
+
$per = array( '۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', $sp );
|
301 |
+
$number = filter_var( $num, FILTER_SANITIZE_NUMBER_INT );
|
302 |
+
|
303 |
+
return empty( $number ) ? str_replace( $per, $eng, $num ) : str_replace( $eng, $per, $num );
|
304 |
+
}
|
305 |
+
|
306 |
+
/**
|
307 |
+
* bn_parsidate::getInstance()
|
308 |
+
* create instance of bn_parsidate class
|
309 |
+
*
|
310 |
+
* @return instance
|
311 |
+
*/
|
312 |
+
public static function getInstance() {
|
313 |
+
if ( ! isset( self::$instance ) ) {
|
314 |
+
self::$instance = new self();
|
315 |
+
}
|
316 |
+
|
317 |
+
return self::$instance;
|
318 |
+
}
|
319 |
+
|
320 |
+
/**
|
321 |
+
* bn_parsidate::gregurian_date()
|
322 |
+
* convert persian datetime to gregorian datetime
|
323 |
+
*
|
324 |
+
* @param mixed $format
|
325 |
+
* @param mixed $persiandate
|
326 |
+
*
|
327 |
+
* @return mixed
|
328 |
+
*/
|
329 |
+
public function gregurian_date( $format, $persiandate ) {
|
330 |
+
preg_match_all( '!\d+!', $persiandate, $matches );
|
331 |
+
$matches = $matches[0];
|
332 |
+
list( $year, $mon, $day ) = self::persian_to_gregorian( $matches[0], $matches[1], $matches[2] );
|
333 |
+
|
334 |
+
return date( $format, mktime( ( isset( $matches[3] ) ? $matches[3] : 0 ), ( isset( $matches[4] ) ? $matches[4] : 0 ), ( isset( $matches[5] ) ? $matches[5] : 0 ), $mon, $day, $year ) );
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
* bn_parsidate::persian_to_gregorian()
|
339 |
+
* convert persian date to gregorian date
|
340 |
+
*
|
341 |
+
* @param mixed $jy
|
342 |
+
* @param mixed $jm
|
343 |
+
* @param mixed $jd
|
344 |
+
*
|
345 |
+
* @return array
|
346 |
+
*/
|
347 |
+
public function persian_to_gregorian( $jy, $jm, $jd ) {
|
348 |
+
$doyj = ( $jm - 2 > - 1 ? $this->j_days_sum_month[ (int) $jm ] + $jd : $jd );
|
349 |
+
$d4 = ( $jy + 1 ) % 4;
|
350 |
+
$d33 = (int) ( ( ( $jy - 55 ) % 132 ) * .0305 );
|
351 |
+
$a = ( $d33 != 3 and $d4 <= $d33 ) ? 287 : 286;
|
352 |
+
$b = ( ( $d33 == 1 or $d33 == 2 ) and ( $d33 == $d4 or $d4 == 1 ) ) ? 78 : ( ( $d33 == 3 and $d4 == 0 ) ? 80 : 79 );
|
353 |
+
if ( (int) ( ( $jy - 19 ) / 63 ) == 20 ) {
|
354 |
+
$a --;
|
355 |
+
$b ++;
|
356 |
+
}
|
357 |
+
if ( $doyj <= $a ) {
|
358 |
+
$gy = $jy + 621;
|
359 |
+
$gd = $doyj + $b;
|
360 |
+
} else {
|
361 |
+
$gy = $jy + 622;
|
362 |
+
$gd = $doyj - $a;
|
363 |
+
}
|
364 |
+
foreach ( array( 0, 31, ( $gy % 4 == 0 ) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ) as $gm => $days ) {
|
365 |
+
if ( $gd <= $days ) {
|
366 |
+
break;
|
367 |
+
}
|
368 |
+
$gd -= $days;
|
369 |
+
}
|
370 |
+
|
371 |
+
return array( $gy, $gm, $gd );
|
372 |
+
}
|
373 |
+
}
|
374 |
+
|
375 |
+
/*
|
376 |
+
* parsidate function
|
377 |
+
*/
|
378 |
+
/**
|
379 |
+
* parsidate()
|
380 |
+
* convert gregorian datetime to persian datetime
|
381 |
+
*
|
382 |
+
* @param mixed $input
|
383 |
+
* @param string $datetime
|
384 |
+
* @param string $lang
|
385 |
+
*
|
386 |
+
* @return datetime
|
387 |
+
*/
|
388 |
+
function parsidate( $input, $datetime = 'now', $lang = 'per' ) {
|
389 |
+
$bndate = bn_parsidate::getInstance();
|
390 |
+
$bndate = $bndate->persian_date( $input, $datetime, $lang );
|
391 |
+
|
392 |
+
return $bndate;
|
393 |
+
}
|
394 |
+
|
395 |
+
/**
|
396 |
+
* gregdate()
|
397 |
+
* convert persian datetime to gregorian datetime
|
398 |
+
*
|
399 |
+
* @param mixed $input
|
400 |
+
* @param mixed $datetime
|
401 |
+
*
|
402 |
+
* @return datetime
|
403 |
+
*/
|
404 |
+
function gregdate( $input, $datetime ) {
|
405 |
+
$bndate = bn_parsidate::getInstance();
|
406 |
+
$bndate = $bndate->gregurian_date( $input, $datetime );
|
407 |
+
|
408 |
+
return $bndate;
|
409 |
+
}
|
includes/plugins/edd.php
CHANGED
@@ -7,36 +7,34 @@
|
|
7 |
* @subpackage Plugins/EDD
|
8 |
* @author Ehsaan
|
9 |
*/
|
10 |
-
class WPP_EDD
|
11 |
-
{
|
12 |
public static $instance = null;
|
13 |
|
14 |
/**
|
15 |
* Hooks required tags
|
16 |
*/
|
17 |
-
private function __construct()
|
18 |
-
{
|
19 |
global $wpp_settings;
|
20 |
-
add_filter('wpp_plugins_compability_settings', array($this, 'add_settings'));
|
21 |
|
22 |
-
if (isset($wpp_settings['edd_prices']) && $wpp_settings['edd_prices'] != 'disable') {
|
23 |
-
add_filter('edd_rial_currency_filter_after', 'per_number', 10, 2);
|
24 |
}
|
25 |
|
26 |
-
if (isset($wpp_settings['edd_rial_fix']) && $wpp_settings['edd_rial_fix'] != 'disable') {
|
27 |
-
add_filter('edd_rial_currency_filter_after', array($this, 'rial_fix'), 10, 2);
|
28 |
}
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
* Returns an instance of class
|
33 |
*
|
34 |
-
* @return
|
35 |
*/
|
36 |
-
public static function getInstance()
|
37 |
-
|
38 |
-
if (self::$instance == null)
|
39 |
self::$instance = new WPP_EDD();
|
|
|
40 |
|
41 |
return self::$instance;
|
42 |
}
|
@@ -44,46 +42,45 @@ class WPP_EDD
|
|
44 |
/**
|
45 |
* RIAL fix for EDD
|
46 |
*/
|
47 |
-
public function rial_fix($price, $did)
|
48 |
-
|
49 |
-
return str_replace('RIAL', 'ریال', $price);
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
* Adds settings for toggle fixing
|
54 |
*
|
55 |
* @param array $old_settings Old settings
|
|
|
56 |
* @return array New settings
|
57 |
*/
|
58 |
-
public function add_settings($old_settings)
|
59 |
-
|
60 |
-
|
61 |
-
'
|
62 |
-
'disable' => __('Disable', 'wp-parsidate')
|
63 |
);
|
64 |
$settings = array(
|
65 |
-
'edd'
|
66 |
-
'id'
|
67 |
-
'name' => __('Easy Digital Downloads', 'wp-parsidate'),
|
68 |
'type' => 'header'
|
69 |
),
|
70 |
-
'edd_prices'
|
71 |
-
'id'
|
72 |
-
'name'
|
73 |
-
'type'
|
74 |
'options' => $options,
|
75 |
-
'std'
|
76 |
),
|
77 |
'edd_rial_fix' => array(
|
78 |
-
'id'
|
79 |
-
'name'
|
80 |
-
'type'
|
81 |
'options' => $options,
|
82 |
-
'std'
|
83 |
)
|
84 |
);
|
85 |
|
86 |
-
return array_merge($old_settings, $settings);
|
87 |
}
|
88 |
}
|
89 |
|
7 |
* @subpackage Plugins/EDD
|
8 |
* @author Ehsaan
|
9 |
*/
|
10 |
+
class WPP_EDD {
|
|
|
11 |
public static $instance = null;
|
12 |
|
13 |
/**
|
14 |
* Hooks required tags
|
15 |
*/
|
16 |
+
private function __construct() {
|
|
|
17 |
global $wpp_settings;
|
18 |
+
add_filter( 'wpp_plugins_compability_settings', array( $this, 'add_settings' ) );
|
19 |
|
20 |
+
if ( isset( $wpp_settings['edd_prices'] ) && $wpp_settings['edd_prices'] != 'disable' ) {
|
21 |
+
add_filter( 'edd_rial_currency_filter_after', 'per_number', 10, 2 );
|
22 |
}
|
23 |
|
24 |
+
if ( isset( $wpp_settings['edd_rial_fix'] ) && $wpp_settings['edd_rial_fix'] != 'disable' ) {
|
25 |
+
add_filter( 'edd_rial_currency_filter_after', array( $this, 'rial_fix' ), 10, 2 );
|
26 |
}
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
* Returns an instance of class
|
31 |
*
|
32 |
+
* @return WPP_EDD
|
33 |
*/
|
34 |
+
public static function getInstance() {
|
35 |
+
if ( self::$instance == null ) {
|
|
|
36 |
self::$instance = new WPP_EDD();
|
37 |
+
}
|
38 |
|
39 |
return self::$instance;
|
40 |
}
|
42 |
/**
|
43 |
* RIAL fix for EDD
|
44 |
*/
|
45 |
+
public function rial_fix( $price, $did ) {
|
46 |
+
return str_replace( 'RIAL', 'ریال', $price );
|
|
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
* Adds settings for toggle fixing
|
51 |
*
|
52 |
* @param array $old_settings Old settings
|
53 |
+
*
|
54 |
* @return array New settings
|
55 |
*/
|
56 |
+
public function add_settings( $old_settings ) {
|
57 |
+
$options = array(
|
58 |
+
'enable' => __( 'Enable', 'wp-parsidate' ),
|
59 |
+
'disable' => __( 'Disable', 'wp-parsidate' )
|
|
|
60 |
);
|
61 |
$settings = array(
|
62 |
+
'edd' => array(
|
63 |
+
'id' => 'edd',
|
64 |
+
'name' => __( 'Easy Digital Downloads', 'wp-parsidate' ),
|
65 |
'type' => 'header'
|
66 |
),
|
67 |
+
'edd_prices' => array(
|
68 |
+
'id' => 'edd_prices',
|
69 |
+
'name' => __( 'Fix prices', 'wp-parsidate' ),
|
70 |
+
'type' => 'radio',
|
71 |
'options' => $options,
|
72 |
+
'std' => 'disable'
|
73 |
),
|
74 |
'edd_rial_fix' => array(
|
75 |
+
'id' => 'edd_rial_fix',
|
76 |
+
'name' => __( 'Replace ریال with RIAL', 'wp-parsidate' ),
|
77 |
+
'type' => 'radio',
|
78 |
'options' => $options,
|
79 |
+
'std' => 'disable'
|
80 |
)
|
81 |
);
|
82 |
|
83 |
+
return array_merge( $old_settings, $settings );
|
84 |
}
|
85 |
}
|
86 |
|
includes/plugins/woocommerce.php
CHANGED
@@ -1,73 +1,71 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Makes WooCommerce compatible with WP-Parsidate plugin
|
5 |
-
*
|
6 |
-
* @package WP-Parsidate
|
7 |
-
* @subpackage Plugins/WooCommerce
|
8 |
-
* @author Ehsaan
|
9 |
-
* @author Farhan Nisi
|
10 |
-
*/
|
11 |
-
class WPP_WooCommerce
|
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 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
'
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
'
|
62 |
-
'
|
63 |
-
'
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
);
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
return WPP_WooCommerce::getInstance();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Makes WooCommerce compatible with WP-Parsidate plugin
|
5 |
+
*
|
6 |
+
* @package WP-Parsidate
|
7 |
+
* @subpackage Plugins/WooCommerce
|
8 |
+
* @author Ehsaan
|
9 |
+
* @author Farhan Nisi
|
10 |
+
*/
|
11 |
+
class WPP_WooCommerce {
|
12 |
+
public static $instance = null;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Hooks required tags
|
16 |
+
*/
|
17 |
+
private function __construct() {
|
18 |
+
global $wpp_settings;
|
19 |
+
add_filter( 'wpp_plugins_compability_settings', array( $this, 'add_settings' ) );
|
20 |
+
|
21 |
+
if ( isset( $wpp_settings['woo_per_price'] ) && $wpp_settings['woo_per_price'] != 'disable' ) {
|
22 |
+
add_filter( 'woocommerce_sale_price_html', 'per_number' );
|
23 |
+
add_filter( 'woocommerce_price_html', 'per_number' );
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Returns an instance of class
|
29 |
+
*
|
30 |
+
* @return WPP_WooCommerce
|
31 |
+
*/
|
32 |
+
public static function getInstance() {
|
33 |
+
if ( self::$instance == null ) {
|
34 |
+
self::$instance = new WPP_WooCommerce();
|
35 |
+
}
|
36 |
+
|
37 |
+
return self::$instance;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Adds settings for toggle fixing
|
42 |
+
*
|
43 |
+
* @param array $old_settings Old settings
|
44 |
+
*
|
45 |
+
* @return array New settings
|
46 |
+
*/
|
47 |
+
public function add_settings( $old_settings ) {
|
48 |
+
$options = array(
|
49 |
+
'enable' => __( 'Enable', 'wp-parsidate' ),
|
50 |
+
'disable' => __( 'Disable', 'wp-parsidate' )
|
51 |
+
);
|
52 |
+
$settings = array(
|
53 |
+
'woocommerce' => array(
|
54 |
+
'id' => 'woocommerce',
|
55 |
+
'name' => __( 'WooCommerce', 'wp-parsidate' ),
|
56 |
+
'type' => 'header'
|
57 |
+
),
|
58 |
+
'woo_per_price' => array(
|
59 |
+
'id' => 'woo_per_price',
|
60 |
+
'name' => __( 'Fix prices', 'wp-parsidate' ),
|
61 |
+
'type' => 'radio',
|
62 |
+
'options' => $options,
|
63 |
+
'std' => 'disable'
|
64 |
+
)
|
65 |
+
);
|
66 |
+
|
67 |
+
return array_merge( $old_settings, $settings );
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
return WPP_WooCommerce::getInstance();
|
|
|
|
includes/settings.php
CHANGED
@@ -1,627 +1,621 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Adds settings part to plugin
|
4 |
-
* Originally, wrote by Pippin Williamson
|
5 |
-
*
|
6 |
-
* @author Pippin Williamson
|
7 |
-
* @author Ehsaan
|
8 |
-
* @package WP-Parsidate
|
9 |
-
* @subpackage Admin/Settings
|
10 |
-
*/
|
11 |
-
if (!defined('ABSPATH'))
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
__('Parsi Settings', 'wp-parsidate'),
|
27 |
-
'
|
28 |
-
'
|
29 |
-
'
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
__('Parsi Settings', 'wp-parsidate'),
|
35 |
-
'
|
36 |
-
'
|
37 |
-
'
|
38 |
-
'
|
39 |
-
|
40 |
-
|
41 |
-
}
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
*
|
46 |
-
*
|
47 |
-
* @
|
48 |
-
|
49 |
-
|
50 |
-
{
|
51 |
-
$settings = get_option('wpp_settings');
|
52 |
-
if (empty($settings)) {
|
53 |
-
update_option('wpp_settings', array(
|
54 |
-
'admin_lang'
|
55 |
-
'user_lang'
|
56 |
-
'submenu_move'
|
57 |
-
'persian_date'
|
58 |
-
'droidsans_editor'
|
59 |
-
'droidsans_admin'
|
60 |
-
'conv_title'
|
61 |
-
'conv_contents'
|
62 |
-
'conv_excerpt'
|
63 |
-
'conv_comments'
|
64 |
-
'conv_comment_count' => 'disable',
|
65 |
-
'conv_dates'
|
66 |
-
'conv_cats'
|
67 |
-
'conv_arabic'
|
68 |
-
'conv_permalinks'
|
69 |
-
'news_source'
|
70 |
-
));
|
71 |
-
}
|
72 |
-
|
73 |
-
return apply_filters('wpp_get_settings', $settings);
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Registers settings in WP core
|
78 |
-
*
|
79 |
-
* @since 2.0
|
80 |
-
* @return void
|
81 |
-
*/
|
82 |
-
function wpp_register_settings()
|
83 |
-
{
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
foreach (wpp_get_registered_settings() as $tab => $settings) {
|
88 |
-
add_settings_section(
|
89 |
-
'wpp_settings_' . $tab,
|
90 |
-
__return_null(),
|
91 |
-
'__return_false',
|
92 |
-
'wpp_settings_' . $tab
|
93 |
-
);
|
94 |
-
|
95 |
-
foreach ($settings as $option) {
|
96 |
-
$name = isset($option['name']) ? $option['name'] : '';
|
97 |
-
|
98 |
-
add_settings_field(
|
99 |
-
'wpp_settings[' . $option['id'] . ']',
|
100 |
-
$name,
|
101 |
-
function_exists('wpp_' . $option['type'] . '_callback') ? 'wpp_' . $option['type'] . '_callback' : 'wpp_missing_callback',
|
102 |
-
'wpp_settings_' . $tab,
|
103 |
-
'wpp_settings_' . $tab,
|
104 |
-
array(
|
105 |
-
'id'
|
106 |
-
'desc'
|
107 |
-
'name'
|
108 |
-
'section' => $tab,
|
109 |
-
'size'
|
110 |
-
'options' => isset($option['options']) ? $option['options'] : '',
|
111 |
-
'std'
|
112 |
-
)
|
113 |
-
);
|
114 |
-
|
115 |
-
register_setting('wpp_settings', 'wpp_settings', 'wpp_settings_sanitize');
|
116 |
-
}
|
117 |
-
}
|
118 |
-
}
|
119 |
-
|
120 |
-
add_action('admin_init', 'wpp_register_settings');
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Gets settings tabs
|
124 |
-
*
|
125 |
-
* @since 2.0
|
126 |
-
* @return array Tabs list
|
127 |
-
*/
|
128 |
-
function wpp_get_tabs()
|
129 |
-
|
130 |
-
|
131 |
-
'
|
132 |
-
'
|
133 |
-
|
134 |
-
|
135 |
-
return $tabs;
|
136 |
-
}
|
137 |
-
|
138 |
-
/**
|
139 |
-
* Sanitizes and saves settings after submit
|
140 |
-
*
|
141 |
-
* @since 2.0
|
142 |
-
*
|
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 |
-
return $output;
|
199 |
-
|
200 |
-
}
|
201 |
-
|
202 |
-
/**
|
203 |
-
* Get settings fields
|
204 |
-
*
|
205 |
-
* @since 2.0
|
206 |
-
* @return array Fields
|
207 |
-
*/
|
208 |
-
function wpp_get_registered_settings()
|
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 |
-
'
|
252 |
-
'
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
'
|
257 |
-
'
|
258 |
-
'
|
259 |
-
'
|
260 |
-
|
261 |
-
|
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 |
-
'
|
349 |
-
|
350 |
-
|
351 |
-
))
|
352 |
-
|
353 |
-
|
354 |
-
return $settings;
|
355 |
-
}
|
356 |
-
|
357 |
-
/* Form Callbacks Made by EDD Development Team */
|
358 |
-
function wpp_header_callback($args)
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
$
|
368 |
-
|
369 |
-
$html
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
$
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
$html
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
$
|
437 |
-
$step =
|
438 |
-
|
439 |
-
|
440 |
-
$html
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
$html
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
$html
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
$html
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
$html
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
$
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
$
|
559 |
-
|
560 |
-
$html
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
$
|
576 |
-
|
577 |
-
|
578 |
-
$html
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
));
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
</div><!-- .wrap -->
|
623 |
-
<?php
|
624 |
-
echo ob_get_clean();
|
625 |
-
}
|
626 |
-
|
627 |
-
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Adds settings part to plugin
|
4 |
+
* Originally, wrote by Pippin Williamson
|
5 |
+
*
|
6 |
+
* @author Pippin Williamson
|
7 |
+
* @author Ehsaan
|
8 |
+
* @package WP-Parsidate
|
9 |
+
* @subpackage Admin/Settings
|
10 |
+
*/
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit;
|
13 |
+
} // No direct access allowed ;)
|
14 |
+
|
15 |
+
add_action( 'admin_menu', 'wpp_add_settings_menu', 11 );
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Add WP-Parsidate admin page settings
|
19 |
+
* */
|
20 |
+
function wpp_add_settings_menu() {
|
21 |
+
global $wpp_settings;
|
22 |
+
|
23 |
+
if ( $wpp_settings['submenu_move'] != 'disable' ) {
|
24 |
+
add_submenu_page(
|
25 |
+
'options-general.php',
|
26 |
+
__( 'Parsi Settings', 'wp-parsidate' ),
|
27 |
+
__( 'Parsi Settings', 'wp-parsidate' ),
|
28 |
+
'manage_options',
|
29 |
+
'wp-parsi-settings',
|
30 |
+
'wpp_render_settings'
|
31 |
+
);
|
32 |
+
} else {
|
33 |
+
add_menu_page(
|
34 |
+
__( 'Parsi Settings', 'wp-parsidate' ),
|
35 |
+
__( 'Parsi Settings', 'wp-parsidate' ),
|
36 |
+
'manage_options',
|
37 |
+
'wp-parsi-settings',
|
38 |
+
'wpp_render_settings',
|
39 |
+
'dashicons-admin-site'
|
40 |
+
);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Gets saved settings from WP core
|
46 |
+
*
|
47 |
+
* @since 2.0
|
48 |
+
* @return array Parsi Settings
|
49 |
+
*/
|
50 |
+
function wp_parsi_get_settings() {
|
51 |
+
$settings = get_option( 'wpp_settings' );
|
52 |
+
if ( empty( $settings ) ) {
|
53 |
+
update_option( 'wpp_settings', array(
|
54 |
+
'admin_lang' => 'enable',
|
55 |
+
'user_lang' => 'enable',
|
56 |
+
'submenu_move' => 'disable',
|
57 |
+
'persian_date' => 'disable',
|
58 |
+
'droidsans_editor' => 'enable',
|
59 |
+
'droidsans_admin' => 'enable',
|
60 |
+
'conv_title' => 'disable',
|
61 |
+
'conv_contents' => 'disable',
|
62 |
+
'conv_excerpt' => 'disable',
|
63 |
+
'conv_comments' => 'disable',
|
64 |
+
'conv_comment_count' => 'disable',
|
65 |
+
'conv_dates' => 'disable',
|
66 |
+
'conv_cats' => 'disable',
|
67 |
+
'conv_arabic' => 'disable',
|
68 |
+
'conv_permalinks' => 'disable',
|
69 |
+
'news_source' => 'parsi'
|
70 |
+
) );
|
71 |
+
}
|
72 |
+
|
73 |
+
return apply_filters( 'wpp_get_settings', $settings );
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Registers settings in WP core
|
78 |
+
*
|
79 |
+
* @since 2.0
|
80 |
+
* @return void
|
81 |
+
*/
|
82 |
+
function wpp_register_settings() {
|
83 |
+
if ( false == get_option( 'wpp_settings' ) ) {
|
84 |
+
add_option( 'wpp_settings' );
|
85 |
+
}
|
86 |
+
|
87 |
+
foreach ( wpp_get_registered_settings() as $tab => $settings ) {
|
88 |
+
add_settings_section(
|
89 |
+
'wpp_settings_' . $tab,
|
90 |
+
__return_null(),
|
91 |
+
'__return_false',
|
92 |
+
'wpp_settings_' . $tab
|
93 |
+
);
|
94 |
+
|
95 |
+
foreach ( $settings as $option ) {
|
96 |
+
$name = isset( $option['name'] ) ? $option['name'] : '';
|
97 |
+
|
98 |
+
add_settings_field(
|
99 |
+
'wpp_settings[' . $option['id'] . ']',
|
100 |
+
$name,
|
101 |
+
function_exists( 'wpp_' . $option['type'] . '_callback' ) ? 'wpp_' . $option['type'] . '_callback' : 'wpp_missing_callback',
|
102 |
+
'wpp_settings_' . $tab,
|
103 |
+
'wpp_settings_' . $tab,
|
104 |
+
array(
|
105 |
+
'id' => isset( $option['id'] ) ? $option['id'] : null,
|
106 |
+
'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '',
|
107 |
+
'name' => isset( $option['name'] ) ? $option['name'] : null,
|
108 |
+
'section' => $tab,
|
109 |
+
'size' => isset( $option['size'] ) ? $option['size'] : null,
|
110 |
+
'options' => isset( $option['options'] ) ? $option['options'] : '',
|
111 |
+
'std' => isset( $option['std'] ) ? $option['std'] : ''
|
112 |
+
)
|
113 |
+
);
|
114 |
+
|
115 |
+
register_setting( 'wpp_settings', 'wpp_settings', 'wpp_settings_sanitize' );
|
116 |
+
}
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
add_action( 'admin_init', 'wpp_register_settings' );
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Gets settings tabs
|
124 |
+
*
|
125 |
+
* @since 2.0
|
126 |
+
* @return array Tabs list
|
127 |
+
*/
|
128 |
+
function wpp_get_tabs() {
|
129 |
+
$tabs = array(
|
130 |
+
'core' => sprintf( __( '%s Core', 'wp-parsidate' ), '<span class="dashicons dashicons-admin-site"></span>' ),
|
131 |
+
'conv' => sprintf( __( '%s Converts', 'wp-parsidate' ), '<span class="dashicons dashicons-admin-settings"></span>' ),
|
132 |
+
'plugins' => sprintf( __( '%s Plugins compability', 'wp-parsidate' ), '<span class="dashicons dashicons-admin-plugins"></span>' )
|
133 |
+
);
|
134 |
+
|
135 |
+
return $tabs;
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Sanitizes and saves settings after submit
|
140 |
+
*
|
141 |
+
* @since 2.0
|
142 |
+
*
|
143 |
+
* @param array $input Settings input
|
144 |
+
*
|
145 |
+
* @return array New settings
|
146 |
+
*/
|
147 |
+
function wpp_settings_sanitize( $input = array() ) {
|
148 |
+
|
149 |
+
global $wpp_settings;
|
150 |
+
|
151 |
+
if ( empty( $_POST['_wp_http_referer'] ) ) {
|
152 |
+
return $input;
|
153 |
+
}
|
154 |
+
|
155 |
+
parse_str( $_POST['_wp_http_referer'], $referrer );
|
156 |
+
|
157 |
+
$settings = wpp_get_registered_settings();
|
158 |
+
$tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'core';
|
159 |
+
|
160 |
+
$input = $input ? $input : array();
|
161 |
+
$input = apply_filters( 'wpp_settings_' . $tab . '_sanitize', $input );
|
162 |
+
|
163 |
+
// Loop through each setting being saved and pass it through a sanitization filter
|
164 |
+
foreach ( $input as $key => $value ) {
|
165 |
+
|
166 |
+
// Get the setting type (checkbox, select, etc)
|
167 |
+
$type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false;
|
168 |
+
|
169 |
+
if ( $type ) {
|
170 |
+
// Field type specific filter
|
171 |
+
$input[ $key ] = apply_filters( 'wpp_settings_sanitize_' . $type, $value, $key );
|
172 |
+
}
|
173 |
+
|
174 |
+
// General filter
|
175 |
+
$input[ $key ] = apply_filters( 'wpp_settings_sanitize', $value, $key );
|
176 |
+
}
|
177 |
+
|
178 |
+
|
179 |
+
// Loop through the whitelist and unset any that are empty for the tab being saved
|
180 |
+
if ( ! empty( $settings[ $tab ] ) ) {
|
181 |
+
foreach ( $settings[ $tab ] as $key => $value ) {
|
182 |
+
|
183 |
+
// settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
|
184 |
+
if ( is_numeric( $key ) ) {
|
185 |
+
$key = $value['id'];
|
186 |
+
}
|
187 |
+
|
188 |
+
if ( empty( $input[ $key ] ) ) {
|
189 |
+
unset( $wpp_settings[ $key ] );
|
190 |
+
}
|
191 |
+
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
// Merge our new settings with the existing
|
196 |
+
$output = array_merge( $wpp_settings, $input );
|
197 |
+
|
198 |
+
return $output;
|
199 |
+
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Get settings fields
|
204 |
+
*
|
205 |
+
* @since 2.0
|
206 |
+
* @return array Fields
|
207 |
+
*/
|
208 |
+
function wpp_get_registered_settings() {
|
209 |
+
$options = array(
|
210 |
+
'enable' => __( 'Enable', 'wp-parsidate' ),
|
211 |
+
'disable' => __( 'Disable', 'wp-parsidate' )
|
212 |
+
);
|
213 |
+
$settings = apply_filters( 'wpp_registered_settings', array(
|
214 |
+
'core' => apply_filters( 'wpp_core_settings', array(
|
215 |
+
'admin_lang' => array(
|
216 |
+
'id' => 'admin_lang',
|
217 |
+
'name' => __( 'Change Locale in admin', 'wp-parsidate' ),
|
218 |
+
'type' => 'radio',
|
219 |
+
'options' => $options,
|
220 |
+
'std' => 'enable',
|
221 |
+
'desc' => __( 'This option change WordPress locale in Admin', 'wp-parsidate' )
|
222 |
+
),
|
223 |
+
'user_lang' => array(
|
224 |
+
'id' => 'user_lang',
|
225 |
+
'name' => __( 'Change Locale in theme', 'wp-parsidate' ),
|
226 |
+
'type' => 'radio',
|
227 |
+
'options' => $options,
|
228 |
+
'std' => 'enable',
|
229 |
+
'desc' => __( 'This option change WordPress locale in theme', 'wp-parsidate' )
|
230 |
+
),
|
231 |
+
'persian_date' => array(
|
232 |
+
'id' => 'persian_date',
|
233 |
+
'name' => __( 'Shamsi date', 'wp-parsidate' ),
|
234 |
+
'type' => 'radio',
|
235 |
+
'options' => $options,
|
236 |
+
'std' => 'disable',
|
237 |
+
'desc' => __( 'By enabling this, Dates will convert to Shamsi (Jalali) dates', 'wp-parsidate' )
|
238 |
+
),
|
239 |
+
'submenu_move' => array(
|
240 |
+
'id' => 'submenu_move',
|
241 |
+
'name' => __( 'Move page to submenu?', 'wp-parsidate' ),
|
242 |
+
'type' => 'radio',
|
243 |
+
'options' => $options,
|
244 |
+
'std' => 'disable',
|
245 |
+
'desc' => __( 'With enabling this option, page item will be moved to Settings menu as submenu.', 'wp-parsidate' )
|
246 |
+
),
|
247 |
+
) ),
|
248 |
+
'conv' => apply_filters( 'wpp_conv_settings', array(
|
249 |
+
'conv_nums' => array(
|
250 |
+
'id' => 'conv_nums',
|
251 |
+
'name' => __( 'Persian digits', 'wp-parsidate' ),
|
252 |
+
'type' => 'header'
|
253 |
+
),
|
254 |
+
'conv_page_title' => array(
|
255 |
+
'id' => 'conv_page_title',
|
256 |
+
'name' => __( 'Page title', 'wp-parsidate' ),
|
257 |
+
'type' => 'radio',
|
258 |
+
'options' => $options,
|
259 |
+
'std' => 'disable'
|
260 |
+
),
|
261 |
+
'conv_title' => array(
|
262 |
+
'id' => 'conv_title',
|
263 |
+
'name' => __( 'Post title', 'wp-parsidate' ),
|
264 |
+
'type' => 'radio',
|
265 |
+
'options' => $options,
|
266 |
+
'std' => 'disable'
|
267 |
+
),
|
268 |
+
'conv_contents' => array(
|
269 |
+
'id' => 'conv_contents',
|
270 |
+
'name' => __( 'Post content', 'wp-parsidate' ),
|
271 |
+
'type' => 'radio',
|
272 |
+
'options' => $options,
|
273 |
+
'std' => 'enable'
|
274 |
+
),
|
275 |
+
'conv_excerpt' => array(
|
276 |
+
'id' => 'conv_excerpt',
|
277 |
+
'name' => __( 'Post excerpt', 'wp-parsidate' ),
|
278 |
+
'type' => 'radio',
|
279 |
+
'options' => $options,
|
280 |
+
'std' => 'disable'
|
281 |
+
),
|
282 |
+
'conv_comments' => array(
|
283 |
+
'id' => 'conv_comments',
|
284 |
+
'name' => __( 'Comments text', 'wp-parsidate' ),
|
285 |
+
'type' => 'radio',
|
286 |
+
'options' => $options,
|
287 |
+
'std' => 'disable'
|
288 |
+
),
|
289 |
+
'conv_comment_count' => array(
|
290 |
+
'id' => 'conv_comment_count',
|
291 |
+
'name' => __( 'Comments count', 'wp-parsidate' ),
|
292 |
+
'type' => 'radio',
|
293 |
+
'options' => $options,
|
294 |
+
'std' => 'disable'
|
295 |
+
),
|
296 |
+
'conv_dates' => array(
|
297 |
+
'id' => 'conv_dates',
|
298 |
+
'name' => __( 'Dates', 'wp-parsidate' ),
|
299 |
+
'type' => 'radio',
|
300 |
+
'options' => $options,
|
301 |
+
'std' => 'disable'
|
302 |
+
),
|
303 |
+
'conv_cats' => array(
|
304 |
+
'id' => 'conv_cats',
|
305 |
+
'name' => __( 'Categories', 'wp-parsidate' ),
|
306 |
+
'type' => 'radio',
|
307 |
+
'options' => $options,
|
308 |
+
'std' => 'disable'
|
309 |
+
),
|
310 |
+
'sep' => array(
|
311 |
+
'id' => 'sep',
|
312 |
+
'type' => 'header'
|
313 |
+
),
|
314 |
+
'conv_arabic' => array(
|
315 |
+
'id' => 'conv_arabic',
|
316 |
+
'name' => __( 'Fix arabic characters', 'wp-parsidate' ),
|
317 |
+
'type' => 'radio',
|
318 |
+
'options' => $options,
|
319 |
+
'std' => 'disable',
|
320 |
+
'desc' => __( 'Fixes arabic characters caused by wrong keyboard layouts', 'wp-parsidate' )
|
321 |
+
),
|
322 |
+
'conv_permalinks' => array(
|
323 |
+
'id' => 'conv_permalinks',
|
324 |
+
'name' => __( 'Fix permalinks dates', 'wp-parsidate' ),
|
325 |
+
'type' => 'radio',
|
326 |
+
'options' => $options,
|
327 |
+
'std' => 'disable',
|
328 |
+
'desc' => __( 'By enabling this, dates in permalinks converted to Shamsi (Jalali) date', 'wp-parsidate' )
|
329 |
+
),
|
330 |
+
'sep_font' => array(
|
331 |
+
'id' => 'sep_font',
|
332 |
+
'type' => 'header'
|
333 |
+
),
|
334 |
+
'droidsans_admin' => array(
|
335 |
+
'id' => 'droidsans_admin',
|
336 |
+
'name' => __( 'Use Droid Sans font for admin side', 'wp-parsidate' ),
|
337 |
+
'type' => 'radio',
|
338 |
+
'options' => $options,
|
339 |
+
'std' => 'enable',
|
340 |
+
'desc' => __( 'Droid Sans Naskh and Roboto font families will be activated in admin side, if this is enabled.', 'wp-parsidate' )
|
341 |
+
),
|
342 |
+
'droidsans_editor' => array(
|
343 |
+
'id' => 'droidsans_editor',
|
344 |
+
'name' => __( 'Use Droid Sans font for editors', 'wp-parsidate' ),
|
345 |
+
'type' => 'radio',
|
346 |
+
'options' => $options,
|
347 |
+
'std' => 'enable',
|
348 |
+
'desc' => __( 'Droid Sans Naskh and Roboto font families will be activated in all rich editors in back end.', 'wp-parsidate' )
|
349 |
+
)
|
350 |
+
) ),
|
351 |
+
'plugins' => apply_filters( 'wpp_plugins_compability_settings', array() )
|
352 |
+
) );
|
353 |
+
|
354 |
+
return $settings;
|
355 |
+
}
|
356 |
+
|
357 |
+
/* Form Callbacks Made by EDD Development Team */
|
358 |
+
function wpp_header_callback( $args ) {
|
359 |
+
echo '<hr/>';
|
360 |
+
}
|
361 |
+
|
362 |
+
function wpp_checkbox_callback( $args ) {
|
363 |
+
global $wpp_settings;
|
364 |
+
|
365 |
+
$checked = isset( $wpp_settings[ $args['id'] ] ) ? checked( 1, $wpp_settings[ $args['id'] ], false ) : '';
|
366 |
+
$html = '<input type="checkbox" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="1" ' . $checked . '/>';
|
367 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
368 |
+
|
369 |
+
echo $html;
|
370 |
+
}
|
371 |
+
|
372 |
+
function wpp_multicheck_callback( $args ) {
|
373 |
+
global $wpp_settings;
|
374 |
+
|
375 |
+
$html = '';
|
376 |
+
foreach ( $args['options'] as $key => $value ) {
|
377 |
+
$option_name = $args['id'] . '-' . $key;
|
378 |
+
wpp_checkbox_callback( array(
|
379 |
+
'id' => $option_name,
|
380 |
+
'desc' => $value
|
381 |
+
) );
|
382 |
+
echo '<br>';
|
383 |
+
}
|
384 |
+
|
385 |
+
echo $html;
|
386 |
+
}
|
387 |
+
|
388 |
+
function wpp_radio_callback( $args ) {
|
389 |
+
global $wpp_settings;
|
390 |
+
|
391 |
+
foreach ( $args['options'] as $key => $option ) :
|
392 |
+
$checked = false;
|
393 |
+
|
394 |
+
if ( isset( $wpp_settings[ $args['id'] ] ) && $wpp_settings[ $args['id'] ] == $key ) {
|
395 |
+
$checked = true;
|
396 |
+
} elseif ( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpp_settings[ $args['id'] ] ) ) {
|
397 |
+
$checked = true;
|
398 |
+
}
|
399 |
+
|
400 |
+
echo '<input name="wpp_settings[' . $args['id'] . ']"" id="wpp_settings[' . $args['id'] . '][' . $key . ']" type="radio" value="' . $key . '" ' . checked( true, $checked, false ) . '/>';
|
401 |
+
echo '<label for="wpp_settings[' . $args['id'] . '][' . $key . ']">' . $option . '</label> ';
|
402 |
+
endforeach;
|
403 |
+
|
404 |
+
echo '<p class="description">' . $args['desc'] . '</p>';
|
405 |
+
}
|
406 |
+
|
407 |
+
function wpp_text_callback( $args ) {
|
408 |
+
global $wpp_settings;
|
409 |
+
|
410 |
+
if ( isset( $wpp_settings[ $args['id'] ] ) ) {
|
411 |
+
$value = $wpp_settings[ $args['id'] ];
|
412 |
+
} else {
|
413 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
414 |
+
}
|
415 |
+
|
416 |
+
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
417 |
+
$html = '<input type="text" class="' . $size . '-text" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
|
418 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
419 |
+
|
420 |
+
echo $html;
|
421 |
+
}
|
422 |
+
|
423 |
+
function wpp_number_callback( $args ) {
|
424 |
+
global $wpp_settings;
|
425 |
+
|
426 |
+
if ( isset( $wpp_settings[ $args['id'] ] ) ) {
|
427 |
+
$value = $wpp_settings[ $args['id'] ];
|
428 |
+
} else {
|
429 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
430 |
+
}
|
431 |
+
|
432 |
+
$max = isset( $args['max'] ) ? $args['max'] : 999999;
|
433 |
+
$min = isset( $args['min'] ) ? $args['min'] : 0;
|
434 |
+
$step = isset( $args['step'] ) ? $args['step'] : 1;
|
435 |
+
|
436 |
+
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
437 |
+
$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . $size . '-text" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
|
438 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
439 |
+
|
440 |
+
echo $html;
|
441 |
+
}
|
442 |
+
|
443 |
+
function wpp_textarea_callback( $args ) {
|
444 |
+
global $wpp_settings;
|
445 |
+
|
446 |
+
if ( isset( $wpp_settings[ $args['id'] ] ) ) {
|
447 |
+
$value = $wpp_settings[ $args['id'] ];
|
448 |
+
} else {
|
449 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
450 |
+
}
|
451 |
+
|
452 |
+
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
453 |
+
$html = '<textarea class="large-text" cols="50" rows="5" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
|
454 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
455 |
+
|
456 |
+
echo $html;
|
457 |
+
}
|
458 |
+
|
459 |
+
function wpp_password_callback( $args ) {
|
460 |
+
global $wpp_settings;
|
461 |
+
|
462 |
+
if ( isset( $wpp_settings[ $args['id'] ] ) ) {
|
463 |
+
$value = $wpp_settings[ $args['id'] ];
|
464 |
+
} else {
|
465 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
466 |
+
}
|
467 |
+
|
468 |
+
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
469 |
+
$html = '<input type="password" class="' . $size . '-text" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '"/>';
|
470 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
471 |
+
|
472 |
+
echo $html;
|
473 |
+
}
|
474 |
+
|
475 |
+
function wpp_missing_callback( $args ) {
|
476 |
+
echo '–';
|
477 |
+
|
478 |
+
return false;
|
479 |
+
}
|
480 |
+
|
481 |
+
|
482 |
+
function wpp_select_callback( $args ) {
|
483 |
+
global $wpp_settings;
|
484 |
+
|
485 |
+
if ( isset( $wpp_settings[ $args['id'] ] ) ) {
|
486 |
+
$value = $wpp_settings[ $args['id'] ];
|
487 |
+
} else {
|
488 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
489 |
+
}
|
490 |
+
|
491 |
+
$html = '<select id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']"/>';
|
492 |
+
|
493 |
+
foreach ( $args['options'] as $option => $name ) :
|
494 |
+
$selected = selected( $option, $value, false );
|
495 |
+
$html .= '<option value="' . $option . '" ' . $selected . '>' . $name . '</option>';
|
496 |
+
endforeach;
|
497 |
+
|
498 |
+
$html .= '</select>';
|
499 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
500 |
+
|
501 |
+
echo $html;
|
502 |
+
}
|
503 |
+
|
504 |
+
function wpp_color_select_callback( $args ) {
|
505 |
+
global $wpp_settings;
|
506 |
+
|
507 |
+
if ( isset( $wpp_settings[ $args['id'] ] ) ) {
|
508 |
+
$value = $wpp_settings[ $args['id'] ];
|
509 |
+
} else {
|
510 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
511 |
+
}
|
512 |
+
|
513 |
+
$html = '<select id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']"/>';
|
514 |
+
|
515 |
+
foreach ( $args['options'] as $option => $color ) :
|
516 |
+
$selected = selected( $option, $value, false );
|
517 |
+
$html .= '<option value="' . $option . '" ' . $selected . '>' . $color['label'] . '</option>';
|
518 |
+
endforeach;
|
519 |
+
|
520 |
+
$html .= '</select>';
|
521 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
522 |
+
|
523 |
+
echo $html;
|
524 |
+
}
|
525 |
+
|
526 |
+
function wpp_rich_editor_callback( $args ) {
|
527 |
+
global $wpp_settings, $wp_version;
|
528 |
+
|
529 |
+
if ( isset( $wpp_settings[ $args['id'] ] ) ) {
|
530 |
+
$value = $wpp_settings[ $args['id'] ];
|
531 |
+
} else {
|
532 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
533 |
+
}
|
534 |
+
|
535 |
+
if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
|
536 |
+
$html = wp_editor( stripslashes( $value ), 'wpp_settings[' . $args['id'] . ']', array( 'textarea_name' => 'wpp_settings[' . $args['id'] . ']' ) );
|
537 |
+
} else {
|
538 |
+
$html = '<textarea class="large-text" rows="10" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
|
539 |
+
}
|
540 |
+
|
541 |
+
$html .= '<br/><label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
542 |
+
|
543 |
+
echo $html;
|
544 |
+
}
|
545 |
+
|
546 |
+
function wpp_upload_callback( $args ) {
|
547 |
+
global $wpp_settings;
|
548 |
+
|
549 |
+
if ( isset( $wpp_settings[ $args['id'] ] ) ) {
|
550 |
+
$value = $wpp_settings[ $args['id'] ];
|
551 |
+
} else {
|
552 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
553 |
+
}
|
554 |
+
|
555 |
+
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
556 |
+
$html = '<input type="text" class="' . $size . '-text wpp_upload_field" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
|
557 |
+
$html .= '<span> <input type="button" class="wpp_settings_upload_button button-secondary" value="' . __( 'Upload File', 'wpp' ) . '"/></span>';
|
558 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
559 |
+
|
560 |
+
echo $html;
|
561 |
+
}
|
562 |
+
|
563 |
+
function wpp_color_callback( $args ) {
|
564 |
+
global $wpp_settings;
|
565 |
+
|
566 |
+
if ( isset( $wpp_settings[ $args['id'] ] ) ) {
|
567 |
+
$value = $wpp_settings[ $args['id'] ];
|
568 |
+
} else {
|
569 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
570 |
+
}
|
571 |
+
|
572 |
+
$default = isset( $args['std'] ) ? $args['std'] : '';
|
573 |
+
|
574 |
+
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
575 |
+
$html = '<input type="text" class="wpp-color-picker" id="wpp_settings[' . $args['id'] . ']" name="wpp_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
|
576 |
+
$html .= '<label for="wpp_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
577 |
+
|
578 |
+
echo $html;
|
579 |
+
}
|
580 |
+
|
581 |
+
function wpp_render_settings() {
|
582 |
+
global $wpp_settings;
|
583 |
+
$active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], wpp_get_tabs() ) ? $_GET['tab'] : 'core';
|
584 |
+
|
585 |
+
ob_start();
|
586 |
+
?>
|
587 |
+
<div class="wrap wpp-settings-wrap">
|
588 |
+
<h2><?php _e( 'Parsi Settings', 'wp-parsidate' ) ?></h2>
|
589 |
+
<h2 class="nav-tab-wrapper">
|
590 |
+
<?php
|
591 |
+
foreach ( wpp_get_tabs() as $tab_id => $tab_name ) {
|
592 |
+
|
593 |
+
$tab_url = add_query_arg( array(
|
594 |
+
'settings-updated' => false,
|
595 |
+
'tab' => $tab_id
|
596 |
+
) );
|
597 |
+
|
598 |
+
$active = $active_tab == $tab_id ? ' nav-tab-active' : '';
|
599 |
+
|
600 |
+
echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
|
601 |
+
echo $tab_name;
|
602 |
+
echo '</a>';
|
603 |
+
}
|
604 |
+
?>
|
605 |
+
</h2>
|
606 |
+
<?php settings_errors( 'wpp-notices' ); ?>
|
607 |
+
<div id="tab_container">
|
608 |
+
<form method="post" action="options.php">
|
609 |
+
<table class="form-table">
|
610 |
+
<?php
|
611 |
+
settings_fields( 'wpp_settings' );
|
612 |
+
do_settings_fields( 'wpp_settings_' . $active_tab, 'wpp_settings_' . $active_tab );
|
613 |
+
?>
|
614 |
+
</table>
|
615 |
+
<?php submit_button(); ?>
|
616 |
+
</form>
|
617 |
+
</div><!-- #tab_container-->
|
618 |
+
</div><!-- .wrap -->
|
619 |
+
<?php
|
620 |
+
echo ob_get_clean();
|
621 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
includes/widget/widget_archive.php
CHANGED
@@ -1,79 +1,99 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* @author lord_viper
|
4 |
* @copyright 2013
|
5 |
-
*/
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
public function form($instance)
|
21 |
-
{
|
22 |
-
$type= isset($instance['parsidate_archive_type']) ? $instance['parsidate_archive_type'] : 'monthly';
|
23 |
-
$instance['parsidate_archive_title']= isset($instance['parsidate_archive_title']) ? strip_tags($instance['parsidate_archive_title']) : __('Jalali Date Archives','wp-parsidate') ;
|
24 |
-
$instance['parsidate_archive_count']= isset($instance['parsidate_archive_count']) ? $instance['parsidate_archive_count'] : 0;
|
25 |
-
$instance['parsidate_archive_list'] = isset($instance['parsidate_archive_list']) ? $instance['parsidate_archive_list'] : 0;
|
26 |
|
27 |
-
|
28 |
<p style="text-align:right; direction:rtl">
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
<label
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
</p>
|
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 |
-
echo "<select name='parsidate_archive_list' onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value='0'>".esc_attr($title)."</option>";
|
67 |
-
wp_get_parchives("type=$type&format=option&show_post_count=$post_count",$ddl_style);
|
68 |
echo '</select>';
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
echo '<ul>';
|
73 |
-
wpp_get_archives("type=$type&show_post_count=$post_count",$ddl_style);
|
74 |
echo '</ul>';
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
}
|
79 |
-
?>
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* @author lord_viper
|
5 |
* @copyright 2013
|
6 |
+
*/
|
7 |
+
class parsidate_archive extends WP_Widget {
|
8 |
+
public function __construct() {
|
9 |
+
global $wp_version;
|
10 |
+
|
11 |
+
// backwards compability
|
12 |
+
if ( version_compare( $wp_version, '4.3', '>=' ) ) {
|
13 |
+
parent::__construct( false, __( 'Jalali Date Archives', 'wp-parsidate' ), 'description=' . __( 'Jalali Date Archives', 'wp-parsidate' ) );
|
14 |
+
} else {
|
15 |
+
parent::WP_Widget( false, __( 'Jalali Date Archives', 'wp-parsidate' ), 'description=' . __( 'Jalali Date Archives', 'wp-parsidate' ) );
|
16 |
+
}
|
17 |
+
}
|
18 |
|
19 |
+
public function form( $instance ) {
|
20 |
+
global $wpp_settings;
|
21 |
+
$type = isset( $instance['parsidate_archive_type'] ) ? $instance['parsidate_archive_type'] : 'monthly';
|
22 |
+
$instance['parsidate_archive_title'] = isset( $instance['parsidate_archive_title'] ) ? strip_tags( $instance['parsidate_archive_title'] ) : __( 'Jalali Date Archives', 'wp-parsidate' );
|
23 |
+
$instance['parsidate_archive_count'] = isset( $instance['parsidate_archive_count'] ) ? $instance['parsidate_archive_count'] : 0;
|
24 |
+
$instance['parsidate_archive_list'] = isset( $instance['parsidate_archive_list'] ) ? $instance['parsidate_archive_list'] : 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
+
?>
|
27 |
<p style="text-align:right; direction:rtl">
|
28 |
+
<label></label>
|
29 |
+
<input style="width: 200px;" id="<?php echo $this->get_field_id( 'parsidate_archive_title' ); ?>"
|
30 |
+
name="<?php echo $this->get_field_name( 'parsidate_archive_title' ); ?>" type="text"
|
31 |
+
value="<?php echo( empty( $instance['parsidate_archive_title'] ) ? __( 'Jalali Date Archives', 'wp-parsidate' ) : $instance['parsidate_archive_title'] ) ?>"/>
|
32 |
+
<br/>
|
33 |
+
<label><input type="radio" id="parsidate_archive_type1"
|
34 |
+
name="<?php echo $this->get_field_name( 'parsidate_archive_type' ); ?>"
|
35 |
+
value="yearly" <?php checked( $type, 'yearly' ); ?>/><label
|
36 |
+
for="parsidate_archive_type1"><?php _e( 'Yearly', 'wp-parsidate' ) ?></label><br/>
|
37 |
+
<label><input type="radio" id="parsidate_archive_type2"
|
38 |
+
name="<?php echo $this->get_field_name( 'parsidate_archive_type' ); ?>"
|
39 |
+
value="monthly" <?php checked( $type, 'monthly' ); ?>/><?php _e( 'Monthly', 'wp-parsidate' ) ?>
|
40 |
+
</label><br/>
|
41 |
+
<label><input type="radio" id="parsidate_archive_type3"
|
42 |
+
name="<?php echo $this->get_field_name( 'parsidate_archive_type' ); ?>"
|
43 |
+
value="daily" <?php checked( $type, 'daily' ); ?>/><?php _e( 'Daily', 'wp-parsidate' ) ?>
|
44 |
+
</label><br/>
|
45 |
+
<br/>
|
46 |
+
<input type="checkbox" name="<?php echo $this->get_field_name( 'parsidate_archive_count' ); ?>"
|
47 |
+
id="<?php echo $this->get_field_id( 'parsidate_archive_count' ); ?>"
|
48 |
+
value="1" <?php checked( $instance['parsidate_archive_count'], 1, true ); ?>/>
|
49 |
+
<label for="<?php echo $this->get_field_id( 'parsidate_archive_count' ); ?>"><?php _e( 'Show post counts', 'wp-parsidate' ) ?></label>
|
50 |
+
<br/>
|
51 |
+
<input type="checkbox" name="<?php echo $this->get_field_name( 'parsidate_archive_list' ); ?>"
|
52 |
+
id="<?php echo $this->get_field_id( 'parsidate_archive_list' ); ?>"
|
53 |
+
value="1" <?php echo checked( $instance['parsidate_archive_list'], 1, true ); ?>/>
|
54 |
+
<label for="<?php echo $this->get_field_id( 'parsidate_archive_list' ); ?>"><?php _e( 'Display as dropdown', 'wp-parsidate' ) ?></label>
|
55 |
</p>
|
56 |
+
<?php
|
57 |
+
if ( $wpp_settings['conv_permalinks'] == 'disable' ) {
|
58 |
+
echo "<p style='color: #ff8153'>" . __( 'For use widget, active "Fix permalinks dates" option in plugin settings.', 'wp-parsidate' ) . "</p>";
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
public function update( $new_instance, $old_instance ) {
|
63 |
+
$instance = $old_instance;
|
64 |
+
$instance['parsidate_archive_title'] = isset( $new_instance['parsidate_archive_title'] ) ? strip_tags( $new_instance['parsidate_archive_title'] ) : __( 'Jalali Date Archives', 'wp-parsidate' );
|
65 |
+
$instance['parsidate_archive_count'] = isset( $new_instance['parsidate_archive_count'] ) ? $new_instance['parsidate_archive_count'] : 0;
|
66 |
+
$instance['parsidate_archive_list'] = isset( $new_instance['parsidate_archive_list'] ) ? $new_instance['parsidate_archive_list'] : 0;
|
67 |
+
$instance['parsidate_archive_type'] = isset( $new_instance['parsidate_archive_type'] ) ? $new_instance['parsidate_archive_type'] : 'monthly';
|
68 |
+
|
69 |
+
return $instance;
|
70 |
+
}
|
71 |
+
|
72 |
+
public function widget( $args, $instance ) {
|
73 |
+
global $wpp_settings;
|
74 |
+
if ( $wpp_settings['conv_permalinks'] == 'disable' ) {
|
75 |
+
return;
|
76 |
+
}
|
77 |
+
|
78 |
+
$type = isset( $instance['parsidate_archive_type'] ) ? $instance['parsidate_archive_type'] : 'monthly';
|
79 |
+
$title = isset( $instance['parsidate_archive_title'] ) ? $instance['parsidate_archive_title'] : __( 'Jalali Date Archives', 'wp-parsidate' );
|
80 |
+
$post_count = isset( $instance['parsidate_archive_count'] ) ? $instance['parsidate_archive_count'] : false;
|
81 |
+
$ddl_style = isset( $instance['parsidate_archive_list'] ) ? $instance['parsidate_archive_list'] : false;
|
82 |
+
|
83 |
+
echo $args['before_widget'];
|
84 |
+
if ( ! empty( $instance['parsidate_archive_title'] ) ) {
|
85 |
+
echo $args['before_title'] . apply_filters( 'widget_title', $instance['parsidate_archive_title'] ) . $args['after_title'];
|
86 |
+
}
|
87 |
|
88 |
+
if ( $ddl_style ) {
|
89 |
+
echo "<select name='parsidate_archive_list' onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value='0'>" . esc_attr( $title ) . "</option>";
|
90 |
+
wp_get_parchives( "type=$type&format=option&show_post_count=$post_count" );
|
|
|
|
|
91 |
echo '</select>';
|
92 |
+
} else {
|
93 |
+
echo '<ul>';
|
94 |
+
wpp_get_archives( "type=$type&show_post_count=$post_count" );
|
|
|
|
|
95 |
echo '</ul>';
|
96 |
+
}
|
97 |
+
echo $args['after_widget'];
|
98 |
+
}
|
99 |
+
}
|
|
includes/widget/widget_calendar.php
CHANGED
@@ -4,41 +4,49 @@
|
|
4 |
* @author lord_viper
|
5 |
* @copyright 2013
|
6 |
*/
|
7 |
-
class parsidate_calendar extends WP_Widget
|
8 |
-
{
|
9 |
-
public function __construct()
|
10 |
-
{
|
11 |
global $wp_version;
|
12 |
-
if (version_compare($wp_version, '4.3', '>='))
|
13 |
-
parent::__construct(false, __('Jalali Date Calender', 'wp-parsidate'), 'description=' . __('Jalali Date Calender', 'wp-parsidate'));
|
14 |
-
else
|
15 |
-
parent::WP_Widget(false, __('Jalali Date Calender', 'wp-parsidate'), 'description=' . __('Jalali Date Calender', 'wp-parsidate'));
|
|
|
16 |
}
|
17 |
|
18 |
-
public function form($instance)
|
19 |
-
|
20 |
?>
|
21 |
<p style="text-align:right; direction:rtl">
|
22 |
-
<label><?php _e('Title:', 'wp-parsidate') ?></label>
|
23 |
-
<input style="width: 200px;" id="<?php echo $this->get_field_id('parsidate_calendar_title'
|
|
|
|
|
24 |
</p>
|
25 |
<?php
|
|
|
|
|
|
|
26 |
}
|
27 |
|
28 |
-
public function update($new_instance, $old_instance)
|
29 |
-
|
30 |
-
$instance = $
|
31 |
-
|
32 |
return $instance;
|
33 |
}
|
34 |
|
35 |
-
public function widget($args, $instance)
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
40 |
wpp_get_calendar();
|
41 |
-
echo $after_widget;
|
42 |
}
|
43 |
}
|
44 |
|
4 |
* @author lord_viper
|
5 |
* @copyright 2013
|
6 |
*/
|
7 |
+
class parsidate_calendar extends WP_Widget {
|
8 |
+
public function __construct() {
|
|
|
|
|
9 |
global $wp_version;
|
10 |
+
if ( version_compare( $wp_version, '4.3', '>=' ) ) {
|
11 |
+
parent::__construct( false, __( 'Jalali Date Calender', 'wp-parsidate' ), 'description=' . __( 'Jalali Date Calender', 'wp-parsidate' ) );
|
12 |
+
} else {
|
13 |
+
parent::WP_Widget( false, __( 'Jalali Date Calender', 'wp-parsidate' ), 'description=' . __( 'Jalali Date Calender', 'wp-parsidate' ) );
|
14 |
+
}
|
15 |
}
|
16 |
|
17 |
+
public function form( $instance ) {
|
18 |
+
global $wpp_settings;
|
19 |
?>
|
20 |
<p style="text-align:right; direction:rtl">
|
21 |
+
<label><?php _e( 'Title:', 'wp-parsidate' ) ?></label>
|
22 |
+
<input style="width: 200px;" id="<?php echo $this->get_field_id( 'parsidate_calendar_title' ); ?>"
|
23 |
+
name="<?php echo $this->get_field_name( 'parsidate_calendar_title' ); ?>" type="text"
|
24 |
+
value="<?php echo( empty( $instance['parsidate_calendar_title'] ) ? __( 'Jalali Date Calender', 'wp-parsidate' ) : $instance['parsidate_calendar_title'] ) ?>"/>
|
25 |
</p>
|
26 |
<?php
|
27 |
+
if ( $wpp_settings['conv_permalinks'] == 'disable' ) {
|
28 |
+
echo "<p style='color: #ff8153'>" . __( 'For use widget, active "Fix permalinks dates" option in plugin settings.', 'wp-parsidate' ) . "</p>";
|
29 |
+
}
|
30 |
}
|
31 |
|
32 |
+
public function update( $new_instance, $old_instance ) {
|
33 |
+
$instance = $old_instance;
|
34 |
+
$instance['parsidate_calendar_title'] = strip_tags( $new_instance['parsidate_calendar_title'] );
|
35 |
+
|
36 |
return $instance;
|
37 |
}
|
38 |
|
39 |
+
public function widget( $args, $instance ) {
|
40 |
+
global $wpp_settings;
|
41 |
+
if ( $wpp_settings['conv_permalinks'] == 'disable' ) {
|
42 |
+
return;
|
43 |
+
}
|
44 |
+
echo $args['before_widget'];
|
45 |
+
if ( ! empty( $instance['parsidate_calendar_title'] ) ) {
|
46 |
+
echo $args['before_title'] . apply_filters( 'widget_title', $instance['parsidate_calendar_title'] ) . $args['after_title'];
|
47 |
+
}
|
48 |
wpp_get_calendar();
|
49 |
+
echo $args['after_widget'];
|
50 |
}
|
51 |
}
|
52 |
|
{parsi-languages → languages}/common-strings.php
RENAMED
@@ -1,4 +1,4 @@
|
|
1 |
-
<?php
|
2 |
-
__( 'WP-Parsidate', 'wp-parsidate' );
|
3 |
-
__( '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.', 'wp-parsidate' );
|
4 |
__( 'WP-Parsi Team', 'wpo' );
|
1 |
+
<?php
|
2 |
+
__( 'WP-Parsidate', 'wp-parsidate' );
|
3 |
+
__( '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.', 'wp-parsidate' );
|
4 |
__( 'WP-Parsi Team', 'wpo' );
|
languages/fa_IR.mo
ADDED
Binary file
|
{parsi-languages → languages}/fa_IR.po
RENAMED
@@ -1,26 +1,26 @@
|
|
1 |
msgid ""
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: WP-Parsi additional strings\n"
|
4 |
-
"POT-Creation-Date:
|
5 |
-
"PO-Revision-Date:
|
6 |
"Last-Translator: Ehsan <iehsan.ir@gmail.com>\n"
|
7 |
"Language-Team: WP-Pari Team\n"
|
8 |
"Language: fa_IR\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"X-Generator: Poedit
|
13 |
"X-Poedit-Basepath: .\n"
|
14 |
"Plural-Forms: nplurals=1; plural=0;\n"
|
15 |
"X-Poedit-KeywordsList: __;_e\n"
|
16 |
"X-Poedit-SourceCharset: UTF-8\n"
|
17 |
"X-Poedit-SearchPath-0: ..\n"
|
18 |
|
19 |
-
#: ../includes/admin/lists-fix.php:
|
20 |
msgid "Show All Dates"
|
21 |
msgstr "نمایش همهی تاریخها"
|
22 |
|
23 |
-
#: ../includes/general.php:
|
24 |
#, php-format
|
25 |
msgid ""
|
26 |
"<div class=\"updated wpp-message\"><p>ParsiDate activated, you may need to "
|
@@ -31,163 +31,159 @@ msgstr ""
|
|
31 |
"نیاز به پیکربندی آن دارید. <a href=\"%s\">برگهی پیکربندی</a> – <a href="
|
32 |
"\"%s\">بیخیال</a></p></div>"
|
33 |
|
34 |
-
#: ../includes/plugins/edd.php:
|
35 |
-
#: ../includes/settings.php:
|
36 |
msgid "Enable"
|
37 |
msgstr "فعال"
|
38 |
|
39 |
-
#: ../includes/plugins/edd.php:
|
40 |
-
#: ../includes/settings.php:
|
41 |
msgid "Disable"
|
42 |
msgstr "غیرفعال"
|
43 |
|
44 |
-
#: ../includes/plugins/edd.php:
|
45 |
msgid "Easy Digital Downloads"
|
46 |
msgstr "Easy Digital Downloads"
|
47 |
|
48 |
-
#: ../includes/plugins/edd.php:
|
49 |
msgid "Fix prices"
|
50 |
msgstr "تصحیح قیمتها"
|
51 |
|
52 |
-
#: ../includes/plugins/edd.php:
|
53 |
msgid "Replace ریال with RIAL"
|
54 |
msgstr "جایگزینی ریال با RIAL"
|
55 |
|
56 |
-
#: ../includes/plugins/woocommerce.php:
|
57 |
msgid "WooCommerce"
|
58 |
msgstr "ووکامرس"
|
59 |
|
60 |
-
#: ../includes/settings.php:
|
61 |
-
#: ../includes/settings.php:
|
62 |
-
#: ../includes/settings.php:
|
63 |
msgid "Parsi Settings"
|
64 |
msgstr "تنظیمات پارسی"
|
65 |
|
66 |
-
#: ../includes/settings.php:
|
67 |
#, php-format
|
68 |
msgid "%s Core"
|
69 |
msgstr "%s هسته"
|
70 |
|
71 |
-
#: ../includes/settings.php:
|
72 |
#, php-format
|
73 |
msgid "%s Converts"
|
74 |
msgstr "%s تبدیل"
|
75 |
|
76 |
-
#: ../includes/settings.php:
|
77 |
#, php-format
|
78 |
msgid "%s Plugins compability"
|
79 |
msgstr "%s هماهنگی با افزونهها"
|
80 |
|
81 |
-
#: ../includes/settings.php:
|
82 |
-
msgid "Settings updated"
|
83 |
-
msgstr "پیکربندی بهروز شد"
|
84 |
-
|
85 |
-
#: ../includes/settings.php:211
|
86 |
msgid "Change Locale in admin"
|
87 |
msgstr "تغییر زبان مدیریت"
|
88 |
|
89 |
-
#: ../includes/settings.php:
|
90 |
msgid "This option change WordPress locale in Admin"
|
91 |
msgstr "این گزینه باعث تغییر زبان مدیریت میشود"
|
92 |
|
93 |
-
#: ../includes/settings.php:
|
94 |
msgid "Change Locale in theme"
|
95 |
msgstr "تغییر زبان سایت"
|
96 |
|
97 |
-
#: ../includes/settings.php:
|
98 |
msgid "This option change WordPress locale in theme"
|
99 |
msgstr "این گزینه باعث تغییر زبان سایت میشود"
|
100 |
|
101 |
-
#: ../includes/settings.php:
|
102 |
msgid "Shamsi date"
|
103 |
msgstr "تاریخ خورشیدی"
|
104 |
|
105 |
-
#: ../includes/settings.php:
|
106 |
msgid "By enabling this, Dates will convert to Shamsi (Jalali) dates"
|
107 |
msgstr "با فعالکردن این گزینه، تاریخها به صورت تاریخ خورشیدی (جلالی) درمیآیند"
|
108 |
|
109 |
-
#: ../includes/settings.php:
|
110 |
msgid "Move page to submenu?"
|
111 |
msgstr "انتقال این برگه به زیرمنو؟"
|
112 |
|
113 |
-
#: ../includes/settings.php:
|
114 |
msgid ""
|
115 |
"With enabling this option, page item will be moved to Settings menu as submenu."
|
116 |
msgstr ""
|
117 |
"با فعالکردن این گزینه، مورد پیکربندی پلاگین به زیرمنوی \"تنظیمات\" منتقل میشود."
|
118 |
|
119 |
-
#: ../includes/settings.php:
|
120 |
msgid "Persian digits"
|
121 |
msgstr "رقمهای پارسی"
|
122 |
|
123 |
-
#: ../includes/settings.php:
|
124 |
msgid "Page title"
|
125 |
msgstr "در عنوان صفحه"
|
126 |
|
127 |
-
#: ../includes/settings.php:
|
128 |
msgid "Post title"
|
129 |
msgstr "در عنوان نوشتهها"
|
130 |
|
131 |
-
#: ../includes/settings.php:
|
132 |
msgid "Post content"
|
133 |
msgstr "در محتوای نوشتهها"
|
134 |
|
135 |
-
#: ../includes/settings.php:
|
136 |
msgid "Post excerpt"
|
137 |
msgstr "در خلاصهی نوشتهها"
|
138 |
|
139 |
-
#: ../includes/settings.php:
|
140 |
msgid "Comments text"
|
141 |
msgstr "در نوشتهی دیدگاهها"
|
142 |
|
143 |
-
#: ../includes/settings.php:
|
144 |
msgid "Comments count"
|
145 |
msgstr "تعداد دیدگاهها"
|
146 |
|
147 |
-
#: ../includes/settings.php:
|
148 |
msgid "Dates"
|
149 |
msgstr "تاریخها"
|
150 |
|
151 |
-
#: ../includes/settings.php:
|
152 |
msgid "Categories"
|
153 |
msgstr "دستهبندیها"
|
154 |
|
155 |
-
#: ../includes/settings.php:
|
156 |
msgid "Fix arabic characters"
|
157 |
msgstr "تصحیح حروف عربی"
|
158 |
|
159 |
-
#: ../includes/settings.php:
|
160 |
msgid "Fixes arabic characters caused by wrong keyboard layouts"
|
161 |
msgstr ""
|
162 |
"این گزینه، حروف عربی را در کل سیستم به حروف فارسی تصحیح میکند<br>برای مثال "
|
163 |
"٤/٥/٦ به ۴ / ۵ / ۶ و ك / ي به ک / ی"
|
164 |
|
165 |
-
#: ../includes/settings.php:
|
166 |
msgid "Fix permalinks dates"
|
167 |
msgstr "تبدیل تاریخ در پیوندهای یکتا"
|
168 |
|
169 |
-
#: ../includes/settings.php:
|
170 |
msgid "By enabling this, dates in permalinks converted to Shamsi (Jalali) date"
|
171 |
msgstr ""
|
172 |
"با فعالکردن این گزینه، تاریخها در پیوندهای یکتا به تاریخ خورشیدی (جلالی) تبدیل "
|
173 |
"میشوند"
|
174 |
|
175 |
-
#: ../includes/settings.php:
|
176 |
msgid "Use Droid Sans font for admin side"
|
177 |
msgstr "استفاده از قلم \"دروید سنس\" برای مدیریت"
|
178 |
|
179 |
-
#: ../includes/settings.php:
|
180 |
msgid ""
|
181 |
"Droid Sans Naskh and Roboto font families will be activated in admin side, if "
|
182 |
-
"this is enabled"
|
183 |
msgstr ""
|
184 |
"خانواده فونتهای \"Droid Sans Naskh\"و \"Roboto\" در قسمت مدیریت فعال خواهند شد."
|
185 |
|
186 |
-
#: ../includes/settings.php:
|
187 |
msgid "Use Droid Sans font for editors"
|
188 |
msgstr "استفاده از قلم \"دروید سنس\" برای ویرایشگر"
|
189 |
|
190 |
-
#: ../includes/settings.php:
|
191 |
msgid ""
|
192 |
"Droid Sans Naskh and Roboto font families will be activated in all rich editors "
|
193 |
"in back end."
|
@@ -195,54 +191,69 @@ msgstr ""
|
|
195 |
"خانواده فونتهای \"Droid Sans Naskh\"و \"Roboto\" در همهی ویرایشگرها فعال خواهند "
|
196 |
"شد."
|
197 |
|
198 |
-
#: ../includes/settings.php:
|
199 |
msgid "Upload File"
|
200 |
msgstr "آپلود فایل"
|
201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
#: ../includes/widget/widget_archive.php:15
|
203 |
-
#: ../includes/widget/widget_archive.php:
|
204 |
-
#: ../includes/widget/widget_archive.php:
|
205 |
-
#: ../includes/widget/widget_archive.php:
|
206 |
-
#: ../includes/widget/widget_archive.php:
|
207 |
-
#: ../includes/widget/widget_archive.php:59
|
208 |
msgid "Jalali Date Archives"
|
209 |
msgstr "بایگانی تاریخ خورشیدی"
|
210 |
|
211 |
-
#: ../includes/widget/widget_archive.php:
|
212 |
msgid "Yearly"
|
213 |
msgstr "سالانه"
|
214 |
|
215 |
-
#: ../includes/widget/widget_archive.php:
|
216 |
msgid "Monthly"
|
217 |
msgstr "ماهانه"
|
218 |
|
219 |
-
#: ../includes/widget/widget_archive.php:
|
220 |
msgid "Daily"
|
221 |
msgstr "روزانه"
|
222 |
|
223 |
-
#: ../includes/widget/widget_archive.php:
|
224 |
msgid "Show post counts"
|
225 |
-
msgstr "
|
226 |
|
227 |
-
#: ../includes/widget/widget_archive.php:
|
228 |
msgid "Display as dropdown"
|
229 |
-
msgstr "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
|
|
|
231 |
#: ../includes/widget/widget_calendar.php:13
|
232 |
-
#: ../includes/widget/widget_calendar.php:
|
233 |
-
#: ../includes/widget/widget_calendar.php:23
|
234 |
msgid "Jalali Date Calender"
|
235 |
msgstr "گاهشمار تاریخ خورشیدی"
|
236 |
|
237 |
-
#: ../includes/widget/widget_calendar.php:
|
238 |
msgid "Title:"
|
239 |
msgstr "عنوان:"
|
240 |
|
241 |
-
#: ../
|
242 |
msgid "WP-Parsidate"
|
243 |
msgstr "بسته وردپرس پارسی"
|
244 |
|
245 |
-
#: ../
|
246 |
msgid ""
|
247 |
"Persian package for WordPress, Adds full RTL and Shamsi (Jalali) support for: "
|
248 |
"posts, comments, pages, archives, search, categories, permalinks and all admin "
|
@@ -254,14 +265,17 @@ msgstr ""
|
|
254 |
"دستهبندیها و پیوندهای یکتا پشتیبانی میکند و تمام قسمتهای مدیریت و ویرایشگر را "
|
255 |
"پارسی میکند. این افزونه همچنین یک ابزارک بایگانی شمسی نیز دارد."
|
256 |
|
257 |
-
#: ../
|
258 |
msgid "WP-Parsi Team"
|
259 |
msgstr "تیم وردپرس پارسی"
|
260 |
|
261 |
-
#: ../wp-parsidate.php:
|
262 |
msgid "settings"
|
263 |
msgstr "تنظیمات"
|
264 |
|
|
|
|
|
|
|
265 |
#~ msgid ""
|
266 |
#~ "WP-Parsidate plugin Activated, Please go to <a href=\"%s\">plugin page "
|
267 |
#~ "settings</a> and setup plugin."
|
@@ -289,6 +303,3 @@ msgstr "تنظیمات"
|
|
289 |
|
290 |
#~ msgid "WP-Parsi news"
|
291 |
#~ msgstr "اخبار وردپرس پارسی"
|
292 |
-
|
293 |
-
#~ msgid "WordPress.org News"
|
294 |
-
#~ msgstr "اخبار WordPress.org"
|
1 |
msgid ""
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: WP-Parsi additional strings\n"
|
4 |
+
"POT-Creation-Date: 2017-06-06 13:53+0430\n"
|
5 |
+
"PO-Revision-Date: 2017-06-06 13:59+0430\n"
|
6 |
"Last-Translator: Ehsan <iehsan.ir@gmail.com>\n"
|
7 |
"Language-Team: WP-Pari Team\n"
|
8 |
"Language: fa_IR\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"X-Generator: Poedit 2.0.1\n"
|
13 |
"X-Poedit-Basepath: .\n"
|
14 |
"Plural-Forms: nplurals=1; plural=0;\n"
|
15 |
"X-Poedit-KeywordsList: __;_e\n"
|
16 |
"X-Poedit-SourceCharset: UTF-8\n"
|
17 |
"X-Poedit-SearchPath-0: ..\n"
|
18 |
|
19 |
+
#: ../includes/admin/lists-fix.php:83
|
20 |
msgid "Show All Dates"
|
21 |
msgstr "نمایش همهی تاریخها"
|
22 |
|
23 |
+
#: ../includes/general.php:156
|
24 |
#, php-format
|
25 |
msgid ""
|
26 |
"<div class=\"updated wpp-message\"><p>ParsiDate activated, you may need to "
|
31 |
"نیاز به پیکربندی آن دارید. <a href=\"%s\">برگهی پیکربندی</a> – <a href="
|
32 |
"\"%s\">بیخیال</a></p></div>"
|
33 |
|
34 |
+
#: ../includes/plugins/edd.php:58 ../includes/plugins/woocommerce.php:49
|
35 |
+
#: ../includes/settings.php:210
|
36 |
msgid "Enable"
|
37 |
msgstr "فعال"
|
38 |
|
39 |
+
#: ../includes/plugins/edd.php:59 ../includes/plugins/woocommerce.php:50
|
40 |
+
#: ../includes/settings.php:211
|
41 |
msgid "Disable"
|
42 |
msgstr "غیرفعال"
|
43 |
|
44 |
+
#: ../includes/plugins/edd.php:64
|
45 |
msgid "Easy Digital Downloads"
|
46 |
msgstr "Easy Digital Downloads"
|
47 |
|
48 |
+
#: ../includes/plugins/edd.php:69 ../includes/plugins/woocommerce.php:60
|
49 |
msgid "Fix prices"
|
50 |
msgstr "تصحیح قیمتها"
|
51 |
|
52 |
+
#: ../includes/plugins/edd.php:76
|
53 |
msgid "Replace ریال with RIAL"
|
54 |
msgstr "جایگزینی ریال با RIAL"
|
55 |
|
56 |
+
#: ../includes/plugins/woocommerce.php:55
|
57 |
msgid "WooCommerce"
|
58 |
msgstr "ووکامرس"
|
59 |
|
60 |
+
#: ../includes/settings.php:26 ../includes/settings.php:27
|
61 |
+
#: ../includes/settings.php:34 ../includes/settings.php:35
|
62 |
+
#: ../includes/settings.php:588
|
63 |
msgid "Parsi Settings"
|
64 |
msgstr "تنظیمات پارسی"
|
65 |
|
66 |
+
#: ../includes/settings.php:130
|
67 |
#, php-format
|
68 |
msgid "%s Core"
|
69 |
msgstr "%s هسته"
|
70 |
|
71 |
+
#: ../includes/settings.php:131
|
72 |
#, php-format
|
73 |
msgid "%s Converts"
|
74 |
msgstr "%s تبدیل"
|
75 |
|
76 |
+
#: ../includes/settings.php:132
|
77 |
#, php-format
|
78 |
msgid "%s Plugins compability"
|
79 |
msgstr "%s هماهنگی با افزونهها"
|
80 |
|
81 |
+
#: ../includes/settings.php:217
|
|
|
|
|
|
|
|
|
82 |
msgid "Change Locale in admin"
|
83 |
msgstr "تغییر زبان مدیریت"
|
84 |
|
85 |
+
#: ../includes/settings.php:221
|
86 |
msgid "This option change WordPress locale in Admin"
|
87 |
msgstr "این گزینه باعث تغییر زبان مدیریت میشود"
|
88 |
|
89 |
+
#: ../includes/settings.php:225
|
90 |
msgid "Change Locale in theme"
|
91 |
msgstr "تغییر زبان سایت"
|
92 |
|
93 |
+
#: ../includes/settings.php:229
|
94 |
msgid "This option change WordPress locale in theme"
|
95 |
msgstr "این گزینه باعث تغییر زبان سایت میشود"
|
96 |
|
97 |
+
#: ../includes/settings.php:233
|
98 |
msgid "Shamsi date"
|
99 |
msgstr "تاریخ خورشیدی"
|
100 |
|
101 |
+
#: ../includes/settings.php:237
|
102 |
msgid "By enabling this, Dates will convert to Shamsi (Jalali) dates"
|
103 |
msgstr "با فعالکردن این گزینه، تاریخها به صورت تاریخ خورشیدی (جلالی) درمیآیند"
|
104 |
|
105 |
+
#: ../includes/settings.php:241
|
106 |
msgid "Move page to submenu?"
|
107 |
msgstr "انتقال این برگه به زیرمنو؟"
|
108 |
|
109 |
+
#: ../includes/settings.php:245
|
110 |
msgid ""
|
111 |
"With enabling this option, page item will be moved to Settings menu as submenu."
|
112 |
msgstr ""
|
113 |
"با فعالکردن این گزینه، مورد پیکربندی پلاگین به زیرمنوی \"تنظیمات\" منتقل میشود."
|
114 |
|
115 |
+
#: ../includes/settings.php:251
|
116 |
msgid "Persian digits"
|
117 |
msgstr "رقمهای پارسی"
|
118 |
|
119 |
+
#: ../includes/settings.php:256
|
120 |
msgid "Page title"
|
121 |
msgstr "در عنوان صفحه"
|
122 |
|
123 |
+
#: ../includes/settings.php:263
|
124 |
msgid "Post title"
|
125 |
msgstr "در عنوان نوشتهها"
|
126 |
|
127 |
+
#: ../includes/settings.php:270
|
128 |
msgid "Post content"
|
129 |
msgstr "در محتوای نوشتهها"
|
130 |
|
131 |
+
#: ../includes/settings.php:277
|
132 |
msgid "Post excerpt"
|
133 |
msgstr "در خلاصهی نوشتهها"
|
134 |
|
135 |
+
#: ../includes/settings.php:284
|
136 |
msgid "Comments text"
|
137 |
msgstr "در نوشتهی دیدگاهها"
|
138 |
|
139 |
+
#: ../includes/settings.php:291
|
140 |
msgid "Comments count"
|
141 |
msgstr "تعداد دیدگاهها"
|
142 |
|
143 |
+
#: ../includes/settings.php:298
|
144 |
msgid "Dates"
|
145 |
msgstr "تاریخها"
|
146 |
|
147 |
+
#: ../includes/settings.php:305
|
148 |
msgid "Categories"
|
149 |
msgstr "دستهبندیها"
|
150 |
|
151 |
+
#: ../includes/settings.php:316
|
152 |
msgid "Fix arabic characters"
|
153 |
msgstr "تصحیح حروف عربی"
|
154 |
|
155 |
+
#: ../includes/settings.php:320
|
156 |
msgid "Fixes arabic characters caused by wrong keyboard layouts"
|
157 |
msgstr ""
|
158 |
"این گزینه، حروف عربی را در کل سیستم به حروف فارسی تصحیح میکند<br>برای مثال "
|
159 |
"٤/٥/٦ به ۴ / ۵ / ۶ و ك / ي به ک / ی"
|
160 |
|
161 |
+
#: ../includes/settings.php:324
|
162 |
msgid "Fix permalinks dates"
|
163 |
msgstr "تبدیل تاریخ در پیوندهای یکتا"
|
164 |
|
165 |
+
#: ../includes/settings.php:328
|
166 |
msgid "By enabling this, dates in permalinks converted to Shamsi (Jalali) date"
|
167 |
msgstr ""
|
168 |
"با فعالکردن این گزینه، تاریخها در پیوندهای یکتا به تاریخ خورشیدی (جلالی) تبدیل "
|
169 |
"میشوند"
|
170 |
|
171 |
+
#: ../includes/settings.php:336
|
172 |
msgid "Use Droid Sans font for admin side"
|
173 |
msgstr "استفاده از قلم \"دروید سنس\" برای مدیریت"
|
174 |
|
175 |
+
#: ../includes/settings.php:340
|
176 |
msgid ""
|
177 |
"Droid Sans Naskh and Roboto font families will be activated in admin side, if "
|
178 |
+
"this is enabled."
|
179 |
msgstr ""
|
180 |
"خانواده فونتهای \"Droid Sans Naskh\"و \"Roboto\" در قسمت مدیریت فعال خواهند شد."
|
181 |
|
182 |
+
#: ../includes/settings.php:344
|
183 |
msgid "Use Droid Sans font for editors"
|
184 |
msgstr "استفاده از قلم \"دروید سنس\" برای ویرایشگر"
|
185 |
|
186 |
+
#: ../includes/settings.php:348
|
187 |
msgid ""
|
188 |
"Droid Sans Naskh and Roboto font families will be activated in all rich editors "
|
189 |
"in back end."
|
191 |
"خانواده فونتهای \"Droid Sans Naskh\"و \"Roboto\" در همهی ویرایشگرها فعال خواهند "
|
192 |
"شد."
|
193 |
|
194 |
+
#: ../includes/settings.php:557
|
195 |
msgid "Upload File"
|
196 |
msgstr "آپلود فایل"
|
197 |
|
198 |
+
#: ../includes/widget/admin-widgets.php:13
|
199 |
+
msgid "WordPress Planet"
|
200 |
+
msgstr "سیاره وردپرس"
|
201 |
+
|
202 |
+
#: ../includes/widget/admin-widgets.php:31
|
203 |
+
msgid "No items"
|
204 |
+
msgstr "موردی پیدا نشد"
|
205 |
+
|
206 |
+
#: ../includes/widget/widget_archive.php:13
|
207 |
#: ../includes/widget/widget_archive.php:15
|
208 |
+
#: ../includes/widget/widget_archive.php:22
|
209 |
+
#: ../includes/widget/widget_archive.php:31
|
210 |
+
#: ../includes/widget/widget_archive.php:64
|
211 |
+
#: ../includes/widget/widget_archive.php:79
|
|
|
212 |
msgid "Jalali Date Archives"
|
213 |
msgstr "بایگانی تاریخ خورشیدی"
|
214 |
|
215 |
+
#: ../includes/widget/widget_archive.php:36
|
216 |
msgid "Yearly"
|
217 |
msgstr "سالانه"
|
218 |
|
219 |
+
#: ../includes/widget/widget_archive.php:39
|
220 |
msgid "Monthly"
|
221 |
msgstr "ماهانه"
|
222 |
|
223 |
+
#: ../includes/widget/widget_archive.php:43
|
224 |
msgid "Daily"
|
225 |
msgstr "روزانه"
|
226 |
|
227 |
+
#: ../includes/widget/widget_archive.php:49
|
228 |
msgid "Show post counts"
|
229 |
+
msgstr "نمايش تعداد نوشتهها"
|
230 |
|
231 |
+
#: ../includes/widget/widget_archive.php:54
|
232 |
msgid "Display as dropdown"
|
233 |
+
msgstr "نمايش به صورت ليست بازشو"
|
234 |
+
|
235 |
+
#: ../includes/widget/widget_archive.php:58
|
236 |
+
#: ../includes/widget/widget_calendar.php:28
|
237 |
+
msgid "For use widget, active \"Fix permalinks dates\" option in plugin settings."
|
238 |
+
msgstr ""
|
239 |
+
"برای استفاده از ابزارک، گزینه \"تبدیل تاریخ در پیوندهای یکتا\" را در تنظیمات "
|
240 |
+
"افزونه فعال کنید."
|
241 |
|
242 |
+
#: ../includes/widget/widget_calendar.php:11
|
243 |
#: ../includes/widget/widget_calendar.php:13
|
244 |
+
#: ../includes/widget/widget_calendar.php:24
|
|
|
245 |
msgid "Jalali Date Calender"
|
246 |
msgstr "گاهشمار تاریخ خورشیدی"
|
247 |
|
248 |
+
#: ../includes/widget/widget_calendar.php:21
|
249 |
msgid "Title:"
|
250 |
msgstr "عنوان:"
|
251 |
|
252 |
+
#: ../languages/common-strings.php:2
|
253 |
msgid "WP-Parsidate"
|
254 |
msgstr "بسته وردپرس پارسی"
|
255 |
|
256 |
+
#: ../languages/common-strings.php:3
|
257 |
msgid ""
|
258 |
"Persian package for WordPress, Adds full RTL and Shamsi (Jalali) support for: "
|
259 |
"posts, comments, pages, archives, search, categories, permalinks and all admin "
|
265 |
"دستهبندیها و پیوندهای یکتا پشتیبانی میکند و تمام قسمتهای مدیریت و ویرایشگر را "
|
266 |
"پارسی میکند. این افزونه همچنین یک ابزارک بایگانی شمسی نیز دارد."
|
267 |
|
268 |
+
#: ../languages/common-strings.php:4
|
269 |
msgid "WP-Parsi Team"
|
270 |
msgstr "تیم وردپرس پارسی"
|
271 |
|
272 |
+
#: ../wp-parsidate.php:162
|
273 |
msgid "settings"
|
274 |
msgstr "تنظیمات"
|
275 |
|
276 |
+
#~ msgid "Settings updated"
|
277 |
+
#~ msgstr "پیکربندی بهروز شد"
|
278 |
+
|
279 |
#~ msgid ""
|
280 |
#~ "WP-Parsidate plugin Activated, Please go to <a href=\"%s\">plugin page "
|
281 |
#~ "settings</a> and setup plugin."
|
303 |
|
304 |
#~ msgid "WP-Parsi news"
|
305 |
#~ msgstr "اخبار وردپرس پارسی"
|
|
|
|
|
|
parsi-languages/fa_IR.mo
DELETED
Binary file
|
readme.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
=== Parsi Date ===
|
2 |
-
Contributors: lord_viper, man4toman, iEhsan.ir
|
3 |
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
|
@@ -14,6 +14,7 @@ This package is made by Persian developers to bring so much better experience of
|
|
14 |
|
15 |
List of some features:
|
16 |
|
|
|
17 |
* Shamsi (Jalali) date in Posts, comments, pages, archives, search, categories
|
18 |
* Shamsi (Jalali) date in Permalinks
|
19 |
* Shamsi (Jalali) date in admin sections such as posts lists, comments lists, pages lists
|
@@ -25,7 +26,6 @@ List of some features:
|
|
25 |
* Poweful and fast function for Persian numbers
|
26 |
* Low resources usage
|
27 |
|
28 |
-
|
29 |
== Installation ==
|
30 |
|
31 |
1. Upload plugin folder to the `/wp-content/plugins/` directory
|
@@ -41,6 +41,11 @@ List of some features:
|
|
41 |
4. 'Jalali Date Calender' in action
|
42 |
|
43 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
44 |
= 2.2.3 =
|
45 |
* Conflict timezone with wordpress default timezone [#issue](https://github.com/wordpress-parsi/wp-parsidate/issues/1)
|
46 |
|
1 |
=== Parsi Date ===
|
2 |
+
Contributors: lord_viper, man4toman, iEhsan.ir, parselearn
|
3 |
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
|
14 |
|
15 |
List of some features:
|
16 |
|
17 |
+
* [WP-Planet.ir](http://wp-planet.ir) Widget
|
18 |
* Shamsi (Jalali) date in Posts, comments, pages, archives, search, categories
|
19 |
* Shamsi (Jalali) date in Permalinks
|
20 |
* Shamsi (Jalali) date in admin sections such as posts lists, comments lists, pages lists
|
26 |
* Poweful and fast function for Persian numbers
|
27 |
* Low resources usage
|
28 |
|
|
|
29 |
== Installation ==
|
30 |
|
31 |
1. Upload plugin folder to the `/wp-content/plugins/` directory
|
41 |
4. 'Jalali Date Calender' in action
|
42 |
|
43 |
== Changelog ==
|
44 |
+
|
45 |
+
= 2.3 =
|
46 |
+
* Add [WP-Planet.ir](http://wp-planet.ir) widget
|
47 |
+
* Fix some bug
|
48 |
+
|
49 |
= 2.2.3 =
|
50 |
* Conflict timezone with wordpress default timezone [#issue](https://github.com/wordpress-parsi/wp-parsidate/issues/1)
|
51 |
|
wp-parsidate.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: WP-Parsidate
|
4 |
-
* Version: 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
|
@@ -31,21 +31,23 @@
|
|
31 |
*/
|
32 |
|
33 |
|
34 |
-
if (!defined('ABSPATH'))
|
|
|
|
|
35 |
|
36 |
-
final class WP_Parsidate
|
37 |
-
{
|
38 |
/**
|
39 |
* @var WP_Parsidate Class instance
|
40 |
*/
|
41 |
public static $instance = null;
|
42 |
|
43 |
-
private function __construct()
|
44 |
-
|
45 |
-
$this->consts();
|
46 |
$this->setup_vars();
|
47 |
$this->include_files();
|
48 |
-
add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'parsi_settings_link'));
|
|
|
|
|
49 |
}
|
50 |
|
51 |
/**
|
@@ -54,19 +56,22 @@ final class WP_Parsidate
|
|
54 |
* @since 2.0
|
55 |
* @return void
|
56 |
*/
|
57 |
-
private function
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
if (!defined('WP_PARSI_DIR'))
|
63 |
-
define('WP_PARSI_DIR', plugin_dir_path(WP_PARSI_ROOT));
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
70 |
}
|
71 |
|
72 |
/**
|
@@ -75,10 +80,10 @@ final class WP_Parsidate
|
|
75 |
* @since 2.0
|
76 |
* @return void
|
77 |
*/
|
78 |
-
private function setup_vars()
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
'فروردین',
|
83 |
'اردیبهشت',
|
84 |
'خرداد',
|
@@ -100,9 +105,8 @@ final class WP_Parsidate
|
|
100 |
* @since 2.0
|
101 |
* @return void
|
102 |
*/
|
103 |
-
public function include_files()
|
104 |
-
|
105 |
-
require_once(WP_PARSI_DIR . 'includes/settings.php');
|
106 |
global $wpp_settings;
|
107 |
$wpp_settings = wp_parsi_get_settings();
|
108 |
|
@@ -115,7 +119,7 @@ final class WP_Parsidate
|
|
115 |
'fixes-misc',
|
116 |
'admin/styles-fix',
|
117 |
'admin/lists-fix',
|
118 |
-
'admin/
|
119 |
'fixes-calendar',
|
120 |
'fixes-archives',
|
121 |
'plugins/woocommerce',
|
@@ -124,13 +128,13 @@ final class WP_Parsidate
|
|
124 |
'widget/widget_calendar'
|
125 |
);
|
126 |
|
127 |
-
foreach ($files as $file)
|
128 |
-
require_once(WP_PARSI_DIR . 'includes/' . $file . '.php');
|
129 |
-
|
130 |
-
if (get_locale() == 'fa_IR')
|
131 |
-
load_textdomain('wp-parsidate', WP_PARSI_DIR . 'parsi-languages/fa_IR.mo');
|
132 |
|
133 |
-
|
|
|
|
|
134 |
}
|
135 |
|
136 |
/**
|
@@ -139,10 +143,10 @@ final class WP_Parsidate
|
|
139 |
* @since 2.0
|
140 |
* @return WP_Parsidate Instance of WP_Parsidate
|
141 |
*/
|
142 |
-
public static function get_instance()
|
143 |
-
|
144 |
-
if (self::$instance == null)
|
145 |
self::$instance = new WP_Parsidate();
|
|
|
146 |
|
147 |
return self::$instance;
|
148 |
}
|
@@ -150,13 +154,14 @@ final class WP_Parsidate
|
|
150 |
/**
|
151 |
* Add Setting Link To Install Plugin
|
152 |
*
|
153 |
-
* @param
|
|
|
154 |
* @return array
|
155 |
*/
|
156 |
-
public static function parsi_settings_link($links)
|
157 |
-
|
158 |
-
|
159 |
-
return array_merge($links, $
|
160 |
}
|
161 |
|
162 |
/**
|
@@ -165,10 +170,10 @@ final class WP_Parsidate
|
|
165 |
* @since 2.0
|
166 |
* @return boolean
|
167 |
*/
|
168 |
-
public function register_widget()
|
169 |
-
|
170 |
-
register_widget('
|
171 |
-
|
172 |
return true;
|
173 |
}
|
174 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: WP-Parsidate
|
4 |
+
* Version: 2.3.0.1
|
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
|
31 |
*/
|
32 |
|
33 |
|
34 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
35 |
+
exit;
|
36 |
+
} // No direct access allowed
|
37 |
|
38 |
+
final class WP_Parsidate {
|
|
|
39 |
/**
|
40 |
* @var WP_Parsidate Class instance
|
41 |
*/
|
42 |
public static $instance = null;
|
43 |
|
44 |
+
private function __construct() {
|
45 |
+
$this->define_const();
|
|
|
46 |
$this->setup_vars();
|
47 |
$this->include_files();
|
48 |
+
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'parsi_settings_link' ) );
|
49 |
+
add_action( 'widgets_init', array( $this, 'register_widget' ) );
|
50 |
+
add_action( 'wp_dashboard_setup', 'wpp_add_dashboard_widgets' );
|
51 |
}
|
52 |
|
53 |
/**
|
56 |
* @since 2.0
|
57 |
* @return void
|
58 |
*/
|
59 |
+
private function define_const() {
|
60 |
+
if ( ! defined( 'WP_PARSI_ROOT' ) ) {
|
61 |
+
define( 'WP_PARSI_ROOT', __FILE__ );
|
62 |
+
}
|
63 |
+
|
64 |
+
if ( ! defined( 'WP_PARSI_DIR' ) ) {
|
65 |
+
define( 'WP_PARSI_DIR', plugin_dir_path( WP_PARSI_ROOT ) );
|
66 |
+
}
|
67 |
+
|
68 |
+
if ( ! defined( 'WP_PARSI_URL' ) ) {
|
69 |
+
define( 'WP_PARSI_URL', plugin_dir_url( WP_PARSI_ROOT ) );
|
70 |
+
}
|
71 |
+
|
72 |
+
if ( ! defined( 'WP_PARSI_VER' ) ) {
|
73 |
+
define( 'WP_PARSI_VER', '2.2' );
|
74 |
+
}
|
75 |
}
|
76 |
|
77 |
/**
|
80 |
* @since 2.0
|
81 |
* @return void
|
82 |
*/
|
83 |
+
private function setup_vars() {
|
84 |
+
global $persian_month_names;
|
85 |
+
$persian_month_names = array(
|
86 |
+
'',
|
87 |
'فروردین',
|
88 |
'اردیبهشت',
|
89 |
'خرداد',
|
105 |
* @since 2.0
|
106 |
* @return void
|
107 |
*/
|
108 |
+
public function include_files() {
|
109 |
+
require_once( WP_PARSI_DIR . 'includes/settings.php' );
|
|
|
110 |
global $wpp_settings;
|
111 |
$wpp_settings = wp_parsi_get_settings();
|
112 |
|
119 |
'fixes-misc',
|
120 |
'admin/styles-fix',
|
121 |
'admin/lists-fix',
|
122 |
+
'admin/widgets',
|
123 |
'fixes-calendar',
|
124 |
'fixes-archives',
|
125 |
'plugins/woocommerce',
|
128 |
'widget/widget_calendar'
|
129 |
);
|
130 |
|
131 |
+
foreach ( $files as $file ) {
|
132 |
+
require_once( WP_PARSI_DIR . 'includes/' . $file . '.php' );
|
133 |
+
}
|
|
|
|
|
134 |
|
135 |
+
if ( get_locale() == 'fa_IR' ) {
|
136 |
+
load_textdomain( 'wp-parsidate', WP_PARSI_DIR . 'languages/fa_IR.mo' );
|
137 |
+
}
|
138 |
}
|
139 |
|
140 |
/**
|
143 |
* @since 2.0
|
144 |
* @return WP_Parsidate Instance of WP_Parsidate
|
145 |
*/
|
146 |
+
public static function get_instance() {
|
147 |
+
if ( self::$instance == null ) {
|
|
|
148 |
self::$instance = new WP_Parsidate();
|
149 |
+
}
|
150 |
|
151 |
return self::$instance;
|
152 |
}
|
154 |
/**
|
155 |
* Add Setting Link To Install Plugin
|
156 |
*
|
157 |
+
* @param array $links
|
158 |
+
*
|
159 |
* @return array
|
160 |
*/
|
161 |
+
public static function parsi_settings_link( $links ) {
|
162 |
+
$settings_link = array( '<a href="' . menu_page_url( 'wp-parsi-settings', false ) . '">' . __( 'settings', 'wp-parsidate' ) . '</a>' );
|
163 |
+
|
164 |
+
return array_merge( $links, $settings_link );
|
165 |
}
|
166 |
|
167 |
/**
|
170 |
* @since 2.0
|
171 |
* @return boolean
|
172 |
*/
|
173 |
+
public function register_widget() {
|
174 |
+
register_widget( 'parsidate_archive' );
|
175 |
+
register_widget( 'parsidate_calendar' );
|
176 |
+
|
177 |
return true;
|
178 |
}
|
179 |
}
|