wp-jalali - Version 5.0.0-RC

Version Description

Download this release

Release Info

Developer mani_monaj
Plugin Icon 128x128 wp-jalali
Version 5.0.0-RC
Comparing to
See all releases

Code changes from version 4.5.3 to 5.0.0-RC

assets/banner-772x250.png ADDED
Binary file
assets/css/admin.css ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @font-face {
2
+ font-family: 'ztjalali_icon';
3
+ src: url('../icon/ztjalali.eot?66463877');
4
+ src: url('../icon/ztjalali.eot?66463877#iefix') format('embedded-opentype'),
5
+ url('../icon/ztjalali.woff?66463877') format('woff'),
6
+ url('../icon/ztjalali.ttf?66463877') format('truetype'),
7
+ url('../icon/ztjalali.svg?66463877#ztjalali') format('svg');
8
+ font-weight: normal;
9
+ font-style: normal;
10
+ }
11
+
12
+ /*
13
+ [class^="icon-"]:before, [class*=" icon-"]:before {
14
+ font-family: "zt-wppersian";
15
+ font-style: normal;
16
+ font-weight: normal;
17
+ speak: none;
18
+
19
+ display: inline-block;
20
+ text-decoration: inherit;
21
+ width: 1em;
22
+ margin-right: .2em;
23
+ text-align: center;
24
+ opacity: .8;
25
+
26
+ For safety - reset parent styles, that can break glyph codes
27
+ font-variant: normal;
28
+ text-transform: none;
29
+
30
+ fix buttons height, for twitter bootstrap
31
+ line-height: 1em;
32
+
33
+ Animation center compensation - margins should be symmetric
34
+ remove if not needed
35
+ margin-left: .2em;
36
+
37
+ you can be more comfortable with increased icons size
38
+ font-size: 120%;
39
+
40
+ Uncomment for 3D effect
41
+ text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3);
42
+ }
43
+
44
+ .icon-wppersianb:before { content: '\e800'; } '' */
45
+
46
+ .dashicons-ztjalali:before{
47
+ content: '\e800';
48
+ font-family: "ztjalali_icon";
49
+ font-style: normal;
50
+ font-weight: normal;
51
+ speak: none;
52
+ display: inline-block;
53
+ text-decoration: inherit;
54
+ width: 1em;
55
+ text-align: center;
56
+ opacity: .8;
57
+ }
58
+
59
+ .form-table td{
60
+ font-size: 11px !important;
61
+
62
+ }
63
+ #wpcontent #wp-toolbar .menupop a,#wpcontent #wp-toolbar .menupop a .ab-label {
64
+ font-family: tahoma !important;
65
+ }
66
+ #dashboard_right_now .versions .b, #post-status-display, #post-visibility-display, #adminmenu .wp-submenu li.current, #adminmenu .wp-submenu li.current a, #adminmenu .wp-submenu li.current a:hover, .media-item .percent, .plugins .name, #pass-strength-result.strong, #pass-strength-result.short, #ed_reply_toolbar #ed_reply_strong, .item-controls .item-order a, .feature-filter .feature-name{
67
+ font-weight: normal !important
68
+ }
69
+
70
+ #Jaa, #Jhh, #Jjj, #Jmn {
71
+ font-size: 12px;
72
+ padding: 1px;
73
+ }
74
+ #Jhh, #Jjj, #Jmn {
75
+ width: 2em;
76
+ }
77
+ #Jaa {
78
+ width: 3.4em;
79
+ }
80
+
81
+ .ztjalali_option_logo {
82
+ margin: 20px 0;
83
+ text-align: center;
84
+ }
85
+ .ztjalali-badge {
86
+ background: url("../img/wp-jalali-80x80.png") no-repeat scroll center 24px / 80px 80px #fff !important;
87
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
88
+ color: #78c8e6;
89
+ display: inline-block;
90
+ font-size: 14px;
91
+ font-weight: 600;
92
+ height: 40px;
93
+ margin: 5px 0 0;
94
+ padding-top: 120px;
95
+ text-align: center;
96
+ text-rendering: optimizelegibility;
97
+ width: 150px;
98
+ left: 0;
99
+ position: absolute;
100
+ top: 0;
101
+ }
102
+ .zt-badge {
103
+ background: url("../img/zakrot.com.png") no-repeat scroll center 24px / 80px 80px #fff !important;
104
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
105
+ color: #78c8e6;
106
+ display: inline-block;
107
+ font-size: 14px;
108
+ font-weight: 600;
109
+ height: 40px;
110
+ margin: 5px 0 0;
111
+ padding-top: 120px;
112
+ text-align: center;
113
+ text-rendering: optimizelegibility;
114
+ width: 150px;
115
+ left: 160px;
116
+ position: absolute;
117
+ top: 0;
118
+ }
119
+ .ztjalali-welcome-top{
120
+ margin: 1em 0 1em 350px !important;
121
+ }
122
+ /*#toplevel_page_ztjalali_admin_page .wp-menu-name {
123
+ position: fixed !important;
124
+ }*/
assets/css/admin_style.css ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @font-face {
2
+ font-family: 'yekan';
3
+ src: url('../fonts/BYekan.eot?#') format('eot'), /* IE6–8 */
4
+ url('../fonts/BYekan.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/
5
+ url('../fonts/BYekan.ttf') format('truetype'); /* Saf3—5, Chrome4+, FF3.5, Opera 10+ */
6
+ }
7
+
8
+ #adminmenu a.menu-top, #adminmenu .wp-submenu-head{
9
+ font-size: 13px !important;
10
+ font-family: yekan !important;
11
+ }
12
+ #adminmenu .wp-submenu a {
13
+ font-size: 13px;
14
+ font-family: yekan !important;
15
+
16
+ }
17
+ .wrap h2, .subtitle {
18
+ font-weight: normal;
19
+ font-family: yekan !important;
20
+ font-size: 21px !important;
21
+ }
22
+ .form-table th, .form-wrap label {
23
+ font-family: yekan !important;
24
+ font-size: 13px !important;
25
+ font-weight: normal
26
+ }
assets/css/theme_editing.css ADDED
@@ -0,0 +1 @@
 
1
+ .wrap #template textarea{direction: ltr;text-align: left;}
assets/css/wysiwyg.css ADDED
@@ -0,0 +1,2 @@
 
 
1
+ body{font-family:tahoma;font-size:12px;}
2
+ #tinymce{font-family: tahoma; font-size:12px;}
assets/fonts/BYekan.eot ADDED
Binary file
assets/fonts/BYekan.ttf ADDED
Binary file
assets/fonts/BYekan.woff ADDED
Binary file
assets/icon-128x128.png ADDED
Binary file
assets/icon-256x256.png ADDED
Binary file
assets/icon/ztjalali.eot ADDED
Binary file
assets/icon/ztjalali.svg ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg xmlns="http://www.w3.org/2000/svg">
4
+ <metadata>Copyright (C) 2014 by original authors @ fontello.com</metadata>
5
+ <defs>
6
+ <font id="ztjalali" horiz-adv-x="1000" >
7
+ <font-face font-family="ztjalali" font-weight="400" font-stretch="normal" units-per-em="1000" ascent="850" descent="-150" />
8
+ <missing-glyph horiz-adv-x="1000" />
9
+ <glyph glyph-name="wp" unicode="&#xe800;" d="m501 741c-216 0-392-176-392-392 0-216 176-392 392-392 216 0 392 176 392 392 0 216-176 392-392 392z m292-334c-8-20-95-21-124 3-29 24-3 71 37 73 40 2 95-55 87-76z m-151-311c-132-82-306 5-311-2-4-7 92-68 198-102-10 0-19-1-28-1-104 0-198 45-263 116 25 1 212 7 253 43 30 17 75 91 70 174-6 113-68 237-140 229-83-9-131-147-120-231 5-39 37-56 61-60 72-11 131 25 136 23-15-80-205-82-205-82l-117-3c0 0 0 0 0 0-21 45-32 96-32 149 0 131 70 245 175 307l105-60 64 110c4 0 9 0 13 0 110 0 208-49 274-127-12 8-25 13-39 14-73 8-167-245-86-292 66-39 134 2 165 11 13-16-41-135-173-216z m-161 282c-3-11-62-25-115-10-53 16-21 79 25 80 46 1 92-60 90-70z" horiz-adv-x="1000" />
10
+ <glyph glyph-name="zakrot" unicode="&#xe801;" d="m502 741c-217 0-393-176-393-393 0-217 176-392 393-392 217 0 392 175 392 392 0 217-175 393-392 393z m-314-326c72-10 192-30 310-61 74-20 147-45 208-67-58-3-126-8-194-15-124-12-246-32-309-43-14 37-22 77-22 119 0 23 2 46 7 67z m84-291c46-9 103-21 159-36 57-16 113-33 158-49-28-8-57-12-87-12-90 0-172 37-230 97z m408-42c-41 15-135 49-230 74-35 9-70 18-102 25 52 7 112 15 171 21 104 10 209 16 277 19-24-57-65-105-116-139z m-162 340c-116 31-235 51-308 61 51 110 163 186 292 186 177 0 321-143 321-321 0-10-1-20-2-30-67 27-183 72-303 104z" horiz-adv-x="1000" />
11
+ </font>
12
+ </defs>
13
+ </svg>
assets/icon/ztjalali.ttf ADDED
Binary file
assets/icon/ztjalali.woff ADDED
Binary file
assets/img/wp-jalali-80x80.png ADDED
Binary file
assets/img/zakrot.com.png ADDED
Binary file
assets/js/admin-af.js ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($) {
2
+ /**
3
+ * create vars
4
+ */
5
+ var jalaliMonthNames = ["", "حمل", "ثور", "جوزا", "سرطان", "اسد", "سنبله", "میزان", "عقرب", "قوس", "جدی", "دلو", "حوت"];
6
+ var timestampdiv = $('#timestampdiv');
7
+ /* =================================================================== */
8
+ /**
9
+ *define functions
10
+ */
11
+ function timestampDivModifier(year, month, day, hour, min) {
12
+ content = '<div class="timestamp-wrap jalaliDivBox">';
13
+ content += '<select id="Jmm" name="Jmm">';
14
+ for (var i = 1; i <= 12; i++) {
15
+ if (i == month)
16
+ sel = 'selected="selected"';
17
+ else
18
+ sel = '';
19
+ content += '<option ' + sel + ' value="' + i + '">' + jalaliMonthNames[i] + '</option>';
20
+ }
21
+ content += '</select>';
22
+
23
+ content += '<input type="text" name="Jjj" value="' + day + '" id="Jjj" size="2" maxlength="2" autocomplete="off" />,';
24
+ content += '<input type="text" name="Jaa" value="' + year + '" id="Jaa" size="4" maxlength="4" autocomplete="off" /> @';
25
+ content += '<input type="text" name="Jmn" value="' + min + '" id="Jmn" size="2" maxlength="2" autocomplete="off" /> : ';
26
+ content += '<input type="text" name="Jhh" value="' + hour + '" id="Jhh" size="2" maxlength="2" autocomplete="off" />';
27
+ content += '</div>';
28
+ return content;
29
+ }
30
+
31
+ function changeTimestampViewer(){
32
+ y = $('input[name=aa]').val();
33
+ m = $('select[name=mm]').val();
34
+ d = $('input[name=jj]').val();
35
+ h = $('input[name=hh]').val();
36
+ i = $('input[name=mn]').val();
37
+ //alert(y+','+m+','+d);
38
+ jd = JalaliDate.gregorianToJalali(y, m, d);
39
+ //alert(jd);
40
+ ret='';
41
+ $text = jalaliMonthNames[jd[1]]+' '+jd[2]+', '+jd[0]+' @'+h+':'+i;
42
+ for (var i = 0; i < $text.length ; i++){
43
+ if(!isNaN($text[i]) && $text[i]!=' '){
44
+ ret += String.fromCharCode($text.charCodeAt(i) + 1728);
45
+ }else{
46
+ ret += $text[i];
47
+ }
48
+ }
49
+ $('#timestamp b').text(ret);
50
+
51
+ }
52
+ /* =================================================================== */
53
+ $('#the-list').on('click', '.editinline', function() {
54
+ var tr = $(this).closest('td');
55
+ var year = tr.find('.aa').html();
56
+ if (year > 1700){
57
+ var month = tr.find('.mm').html();
58
+ var day = tr.find('.jj').html();
59
+ var hour = tr.find('.hh').html();
60
+ var min = tr.find('.mn').html();
61
+ var date = JalaliDate.gregorianToJalali(year, month, day);
62
+ // $('.jalaliDivBox').remove();
63
+ $('.inline-edit-date div').hide();
64
+ $('.inline-edit-date').prepend(timestampDivModifier(date[0], date[1], date[2], hour, min));
65
+ }
66
+ });
67
+
68
+ $('.inline-edit-date').on('keyup', '#Jhh', function(e) {
69
+ $('input[name=hh]').val($(this).val());
70
+ });
71
+
72
+ $('.inline-edit-date').on('keyup', '#Jmn', function(e) {
73
+ $('input[name=mn]').val($(this).val());
74
+ });
75
+
76
+ $('.inline-edit-date').on('keyup', '#Jaa , #Jjj', function(e) {
77
+ year = $('#Jaa').val();
78
+ month = $('#Jmm').val();
79
+ day = $('#Jjj').val();
80
+ date = JalaliDate.jalaliToGregorian(year, month, day);
81
+ $('input[name=aa]').val(date[0]);
82
+ $('select[name=mm]').val(date[1]);
83
+ $('input[name=jj]').val(date[2]);
84
+ });
85
+
86
+ $('.inline-edit-date').on('change', '#Jmm', function() {
87
+ year = $('#Jaa').val();
88
+ month = $('#Jmm').val();
89
+ day = $('#Jjj').val();
90
+ date = JalaliDate.jalaliToGregorian(year, month, day);
91
+ $('input[name=aa]').val(date[0]);
92
+ if(date[1]<10)date[1] = '0'+date[1];
93
+ $('select[name=mm]').val(date[1]);
94
+ $('input[name=jj]').val(date[2]);
95
+ });
96
+
97
+ /* =================================================================== */
98
+ /**
99
+ * in edit.php
100
+ */
101
+
102
+ $('a.edit-timestamp').on('click', function() {
103
+ var date = JalaliDate.gregorianToJalali($('#aa').val(), $('#mm').val(), $('#jj').val());
104
+ var divCnt = timestampDivModifier(date[0], date[1], date[2], $('#hh').val(), $('#mn').val());
105
+ $('#timestampdiv .timestamp-wrap').hide();
106
+ $('#timestampdiv').prepend(divCnt);
107
+ });
108
+
109
+
110
+ $('#timestampdiv .cancel-timestamp').on('click', function() {
111
+ $('.jalaliDivBox').remove();
112
+ });
113
+
114
+ $('.save-timestamp,#publish').on('click', function() {
115
+ if($('#Jhh').val()!== undefined){
116
+ $('input[name=hh]').val($('#Jhh').val());
117
+ $('input[name=mn]').val($('#Jmn').val());
118
+ year = $('#Jaa').val();
119
+ month = $('#Jmm').val();
120
+ day = $('#Jjj').val();
121
+ jDate = [year,month,day];
122
+ date = JalaliDate.jalaliToGregorian(year, month, day);
123
+ if(date[1]<10)date[1] = '0'+date[1];
124
+ $('input[name=aa]').val(date[0]);
125
+ $('select[name=mm]').val(date[1]);
126
+ $('input[name=jj]').val(date[2]);
127
+ }
128
+
129
+ setTimeout(function(){
130
+ if($('#timestampdiv .timestamp-wrap:eq(1)').hasClass('form-invalid')){
131
+ $('.jalaliDivBox').addClass('.form-invalid');
132
+ }else{
133
+ $('.jalaliDivBox').remove();
134
+ $('#timestampdiv').slideUp('fast');
135
+ $('a.edit-timestamp').slideDown('fast');
136
+ setTimeout(function(){changeTimestampViewer()},100);
137
+ }
138
+ },100);
139
+ });
140
+
141
+
142
+ /* =================================================================== */
143
+
144
+ });
assets/js/admin-ir.js ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($) {
2
+ /**
3
+ * create vars
4
+ */
5
+ var jalaliMonthNames = ['', 'فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'];
6
+ var timestampdiv = $('#timestampdiv');
7
+ /* =================================================================== */
8
+ /**
9
+ *define functions
10
+ */
11
+ function timestampDivModifier(year, month, day, hour, min) {
12
+ content = '<div class="timestamp-wrap jalaliDivBox">';
13
+ content += '<select id="Jmm" name="Jmm">';
14
+ for (var i = 1; i <= 12; i++) {
15
+ if (i == month)
16
+ sel = 'selected="selected"';
17
+ else
18
+ sel = '';
19
+ content += '<option ' + sel + ' value="' + i + '">' + jalaliMonthNames[i] + '</option>';
20
+ }
21
+ content += '</select>';
22
+
23
+ content += '<input type="text" name="Jjj" value="' + day + '" id="Jjj" size="2" maxlength="2" autocomplete="off" />,';
24
+ content += '<input type="text" name="Jaa" value="' + year + '" id="Jaa" size="4" maxlength="4" autocomplete="off" /> @';
25
+ content += '<input type="text" name="Jmn" value="' + min + '" id="Jmn" size="2" maxlength="2" autocomplete="off" /> : ';
26
+ content += '<input type="text" name="Jhh" value="' + hour + '" id="Jhh" size="2" maxlength="2" autocomplete="off" />';
27
+ content += '</div>';
28
+ return content;
29
+ }
30
+
31
+ function changeTimestampViewer(){
32
+ y = $('input[name=aa]').val();
33
+ m = $('select[name=mm]').val();
34
+ d = $('input[name=jj]').val();
35
+ h = $('input[name=hh]').val();
36
+ i = $('input[name=mn]').val();
37
+ //alert(y+','+m+','+d);
38
+ jd = JalaliDate.gregorianToJalali(y, m, d);
39
+ //alert(jd);
40
+ ret='';
41
+ $text = jalaliMonthNames[jd[1]]+' '+jd[2]+', '+jd[0]+' @'+h+':'+i;
42
+ for (var i = 0; i < $text.length ; i++){
43
+ if(!isNaN($text[i]) && $text[i]!=' '){
44
+ ret += String.fromCharCode($text.charCodeAt(i) + 1728);
45
+ }else{
46
+ ret += $text[i];
47
+ }
48
+ }
49
+ $('#timestamp b').text(ret);
50
+
51
+ }
52
+ /* =================================================================== */
53
+ $('#the-list').on('click', '.editinline', function() {
54
+ var tr = $(this).closest('td');
55
+ var year = tr.find('.aa').html();
56
+ if (year > 1700){
57
+ var month = tr.find('.mm').html();
58
+ var day = tr.find('.jj').html();
59
+ var hour = tr.find('.hh').html();
60
+ var min = tr.find('.mn').html();
61
+ var date = JalaliDate.gregorianToJalali(year, month, day);
62
+ // $('.jalaliDivBox').remove();
63
+ $('.inline-edit-date div').hide();
64
+ $('.inline-edit-date').prepend(timestampDivModifier(date[0], date[1], date[2], hour, min));
65
+ }
66
+ });
67
+
68
+ $('.inline-edit-date').on('keyup', '#Jhh', function(e) {
69
+ $('input[name=hh]').val($(this).val());
70
+ });
71
+
72
+ $('.inline-edit-date').on('keyup', '#Jmn', function(e) {
73
+ $('input[name=mn]').val($(this).val());
74
+ });
75
+
76
+ $('.inline-edit-date').on('keyup', '#Jaa , #Jjj', function(e) {
77
+ year = $('#Jaa').val();
78
+ month = $('#Jmm').val();
79
+ day = $('#Jjj').val();
80
+ date = JalaliDate.jalaliToGregorian(year, month, day);
81
+ $('input[name=aa]').val(date[0]);
82
+ $('select[name=mm]').val(date[1]);
83
+ $('input[name=jj]').val(date[2]);
84
+ });
85
+
86
+ $('.inline-edit-date').on('change', '#Jmm', function() {
87
+ year = $('#Jaa').val();
88
+ month = $('#Jmm').val();
89
+ day = $('#Jjj').val();
90
+ date = JalaliDate.jalaliToGregorian(year, month, day);
91
+ $('input[name=aa]').val(date[0]);
92
+ if(date[1]<10)date[1] = '0'+date[1];
93
+ $('select[name=mm]').val(date[1]);
94
+ $('input[name=jj]').val(date[2]);
95
+ });
96
+
97
+ /* =================================================================== */
98
+ /**
99
+ * in edit.php
100
+ */
101
+
102
+ $('a.edit-timestamp').on('click', function() {
103
+ var date = JalaliDate.gregorianToJalali($('#aa').val(), $('#mm').val(), $('#jj').val());
104
+ var divCnt = timestampDivModifier(date[0], date[1], date[2], $('#hh').val(), $('#mn').val());
105
+ $('#timestampdiv .timestamp-wrap').hide();
106
+ $('#timestampdiv').prepend(divCnt);
107
+ });
108
+
109
+
110
+ $('#timestampdiv .cancel-timestamp').on('click', function() {
111
+ $('.jalaliDivBox').remove();
112
+ });
113
+
114
+ $('.save-timestamp,#publish').on('click', function() {
115
+ if($('#Jhh').val()!== undefined){
116
+ $('input[name=hh]').val($('#Jhh').val());
117
+ $('input[name=mn]').val($('#Jmn').val());
118
+ year = $('#Jaa').val();
119
+ month = $('#Jmm').val();
120
+ day = $('#Jjj').val();
121
+ jDate = [year,month,day];
122
+ date = JalaliDate.jalaliToGregorian(year, month, day);
123
+ if(date[1]<10)date[1] = '0'+date[1];
124
+ $('input[name=aa]').val(date[0]);
125
+ $('select[name=mm]').val(date[1]);
126
+ $('input[name=jj]').val(date[2]);
127
+ }
128
+
129
+ setTimeout(function(){
130
+ if($('#timestampdiv .timestamp-wrap:eq(1)').hasClass('form-invalid')){
131
+ $('.jalaliDivBox').addClass('.form-invalid');
132
+ }else{
133
+ $('.jalaliDivBox').remove();
134
+ $('#timestampdiv').slideUp('fast');
135
+ $('a.edit-timestamp').slideDown('fast');
136
+ setTimeout(function(){changeTimestampViewer()},100);
137
+ }
138
+ },100);
139
+ });
140
+
141
+
142
+ /* =================================================================== */
143
+
144
+ });
assets/js/date.js ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * JalaliJSCalendar - Jalali Extension for Date Object
3
+ * Copyright (c) 2008 Ali Farhadi (http://farhadi.ir/)
4
+ * Released under the terms of the GNU General Public License.
5
+ * See the GPL for details (http://www.gnu.org/licenses/gpl.html).
6
+ *
7
+ * Based on code from http://farsiweb.info
8
+ */
9
+
10
+ JalaliDate = {
11
+ g_days_in_month: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
12
+ j_days_in_month: [31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29]
13
+ };
14
+
15
+ JalaliDate.jalaliToGregorian = function(j_y, j_m, j_d)
16
+ {
17
+ j_y = parseInt(j_y);
18
+ j_m = parseInt(j_m);
19
+ j_d = parseInt(j_d);
20
+ var jy = j_y-979;
21
+ var jm = j_m-1;
22
+ var jd = j_d-1;
23
+
24
+ var j_day_no = 365*jy + parseInt(jy / 33)*8 + parseInt((jy%33+3) / 4);
25
+ for (var i=0; i < jm; ++i) j_day_no += JalaliDate.j_days_in_month[i];
26
+
27
+ j_day_no += jd;
28
+
29
+ var g_day_no = j_day_no+79;
30
+
31
+ var gy = 1600 + 400 * parseInt(g_day_no / 146097); /* 146097 = 365*400 + 400/4 - 400/100 + 400/400 */
32
+ g_day_no = g_day_no % 146097;
33
+
34
+ var leap = true;
35
+ if (g_day_no >= 36525) /* 36525 = 365*100 + 100/4 */
36
+ {
37
+ g_day_no--;
38
+ gy += 100*parseInt(g_day_no/ 36524); /* 36524 = 365*100 + 100/4 - 100/100 */
39
+ g_day_no = g_day_no % 36524;
40
+
41
+ if (g_day_no >= 365)
42
+ g_day_no++;
43
+ else
44
+ leap = false;
45
+ }
46
+
47
+ gy += 4*parseInt(g_day_no/ 1461); /* 1461 = 365*4 + 4/4 */
48
+ g_day_no %= 1461;
49
+
50
+ if (g_day_no >= 366) {
51
+ leap = false;
52
+
53
+ g_day_no--;
54
+ gy += parseInt(g_day_no/ 365);
55
+ g_day_no = g_day_no % 365;
56
+ }
57
+
58
+ for (var i = 0; g_day_no >= JalaliDate.g_days_in_month[i] + (i == 1 && leap); i++)
59
+ g_day_no -= JalaliDate.g_days_in_month[i] + (i == 1 && leap);
60
+ var gm = i+1;
61
+ var gd = g_day_no+1;
62
+
63
+ return [gy, gm, gd];
64
+ }
65
+
66
+ JalaliDate.checkDate = function(j_y, j_m, j_d)
67
+ {
68
+ return !(j_y < 0 || j_y > 32767 || j_m < 1 || j_m > 12 || j_d < 1 || j_d >
69
+ (JalaliDate.j_days_in_month[j_m-1] + (j_m == 12 && !((j_y-979)%33%4))));
70
+ }
71
+
72
+ JalaliDate.gregorianToJalali = function(g_y, g_m, g_d)
73
+ {
74
+ g_y = parseInt(g_y);
75
+ g_m = parseInt(g_m);
76
+ g_d = parseInt(g_d);
77
+ var gy = g_y-1600;
78
+ var gm = g_m-1;
79
+ var gd = g_d-1;
80
+
81
+ var g_day_no = 365*gy+parseInt((gy+3) / 4)-parseInt((gy+99)/100)+parseInt((gy+399)/400);
82
+
83
+ for (var i=0; i < gm; ++i)
84
+ g_day_no += JalaliDate.g_days_in_month[i];
85
+ if (gm>1 && ((gy%4==0 && gy%100!=0) || (gy%400==0)))
86
+ /* leap and after Feb */
87
+ ++g_day_no;
88
+ g_day_no += gd;
89
+
90
+ var j_day_no = g_day_no-79;
91
+
92
+ var j_np = parseInt(j_day_no/ 12053);
93
+ j_day_no %= 12053;
94
+
95
+ var jy = 979+33*j_np+4*parseInt(j_day_no/1461);
96
+
97
+ j_day_no %= 1461;
98
+
99
+ if (j_day_no >= 366) {
100
+ jy += parseInt((j_day_no-1)/ 365);
101
+ j_day_no = (j_day_no-1)%365;
102
+ }
103
+
104
+ for (var i = 0; i < 11 && j_day_no >= JalaliDate.j_days_in_month[i]; ++i) {
105
+ j_day_no -= JalaliDate.j_days_in_month[i];
106
+ }
107
+ var jm = i+1;
108
+ var jd = j_day_no+1;
109
+
110
+
111
+ return [jy, jm, jd];
112
+ }
113
+
114
+ Date.prototype.setJalaliFullYear = function(y, m, d) {
115
+ var gd = this.getDate();
116
+ var gm = this.getMonth();
117
+ var gy = this.getFullYear();
118
+ var j = JalaliDate.gregorianToJalali(gy, gm+1, gd);
119
+ if (y < 100) y += 1300;
120
+ j[0] = y;
121
+ if (m != undefined) {
122
+ if (m > 11) {
123
+ j[0] += Math.floor(m / 12);
124
+ m = m % 12;
125
+ }
126
+ j[1] = m + 1;
127
+ }
128
+ if (d != undefined) j[2] = d;
129
+ var g = JalaliDate.jalaliToGregorian(j[0], j[1], j[2]);
130
+ return this.setFullYear(g[0], g[1]-1, g[2]);
131
+ }
132
+
133
+ Date.prototype.setJalaliMonth = function(m, d) {
134
+ var gd = this.getDate();
135
+ var gm = this.getMonth();
136
+ var gy = this.getFullYear();
137
+ var j = JalaliDate.gregorianToJalali(gy, gm+1, gd);
138
+ if (m > 11) {
139
+ j[0] += math.floor(m / 12);
140
+ m = m % 12;
141
+ }
142
+ j[1] = m+1;
143
+ if (d != undefined) j[2] = d;
144
+ var g = JalaliDate.jalaliToGregorian(j[0], j[1], j[2]);
145
+ return this.setFullYear(g[0], g[1]-1, g[2]);
146
+ }
147
+
148
+ Date.prototype.setJalaliDate = function(d) {
149
+ var gd = this.getDate();
150
+ var gm = this.getMonth();
151
+ var gy = this.getFullYear();
152
+ var j = JalaliDate.gregorianToJalali(gy, gm+1, gd);
153
+ j[2] = d;
154
+ var g = JalaliDate.jalaliToGregorian(j[0], j[1], j[2]);
155
+ return this.setFullYear(g[0], g[1]-1, g[2]);
156
+ }
157
+
158
+ Date.prototype.getJalaliFullYear = function() {
159
+ var gd = this.getDate();
160
+ var gm = this.getMonth();
161
+ var gy = this.getFullYear();
162
+ var j = JalaliDate.gregorianToJalali(gy, gm+1, gd);
163
+ return j[0];
164
+ }
165
+
166
+ Date.prototype.getJalaliMonth = function() {
167
+ var gd = this.getDate();
168
+ var gm = this.getMonth();
169
+ var gy = this.getFullYear();
170
+ var j = JalaliDate.gregorianToJalali(gy, gm+1, gd);
171
+ return j[1]-1;
172
+ }
173
+
174
+ Date.prototype.getJalaliDate = function() {
175
+ var gd = this.getDate();
176
+ var gm = this.getMonth();
177
+ var gy = this.getFullYear();
178
+ var j = JalaliDate.gregorianToJalali(gy, gm+1, gd);
179
+ return j[2];
180
+ }
181
+
182
+ Date.prototype.getJalaliDay = function() {
183
+ var day = this.getDay();
184
+ day = (day + 1) % 7;
185
+ return day;
186
+ }
187
+
188
+
189
+ /**
190
+ * Jalali UTC functions
191
+ */
192
+
193
+ Date.prototype.setJalaliUTCFullYear = function(y, m, d) {
194
+ var gd = this.getUTCDate();
195
+ var gm = this.getUTCMonth();
196
+ var gy = this.getUTCFullYear();
197
+ var j = JalaliDate.gregorianToJalali(gy, gm+1, gd);
198
+ if (y < 100) y += 1300;
199
+ j[0] = y;
200
+ if (m != undefined) {
201
+ if (m > 11) {
202
+ j[0] += Math.floor(m / 12);
203
+ m = m % 12;
204
+ }
205
+ j[1] = m + 1;
206
+ }
207
+ if (d != undefined) j[2] = d;
208
+ var g = JalaliDate.jalaliToGregorian(j[0], j[1], j[2]);
209
+ return this.setUTCFullYear(g[0], g[1]-1, g[2]);
210
+ }
211
+
212
+ Date.prototype.setJalaliUTCMonth = function(m, d) {
213
+ var gd = this.getUTCDate();
214
+ var gm = this.getUTCMonth();
215
+ var gy = this.getUTCFullYear();
216
+ var j = JalaliDate.gregorianToJalali(gy, gm+1, gd);
217
+ if (m > 11) {
218
+ j[0] += math.floor(m / 12);
219
+ m = m % 12;
220
+ }
221
+ j[1] = m+1;
222
+ if (d != undefined) j[2] = d;
223
+ var g = JalaliDate.jalaliToGregorian(j[0], j[1], j[2]);
224
+ return this.setUTCFullYear(g[0], g[1]-1, g[2]);
225
+ }
226
+
227
+ Date.prototype.setJalaliUTCDate = function(d) {
228
+ var gd = this.getUTCDate();
229
+ var gm = this.getUTCMonth();
230
+ var gy = this.getUTCFullYear();
231
+ var j = JalaliDate.gregorianToJalali(gy, gm+1, gd);
232
+ j[2] = d;
233
+ var g = JalaliDate.jalaliToGregorian(j[0], j[1], j[2]);
234
+ return this.setUTCFullYear(g[0], g[1]-1, g[2]);
235
+ }
236
+
237
+ Date.prototype.getJalaliUTCFullYear = function() {
238
+ var gd = this.getUTCDate();
239
+ var gm = this.getUTCMonth();
240
+ var gy = this.getUTCFullYear();
241
+ var j = JalaliDate.gregorianToJalali(gy, gm+1, gd);
242
+ return j[0];
243
+ }
244
+
245
+ Date.prototype.getJalaliUTCMonth = function() {
246
+ var gd = this.getUTCDate();
247
+ var gm = this.getUTCMonth();
248
+ var gy = this.getUTCFullYear();
249
+ var j = JalaliDate.gregorianToJalali(gy, gm+1, gd);
250
+ return j[1]-1;
251
+ }
252
+
253
+ Date.prototype.getJalaliUTCDate = function() {
254
+ var gd = this.getUTCDate();
255
+ var gm = this.getUTCMonth();
256
+ var gy = this.getUTCFullYear();
257
+ var j = JalaliDate.gregorianToJalali(gy, gm+1, gd);
258
+ return j[2];
259
+ }
260
+
261
+ Date.prototype.getJalaliUTCDay = function() {
262
+ var day = this.getUTCDay();
263
+ day = (day + 1) % 7;
264
+ return day;
265
+ }
inc/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php
inc/wp-jalali-admin-option.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * admin options page
4
+ */
5
+ global $ztjalali_option;
6
+ ?>
7
+
8
+ <div class="wrap">
9
+ <h2><?php _e('wp persian option', 'ztjalali'); ?></h2>
10
+ <div class="ztjalali_option_logo">
11
+ <a href="http://wp-persian.com" target="_BLANK" title="وردپرس فارسی">
12
+ <img src="<?php echo plugins_url('/assets/img/wp-jalali-80x80.png', dirname(__FILE__)); ?>" />
13
+ </a>
14
+ </div>
15
+
16
+ <form method="post">
17
+ <?php wp_nonce_field('jalali_save_options'); ?>
18
+ <table class="form-table">
19
+ <tbody>
20
+ <tr>
21
+ <th scope="row"><?php _e('date option', 'ztjalali'); ?></th>
22
+ <td>
23
+ <fieldset>
24
+ <legend class="screen-reader-text"><span><?php _e('date option', 'ztjalali'); ?></span></legend>
25
+ <label for="change_date_to_jalali">
26
+ <input type="checkbox" id="change_date_to_jalali" name="change_date_to_jalali" value="1" <?php checked($ztjalali_option['change_date_to_jalali'], TRUE); ?> />
27
+ <?php _e('change_date_to_jalali Description', 'ztjalali'); ?>
28
+ </label>
29
+ <br />
30
+ <label for="change_jdate_number_to_persian">
31
+ <input type="checkbox" id="change_jdate_number_to_persian" name="change_jdate_number_to_persian" value="1" <?php checked($ztjalali_option['change_jdate_number_to_persian'], TRUE); ?> />
32
+ <?php _e('change_jdate_number_to_persian Description', 'ztjalali'); ?>
33
+ </label>
34
+ <br />
35
+ <label for="change_url_date_to_jalali">
36
+ <input type="checkbox" id="change_url_date_to_jalali" name="change_url_date_to_jalali" value="1" <?php checked($ztjalali_option['change_url_date_to_jalali'], TRUE); ?> />
37
+ <?php _e('change_url_date_to_jalali Description', 'ztjalali'); ?>
38
+ </label>
39
+ </fieldset>
40
+ </td>
41
+ </tr>
42
+
43
+ <tr>
44
+ <th scope="row"><label for="afghan_month_name"><?php _e('month_name', 'ztjalali'); ?></label></th>
45
+ <td>
46
+ <select id="afghan_month_name" name="afghan_month_name">
47
+ <option <?php selected($ztjalali_option['afghan_month_name'], FALSE); ?> value="0"><?php _e('iran', 'ztjalali'); ?></option>
48
+ <option <?php selected($ztjalali_option['afghan_month_name'], TRUE); ?> value="1"><?php _e('afghanistan', 'ztjalali'); ?></option>
49
+ </select>
50
+ </td>
51
+ </tr>
52
+
53
+ <tr>
54
+ <th scope="row"><?php _e('number option', 'ztjalali'); ?></th>
55
+ <td>
56
+ <fieldset>
57
+ <legend class="screen-reader-text"><span><?php _e('number option', 'ztjalali'); ?></span></legend>
58
+ <label for="change_title_number_to_persian">
59
+ <input type="checkbox" id="change_title_number_to_persian" name="change_title_number_to_persian" value="1" <?php checked($ztjalali_option['change_title_number_to_persian'], TRUE); ?> />
60
+ <?php _e('change_title_number_to_persian Description', 'ztjalali'); ?>
61
+ </label>
62
+ <br />
63
+ <label for="change_content_number_to_persian">
64
+ <input type="checkbox" id="change_content_number_to_persian" name="change_content_number_to_persian" value="1" <?php checked($ztjalali_option['change_content_number_to_persian'], TRUE); ?> />
65
+ <?php _e('change_content_number_to_persian Description', 'ztjalali'); ?>
66
+ </label>
67
+ <br />
68
+ <label for="change_excerpt_number_to_persian">
69
+ <input type="checkbox" id="change_excerpt_number_to_persian" name="change_excerpt_number_to_persian" value="1" <?php checked($ztjalali_option['change_excerpt_number_to_persian'], TRUE); ?> />
70
+ <?php _e('change_excerpt_number_to_persian Description', 'ztjalali'); ?>
71
+ </label>
72
+ <br />
73
+ <label for="change_comment_number_to_persian">
74
+ <input type="checkbox" id="change_comment_number_to_persian" name="change_comment_number_to_persian" value="1" <?php checked($ztjalali_option['change_comment_number_to_persian'], TRUE); ?> />
75
+ <?php _e('change_comment_number_to_persian Description', 'ztjalali'); ?>
76
+ </label>
77
+ <br />
78
+ <label for="change_commentcount_number_to_persian">
79
+ <input type="checkbox" id="change_commentcount_number_to_persian" name="change_commentcount_number_to_persian" value="1" <?php checked($ztjalali_option['change_commentcount_number_to_persian'], TRUE); ?> />
80
+ <?php _e('change_commentcount_number_to_persian Description', 'ztjalali'); ?>
81
+ </label>
82
+ <br />
83
+ <label for="change_category_number_to_persian">
84
+ <input type="checkbox" id="change_category_number_to_persian" name="change_category_number_to_persian" value="1" <?php checked($ztjalali_option['change_category_number_to_persian'], TRUE); ?> />
85
+ <?php _e('change_category_number_to_persian Description', 'ztjalali'); ?>
86
+ </label>
87
+ <br />
88
+ <label for="change_point_to_persian">
89
+ <input type="checkbox" id="change_point_to_persian" name="change_point_to_persian" value="1" <?php checked($ztjalali_option['change_point_to_persian'], TRUE); ?> />
90
+ <?php _e('change_point_to_persian Description', 'ztjalali'); ?>
91
+ </label>
92
+ </fieldset>
93
+ </td>
94
+ </tr>
95
+
96
+ <tr>
97
+ <th scope="row"><?php _e('text option', 'ztjalali'); ?></th>
98
+ <td>
99
+ <fieldset>
100
+ <legend class="screen-reader-text"><span><?php _e('text option', 'ztjalali'); ?></span></legend>
101
+ <label for="change_arabic_to_persian">
102
+ <input type="checkbox" id="change_arabic_to_persian" name="change_arabic_to_persian" value="1" <?php checked($ztjalali_option['change_arabic_to_persian'], TRUE); ?> />
103
+ <?php _e('change_arabic_to_persian Description', 'ztjalali'); ?>
104
+ </label>
105
+ <br />
106
+ <label for="change_archive_title">
107
+ <input type="checkbox" id="change_archive_title" name="change_archive_title" value="1" <?php checked($ztjalali_option['change_archive_title'], TRUE); ?> />
108
+ <?php _e('change_archive_title Description', 'ztjalali'); ?>
109
+ </label>
110
+ </fieldset>
111
+ </td>
112
+ </tr>
113
+
114
+ <tr>
115
+ <th scope="row"><?php _e('wp-jalali option', 'ztjalali'); ?></th>
116
+ <td>
117
+ <fieldset>
118
+ <legend class="screen-reader-text"><span><?php _e('wp-jalali option', 'ztjalali'); ?></span></legend>
119
+ <label for="ztjalali_admin_style">
120
+ <input type="checkbox" id="ztjalali_admin_style" name="ztjalali_admin_style" value="1" <?php checked($ztjalali_option['ztjalali_admin_style'], TRUE); ?> />
121
+ <?php _e('ztjalali_admin_style Description', 'ztjalali'); ?>
122
+ </label>
123
+
124
+ <label for="save_changes_in_db">
125
+ <input type="checkbox" id="save_changes_in_db" name="save_changes_in_db" value="1" <?php checked($ztjalali_option['save_changes_in_db'], TRUE); ?> />
126
+ <?php _e('save_changes_in_db Description', 'ztjalali'); ?>
127
+ </label>
128
+ </fieldset>
129
+ </td>
130
+ </tr>
131
+
132
+ <tr>
133
+ <th scope="row"><label for="persian_planet"><?php _e('persian_planet', 'ztjalali'); ?></label></th>
134
+ <td>
135
+ <select id="persian_planet" name="persian_planet">
136
+ <option <?php selected($ztjalali_option['persian_planet'], FALSE); ?> value="0"><?php _e('wp-persian news Blog', 'ztjalali'); ?></option>
137
+ <option <?php selected($ztjalali_option['persian_planet'], TRUE); ?> value="1"><?php _e('wp-persian planet', 'ztjalali'); ?></option>
138
+ </select>
139
+ </td>
140
+ </tr>
141
+
142
+ <tr>
143
+ <th scope="row"><?php _e('locale option', 'ztjalali'); ?></th>
144
+ <td>
145
+ <fieldset>
146
+ <legend class="screen-reader-text"><span><?php _e('locale option', 'ztjalali'); ?></span></legend>
147
+ <label for="force_locale">
148
+ <input type="checkbox" id="force_locale" name="force_locale" value="1" <?php checked($ztjalali_option['force_locale'], TRUE); ?> />
149
+ <?php _e('force locale Description', 'ztjalali'); ?>
150
+ </label>
151
+ <br />
152
+ <label for="force_timezone">
153
+ <input type="checkbox" id="force_timezone" name="force_timezone" value="1" <?php checked($ztjalali_option['force_timezone'], TRUE); ?> />
154
+ <?php _e('force timezone Description', 'ztjalali'); ?>
155
+ </label>
156
+ </fieldset>
157
+ </td>
158
+ </tr>
159
+ <?php
160
+ /* ===================================================== * /
161
+ * input text example
162
+ <tr>
163
+ <th scope="row"><label for="blogdescription">معرفی کوتاه</label></th>
164
+ <td><input type="text" class="regular-text" value="Just another WordPress site" id="blogdescription" name="blogdescription">
165
+ <p class="description">در چند واژه بیان کنید که &zwnj;این سایت درباره&zwnj;ی چیست</p></td>
166
+ </tr>
167
+ /* ===================================================== */
168
+ ?>
169
+ </tbody>
170
+ </table>
171
+ <p class="submit">
172
+ <input type="submit" value="<?php _e('save changes', 'ztjalali'); ?>" class="button button-primary" id="save_wper_options" name="save_wper_options">
173
+ </p>
174
+ </form>
175
+ </div>
inc/wp-jalali-admin.php ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * register admin menu
5
+ */
6
+ add_action('admin_menu', 'ztjalali_reg_admin_meun_fn');
7
+
8
+ function ztjalali_reg_admin_meun_fn() {
9
+ global $ztjalali_admin_page;
10
+ $ztjalali_admin_page = add_menu_page(
11
+ __('wp-jalali options', 'ztjalali'), // page title
12
+ __('wp-jalali', 'ztjalali'), // menu title
13
+ 'manage_options', // user access capability
14
+ 'ztjalali_admin_page', // menu slug
15
+ 'ztjalali_admin_page_fn', //menu content function
16
+ // plugins_url('/assets/img/wp-jalali-16x16.png', dirname(__FILE__)), // menu icon
17
+ 'dashicons-ztjalali', // menu icon
18
+ 82 // menu position
19
+ );
20
+ add_submenu_page(NULL, __('wp-jalali help page', 'ztjalali'), __('wp-jalali help', 'ztjalali'), 'manage_options', 'ztjalali_help_page', 'ztjalali_help_page_fn');
21
+ // add_submenu_page('ztjalali_admin_page',__('wp-jalali help page', 'ztjalali'), __('wp-jalali help', 'ztjalali'),'manage_options','ztjalali_help_page', 'ztjalali_help_page_fn');
22
+ add_action('load-' . $ztjalali_admin_page, 'ztjalali_admin_save_option_page_fn');
23
+ }
24
+
25
+ function ztjalali_admin_page_fn() {
26
+ include JALALI_DIR . 'inc' . DIRECTORY_SEPARATOR . 'wp-jalali-admin-option.php';
27
+ }
28
+
29
+ function ztjalali_help_page_fn() {
30
+ // wp_enqueue_style( 'wp-pointer' );
31
+ // wp_enqueue_script( 'wp-pointer' );
32
+ include JALALI_DIR . 'inc' . DIRECTORY_SEPARATOR . 'wp-jalali-help-page.php';
33
+ }
34
+
35
+ function ztjalali_admin_save_option_page_fn() {
36
+ global $ztjalali_admin_page;
37
+ $screen = get_current_screen();
38
+ if ($screen->id != $ztjalali_admin_page)
39
+ return;
40
+
41
+ if (isset($_POST['save_wper_options'])) {
42
+ global $ztjalali_option;
43
+ check_admin_referer('jalali_save_options');
44
+ $ztjalali_option = array(
45
+ 'force_locale' => !empty($_POST['force_locale']),
46
+ 'force_timezone' => !empty($_POST['force_timezone']),
47
+ 'change_date_to_jalali' => !empty($_POST['change_date_to_jalali']),
48
+ 'change_jdate_number_to_persian' => !empty($_POST['change_jdate_number_to_persian']),
49
+ 'change_url_date_to_jalali' => !empty($_POST['change_url_date_to_jalali']),
50
+ 'afghan_month_name' => !empty($_POST['afghan_month_name']),
51
+ 'change_title_number_to_persian' => !empty($_POST['change_title_number_to_persian']),
52
+ 'change_content_number_to_persian' => !empty($_POST['change_content_number_to_persian']),
53
+ 'change_excerpt_number_to_persian' => !empty($_POST['change_excerpt_number_to_persian']),
54
+ 'change_comment_number_to_persian' => !empty($_POST['change_comment_number_to_persian']),
55
+ 'change_commentcount_number_to_persian' => !empty($_POST['change_commentcount_number_to_persian']),
56
+ 'change_category_number_to_persian' => !empty($_POST['change_category_number_to_persian']),
57
+ 'change_point_to_persian' => !empty($_POST['change_point_to_persian']),
58
+ 'change_arabic_to_persian' => !empty($_POST['change_arabic_to_persian']),
59
+ 'change_archive_title' => !empty($_POST['change_archive_title']),
60
+ 'save_changes_in_db' => !empty($_POST['save_changes_in_db']),
61
+ 'ztjalali_admin_style' => !empty($_POST['ztjalali_admin_style']),
62
+ 'persian_planet' => !empty($_POST['persian_planet']),
63
+ );
64
+ update_option('ztjalali_options', json_encode($ztjalali_option))
65
+ OR add_option('ztjalali_options', json_encode($ztjalali_option));
66
+ }
67
+ }
68
+
69
+ /* =================================================================== */
70
+
71
+ /**
72
+ * install help
73
+ */
74
+ add_action('admin_init', 'ztjalali_install_redirect');
75
+
76
+ function ztjalali_install_redirect() {
77
+ if (get_option('ztjalali_do_activation_redirect', false)) {
78
+ delete_option('ztjalali_do_activation_redirect');
79
+ wp_redirect(menu_page_url('ztjalali_help_page', FALSE));
80
+ }
81
+ }
82
+
83
+ /* =================================================================== */
84
+
85
+ /**
86
+ * wp planet options
87
+ */
88
+ add_filter('dashboard_primary_link', 'ztjalali_dashboard_primary_link', 111, 1);
89
+ add_filter('dashboard_primary_feed', 'ztjalali_dashboard_primary_feed', 111, 1);
90
+ add_filter('dashboard_primary_title', 'ztjalali_dashboard_primary_title', 111, 1);
91
+
92
+ add_filter('dashboard_secondary_link', 'ztjalali_dashboard_secondary_link', 111, 1);
93
+ add_filter('dashboard_secondary_feed', 'ztjalali_dashboard_secondary_feed', 111, 1);
94
+ add_filter('dashboard_secondary_title', 'ztjalali_dashboard_secondary_title', 111, 1);
95
+
96
+ global $primary_replacement, $secondary_replacement;
97
+ $primary_replacement = array(
98
+ 1 => array(
99
+ 'link' => 'http://wordpress.org/development/',
100
+ 'feed' => 'http://wordpress.org/development/feed/',
101
+ 'title' => __('WordPress Development Blog', 'ztjalali')
102
+ ),
103
+ 2 => array(
104
+ 'link' => 'http://wp-persian.com/',
105
+ 'feed' => 'http://wp-persian.com/feed/',
106
+ 'title' => __('wp-persian news Blog', 'ztjalali')
107
+ )
108
+ );
109
+ $secondary_replacement = array(
110
+ 1 => array(
111
+ 'link' => 'http://planet.wordpress.org/',
112
+ 'feed' => 'http://planet.wordpress.org/feed/',
113
+ 'title' => __('Other WordPress News', 'ztjalali')
114
+ ),
115
+ 2 => array(
116
+ 'link' => 'http://planet.wp-persian.com/',
117
+ 'feed' => 'http://planet.wp-persian.com/feed/',
118
+ 'title' => __('wp-persian planet', 'ztjalali')
119
+ )
120
+ );
121
+
122
+ function ztjalali_dashboard_primary_link($value) {
123
+ global $primary_replacement, $ztjalali_option;
124
+ if ($ztjalali_option['persian_planet']) {
125
+ return $primary_replacement[2]['link'];
126
+ }
127
+ return $value;
128
+ }
129
+
130
+ function ztjalali_dashboard_primary_feed($value) {
131
+ global $primary_replacement, $ztjalali_option;
132
+ if ($ztjalali_option['persian_planet']) {
133
+ return $primary_replacement[2]['feed'];
134
+ }
135
+ return $value;
136
+ }
137
+
138
+ function ztjalali_dashboard_primary_title($value) {
139
+ global $primary_replacement, $ztjalali_option;
140
+ if ($ztjalali_option['persian_planet']) {
141
+ return $primary_replacement[2]['title'];
142
+ }
143
+ return $value;
144
+ }
145
+
146
+ function ztjalali_dashboard_secondary_link($value) {
147
+ global $secondary_replacement, $ztjalali_option;
148
+ if ($ztjalali_option['persian_planet']) {
149
+ return $secondary_replacement[2]['link'];
150
+ }
151
+ return $value;
152
+ }
153
+
154
+ function ztjalali_dashboard_secondary_feed($value) {
155
+ global $secondary_replacement, $ztjalali_option;
156
+ if ($ztjalali_option['persian_planet']) {
157
+ return $secondary_replacement[2]['feed'];
158
+ }
159
+ return $value;
160
+ }
161
+
162
+ function ztjalali_dashboard_secondary_title($value) {
163
+ global $secondary_replacement, $ztjalali_option;
164
+ if ($ztjalali_option['persian_planet']) {
165
+ return $secondary_replacement[2]['title'];
166
+ }
167
+ return $value;
168
+ }
169
+
170
+ /* =================================================================== */
171
+
inc/wp-jalali-filters.php ADDED
@@ -0,0 +1,516 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * define filters
5
+ */
6
+ //load options
7
+ global $ztjalali_option;
8
+
9
+ //jalali force locale
10
+ if ($ztjalali_option['force_locale'])
11
+ add_filter('locale', 'ztjalali_force_locale');
12
+
13
+ if ($ztjalali_option['force_timezone'])
14
+ date_default_timezone_set('Asia/Tehran');
15
+
16
+ //convert gregorian to jalali filter
17
+ if ($ztjalali_option['change_date_to_jalali'])
18
+ add_filter('date_i18n', 'ztjalali_ch_date_i18n', 111, 4);
19
+
20
+ //if(!defined( 'WP_ADMIN' )){
21
+ //jalali link
22
+ if ($ztjalali_option['change_url_date_to_jalali']) {
23
+ add_filter("post_link", "ztjalali_permalink_filter_fn", 10, 3);
24
+ add_action('pre_get_posts', 'ztjalali_pre_get_posts_filter_fn');
25
+ add_filter('posts_where', 'ztjalali_posts_where_filter_fn');
26
+ // add_filter('year_link', 'ztjalali_year_link_filter_fn', 10, 2);
27
+ // add_filter('month_link', 'ztjalali_month_link_filter_fn', 10, 3);
28
+ // add_filter('day_link', 'ztjalali_day_link_filter_fn', 10, 4);
29
+ }
30
+ if ($ztjalali_option['save_changes_in_db']) {
31
+ // change en number to persian number in db
32
+ if ($ztjalali_option['change_title_number_to_persian'])
33
+ add_filter('title_save_pre', 'ztjalali_ch_number_to_persian');
34
+
35
+ if ($ztjalali_option['change_content_number_to_persian'])
36
+ add_filter('content_save_pre', 'ztjalali_ch_number_to_persian');
37
+
38
+ if ($ztjalali_option['change_excerpt_number_to_persian'])
39
+ add_filter('excerpt_save_pre', 'ztjalali_ch_number_to_persian');
40
+
41
+ if ($ztjalali_option['change_comment_number_to_persian']){
42
+ add_filter('comment_save_pre', 'ztjalali_ch_number_to_persian');
43
+ add_filter('pre_comment_content', 'ztjalali_ch_number_to_persian');
44
+ }
45
+
46
+ // change arabic characters
47
+ if ($ztjalali_option['change_arabic_to_persian']) {
48
+ add_filter('content_save_pre', 'ztjalali_ch_arabic_to_persian');
49
+ add_filter('title_save_pre', 'ztjalali_ch_arabic_to_persian');
50
+ add_filter('excerpt_save_pre', 'ztjalali_ch_arabic_to_persian');
51
+
52
+ add_filter('comment_save_pre', 'ztjalali_ch_arabic_to_persian');
53
+ add_filter('pre_comment_content', 'ztjalali_ch_arabic_to_persian');
54
+ }
55
+ } else {
56
+ // change en number to persian number in visit
57
+ if ($ztjalali_option['change_title_number_to_persian'])
58
+ add_filter('the_title', 'ztjalali_ch_number_to_persian');
59
+
60
+ if ($ztjalali_option['change_content_number_to_persian'])
61
+ add_filter('the_content', 'ztjalali_ch_number_to_persian');
62
+
63
+ if ($ztjalali_option['change_excerpt_number_to_persian'])
64
+ add_filter('the_excerpt', 'ztjalali_ch_number_to_persian');
65
+
66
+ if ($ztjalali_option['change_comment_number_to_persian'])
67
+ add_filter('comment_text', 'ztjalali_ch_number_to_persian');
68
+
69
+ // change arabic characters
70
+ if ($ztjalali_option['change_arabic_to_persian']) {
71
+ add_filter('the_content', 'ztjalali_ch_arabic_to_persian');
72
+ add_filter('the_title', 'ztjalali_ch_arabic_to_persian');
73
+ add_filter('the_excerpt', 'ztjalali_ch_arabic_to_persian');
74
+ add_filter('comment_text', 'ztjalali_ch_arabic_to_persian');
75
+ }
76
+ }
77
+
78
+ if ($ztjalali_option['change_commentcount_number_to_persian'])
79
+ add_filter('comments_number', 'ztjalali_ch_number_to_persian');
80
+
81
+
82
+ if ($ztjalali_option['change_category_number_to_persian'])
83
+ add_filter('wp_list_categories', 'ztjalali_ch_number_to_persian');
84
+
85
+ if ($ztjalali_option['change_arabic_to_persian']) {
86
+ add_filter('wp_list_categories', 'ztjalali_ch_arabic_to_persian');
87
+ }
88
+
89
+ // change archive title
90
+ if ($ztjalali_option['change_archive_title'])
91
+ add_filter('wp_title', 'ztjalali_ch_archive_title', 111, 3);
92
+ //}
93
+ /* =================================================================== */
94
+
95
+ /**
96
+ * force_locale filter fn
97
+ */
98
+ function ztjalali_force_locale() {
99
+ return 'fa_IR';
100
+ }
101
+
102
+ /* =================================================================== */
103
+
104
+ /**
105
+ * convert gregorian to jalali filter handler
106
+ * @param string $j Formatted date string.
107
+ * @param string $req_format Format to display the date.
108
+ * @param int $i Unix timestamp.
109
+ * @param bool $gmt Whether to convert to GMT for time. Default false.
110
+ * @return string
111
+ */
112
+ function ztjalali_ch_date_i18n($j, $req_format, $i, $gmt) {
113
+ return jdate($req_format, $i);
114
+ }
115
+
116
+ /* =================================================================== */
117
+
118
+ /**
119
+ * change archive title filter handler
120
+ * @global array $jdate_month_name
121
+ * @global array $wp_query
122
+ * @param string $title
123
+ * @param string $sep
124
+ * @param string $seplocation
125
+ * @return string
126
+ */
127
+ function ztjalali_ch_archive_title($title, $sep, $seplocation) {
128
+ global $jdate_month_name, $wp_query;
129
+ $query = $wp_query->query;
130
+ if (is_archive() and isset($query['monthnum'])) {
131
+ if ($seplocation == 'right')
132
+ $query = array_reverse($query);
133
+ $query['name'] = get_option('blogname');
134
+ $query['monthnum'] = $jdate_month_name[intval($query['monthnum'])];
135
+ return ztjalali_ch_number_to_persian(implode(" $sep ", $query));
136
+ }elseif (is_archive() and isset($query['year'])) {
137
+ if ($seplocation == 'right')
138
+ $query = array_reverse($query);
139
+ $query['name'] = get_option('blogname');
140
+ return ztjalali_ch_number_to_persian(implode(" $sep ", $query));
141
+ }
142
+ return $title;
143
+ }
144
+
145
+ /* =================================================================== */
146
+
147
+ /**
148
+ * posts where filter handler
149
+ */
150
+ function ztjalali_posts_where_filter_fn($where) {
151
+ global $wp_query, $wpdb, $pagenow;
152
+ if (empty($wp_query->query_vars))
153
+ return $where;
154
+ $m = $hour = $minute = $second = $year = $month = $day = "";
155
+ if (isset($wp_query->query_vars['m']))
156
+ $m = $wp_query->query_vars['m'];
157
+ if (isset($wp_query->query_vars['hour']))
158
+ $hour = $wp_query->query_vars['hour'];
159
+ if (isset($wp_query->query_vars['minute']))
160
+ $minute = $wp_query->query_vars['minute'];
161
+ if (isset($wp_query->query_vars['second']))
162
+ $second = $wp_query->query_vars['second'];
163
+ if (isset($wp_query->query_vars['year']))
164
+ $year = $wp_query->query_vars['year'];
165
+ if (isset($wp_query->query_vars['monthnum']))
166
+ $month = $wp_query->query_vars['monthnum'];
167
+ if (isset($wp_query->query_vars['day']))
168
+ $day = $wp_query->query_vars['day'];
169
+
170
+ if (!empty($m)) {
171
+ $len = strlen($m);
172
+ $year = substr($m, 0, 4);
173
+ if ($len > 5)
174
+ $month = substr($m, 4, 2);
175
+ if ($len > 7)
176
+ $day = substr($m, 6, 2);
177
+ if ($len > 9)
178
+ $hour = substr($m, 8, 2);
179
+ if ($len > 11)
180
+ $minute = substr($m, 10, 2);
181
+ if ($len > 13)
182
+ $second = substr($m, 12, 2);
183
+ }
184
+ if (empty($year) || $year > 1700)
185
+ return $where;
186
+
187
+ $start_month = $start_day = $end_month = $end_day = 1;
188
+ $start_hour = $start_min = $start_sec = $end_hour = $end_min = $end_sec = '00';
189
+ $start_year = $year;
190
+ $end_year = $year + 1;
191
+
192
+ if (!empty($month)) {
193
+ $start_month = $month;
194
+ if ($month == 12)
195
+ $end_month = 1;
196
+ else
197
+ $end_month = $month + 1;
198
+
199
+ if ($end_month == 1)
200
+ $end_year = $start_year + 1;
201
+ else
202
+ $end_year = $start_year;
203
+ }
204
+ $jday_count = array(NULL, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
205
+
206
+ if (!empty($day)) {
207
+ $start_day = $day;
208
+ if ($day == $jday_count[$month])
209
+ $end_day = 1;
210
+ else
211
+ $end_day = $day + 1;
212
+
213
+ if ($end_day == 1)
214
+ $end_month = $start_month + 1;
215
+ else
216
+ $end_month = $start_month;
217
+ }
218
+
219
+ if (!empty($hour)) {
220
+ $start_hour = $hour;
221
+ if ($hour == 24)
222
+ $end_hour = '00';
223
+ else
224
+ $end_hour = $hour + 1;
225
+
226
+ if ($end_hour == '00')
227
+ $end_day = $start_day + 1;
228
+ else
229
+ $end_day = $start_day;
230
+ }
231
+
232
+ if (!empty($minute)) {
233
+ $start_min = $minute;
234
+ if ($minute == 59)
235
+ $end_min = '00';
236
+ else
237
+ $end_min = $minute + 1;
238
+ if ($end_min == '00')
239
+ $end_hour = $start_hour + 1;
240
+ else
241
+ $end_hour = $start_hour;
242
+ }
243
+
244
+ if (!empty($second)) {
245
+ $start_sec = $second;
246
+ if ($second == 59)
247
+ $end_sec = '00';
248
+ else
249
+ $end_sec = $second + 1;
250
+ if ($end_sec == '00')
251
+ $end_min = $start_min + 1;
252
+ else
253
+ $end_min = $start_min;
254
+ }
255
+
256
+ $start_date = jalali_to_gregorian($start_year, $start_month, $start_day);
257
+ $start_date.=" $start_hour:$start_min:$start_sec";
258
+ $end_date = jalali_to_gregorian($end_year, $end_month, $end_day);
259
+ $end_date.=" $end_hour:$end_min:$end_sec";
260
+ $paterns = array('/YEAR\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
261
+ '/DAYOFMONTH\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
262
+ '/MONTH\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
263
+ '/HOUR\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
264
+ '/MINUTE\((.*?)post_date\s*\)\s*=\s*[0-9\']*/',
265
+ '/SECOND\((.*?)post_date\s*\)\s*=\s*[0-9\']*/');
266
+ foreach ($paterns as $ptn) {
267
+ $where = preg_replace($ptn, '1=1', $where);
268
+ }
269
+ $prefixp = "{$wpdb->posts}.";
270
+ $prefixp = (strpos($where, $prefixp) === false) ? '' : $prefixp;
271
+ $where .= " AND {$prefixp}post_date >= '$start_date' AND {$prefixp}post_date < '$end_date' ";
272
+ return $where;
273
+ }
274
+
275
+ /* =================================================================== */
276
+
277
+ /**
278
+ * pre get posts filter handler
279
+ * @param object $post
280
+ */
281
+ function ztjalali_pre_get_posts_filter_fn($query) {
282
+ global $wpdb;
283
+ $query_vars = $query->query;
284
+ $year = $monthnum = $day = "";
285
+ if (isset($query_vars['m']) AND $query_vars['m']>100001) {
286
+ $year= (int)(substr($query_vars['m'],0, 4));
287
+ if($year < 1700){
288
+ $monthnum= (int)(substr($query_vars['m'], 4,2));
289
+ $start_date = jalali_to_gregorian($year, $monthnum, 1);
290
+ $end_date = jalali_to_gregorian($year, $monthnum, jday_of_month($year, $monthnum));
291
+
292
+ $date_query = array(
293
+ array(
294
+ 'after' => array(
295
+ 'year' => $start_date[0],
296
+ 'month' => $start_date[1],
297
+ 'day' => $start_date[2] - 1,
298
+ ),
299
+ 'before' => array(
300
+ 'year' => $end_date[0],
301
+ 'month' => $end_date[1],
302
+ 'day' => $end_date[2] + 1,
303
+ ),
304
+ 'inclusive' => TRUE,
305
+ ),
306
+ );
307
+ $query->set('date_query', $date_query);
308
+ $query->set('m', '');
309
+ }
310
+ return $query;
311
+ }
312
+
313
+ /* ------------------------------------------------------ */
314
+
315
+ if (isset($query_vars['year']))
316
+ $year = $query_vars['year'];
317
+ if (isset($query_vars['monthnum']))
318
+ $monthnum = $query_vars['monthnum'];
319
+ if (isset($query_vars['day']))
320
+ $day = $query_vars['day'];
321
+ if($year > 1700)
322
+ return $query;
323
+ if (isset($query_vars['name'])) {
324
+ $post_date = $wpdb->get_var($wpdb->prepare("select post_date from {$wpdb->posts} where post_name=%s order by ID", $query_vars['name']));
325
+ $Date = explode('-', date('Y-m-d', strtotime($post_date)));
326
+ $jDate = gregorian_to_jalali($Date[0], $Date[1], $Date[2]);
327
+
328
+ if ($year == $jDate[0])
329
+ $query->set('year', $Date[0]);
330
+
331
+ if ($monthnum == $jDate[1])
332
+ $query->set('monthnum', $Date[1]);
333
+
334
+ if ($day == $jDate[2])
335
+ $query->set('day', $Date[2]);
336
+
337
+ return $query;
338
+ }
339
+
340
+ if (isset($query_vars['post_id'])) {
341
+ $post_date = $wpdb->get_var($wpdb->prepare("select post_date from {$wpdb->posts} where ID=%d", $query_vars['post_id']));
342
+ $cDate = getdate(strtotime($post_date));
343
+ if (!empty($year))
344
+ $query->set('year', $cDate['year']);
345
+
346
+ if (!empty($monthnum))
347
+ $query->set('monthnum', $cDate['mon']);
348
+
349
+ if (!empty($day))
350
+ $query->set('day', $cDate['mday']);
351
+
352
+ return $query;
353
+ }
354
+
355
+ if (!empty($year) and ! empty($monthnum) and ! empty($day)) {
356
+ $post_date = jalali_to_gregorian($year, $monthnum, $day);
357
+ $query->set('year', $post_date[0]);
358
+ $query->set('monthnum', $post_date[1]);
359
+ $query->set('day', $post_date[2]);
360
+ return $query;
361
+ }
362
+
363
+ if (!empty($year) and ! empty($monthnum)) {
364
+ $start_date = jalali_to_gregorian($year, $monthnum, 1);
365
+ $end_date = jalali_to_gregorian($year, $monthnum, jday_of_month($year, $monthnum));
366
+
367
+ $date_query = array(
368
+ array(
369
+ 'after' => array(
370
+ 'year' => $start_date[0],
371
+ 'month' => $start_date[1],
372
+ 'day' => $start_date[2] - 1,
373
+ ),
374
+ 'before' => array(
375
+ 'year' => $end_date[0],
376
+ 'month' => $end_date[1],
377
+ 'day' => $end_date[2] + 1,
378
+ ),
379
+ 'inclusive' => TRUE,
380
+ ),
381
+ );
382
+ $query->set('date_query', $date_query);
383
+ $query->set('year', '');
384
+ $query->set('monthnum', '');
385
+
386
+ // $post_date = jalali_to_gregorian($year, $monthnum, 15);
387
+ // $query->set('year', $post_date[0]);
388
+ // $query->set('monthnum', $post_date[1]);
389
+ return $query;
390
+ }
391
+
392
+ if (!empty($year)) {
393
+ $start_date = jalali_to_gregorian($year, 1, 1);
394
+ if (is_jalali_leap_year($year))
395
+ $end_date = jalali_to_gregorian($year, 12, 30);
396
+ else
397
+ $end_date = jalali_to_gregorian($year, 12, 29);
398
+ $date_query = array(
399
+ array(
400
+ 'after' => array(
401
+ 'year' => $start_date[0],
402
+ 'month' => $start_date[1],
403
+ 'day' => $start_date[2] - 1,
404
+ ),
405
+ 'before' => array(
406
+ 'year' => $end_date[0],
407
+ 'month' => $end_date[1],
408
+ 'day' => $end_date[2] + 1,
409
+ ),
410
+ 'inclusive' => TRUE,
411
+ ),
412
+ );
413
+ $query->set('date_query', $date_query);
414
+ $query->set('year', '');
415
+ return $query;
416
+ }
417
+
418
+ return $query;
419
+ }
420
+
421
+ /* =================================================================== */
422
+
423
+ /**
424
+ * jalali link filter handlers
425
+ * @param string $perma
426
+ * @param string $post
427
+ * @param string $leavename
428
+ */
429
+ function ztjalali_permalink_filter_fn($perma, $post, $leavename = false) {
430
+ $rewritecode = array(
431
+ '%year%',
432
+ '%monthnum%',
433
+ '%day%',
434
+ '%hour%',
435
+ '%minute%',
436
+ '%second%',
437
+ $leavename ? '' : '%postname%',
438
+ '%post_id%',
439
+ '%category%',
440
+ '%author%',
441
+ $leavename ? '' : '%pagename%',
442
+ );
443
+
444
+ $sample = true;
445
+
446
+ if (empty($post->ID))
447
+ return false;
448
+
449
+ if ($post->post_type == 'page')
450
+ return get_page_link($post->ID, $leavename, $sample);
451
+ elseif ($post->post_type == 'attachment')
452
+ return get_attachment_link($post->ID, $leavename);
453
+ elseif (in_array($post->post_type, get_post_types(array('_builtin' => false))))
454
+ return get_post_permalink($post->ID, $leavename, $sample);
455
+ $permalink = get_option('permalink_structure');
456
+
457
+ if (empty($permalink) OR in_array($post->post_status, array('draft', 'pending', 'auto-draft')))
458
+ return home_url('?p=' . $post->ID);
459
+
460
+ $unixtime = strtotime($post->post_date);
461
+ $category = "";
462
+ if (strpos($permalink, '%category%') !== false) {
463
+ $cats = get_the_category($post->ID);
464
+ if ($cats) {
465
+ usort($cats, '_usort_terms_by_ID'); // order by ID
466
+ $category_object = get_term($category_object, 'category');
467
+ $category = $category_object->slug;
468
+ if ($parent = $category_object->parent)
469
+ $category = get_category_parents($parent, false, '/', true) . $category;
470
+ }
471
+ if (empty($category)) {
472
+ $default_category = get_term(get_option('default_category'), 'category');
473
+ $category = is_wp_error($default_category) ? '' : $default_category->slug;
474
+ }
475
+ }
476
+
477
+ $author = "";
478
+ if (strpos($permalink, '%author%') !== false) {
479
+ $authordata = get_user_by($post->post_author, $user_id);
480
+ $author = $authordata->user_nicename;
481
+ }
482
+
483
+ $date = explode("-", date('Y-m-d-H-i-s', $unixtime));
484
+ $jdate = gregorian_to_jalali($date[0], $date[1], $date[2]);
485
+ $rewritereplace = array(
486
+ $jdate[0],
487
+ $jdate[1],
488
+ $jdate[2],
489
+ $date[3],
490
+ $date[4],
491
+ $date[5],
492
+ $post->post_name,
493
+ $post->ID,
494
+ $category,
495
+ $author,
496
+ $post->post_name,
497
+ );
498
+ $permalink = home_url(str_replace($rewritecode, $rewritereplace, $permalink));
499
+ return user_trailingslashit($permalink, 'single');
500
+ }
501
+
502
+ //function ztjalali_year_link_filter_fn($link, $y) {
503
+ // if ($y < 1700)
504
+ // return;
505
+ //
506
+ //}
507
+ //
508
+ //function ztjalali_month_link_filter_fn($link, $y, $m) {
509
+ //
510
+ //}
511
+ //
512
+ //function ztjalali_day_link_filter_fn($link, $y, $m, $d) {
513
+ //
514
+ //}
515
+
516
+ /* =================================================================== */
inc/wp-jalali-help-page.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap about-wrap">
2
+
3
+ <h1 id="ztjalali_wellcome">به وردپرس فارسی خوش آمدید</h1>
4
+
5
+ <div class="about-text ztjalali-welcome-top">از شما بابت استفاده از بروزترین نسخه افزونه وردپرس فارسی (wp-jalali) سپاسگزاریم.
6
+ افزونه جلالی (wp-jalali) برای رفاه کاربران از ابتدا بازنویسی شده است، امیدواریم با بازخوردهای موثر ما را در انجام ماموریتمان در خدمت‌رسانی به کاربران فارسی زبان همراهی نمایید.
7
+ </div>
8
+
9
+
10
+ <a href="http://wp-persian.com/"><div class="ztjalali-badge">وردپرس فارسی</div></a>
11
+ <a href="http://zakrot.com/"><div class="zt-badge">زاکروت</div></a>
12
+ <h2 class="nav-tab-wrapper">
13
+ <a class="nav-tab nav-tab-active" href="">
14
+ وردپرس فارسی </a>
15
+ </h2>
16
+
17
+ <div class="changelog">
18
+ <div class="about-overview">
19
+ <img src="<?php echo plugins_url('/assets', dirname(__FILE__)); ?>/banner-772x250.png" class="about-overview-img">
20
+ </div>
21
+ <h2 class="about-headline-callout">نفسی تازه برای وردپرس شما</h2>
22
+
23
+
24
+ <hr>
25
+
26
+ <div class="feature-section col three-col">
27
+ <div class="col-1">
28
+ <!--<img src="//s.w.org/images/core/3.9/editor.jpg?0">-->
29
+ <h4>بهینگی</h4>
30
+ <p>با استفاده از الگورتیم‌های بروزشده سرعت افزونه بالاتر و مصرف منابع تا نصف کاهش داده شده است.</p>
31
+ </div>
32
+ <div class="col-2">
33
+ <h4>کیفیت</h4>
34
+ <p>افزونه حاضر دارای بالاترین کیفیت کدنویسی بوده و بر روی پروژه‌های متعدد سنجیده شده است.</p>
35
+ </div>
36
+ <div class="col-3 last-feature">
37
+ <h4>امنیت</h4>
38
+ <p>ما به مهمترین دغدغه کاربران برای داشتن یک افزونه امن پاسخ مثبت داده‌ایم، آسوده خاطر باشید.</p>
39
+ </div>
40
+ </div>
41
+
42
+
43
+
44
+ <h2 class="about-headline-callout">تجربه&zwnj;ی ابزارک&zwnj;های خوش&zwnj;دست&zwnj;تر</h2>
45
+
46
+
47
+ <hr>
48
+
49
+ <div class="feature-section col two-col">
50
+ <div class="col-1">
51
+ <h4>تقویم جلالی</h4>
52
+ <p>تقویم با تاریخ شمسی پیاده‌سازی شده است و به راحتی می‌توانید از این ابزارک استفاده نمایید.</p>
53
+ </div>
54
+ <div class="col-2 last-feature">
55
+ <h4>بایگانی جلالی</h4>
56
+ <p>پس از مدتی دسترسی به مطالب قبلی سخت می‌شود، با این ابزارک می‌توانید بایگانی را در دسترس کاربران قرار دهید.</p>
57
+ </div>
58
+ </div>
59
+
60
+
61
+
62
+
63
+ <hr>
64
+
65
+ </div>
66
+ </div>
67
+ <?php
68
+ //$tour_cnt = '<h3>به وردپرس فارسی خوش آمدید</h3>';
69
+ //$tour_cnt .= '<p>افزونه وردپرس فارسی با موفقیت فعال شد</p>';
70
+ ?>
71
+ <!--<script type="text/javascript">
72
+ jQuery(document).ready(function($) {
73
+ $('#toplevel_page_ztjalali_admin_page').pointer({
74
+ content: '<?php echo $tour_cnt; ?>',
75
+ position: {
76
+ edge: 'top',
77
+ align: 'center',
78
+ },
79
+ close: function() {
80
+
81
+ }
82
+ }).pointer('open');
83
+
84
+ });
85
+ </script>-->
index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php
languages/ztjalali-fa_IR.mo ADDED
Binary file
languages/ztjalali-fa_IR.po ADDED
@@ -0,0 +1,328 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: wp-jalali v5.0.0-RC\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: 2014-09-04 19:29-0500\n"
7
+ "Last-Translator: superadmin <info@zakrot.com>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
13
+ "X-Generator: Poedit 1.6.9\n"
14
+ "X-Poedit-SourceCharset: utf-8\n"
15
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
16
+ "_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
17
+ "X-Textdomain-Support: yes\n"
18
+ "Language: fa_IR\n"
19
+ "X-Poedit-SearchPath-0: .\n"
20
+
21
+ # @ ztjalali
22
+ #: inc/wp-jalali-admin-option.php:9
23
+ msgid "wp persian option"
24
+ msgstr "تنظیمات وردپرس فارسی"
25
+
26
+ # @ ztjalali
27
+ #: inc/wp-jalali-admin-option.php:143 inc/wp-jalali-admin-option.php:146
28
+ msgid "locale option"
29
+ msgstr "تنظیمات منطقه و زبان"
30
+
31
+ # @ ztjalali
32
+ #: inc/wp-jalali-admin-option.php:149
33
+ msgid "force locale Description"
34
+ msgstr "آیا تمایل دارید زبان سیستم بطور پیش‌فرض فارسی باشد؟"
35
+
36
+ # @ ztjalali
37
+ #: inc/wp-jalali-admin-option.php:154
38
+ msgid "force timezone Description"
39
+ msgstr "آیا تمایل دارید ساعت پیش‌فرض ایران/تهران باشد؟"
40
+
41
+ # @ ztjalali
42
+ #: inc/wp-jalali-admin-option.php:21 inc/wp-jalali-admin-option.php:24
43
+ msgid "date option"
44
+ msgstr "تنظیمات تاریخ"
45
+
46
+ # @ ztjalali
47
+ #: inc/wp-jalali-admin-option.php:27
48
+ msgid "change_date_to_jalali Description"
49
+ msgstr "آیا تمایل دارید تاریخ های میلادی به شمسی تبدیل شود؟"
50
+
51
+ # @ ztjalali
52
+ #: inc/wp-jalali-admin-option.php:32
53
+ msgid "change_jdate_number_to_persian Description"
54
+ msgstr "آیا تمایل دارید، اعداد لاتین به فارسی تبدیل گردد؟"
55
+
56
+ # @ ztjalali
57
+ #: inc/wp-jalali-admin-option.php:37
58
+ msgid "change_url_date_to_jalali Description"
59
+ msgstr "آیا تمایل دارید نشانی(url) به شمسی تبدیل شود؟"
60
+
61
+ # @ ztjalali
62
+ #: inc/wp-jalali-admin-option.php:44
63
+ msgid "month_name"
64
+ msgstr "نام ماه‌ها مطابق با کشور"
65
+
66
+ # @ ztjalali
67
+ #: inc/wp-jalali-admin-option.php:47
68
+ msgid "iran"
69
+ msgstr "ایران"
70
+
71
+ # @ ztjalali
72
+ #: inc/wp-jalali-admin-option.php:48
73
+ msgid "afghanistan"
74
+ msgstr "افغانستان"
75
+
76
+ # @ ztjalali
77
+ #: inc/wp-jalali-admin-option.php:54 inc/wp-jalali-admin-option.php:57
78
+ msgid "number option"
79
+ msgstr "تنظیمات اعداد"
80
+
81
+ # @ ztjalali
82
+ #: inc/wp-jalali-admin-option.php:60
83
+ msgid "change_title_number_to_persian Description"
84
+ msgstr "آیا تمایل دارید اعداد در عنوان نوشته به فارسی تبدیل شوند؟"
85
+
86
+ # @ ztjalali
87
+ #: inc/wp-jalali-admin-option.php:65
88
+ msgid "change_content_number_to_persian Description"
89
+ msgstr "آیا تمایل دارید اعداد در متن نوشته به فارسی تبدیل شوند؟"
90
+
91
+ # @ ztjalali
92
+ #: inc/wp-jalali-admin-option.php:70
93
+ msgid "change_excerpt_number_to_persian Description"
94
+ msgstr "آیا تمایل دارید اعداد در خلاصه نوشته به فارسی تبدیل شوند؟"
95
+
96
+ # @ ztjalali
97
+ #: inc/wp-jalali-admin-option.php:75
98
+ msgid "change_comment_number_to_persian Description"
99
+ msgstr "آیا تمایل دارید اعداد در دیدگاه‌ها به فارسی تبدیل شوند؟"
100
+
101
+ # @ ztjalali
102
+ #: inc/wp-jalali-admin-option.php:80
103
+ msgid "change_commentcount_number_to_persian Description"
104
+ msgstr "آیا تمایل دارید اعداد در شمارنده دیدگاه‌ها به فارسی تبدیل شوند؟"
105
+
106
+ # @ ztjalali
107
+ #: inc/wp-jalali-admin-option.php:85
108
+ msgid "change_category_number_to_persian Description"
109
+ msgstr "آیا تمایل دارید اعداد در دسته‌بندی‌ها به فارسی تبدیل شوند؟"
110
+
111
+ # @ ztjalali
112
+ #: inc/wp-jalali-admin-option.php:90
113
+ msgid "change_point_to_persian Description"
114
+ msgstr "آیا تمایل دارید ممیز اعداد اعشاری از نقطه به ٫ تبدیل شود؟"
115
+
116
+ # @ ztjalali
117
+ #: inc/wp-jalali-admin-option.php:97 inc/wp-jalali-admin-option.php:100
118
+ msgid "text option"
119
+ msgstr "تنظیمات متون"
120
+
121
+ # @ ztjalali
122
+ #: inc/wp-jalali-admin-option.php:103
123
+ msgid "change_arabic_to_persian Description"
124
+ msgstr ""
125
+ " تبدیل خودکار حروف (ي) و (ك) عربی به (ی) و (ک) فارسی در هنگام نمایش و جستجوی "
126
+ "هوشمند برای تمامی ترکیب‌های ممکن در هنگام جستجو. "
127
+
128
+ # @ ztjalali
129
+ #: inc/wp-jalali-admin-option.php:108
130
+ msgid "change_archive_title Description"
131
+ msgstr "آیا تمایل دارید نام ماهها در بایگانی شمسی باشد؟"
132
+
133
+ # @ ztjalali
134
+ #: inc/wp-jalali-admin-option.php:133
135
+ msgid "persian_planet"
136
+ msgstr "چگونگی نمایش اخبار در پیش‌خوان"
137
+
138
+ # @ ztjalali
139
+ #: inc/wp-jalali-admin-option.php:136 inc/wp-jalali-admin.php:106
140
+ msgid "wp-persian news Blog"
141
+ msgstr "نمایش اخبار وردپرس فارسی"
142
+
143
+ # @ ztjalali
144
+ #: inc/wp-jalali-admin-option.php:137 inc/wp-jalali-admin.php:118
145
+ msgid "wp-persian planet"
146
+ msgstr "نمایش سیاره وردپرس فارسی"
147
+
148
+ # @ ztjalali
149
+ #: inc/wp-jalali-admin-option.php:172
150
+ msgid "save changes"
151
+ msgstr "ذخیره تغییرات"
152
+
153
+ # @ ztjalali
154
+ #: inc/wp-jalali-admin.php:11
155
+ msgid "wp-jalali options"
156
+ msgstr "تنظیمات وردپرس فارسی"
157
+
158
+ # @ ztjalali
159
+ #. translators: plugin header field 'Name'
160
+ #: inc/wp-jalali-admin.php:12 wp-jalali.php:0
161
+ msgid "wp-jalali"
162
+ msgstr "وردپرس فارسی"
163
+
164
+ # @ ztjalali
165
+ #: inc/wp-jalali-admin.php:101
166
+ msgid "WordPress Development Blog"
167
+ msgstr "نمایش سیاره وردپرس انگلیسی"
168
+
169
+ # @ ztjalali
170
+ #: inc/wp-jalali-admin.php:113
171
+ msgid "Other WordPress News"
172
+ msgstr "نمایش اخبار وردپرس انگلیسی"
173
+
174
+ # @ ztjalali
175
+ #: widget/widget_archive.php:7 widget/widget_archive.php:14
176
+ #: widget/widget_archive.php:90
177
+ msgid "jalali archive"
178
+ msgstr "بایگانی شمسی"
179
+
180
+ # @ ztjalali
181
+ #: widget/widget_archive.php:7
182
+ msgid "jalali archive widget"
183
+ msgstr "ابزارک بایگانی شمسی"
184
+
185
+ # @ ztjalali
186
+ #: widget/widget_archive.php:31 widget/widget_calendar.php:20
187
+ msgid "title"
188
+ msgstr "عنوان ابزارک"
189
+
190
+ # @ ztjalali
191
+ #: widget/widget_archive.php:38
192
+ msgid "yearly"
193
+ msgstr "سالیانه"
194
+
195
+ # @ ztjalali
196
+ #: widget/widget_archive.php:43
197
+ msgid "monthly"
198
+ msgstr "ماهیانه"
199
+
200
+ # @ ztjalali
201
+ #: widget/widget_archive.php:48
202
+ msgid "daily"
203
+ msgstr "روزانه"
204
+
205
+ # @ ztjalali
206
+ #: widget/widget_archive.php:53
207
+ msgid "post by post"
208
+ msgstr "نوشته به نوشته"
209
+
210
+ # @ ztjalali
211
+ #: widget/widget_archive.php:58
212
+ msgid "link count(zero to unlimit)"
213
+ msgstr "تعداد(0 برای نمایش همه)"
214
+
215
+ # @ ztjalali
216
+ #: widget/widget_archive.php:65
217
+ msgid "show count of post (not work in post by post)"
218
+ msgstr "نمایش تعداد نوشته ها (فقط برای بایگانی روزانه و ماهیانه و سالیانه)"
219
+
220
+ # @ ztjalali
221
+ #: widget/widget_archive.php:71
222
+ msgid "show dropdown list (not work in post by post)"
223
+ msgstr "نمایش به صورت لیست بازشو (فقط برای بایگانی روزانه و ماهیانه و سالیانه)"
224
+
225
+ # @ ztjalali
226
+ #: widget/widget_calendar.php:7 widget/widget_calendar.php:13
227
+ #: widget/widget_calendar.php:43
228
+ msgid "jalali calendar"
229
+ msgstr "تقویم شمسی"
230
+
231
+ # @ ztjalali
232
+ #: widget/widget_calendar.php:7
233
+ msgid "jalali calendar widget"
234
+ msgstr "ابزارک تقویم شمسی"
235
+
236
+ # @ ztjalali
237
+ #: widget/widget_calendar.php:27
238
+ msgid "jcalendar short name of week"
239
+ msgstr "نمایش نام ایام هفته بصورت خلاصه"
240
+
241
+ # @ default
242
+ #. translators: Calendar caption: 1: month name, 2: 4-digit year
243
+ #: widget/widget_calendar.php:166
244
+ #, php-format
245
+ msgctxt "calendar caption"
246
+ msgid "%1$s %2$s"
247
+ msgstr ""
248
+
249
+ # @ ztjalali
250
+ #: widget/widget_calendar.php:198 widget/widget_calendar.php:200
251
+ #: widget/widget_calendar.php:210 widget/widget_calendar.php:212
252
+ #, php-format
253
+ msgid "View posts for %1$s %2$s"
254
+ msgstr "نمایش پست های %1$s %2$s"
255
+
256
+ # @ ztjalali
257
+ #: wp-jalali-init.php:156
258
+ msgid "Powered BY persian wordpress"
259
+ msgstr "قدرت گرفته از وردپرس فارسی"
260
+
261
+ # @ ztjalali
262
+ #: inc/wp-jalali-admin-option.php:115 inc/wp-jalali-admin-option.php:118
263
+ msgid "wp-jalali option"
264
+ msgstr "تنظیمات افزونه جلالی"
265
+
266
+ # @ ztjalali
267
+ #: inc/wp-jalali-admin-option.php:126
268
+ msgid "save_changes_in_db Description"
269
+ msgstr ""
270
+ "آیا تمایل دارید تغییرات حروف عربی و اعداد در هنگام ذخیره کردن نوشته صورت "
271
+ "بگیرد؟ <br/>به این ترتیب عملیات اصلاح فقط یک بار (در هنگام ذخیره نمودن) "
272
+ "انجام می گیرد و کارایی افزونه بیشتر خواهد شد."
273
+
274
+ # @ ztjalali
275
+ #: inc/wp-jalali-admin-option.php:121
276
+ msgid "ztjalali_admin_style Description"
277
+ msgstr ""
278
+ "اصلاح ظاهر مدیریت شامل تغییر قلم ،‌ تغییر اندازه قلم ها و ... که منجر به زیبا "
279
+ "تر شدن محیط مدیریت می شود."
280
+
281
+ # @ ztjalali
282
+ #: wp-jalali-init.php:93
283
+ msgid "setting"
284
+ msgstr "تنظیمات"
285
+
286
+ # @ ztjalali
287
+ #: inc/wp-jalali-admin.php:20
288
+ msgid "wp-jalali help page"
289
+ msgstr "راهنما"
290
+
291
+ # @ ztjalali
292
+ #: inc/wp-jalali-admin.php:20
293
+ msgid "wp-jalali help"
294
+ msgstr "راهنما"
295
+
296
+ # @ ztjalali
297
+ #. translators: plugin header field 'PluginURI'
298
+ #: wp-jalali.php:0
299
+ msgid "http://www.wp-persian.com/wp-jalali"
300
+ msgstr ""
301
+
302
+ # @ ztjalali
303
+ #. translators: plugin header field 'Description'
304
+ #: wp-jalali.php:0
305
+ msgid ""
306
+ "Full Jalali calendar support for Wordpress and localization improvements for "
307
+ "Persian/Afghan/Tajik users."
308
+ msgstr ""
309
+ "پشتیبانی کامل از تقویم جلالی، محلی‌سازی و بهبوده یافته برای کابران فارسی زبان/"
310
+ "افغان/تاجیک وردپرس."
311
+
312
+ # @ ztjalali
313
+ #. translators: plugin header field 'Author'
314
+ #: wp-jalali.php:0
315
+ msgid "Zakrot Web Solutions (in collaboration with WP-Persian team)"
316
+ msgstr "زاکروت، راهکارهای مبتنی بر وب - با همکاری تیم وردپرس فارسی"
317
+
318
+ # @ ztjalali
319
+ #. translators: plugin header field 'AuthorURI'
320
+ #: wp-jalali.php:0
321
+ msgid "http://zakrot.com/"
322
+ msgstr ""
323
+
324
+ # @ ztjalali
325
+ #. translators: plugin header field 'Version'
326
+ #: wp-jalali.php:0
327
+ msgid "5.0.0-RC"
328
+ msgstr ""
lib/date.php ADDED
@@ -0,0 +1,642 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ # 2014 Zakrot Web Solutions
4
+ #
5
+ # changes:
6
+ # function names changed
7
+ # added timesone
8
+ # added jmaketime
9
+ #
10
+ # 2009-2013 Vahid Sohrablou (IranPHP.org)
11
+ # 2000 Roozbeh Pournader and Mohammad Tou'si
12
+ #
13
+ # This program is free software; you can redistribute it and/or
14
+ # modify it under the terms of the GNU General Public License
15
+ # as published by the Free Software Foundation; either version 2
16
+ # of the License, or (at your option) any later version.
17
+ #
18
+ # This program is distributed in the hope that it will be useful,
19
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ # GNU General Public License for more details.
22
+ #
23
+ # A copy of the GNU General Public License is available from:
24
+ #
25
+ # <a href="http://gnu.org/copyleft/gpl.html" target="_blank">http://gnu.org/copyleft/gpl.html</a>
26
+ # Version 1.2.9
27
+
28
+
29
+ /**
30
+ * The format of the outputted date string (jalali equivalent of php date() function)
31
+ * @global array $jdate_month_name
32
+ * @global array $ztjalali_option
33
+ * @param string $format for example 'Y-m-d H:i:s'
34
+ * @param timestamp $timestamp [optional]
35
+ * @param bool $timezone [optional]
36
+ * @param bool $fanum [optional]<br/>convert number to persian ?<br/>
37
+ * default : get from plugin option
38
+ * @return string
39
+ * @since 5.0.0
40
+ */
41
+ function jdate($format, $timestamp = NULL, $timezone = false, $fanum = NULL) {
42
+ global $jdate_month_name, $ztjalali_option;
43
+ static $jdate_month_days = array(0, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
44
+ static $jdate_week_name = array('شنبه', 'یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنج شنبه', 'جمعه');
45
+
46
+ if (!$timestamp)
47
+ $timestamp = time();
48
+ elseif (!is_numeric($timestamp))
49
+ $timestamp = strtotime($timestamp);
50
+ elseif (!is_integer($timestamp))
51
+ $timestamp = intval($timestamp);
52
+
53
+ /* =================================================================== */
54
+ if ($timezone === 'local' OR $timezone === FALSE) {
55
+ //do noting
56
+ } elseif ( $timezone === TRUE) {
57
+ $fanum = FALSE;// support jdate older version
58
+ } elseif ($timezone === 'current') {
59
+ $time_zone = 'Asia/Tehran';
60
+ function_exists('get_option') AND $time_zone = get_option('timezone_string');
61
+ $dtz = new DateTimeZone($time_zone);
62
+ $time_obj = new DateTime('now', $dtz);
63
+ $deff_time = $dtz->getOffset($time_obj);
64
+ $timestamp += $deff_time;
65
+ } elseif (is_numeric($time_zone)) {
66
+ $timestamp += (int) $time_zone;
67
+ } elseif (is_string($time_zone)) {
68
+ $dtz = new DateTimeZone($time_zone);
69
+ $time_obj = new DateTime('now', $dtz);
70
+ $deff_time = $dtz->getOffset($time_obj);
71
+ $timestamp += $deff_time;
72
+ }
73
+ /* =================================================================== */
74
+ if ($fanum === NULL AND ! empty($ztjalali_option['change_jdate_number_to_persian']) AND $ztjalali_option['change_jdate_number_to_persian']) {
75
+ $fanum = TRUE;
76
+ }
77
+ /* =================================================================== */
78
+ # Create need date parametrs
79
+ list($gYear, $gMonth, $gDay, $gWeek) = explode('-', date('Y-m-d-w', $timestamp));
80
+ list($pYear, $pMonth, $pDay) = gregorian_to_jalali($gYear, $gMonth, $gDay);
81
+ $pWeek = ($gWeek + 1);
82
+
83
+ if ($pWeek >= 7) {
84
+ $pWeek = 0;
85
+ }
86
+
87
+ if ($format == '\\') {
88
+ $format = '//';
89
+ }
90
+
91
+ $lenghFormat = strlen($format);
92
+ $i = 0;
93
+ $result = '';
94
+
95
+ while ($i < $lenghFormat) {
96
+ $par = $format{$i};
97
+ if ($par == '\\') {
98
+ $result .= $format{ ++$i};
99
+ $i ++;
100
+ continue;
101
+ }
102
+ switch ($par) {
103
+ # Day
104
+ case 'd':
105
+ $result .= (($pDay < 10) ? ('0' . $pDay) : $pDay);
106
+ break;
107
+
108
+ case 'D':
109
+ $result .= substr($jdate_week_name[$pWeek], 0, 2);
110
+ break;
111
+
112
+ case 'j':
113
+ $result .= $pDay;
114
+ break;
115
+
116
+ case 'l':
117
+ $result .= $jdate_week_name[$pWeek];
118
+ break;
119
+
120
+ case 'N':
121
+ $result .= $pWeek + 1;
122
+ break;
123
+
124
+ case 'w':
125
+ $result .= $pWeek;
126
+ break;
127
+
128
+ case 'z':
129
+ $result .= jday_of_year($pMonth, $pDay);
130
+ break;
131
+
132
+ case 'S':
133
+ $result .= 'ام';
134
+ break;
135
+
136
+ # Week
137
+ case 'W':
138
+ $result .= ceil(jday_of_year($pMonth, $pDay) / 7);
139
+ break;
140
+
141
+ # Month
142
+ case 'F':
143
+ $result .= $jdate_month_name[$pMonth];
144
+ break;
145
+
146
+ case 'm':
147
+ $result .= (($pMonth < 10) ? ('0' . $pMonth) : $pMonth);
148
+ break;
149
+
150
+ case 'M':
151
+ $result .= substr($jdate_month_name[$pMonth], 0, 6);
152
+ break;
153
+
154
+ case 'n':
155
+ $result .= $pMonth;
156
+ break;
157
+
158
+ case 't':
159
+ $result .= jday_of_month($pYear,$pMonth);
160
+ break;
161
+
162
+ # Years
163
+ case 'L':
164
+ $result .= (int) is_jalali_leap_year($pYear);
165
+ break;
166
+
167
+ case 'Y':
168
+ case 'o':
169
+ $result .= $pYear;
170
+ break;
171
+
172
+ case 'y':
173
+ $result .= substr($pYear, 2);
174
+ break;
175
+
176
+ # Time
177
+ case 'a':
178
+ case 'A':
179
+ if (date('a', $timestamp) == 'am') {
180
+ $result .= (($par == 'a') ? '.ق.ظ' : 'قبل از ظهر');
181
+ } else {
182
+ $result .= (($par == 'a') ? '.ب.ظ' : 'بعد از ظهر');
183
+ }
184
+ break;
185
+
186
+ case 'B':
187
+ case 'g':
188
+ case 'G':
189
+ case 'h':
190
+ case 'H':
191
+ case 's':
192
+ case 'u':
193
+ case 'i':
194
+ # Timezone
195
+ case 'e':
196
+ case 'I':
197
+ case 'O':
198
+ case 'P':
199
+ case 'T':
200
+ case 'Z':
201
+ $result .= date($par, $timestamp);
202
+ break;
203
+
204
+ # Full Date/Time
205
+ case 'c':
206
+ $result .= ($pYear . '-' . $pMonth . '-' . $pDay . ' ' . date('H:i:s P', $timestamp));
207
+ break;
208
+
209
+ case 'r':
210
+ $result .= (substr($jdate_week_name[$pWeek], 0, 2) . '، ' . $pDay . ' ' . substr($jdate_month_name[$pMonth], 0, 6) . ' ' . $pYear . ' ' . date('H::i:s P', $timestamp));
211
+ break;
212
+
213
+ case 'U':
214
+ $result .= $timestamp;
215
+ break;
216
+
217
+ default:
218
+ $result .= $par;
219
+ }
220
+ $i ++;
221
+ }
222
+ if ($fanum)
223
+ return ztjalali_persian_num($result);
224
+ return $result;
225
+ }
226
+ /* =================================================================== */
227
+
228
+ /**
229
+ * Format a local time/date according to locale settings (jalali equivalent of php strftime() function)
230
+ * @global array $jdate_month_name
231
+ * @param string $format for example 'Y-m-d H:i:s'
232
+ * @param timestamp $timestamp [optional]
233
+ * @param bool $fanum [optional]<br/>convert number to persian ?<br/>
234
+ * default : get from plugin option
235
+ * @return type
236
+ * @since 5.0.0
237
+ */
238
+ function jstrftime($format, $timestamp = NULL, $fanum = false) {
239
+ global $jdate_month_name;
240
+ static $jdate_month_days = array(0, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
241
+ static $jdate_week_name = array('شنبه', 'یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنج شنبه', 'جمعه');
242
+ if (!$timestamp) {
243
+ $timestamp = time();
244
+ }
245
+
246
+ # Create need date parametrs
247
+ list($gYear, $gMonth, $gDay, $gWeek) = explode('-', date('Y-m-d-w', $timestamp));
248
+ list($pYear, $pMonth, $pDay) = gregorian_to_jalali($gYear, $gMonth, $gDay);
249
+ $pWeek = $gWeek + 1;
250
+
251
+ if ($pWeek >= 7) {
252
+ $pWeek = 0;
253
+ }
254
+
255
+ $lenghFormat = strlen($format);
256
+ $i = 0;
257
+ $result = '';
258
+
259
+ while ($i < $lenghFormat) {
260
+ $par = $format{$i};
261
+ if ($par == '%') {
262
+ $type = $format{ ++$i};
263
+ switch ($type) {
264
+ # Day
265
+ case 'a':
266
+ $result .= substr($jdate_week_name[$pWeek], 0, 2);
267
+ break;
268
+
269
+ case 'A':
270
+ $result .= $jdate_week_name[$pWeek];
271
+ break;
272
+
273
+ case 'd':
274
+ $result .= (($pDay < 10) ? '0' . $pDay : $pDay);
275
+ break;
276
+
277
+ case 'e':
278
+ $result.= $pDay;
279
+ break;
280
+
281
+ case 'j':
282
+ $dayinM = jday_of_year($pMonth, $pDay);
283
+ $result .= (($dayinM < 10) ? '00' . $dayinM : ($dayinM < 100) ? '0' . $dayinM : $dayinM);
284
+ break;
285
+
286
+ case 'u':
287
+ $result .= $pWeek + 1;
288
+ break;
289
+
290
+ case 'w':
291
+ $result .= $pWeek;
292
+ break;
293
+
294
+ # Week
295
+ case 'U':
296
+ $result .= floor(jday_of_year($pMonth, $pDay) / 7);
297
+ break;
298
+
299
+ case 'V':
300
+ case 'W':
301
+ $result .= ceil(jday_of_year($pMonth, $pDay) / 7);
302
+ break;
303
+
304
+ # Month
305
+ case 'b':
306
+ case 'h':
307
+ $result .= substr($jdate_month_name[$pMonth], 0, 6);
308
+ break;
309
+
310
+ case 'B':
311
+ $result .= $jdate_month_name[$pMonth];
312
+ break;
313
+
314
+ case 'm':
315
+ $result .= (($pMonth < 10) ? '0' . $pMonth : $pMonth);
316
+ break;
317
+
318
+ # Year
319
+ case 'C':
320
+ $result .= ceil($pYear / 100);
321
+ break;
322
+
323
+ case 'g':
324
+ case 'y':
325
+ $result .= substr($pYear, 2);
326
+ break;
327
+
328
+ case 'G':
329
+ case 'Y':
330
+ $result .= $pYear;
331
+ break;
332
+
333
+ # Time
334
+ case 'H':
335
+ case 'I':
336
+ case 'l':
337
+ case 'M':
338
+ case 'R':
339
+ case 'S':
340
+ case 'T':
341
+ case 'X':
342
+ case 'z':
343
+ case 'Z':
344
+ $result .= strftime('%' . $type, $timestamp);
345
+ break;
346
+
347
+ case 'p':
348
+ case 'P':
349
+ case 'r':
350
+ if (date('a', $timestamp) == 'am') {
351
+ $result .= (($type == 'p') ? 'ق.ظ' : ($type == 'P') ? 'قبل از ظهر' : strftime("%I:%M:%S قبل از ظهر", $timestamp));
352
+ } else {
353
+ $result .= (($type == 'p') ? 'ب.ظ' : ($type == 'P') ? 'بعد از ظهر' : strftime("%I:%M:%S بعد از ظهر", $timestamp));
354
+ }
355
+ break;
356
+
357
+ # Time and Date Stamps
358
+ case 'c':
359
+ $result .= (substr($jdate_week_name[$pWeek], 0, 2) . ' ' . substr($jdate_month_name[$pMonth], 0, 6) . ' ' . $pDay . ' ' . strftime("%T", $timestamp) . ' ' . $pYear);
360
+ break;
361
+
362
+ case 'D':
363
+ case 'x':
364
+ $result .= ((($pMonth < 10) ? '0' . $pMonth : $pMonth) . '-' . (($pDay < 10) ? '0' . $pDay : $pDay) . '-' . substr($pYear, 2));
365
+ break;
366
+
367
+ case 'F':
368
+ $result .= ($pYear . '-' . (($pMonth < 10) ? '0' . $pMonth : $pMonth) . '-' . (($pDay < 10) ? '0' . $pDay : $pDay));
369
+ break;
370
+
371
+ case 's':
372
+ $result .= $timestamp;
373
+ break;
374
+
375
+ # Miscellaneous
376
+ case 'n':
377
+ $result .= "\n";
378
+ break;
379
+
380
+ case 't':
381
+ $result .= "\t";
382
+ break;
383
+
384
+ case '%':
385
+ $result .= '%';
386
+ break;
387
+
388
+ default:
389
+ $result .= '%' . $type;
390
+ }
391
+ } else {
392
+ $result .= $par;
393
+ }
394
+ $i ++;
395
+ }
396
+ if ($fanum)
397
+ return ztjalali_persian_num($result);
398
+ return $result;
399
+ }
400
+ /* =================================================================== */
401
+
402
+ /**
403
+ * return Unix timestamp for a date (jalali equivalent of php mktime() function)
404
+ * @param int $hour [optional] max : 23
405
+ * @param int $minute [optional] max : 59
406
+ * @param int $second [optional] max: 59
407
+ * @param int $month [optional] max: 12
408
+ * @param int $day [optional] max: 31
409
+ * @param int $year [optional]
410
+ * @param int $is_dst [optional]
411
+ * @return timestamp
412
+ * @since 5.0.0
413
+ */
414
+ function jmktime($hour = 0, $minute = 0, $second = 0, $month = 0, $day = 0, $year = 0, $is_dst = -1) {
415
+ if (($hour == 0) && ($minute == 0) && ($second == 0) && ($month == 0) && ($day == 0) && ($year == 0)) {
416
+ return time();
417
+ }
418
+
419
+ list($year, $month, $day) = jalali_to_gregorian($year, $month, $day);
420
+ return mktime($hour, $minute, $second, $month, $day, $year, $is_dst);
421
+ }
422
+ /* =================================================================== */
423
+
424
+ /**
425
+ * validate a jalali date (jalali equivalent of php checkdate() function)
426
+ * @param int $month
427
+ * @param int $day
428
+ * @param int $year
429
+ * @return int
430
+ * @since 5.0.0
431
+ */
432
+ function jcheckdate($month, $day, $year) {
433
+ if (($month < 1) || ($month > 12) || ($year < 1) || ($year > 32767) || ($day < 1)) {
434
+ return 0;
435
+ }
436
+
437
+ static $jdate_month_days = array(0, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
438
+
439
+ if ($day > $jdate_month_days[$month]) {
440
+ if (($month != 12) || ($day != 30) || !is_jalali_leap_year($year)) {
441
+ return 0;
442
+ }
443
+ }
444
+
445
+ return 1;
446
+ }
447
+ /* =================================================================== */
448
+
449
+ /**
450
+ * Get date/time information (jalali equivalent of php getdate() function)
451
+ * @param timestamp $timestamp
452
+ * @return array
453
+ * @since 5.0.0
454
+ */
455
+ function jgetdate($timestamp = NULL) {
456
+ if (!$timestamp) {
457
+ $timestamp = mktime();
458
+ }
459
+
460
+ list($seconds, $minutes, $hours, $mday, $wday, $mon, $year, $yday, $weekday, $month) = explode('-', jdate('s-i-G-j-w-n-Y-z-l-F', $timestamp, false, false));
461
+ return array(0 => $timestamp, 'seconds' => $seconds, 'minutes' => $minutes, 'hours' => $hours, 'mday' => $mday, 'wday' => $wday, 'mon' => $mon, 'year' => $year, 'yday' => $yday, 'weekday' => $weekday, 'month' => $month);
462
+ }
463
+ /* =================================================================== */
464
+
465
+ /**
466
+ * gregorian to jalali convertion
467
+ * @staticvar array $g_days_in_month
468
+ * @staticvar array $j_days_in_month
469
+ * @param int $g_y
470
+ * @param int $g_m
471
+ * @param int $g_d
472
+ * @return array
473
+ * @since 5.0.0
474
+ */
475
+ function gregorian_to_jalali($g_y, $g_m, $g_d) {
476
+ static $g_days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
477
+ static $j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
478
+ $gy = $g_y - 1600;
479
+ $gm = $g_m - 1;
480
+ $g_day_no = (365 * $gy + int_div($gy + 3, 4) - int_div($gy + 99, 100) + int_div($gy + 399, 400));
481
+
482
+ for ($i = 0; $i < $gm; ++$i) {
483
+ $g_day_no += $g_days_in_month[$i];
484
+ }
485
+
486
+ if ($gm > 1 && (($gy % 4 == 0 && $gy % 100 != 0) || ($gy % 400 == 0)))
487
+ # leap and after Feb
488
+ $g_day_no ++;
489
+ $g_day_no += $g_d - 1;
490
+ $j_day_no = $g_day_no - 79;
491
+ $j_np = int_div($j_day_no, 12053); # 12053 = (365 * 33 + 32 / 4)
492
+ $j_day_no = $j_day_no % 12053;
493
+ $jy = (979 + 33 * $j_np + 4 * int_div($j_day_no, 1461)); # 1461 = (365 * 4 + 4 / 4)
494
+ $j_day_no %= 1461;
495
+
496
+ if ($j_day_no >= 366) {
497
+ $jy += int_div($j_day_no - 1, 365);
498
+ $j_day_no = ($j_day_no - 1) % 365;
499
+ }
500
+
501
+ for ($i = 0; ($i < 11 && $j_day_no >= $j_days_in_month[$i]); ++$i) {
502
+ $j_day_no -= $j_days_in_month[$i];
503
+ }
504
+
505
+ return array($jy, $i + 1, $j_day_no + 1);
506
+ }
507
+ /* =================================================================== */
508
+
509
+ /**
510
+ * jalali to gregorian convertion
511
+ * @staticvar array $g_days_in_month
512
+ * @staticvar array $j_days_in_month
513
+ * @param int $j_y
514
+ * @param int $j_m
515
+ * @param int $j_d
516
+ * @return array
517
+ * @since 5.0.0
518
+ */
519
+ function jalali_to_gregorian($j_y, $j_m, $j_d) {
520
+ static $g_days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
521
+ static $j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
522
+ $jy = $j_y - 979;
523
+ $jm = $j_m - 1;
524
+ $j_day_no = (365 * $jy + int_div($jy, 33) * 8 + int_div($jy % 33 + 3, 4));
525
+
526
+ for ($i = 0; $i < $jm; ++$i) {
527
+ $j_day_no += $j_days_in_month[$i];
528
+ }
529
+
530
+ $j_day_no += $j_d - 1;
531
+ $g_day_no = $j_day_no + 79;
532
+ $gy = (1600 + 400 * int_div($g_day_no, 146097)); # 146097 = (365 * 400 + 400 / 4 - 400 / 100 + 400 / 400)
533
+ $g_day_no = $g_day_no % 146097;
534
+ $leap = 1;
535
+
536
+ if ($g_day_no >= 36525) { # 36525 = (365 * 100 + 100 / 4)
537
+ $g_day_no --;
538
+ $gy += (100 * int_div($g_day_no, 36524)); # 36524 = (365 * 100 + 100 / 4 - 100 / 100)
539
+ $g_day_no = $g_day_no % 36524;
540
+ if ($g_day_no >= 365) {
541
+ $g_day_no ++;
542
+ } else {
543
+ $leap = 0;
544
+ }
545
+ }
546
+
547
+ $gy += (4 * int_div($g_day_no, 1461)); # 1461 = (365 * 4 + 4 / 4)
548
+ $g_day_no %= 1461;
549
+
550
+ if ($g_day_no >= 366) {
551
+ $leap = 0;
552
+ $g_day_no --;
553
+ $gy += int_div($g_day_no, 365);
554
+ $g_day_no = ($g_day_no % 365);
555
+ }
556
+
557
+ for ($i = 0; $g_day_no >= ($g_days_in_month[$i] + ($i == 1 && $leap)); $i ++) {
558
+ $g_day_no -= ($g_days_in_month[$i] + ($i == 1 && $leap));
559
+ }
560
+
561
+ return array($gy, $i + 1, $g_day_no + 1);
562
+ }
563
+ /* =================================================================== */
564
+
565
+ /**
566
+ * integer division
567
+ * @param int $a
568
+ * @param int $b
569
+ * @return type
570
+ * @since 5.0.0
571
+ */
572
+ function int_div($a, $b) {
573
+ return (int) ($a / $b);
574
+ }
575
+ /* =================================================================== */
576
+
577
+ /**
578
+ * return day number from first day of year
579
+ * @param int $pMonth
580
+ * @param int $pDay
581
+ * @return type
582
+ * @since 5.0.0
583
+ */
584
+ function jday_of_year($pMonth, $pDay) {
585
+ static $jdate_month_days = array(0, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
586
+ $days = 0;
587
+
588
+ for ($i = 1; $i < $pMonth; $i ++) {
589
+ $days += $jdate_month_days[$i];
590
+ }
591
+
592
+ return ($days + $pDay);
593
+ }
594
+ /* =================================================================== */
595
+
596
+ /**
597
+ * check jalali year is leap(kabise)
598
+ * @param int $year
599
+ * @return int
600
+ * @since 5.0.0
601
+ */
602
+ function is_jalali_leap_year($year) {
603
+ $mod = ($year % 33);
604
+
605
+ if (($mod == 1) or ( $mod == 5) or ( $mod == 9) or ( $mod == 13) or ( $mod == 17) or ( $mod == 22) or ( $mod == 26) or ( $mod == 30)) {
606
+ return 1;
607
+ }
608
+
609
+ return 0;
610
+ }
611
+ /* =================================================================== */
612
+
613
+ /**
614
+ * return last day of month
615
+ * @param int $year
616
+ * @param int $month
617
+ * @return int number of day in month
618
+ * @since 5.0.0
619
+ */
620
+ function jday_of_month($year,$month) {
621
+ static $jdate_month_days = array(0, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
622
+ if(is_jalali_leap_year($year) && ($month == 12))
623
+ return 30;
624
+ $month = (int)$month;
625
+ return $jdate_month_days[$month];
626
+ }
627
+ /* =================================================================== */
628
+
629
+ /**
630
+ * return jalali name of month from month number
631
+ * @global array $jdate_month_name
632
+ * @param int $month
633
+ * @return string
634
+ * @since 5.0.0
635
+ */
636
+ function monthname($month) {
637
+ global $jdate_month_name;
638
+ $month = (int)$month;
639
+ return $jdate_month_name[$month];
640
+ }
641
+ /* =================================================================== */
642
+
lib/deprecated_fns.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * use <b>jmktime()</b> instead jmaketime()
5
+ * @deprecated since 5.0.0
6
+ */
7
+ function jmaketime($hour = 0, $minute = 0, $second = 0, $month = 0, $day = 0, $year = 0, $is_dst = -1) {
8
+ return jmktime($hour, $minute, $second, $month, $day, $year, $is_dst);
9
+ }
10
+
11
+ /**
12
+ * @deprecated since 5.0.0
13
+ */
14
+ function gregorian_week_day($g_y, $g_m, $g_d) {
15
+ global $g_days_in_month;
16
+
17
+ $gy = $g_y - 1600;
18
+ $gm = $g_m - 1;
19
+ $gd = $g_d - 1;
20
+
21
+ $g_day_no = 365 * $gy + div($gy + 3, 4) - div($gy + 99, 100) + div($gy + 399, 400);
22
+
23
+ for ($i = 0; $i < $gm; ++$i)
24
+ $g_day_no += $g_days_in_month[$i];
25
+ if ($gm > 1 && (($gy % 4 == 0 && $gy % 100 != 0) || ($gy % 400 == 0)))
26
+ /* leap and after Feb */
27
+ ++$g_day_no;
28
+ $g_day_no += $gd;
29
+
30
+ return ($g_day_no + 5) % 7 + 1;
31
+ }
32
+
33
+ /**
34
+ *
35
+ * @deprecated since 5.0.0
36
+ */
37
+ function jalali_week_day($j_y, $j_m, $j_d) {
38
+ global $j_days_in_month;
39
+
40
+ $jy = $j_y - 979;
41
+ $jm = $j_m - 1;
42
+ $jd = $j_d - 1;
43
+
44
+ $j_day_no = 365 * $jy + div($jy, 33) * 8 + div($jy % 33 + 3, 4);
45
+
46
+ for ($i = 0; $i < $jm; ++$i)
47
+ $j_day_no += $j_days_in_month[$i];
48
+
49
+ $j_day_no += $jd;
50
+
51
+ return ($j_day_no + 2) % 7 + 1;
52
+ }
53
+
54
+ /**
55
+ * Find Day Begining Of Month
56
+ *
57
+ * @deprecated since 5.0.0
58
+ */
59
+ function mstart($month, $day, $year) {
60
+ list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
61
+ list( $year, $month, $day ) = jalali_to_gregorian($jyear, $jmonth, "1");
62
+ $timestamp = mktime(0, 0, 0, $month, $day, $year);
63
+ return date("w", $timestamp);
64
+ }
65
+
66
+ /**
67
+ * Find Number Of Days In This Month<br/>
68
+ * use <b>jday_of_month()</b> instead lastday()
69
+ * @deprecated since 5.0.0
70
+ */
71
+ function lastday($month, $day, $year) {
72
+ $lastdayen = date("d", mktime(0, 0, 0, $month + 1, 0, $year));
73
+ list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
74
+ $lastdatep = $jday;
75
+ $jday = $jday2;
76
+ while ($jday2 != "1") {
77
+ if ($day < $lastdayen) {
78
+ $day++;
79
+ list( $jyear, $jmonth, $jday2 ) = gregorian_to_jalali($year, $month, $day);
80
+ if ($jdate2 == "1")
81
+ break;
82
+ if ($jdate2 != "1")
83
+ $lastdatep++;
84
+ }
85
+ else {
86
+ $day = 0;
87
+ $month++;
88
+ if ($month == 13) {
89
+ $month = "1";
90
+ $year++;
91
+ }
92
+ }
93
+ }
94
+ return $lastdatep - 1;
95
+ }
96
+
97
+ /**
98
+ * use <b>int_div()</b> instead div()
99
+ * @deprecated since 5.0.0
100
+ */
101
+ function div($a, $b) {
102
+ return (int) ($a / $b);
103
+ }
104
+
105
+ /**
106
+ * use <b>ztjalali_convertToFarsi()</b> instead convertToFarsi()
107
+ * @deprecated since 5.0.0
108
+ */
109
+ function convertToFarsi($matches) {
110
+ return ztjalali_convertToFarsi($matches);
111
+ }
112
+
113
+ /**
114
+ * use <b>ztjalali_ch_number_to_persian()</b> OR <b>ztjalali_persian_num()</b> instead farsi_num()
115
+ * @deprecated since 5.0.0
116
+ */
117
+ function farsi_num($str, $fake = null, $fake2 = null) {
118
+ return ztjalali_persian_num($str);
119
+ }
120
+
121
+ /**
122
+ * use <b>ztjalali_english_num()</b> instead english_num()
123
+ * @deprecated since 5.0.0
124
+ */
125
+ function english_num($str) {
126
+ return ztjalali_english_num($str);
127
+ }
128
+
129
+ /**
130
+ * use <b>ztjalali_archive_widget()</b> instead wp_get_jarchives()
131
+ * @deprecated since 5.0.0
132
+ */
133
+ function wp_get_jarchives($args = '') {
134
+ parse_str($args, $r);
135
+ if (!isset($r['type'])) $r['type'] = '';
136
+ if (!isset($r['limit'])) $r['limit'] = '';
137
+ if (!isset($r['format'])) $r['format'] = 'html';
138
+ if (!isset($r['before'])) $r['before'] = '';
139
+ if (!isset($r['after'])) $r['after'] = '';
140
+ if (!isset($r['show_post_count'])) $r['show_post_count'] = false;
141
+ return ztjalali_archive_widget($r['type'],$r['format'], $r['show_post_count'],$r['limit'],$r['before'],$r['after']);
142
+ }
143
+
144
+ /**
145
+ * use <b>ztjalali_calendar_widget()</b> instead get_jcalendar()
146
+ * @deprecated since 5.0.0
147
+ */
148
+ function get_jcalendar() {
149
+ return ztjalali_calendar_widget();
150
+ }
lib/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php
readme.txt CHANGED
@@ -1,50 +1,87 @@
1
- === wp-jalali ===
2
- Contributors: mani_monaj, Gonahkar, moallemi, zakrot
3
- Donate link: http://www.wp-persian.com/donate/
4
- Tags: Persian, Farsi, Jalali, Date, Calendar, i18n, l10n, Iran, Iranian
5
- Requires at least: 2.1
6
- Tested up to: 3.9
7
- Stable tag: 4.5.3
8
-
9
- Turn you Wordpress into a full featured Persian (Iranian) Blogging Platform.
10
-
11
- == Description ==
12
-
13
- This plug-in is a "Full Jalali (خورشیدی - شمسی) Date and Persian (Farsi) (فارسی)" Support Package for wordpress by [WP-Persian.com](http://wp-persian.com/). This plug-in with listed features is a great tool for Iranian users of Wordpress.
14
-
15
- * Full posts' and comments' dates' conversion.
16
- * Jalali (Monthly and Daily) Archive template tag.
17
- * Magic (Jalali/Gregorian) Calendar template tag.
18
- * Jalali/Gregorian compatible permalinks.
19
- * TinyMCE (Wordpress Editor) Persian improvements.
20
- * Auto conversion of Arabic , ك) to Farsi (ی , ک) with smart search
21
- * Cross browser Persian keyboard support for themes' comment forms.
22
- * Jalali Archive/Calendar **fully customized widgets**.
23
- * Auto Persian numbers conversion.
24
- * Fully customizable through specific Wordpress admin page.
25
- * Jalali timestamp edit in new post and new page sections
26
- * Jalali dates in edit tables
27
- * Iran and Afghanistan month names
28
-
29
- This plug-in is now part of [Persian Wordpress Project](http://wp-persian.com/ "پروژه وردپرس فارسی")
30
-
31
- == Installation ==
32
-
33
- 1. Extract the downloaded archive into `wp-jalali` folder. If you downloaded the .zip archive it **contains** the `wp-jalali` folder.
34
- 2. Upload `wp-jalali` to the `/wp-content/plugins/` directory of your wordpress installation.
35
- 3. If you are using older versions of this plug-in, you must deactivate it first through the 'Plugins' menu in Wordpress admin.
36
- 4. Activate the plug-in through the 'Plugins' menu in Wordpress admin.
37
-
38
- == Frequently Asked Questions ==
39
-
40
- = Where can I find more information and documentation about the plug-in? =
41
-
42
- You can read complete documentations on the [plug-in documentation page](http://codex.wp-persian.com/index.php/%D9%BE%D9%84%D8%A7%DA%AF%DB%8C%D9%86_%D9%88%D8%B1%D8%AF%D9%BE%D8%B1%D8%B3_%D9%81%D8%A7%D8%B1%D8%B3%DB%8C) in Persian (فارسی).
43
-
44
- = What is Wordpress Persian Project (پروژه وردپرس فارسی) =
45
-
46
- Please check out [this page](http://wp-persian.com/en/about/).
47
-
48
- == Screenshots ==
49
-
50
- 1. Persian Wordpress Admin Page
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === wp-jalali ===
2
+ Contributors: zakrot, mani_monaj, gonahkar, moallemi
3
+ Donate link: http://www.wp-persian.com/donate
4
+ Tags: Calendar Conversion, Persian, Farsi, Afghan, Tajik, Jalali, Date, Calendar, i18n, l10n
5
+ Tested up to: 4.0.0
6
+ Requires at least: 3.9
7
+ Stable tag: 5.0.0-RC
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Full Jalali calendar support for Wordpress and localization improvements for Persian/Afghan/Tajik users.
12
+
13
+ == Description ==
14
+
15
+ wp-jalali is a "Full Jalali (خورشیدی - شمسی) Calendar and Persian(Farsi)/Afghan/Tajik" support package for Wordpress.
16
+
17
+ Features include:
18
+
19
+ * Transparent and configurable Jalali date conversion for posts, pages and comments
20
+ * Jalali Archive template tag and widget (Monthly and Daily)
21
+ * Jalali/Gregorian Calendar template tag and widget
22
+ * Jalali/Gregorian compatible permalinks
23
+ * Improvements to TinyMCE (Wordpress Editor)
24
+ * Auto conversion of some Arabic characters (ي , ك) to Persian (ی , ک) with smart search
25
+ * Auto conversion of Latin numbers to Persian numbers.
26
+ * Fully customizable through custom admin page
27
+ * Jalali timestamp edit in new post and new page sections
28
+ * Jalali dates in edit tables
29
+ * Support for both Iranian and Afghan month names
30
+
31
+ This plug-in is part of [Persian Wordpress Project](http://wp-persian.com/ "پروژه وردپرس فارسی"). Since version 5.0, this plugin is being maintained in collaboration with [Zakrot Web Solutions](http://zakrot.com/).
32
+
33
+ == Installation ==
34
+
35
+ You can install wp-jalali by either using wordpress.org plugin directory, or by directly uploading plugin files to your server.
36
+
37
+ == Frequently Asked Questions ==
38
+
39
+ = What's new in version 5.0?
40
+
41
+ wp-jalali v5.0 is a full rewrite of the 4.x plugin by [Zakrot Web Solutions](http://zakrot.com/). This version improves plugin's performance significantly and provides a better user and developer experience.
42
+
43
+ = Where can I ask my questions regarding this plugin?
44
+
45
+ TBA
46
+
47
+ = How can I report bugs or contribute to the plugin?
48
+
49
+ All developments are happening on [plugin's github repository](https://github.com/wp-persian/wp-jalali). You can use the [Issue Tracker](https://github.com/wp-persian/wp-jalali/issues) to report bugs and issues. You can also send your patches using github [Pull Requests](https://help.github.com/articles/using-pull-requests) feature.
50
+
51
+ == Screenshots ==
52
+
53
+ 1. Preview of wp-jalali's Custom Admin Page
54
+
55
+ == Changelog ==
56
+
57
+ = 5.0 (Sept 2014) =
58
+
59
+ = 4.5.3 (Aug 24, 2014) =
60
+
61
+ = 4.5.2 (Jan 9, 2014) =
62
+
63
+ = 4.5.1 (Nov 24, 2013) =
64
+
65
+ = 4.5 (Oct 27, 2013) =
66
+
67
+ = 4.4 (Dec 12, 2012) =
68
+
69
+ = 4.3 (Dec 26, 2010) =
70
+
71
+ = 4.2.4 (Jul 30, 2010) =
72
+
73
+ = 4.2.3 (Jul 6, 2010) =
74
+
75
+ = 4.2.2 (Dec 25, 2009) =
76
+
77
+ = 4.2.1 (Jul 4, 2009) =
78
+
79
+ = 4.2 (Dec 16, 2008) =
80
+
81
+ = 4.1 (Aug 12, 2008) =
82
+
83
+ = 4.0 (Apr 20, 2008) =
84
+
85
+ = 3.5.1 (Mar 19, 2008) =
86
+
87
+ = 3.5 (Aug 4, 2007) =
screenshot-1.png CHANGED
Binary file
widget/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php
widget/widget_archive.php ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ztjalali_archive extends WP_Widget {
4
+
5
+ function __construct() {
6
+ parent::__construct(
7
+ 'ztjalali_archive', __('jalali archive', 'ztjalali'), array('description' => __('jalali archive widget', 'ztjalali'),)
8
+ );
9
+ }
10
+
11
+ public function form($instance) {
12
+
13
+ if (!isset($instance['jarchive_title']))
14
+ $instance['jarchive_title'] = __('jalali archive', 'ztjalali');
15
+
16
+ if (!isset($instance['jarchive_type']))
17
+ $instance['jarchive_type'] = 'monthly';
18
+
19
+ if (!isset($instance['jarchive_link_count']))
20
+ $instance['jarchive_link_count'] = 12;
21
+
22
+ if (!isset($instance['jarchive_show_post_count']))
23
+ $instance['jarchive_show_post_count'] = TRUE;
24
+
25
+ if (!isset($instance['jarchive_dropdown']))
26
+ $instance['jarchive_dropdown'] = FALSE;
27
+ ?>
28
+ <div dir="rtl" align="justify">
29
+ <p style="text-align:right">
30
+ <label for="<?php echo $this->get_field_id('jarchive_title'); ?>">
31
+ <?php _e('title', 'ztjalali') ?>:
32
+ <input style="width: 200px;" id="<?php echo $this->get_field_id('jarchive_title'); ?>" name="<?php echo $this->get_field_name('jarchive_title'); ?>" type="text" value="<?php echo $instance['jarchive_title']; ?>" />
33
+ </label>
34
+ </p>
35
+ <p style="text-align:right">
36
+ <label for="<?php echo $this->get_field_id('yearly'); ?>">
37
+ <input name="<?php echo $this->get_field_name('jarchive_type'); ?>" id="<?php echo $this->get_field_id('yearly'); ?>" type="radio" value="yearly" <?php checked($instance['jarchive_type'], 'yearly'); ?> />
38
+ <?php _e('yearly', 'ztjalali') ?>
39
+ </label>
40
+ <br/>
41
+ <label for="<?php echo $this->get_field_id('monthly'); ?>">
42
+ <input name="<?php echo $this->get_field_name('jarchive_type'); ?>" id="<?php echo $this->get_field_id('monthly'); ?>" type="radio" value="monthly" <?php checked($instance['jarchive_type'], 'monthly'); ?> />
43
+ <?php _e('monthly', 'ztjalali') ?>
44
+ </label>
45
+ <br/>
46
+ <label for="<?php echo $this->get_field_id('daily'); ?>">
47
+ <input name="<?php echo $this->get_field_name('jarchive_type'); ?>" id="<?php echo $this->get_field_id('daily'); ?>" type="radio" value="daily" <?php checked($instance['jarchive_type'], 'daily'); ?> />
48
+ <?php _e('daily', 'ztjalali') ?>
49
+ </label>
50
+ <br/>
51
+ <label for="<?php echo $this->get_field_id('postbypost'); ?>">
52
+ <input name="<?php echo $this->get_field_name('jarchive_type'); ?>" id="<?php echo $this->get_field_id('postbypost'); ?>" type="radio" value="postbypost" <?php checked($instance['jarchive_type'], 'postbypost'); ?> />
53
+ <?php _e('post by post', 'ztjalali') ?>
54
+ </label>
55
+ </p>
56
+ <p style="text-align:right">
57
+ <label for="<?php echo $this->get_field_id('jarchive_link_count'); ?>">
58
+ <?php _e('link count(zero to unlimit)', 'ztjalali') ?>:
59
+ <input style="width: 200px;" id="<?php echo $this->get_field_id('jarchive_link_count'); ?>" name="<?php echo $this->get_field_name('jarchive_link_count'); ?>" type="text" value="<?php echo $instance['jarchive_link_count']; ?>" />
60
+ </label>
61
+ </p>
62
+ <p style="text-align:right">
63
+ <label for="<?php echo $this->get_field_id('jarchive_show_post_count'); ?>">
64
+ <input name="<?php echo $this->get_field_name('jarchive_show_post_count'); ?>" type="checkbox" value="1" id="<?php echo $this->get_field_id('jarchive_show_post_count'); ?>" <?php checked($instance['jarchive_show_post_count'], TRUE); ?> />
65
+ <?php _e('show count of post (not work in post by post)', 'ztjalali') ?>
66
+ </label>
67
+ </p>
68
+ <p style="text-align:right">
69
+ <label for="<?php echo $this->get_field_id('dropdown'); ?>">
70
+ <input name="<?php echo $this->get_field_name('jarchive_dropdown'); ?>" type="checkbox" value="1" id="<?php echo $this->get_field_id('dropdown'); ?>" <?php checked($instance['jarchive_dropdown'], TRUE); ?> />
71
+ <?php _e('show dropdown list (not work in post by post)', 'ztjalali') ?>
72
+ </label>
73
+ </p>
74
+ </div>
75
+ <?php
76
+ }
77
+
78
+ public function update($new_instance, $old_instance) {
79
+ $instance = $old_instance;
80
+ $instance['jarchive_title'] = strip_tags($new_instance['jarchive_title']);
81
+ $instance['jarchive_type'] = strip_tags($new_instance['jarchive_type']);
82
+ $instance['jarchive_link_count'] = strip_tags($new_instance['jarchive_link_count']);
83
+ $instance['jarchive_show_post_count'] = (!empty($new_instance['jarchive_show_post_count']) ) ? TRUE : FALSE;
84
+ $instance['jarchive_dropdown'] = (!empty($new_instance['jarchive_dropdown']) ) ? TRUE : FALSE;
85
+ return $instance;
86
+ }
87
+
88
+ public function widget($args, $instance) {
89
+ if (!isset($instance['jarchive_title']))
90
+ $instance['jarchive_title'] = __('jalali archive', 'ztjalali');
91
+
92
+ if (!isset($instance['jarchive_type']))
93
+ $instance['jarchive_type'] = 'monthly';
94
+
95
+ if (!isset($instance['jarchive_link_count']))
96
+ $instance['jarchive_link_count'] = 12;
97
+
98
+ if (!isset($instance['jarchive_show_post_count']))
99
+ $instance['jarchive_show_post_count'] = TRUE;
100
+
101
+ if (!isset($instance['jarchive_dropdown']))
102
+ $instance['jarchive_dropdown'] = FALSE;
103
+
104
+
105
+ extract($args);
106
+ echo $before_widget;
107
+ echo $before_title . $instance['jarchive_title'] . $after_title;
108
+ if ($instance['jarchive_dropdown']) {
109
+ echo "<select name=\"jarchive-dropdown\" onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value=\"\">" . esc_attr($instance['jarchive_title']) . "</option>";
110
+ ztjalali_archive_widget($instance['jarchive_type'],'option',$instance['jarchive_show_post_count'],$instance['jarchive_link_count']);
111
+ echo "</select>";
112
+ } else {
113
+ echo '<ul>';
114
+ ztjalali_archive_widget($instance['jarchive_type'],'html',$instance['jarchive_show_post_count'],$instance['jarchive_link_count']);
115
+ echo '</ul>';
116
+ }
117
+
118
+ echo $after_widget;
119
+ }
120
+
121
+ }
122
+
123
+ /**
124
+ * widget handle action
125
+ */
126
+ add_action('widgets_init', 'register_ztjalali_archive');
127
+
128
+ function register_ztjalali_archive() {
129
+ register_widget('ztjalali_archive');
130
+ }
131
+
132
+ /* =================================================================== */
133
+ /**
134
+ * own widget function
135
+ */
136
+ function ztjalali_archive_widget($type ='monthly',$format='html',$show_post_count=false,$limit=12,$before='',$after='') {
137
+ global $wpdb, $jdate_month_name, $ztjalali_option;
138
+ if ($type === "yearly") {
139
+ $YearlyQry = $wpdb->get_results(
140
+ "SELECT DATE_FORMAT( post_date ,'%Y-%m' ) as date,
141
+ count(ID) as count,
142
+ YEAR(post_date) AS `year`,
143
+ MONTH(post_date) AS `month`,
144
+ DAYOFMONTH(post_date) AS `dayofmonth`
145
+ FROM $wpdb->posts
146
+ WHERE post_date < NOW()
147
+ AND post_type = 'post'
148
+ AND post_status = 'publish'
149
+ GROUP BY date ORDER BY post_date DESC");
150
+
151
+ if (!empty($YearlyQry)) {
152
+ $jYears = array();
153
+ $i = 1;
154
+ foreach ($YearlyQry as $res) {
155
+ $jalali_year = gregorian_to_jalali($res->year, $res->month, $res->dayofmonth);
156
+ $jYears[$jalali_year[0]]['year'] =$res->year ;
157
+ if (!array_key_exists('count', $jYears[$jalali_year[0]])) {
158
+ $jYears[$jalali_year[0]]['count'] = 0;
159
+ }
160
+ $jYears[$jalali_year[0]]['count'] +=$res->count ;
161
+ }
162
+ foreach ($jYears as $jYear =>$data) {
163
+ if ($ztjalali_option['change_url_date_to_jalali'])
164
+ $url = get_year_link($jYear);
165
+ else
166
+ $url = get_year_link($data['year']);
167
+
168
+ $jYear = ztjalali_persian_num($jYear);
169
+ $c_after = $show_post_count ? '&nbsp;(' . ztjalali_persian_num($data['count']) . ')' . $after : '';
170
+ echo get_archives_link($url, $jYear, $format, $before, $c_after);
171
+ if ($i == $limit)
172
+ break;
173
+ $i++;
174
+ }
175
+ }
176
+ } elseif ("monthly" == $type OR empty ($type)) {
177
+ $MonthlyQry = $wpdb->get_results(
178
+ "SELECT DATE_FORMAT( post_date ,'%Y-%m-%d' ) as date,
179
+ count(ID) as count,
180
+ YEAR(post_date) AS `year`,
181
+ MONTH(post_date) AS `month`,
182
+ DAYOFMONTH(post_date) AS `dayofmonth`
183
+ FROM $wpdb->posts
184
+ WHERE post_date < NOW()
185
+ AND post_type = 'post'
186
+ AND post_status = 'publish'
187
+ GROUP BY date ORDER BY post_date DESC");
188
+
189
+ if (!empty($MonthlyQry)) {
190
+ $jMonths = array();
191
+ foreach ($MonthlyQry as $res) {
192
+ $jalali_month = gregorian_to_jalali($res->year, $res->month, $res->dayofmonth);
193
+ $jMonths[$jalali_month[0].'-'.$jalali_month[1]]['year'] =$res->year ;
194
+ $jMonths[$jalali_month[0].'-'.$jalali_month[1]]['month'] =$res->month ;
195
+ if (!array_key_exists('count', $jMonths[$jalali_month[0].'-'.$jalali_month[1]])) {
196
+ $jMonths[$jalali_month[0].'-'.$jalali_month[1]]['count'] = 0;
197
+ }
198
+ $jMonths[$jalali_month[0].'-'.$jalali_month[1]]['count'] +=$res->count ;
199
+ }
200
+ $i = 1;
201
+ foreach ($jMonths as $jMonth =>$data) {
202
+ list($jY,$jM)= explode('-', $jMonth);
203
+ if ($ztjalali_option['change_url_date_to_jalali'])
204
+ $url = get_month_link($jY,$jM);
205
+ else
206
+ $url = get_month_link($data['year'],$data['month']);
207
+
208
+ $jY = ztjalali_persian_num($jY);
209
+ $jM = $jdate_month_name[$jM];
210
+ $c_after = $show_post_count ? '&nbsp;(' . ztjalali_persian_num($data['count']) . ')' . $after : '';
211
+ echo get_archives_link($url, $jM.' '.$jY, $format, $before, $c_after);
212
+ if ($i == $limit)
213
+ break;
214
+ $i++;
215
+ }
216
+ }
217
+ } elseif ("daily" == $type) {
218
+ $limStr = '';
219
+ if (!empty($limit)) {
220
+ $limit = (int) $limit;
221
+ $limStr = ' LIMIT ' . $limit;
222
+ }
223
+ $DailyQry = $wpdb->get_results(
224
+ "SELECT DATE_FORMAT( post_date ,'%Y-%m-%d' ) as date,
225
+ count(ID) as count,
226
+ YEAR(post_date) AS `year`,
227
+ MONTH(post_date) AS `month`,
228
+ DAYOFMONTH(post_date) AS `dayofmonth`
229
+ FROM $wpdb->posts
230
+ WHERE post_date < NOW()
231
+ AND post_type = 'post'
232
+ AND post_status = 'publish'
233
+ GROUP BY date ORDER BY post_date DESC ".$limStr);
234
+
235
+ if (!empty($DailyQry)) {
236
+ foreach ($DailyQry as $Daily) {
237
+ list($jY, $jM, $jD) = gregorian_to_jalali($Daily->year, $Daily->month, $Daily->dayofmonth);
238
+ if ($ztjalali_option['change_url_date_to_jalali'])
239
+ $url = get_day_link($jY, $jM, $jD);
240
+ else
241
+ $url = get_day_link($Daily->year, $Daily->month, $Daily->dayofmonth);
242
+
243
+ $date = mktime(0, 0, 0, $Daily->month, $Daily->dayofmonth, $Daily->year);
244
+ $text = jdate(get_option('date_format'), $date);
245
+ if ($show_post_count)
246
+ $c_after = '&nbsp;(' . ztjalali_persian_num($Daily->count) . ')' . $after;
247
+ echo get_archives_link($url, $text, $format, $before, $c_after);
248
+ }
249
+ }
250
+ } elseif ('postbypost' == $type) {
251
+ $limStr = '';
252
+ if (!empty($limit)) {
253
+ $limit = (int) $limit;
254
+ $limStr = ' LIMIT ' . $limit;
255
+ }
256
+ $byPosts = $wpdb->get_results("SELECT ID, post_date, post_title FROM $wpdb->posts WHERE post_type='post' AND post_date < NOW() AND post_status = 'publish' ORDER BY post_date DESC" . $limStr);
257
+ if (!empty($byPosts)) {
258
+ foreach ($byPosts as $aPost) {
259
+ if ($aPost->post_date != '0000-00-00 00:00:00') {
260
+ $url = get_permalink($aPost->ID);
261
+ echo get_archives_link($url, strip_tags($aPost->post_title), $format, $before, $after);
262
+ }
263
+ }
264
+ }
265
+ }
266
+ }
267
+ ?>
widget/widget_calendar.php ADDED
@@ -0,0 +1,320 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ztjalali_calendar extends WP_Widget {
4
+
5
+ function __construct() {
6
+ parent::__construct(
7
+ 'ztjalali_calendar', __('jalali calendar', 'ztjalali'), array('description' => __('jalali calendar widget', 'ztjalali'),)
8
+ );
9
+ }
10
+
11
+ public function form($instance) {
12
+ if (!isset($instance['jcalendar_title']))
13
+ $instance['jcalendar_title'] = __('jalali calendar', 'ztjalali');
14
+ if (!isset($instance['jcalendar_short_weekname']))
15
+ $instance['jcalendar_short_weekname'] = TRUE;
16
+ ?>
17
+ <div dir="rtl" align="justify">
18
+ <p style="text-align:right">
19
+ <label for="<?php echo $this->get_field_id('jcalendar_title'); ?>">
20
+ <?php _e('title', 'ztjalali') ?>:
21
+ <input style="width: 200px;" id="<?php echo $this->get_field_id('jcalendar_title'); ?>" name="<?php echo $this->get_field_name('jcalendar_title'); ?>" type="text" value="<?php echo $instance['jcalendar_title']; ?>" />
22
+ </label>
23
+ </p>
24
+ <p style="text-align:right">
25
+ <label for="<?php echo $this->get_field_id('jcalendar_short_weekname'); ?>">
26
+ <input name="<?php echo $this->get_field_name('jcalendar_short_weekname'); ?>" type="checkbox" value="1" id="<?php echo $this->get_field_id('jcalendar_short_weekname'); ?>" <?php checked($instance['jcalendar_short_weekname'], TRUE); ?> />
27
+ <?php _e('jcalendar short name of week', 'ztjalali') ?>
28
+ </label>
29
+ </p>
30
+ </div>
31
+ <?php
32
+ }
33
+
34
+ public function update($new_instance, $old_instance) {
35
+ $instance = $old_instance;
36
+ $instance['jcalendar_title'] = strip_tags($new_instance['jcalendar_title']);
37
+ $instance['jcalendar_short_weekname'] = (!empty($new_instance['jcalendar_short_weekname']) ) ? TRUE : FALSE;
38
+ return $instance;
39
+ }
40
+
41
+ public function widget($args, $instance) {
42
+ if (!isset($instance['jcalendar_title']))
43
+ $instance['jcalendar_title'] = __('jalali calendar', 'ztjalali');
44
+ if (!isset($instance['jcalendar_short_weekname']))
45
+ $instance['jcalendar_short_weekname'] = TRUE;
46
+ extract($args);
47
+ echo $before_widget;
48
+ echo $before_title . $instance['jcalendar_title'] . $after_title;
49
+ ztjalali_calendar_widget($instance['jcalendar_short_weekname'], TRUE);
50
+ echo $after_widget;
51
+ }
52
+
53
+ }
54
+
55
+ /**
56
+ * widget handle action
57
+ */
58
+ add_action('widgets_init', 'register_ztjalali_calendar');
59
+
60
+ function register_ztjalali_calendar() {
61
+ register_widget('ztjalali_calendar');
62
+ }
63
+
64
+ /* =================================================================== */
65
+
66
+ /**
67
+ * own widget function
68
+ */
69
+ function ztjalali_calendar_widget($shortname = TRUE, $echo = TRUE, $thisyear = 0, $thismonth = 0) {
70
+ global $wpdb, $posts, $wp;
71
+ global $jdate_month_name, $ztjalali_option;
72
+
73
+ if (isset($wp->query_vars['m'])) {
74
+ $m_year= (int)(substr($wp->query_vars['m'],0, 4));
75
+ $m_month= (int)(substr($wp->query_vars['m'], 4,2));
76
+ if($m_year < 1700){
77
+ list($m_year,$m_month,$tmp_day) = jalali_to_gregorian($m_year, $m_month, 15);
78
+ }
79
+ }
80
+ elseif (isset($wp->query_vars['m']))
81
+ $thisyear =(int)(substr($wp->query_vars['m'],0, 4));
82
+
83
+ if (empty($thisyear)) {
84
+ if (isset($wp->query_vars['year']))
85
+ $thisyear = (int)$wp->query_vars['year'];
86
+ elseif (isset($m_year))
87
+ $thisyear =$m_year;
88
+ else
89
+ $thisyear = date('Y', time());
90
+ }
91
+ if (empty($thismonth)) {
92
+ if (isset($wp->query_vars['monthnum']))
93
+ $thismonth = (int)$wp->query_vars['monthnum'];
94
+ elseif (isset($m_month))
95
+ $thismonth =$m_month;
96
+ else
97
+ $thismonth = date('m', time());
98
+ }
99
+
100
+
101
+ //doing: support $_GET['w']
102
+ // if (isset($_GET['w']))
103
+ // $w = '' . (int)($_GET['w']);
104
+ // if (!empty($w)) {
105
+ //// We need to get the month from MySQL
106
+ // $thisyear = '' . (int)(substr($m, 0, 4));
107
+ // $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
108
+ // $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
109
+ // }
110
+
111
+ /* doing : cache */
112
+ $cache = array();
113
+ $key = md5( $thismonth . $thisyear);
114
+ if ($cache = wp_cache_get('ztjalali_calendar', 'calendar')) {
115
+ if (is_array($cache) && isset($cache[$key])) {
116
+ if ($echo) {
117
+ /** This filter is documented in wp-includes/general-template.php */
118
+ echo apply_filters('ztjalali_calendar', $cache[$key]);
119
+ return;
120
+ } else {
121
+ /** This filter is documented in wp-includes/general-template.php */
122
+ return apply_filters('ztjalali_calendar', $cache[$key]);
123
+ }
124
+ }
125
+ }
126
+
127
+ if (!is_array($cache))
128
+ $cache = array();
129
+ // Quick check. If we have no posts at all, abort!
130
+ if (!$posts) {
131
+ $gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
132
+ if (!$gotsome) {
133
+ $cache[$key] = '';
134
+ wp_cache_set('ztjalali_calendar', $cache, 'calendar');
135
+ return;
136
+ }
137
+ }
138
+
139
+ if($thisyear>1700){
140
+ list($thisyear,$thismonth,$thisday)= gregorian_to_jalali($thisyear, $thismonth, 1);
141
+ }
142
+ $unixmonth = jmktime(0, 0, 0, $thismonth, 1, $thisyear);
143
+ $jthisyear = $thisyear;
144
+ $jthismonth = $thismonth;
145
+ list($thisyear,$thismonth,$jthisday)= jalali_to_gregorian($jthisyear, $jthismonth, 1);
146
+
147
+ $last_day = jdate('t', $unixmonth,FALSE,FALSE);
148
+
149
+ // Get the next and previous month and year with at least one post
150
+ $startdate = date("Y:m:d", jmktime(0, 0, 0, $jthismonth, 1, $jthisyear));
151
+ $enddate = date("Y:m:d", jmktime(23, 59, 59, $jthismonth, $last_day, $jthisyear));
152
+
153
+ $previous = $wpdb->get_row("SELECT DAYOFMONTH(post_date) AS `dayofmonth`,MONTH(post_date) AS month, YEAR(post_date) AS year
154
+ FROM $wpdb->posts
155
+ WHERE post_date < '$startdate'
156
+ AND post_type = 'post' AND post_status = 'publish'
157
+ ORDER BY post_date DESC
158
+ LIMIT 1");
159
+ $next = $wpdb->get_row("SELECT DAYOFMONTH(post_date) AS `dayofmonth`,MONTH(post_date) AS month, YEAR(post_date) AS year
160
+ FROM $wpdb->posts
161
+ WHERE post_date > '$enddate 23:59:59'
162
+ AND post_type = 'post' AND post_status = 'publish'
163
+ ORDER BY post_date ASC
164
+ LIMIT 1");
165
+ /* translators: Calendar caption: 1: month name, 2: 4-digit year */
166
+ $calendar_caption = _x('%1$s %2$s', 'calendar caption');
167
+ $calendar_output = '<table id="wp-calendar" class="widget_calendar">
168
+ <caption>' . sprintf($calendar_caption, $jdate_month_name[(int)$jthismonth], jdate('Y', $unixmonth)) . '</caption>
169
+ <thead>
170
+ <tr>';
171
+
172
+ $myweek =$myshortweek = array();
173
+
174
+ $week_begins = (int)(get_option('start_of_week'));
175
+
176
+
177
+ for ($wdcount = 0; $wdcount <= 6; $wdcount++) {
178
+ $myweek[] = ztjalali_get_week_name(($wdcount + $week_begins) % 7);
179
+ $myshortweek[] = ztjalali_get_short_week_name(($wdcount + $week_begins) % 7);
180
+ }
181
+
182
+ foreach ($myweek as $k=>$wd) {
183
+ $day_name = (true == $shortname) ? $myshortweek[$k] :$wd;
184
+ $wd = esc_attr($wd);
185
+ $calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
186
+ }
187
+
188
+ $calendar_output .= '
189
+ </tr>
190
+ </thead>
191
+
192
+ <tfoot>
193
+ <tr>';
194
+
195
+ if ($previous) {
196
+ $jprevious=gregorian_to_jalali($previous->year, $previous->month, $previous->dayofmonth);
197
+ if ($ztjalali_option['change_url_date_to_jalali'])
198
+ $calendar_output .= "\n\t\t" . '<td colspan="3" id="prev"><a href="' . get_month_link($jprevious[0],$jprevious[1]) . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s','ztjalali'), $jdate_month_name[$jprevious[1]], jdate('Y', mktime(0, 0, 0, $previous->month, 1, $previous->year)))) . '">&laquo; ' . $jdate_month_name[$jprevious[1]] . '</a></td>';
199
+ else
200
+ $calendar_output .= "\n\t\t" . '<td colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s','ztjalali'), $jdate_month_name[$jprevious[1]], jdate('Y', mktime(0, 0, 0, $previous->month, 1, $previous->year)))) . '">&laquo; ' . $jdate_month_name[$jprevious[1]] . '</a></td>';
201
+ } else {
202
+ $calendar_output .= "\n\t\t" . '<td colspan="3" id="prev" class="pad">&nbsp;</td>';
203
+ }
204
+
205
+ $calendar_output .= "\n\t\t" . '<td class="pad">&nbsp;</td>';
206
+
207
+ if ($next) {
208
+ $jnext=gregorian_to_jalali($next->year, $next->month, $next->dayofmonth);
209
+ if ($ztjalali_option['change_url_date_to_jalali'])
210
+ $calendar_output .= "\n\t\t" . '<td colspan="3" id="next"><a href="' . get_month_link($jnext[0], $jnext[1]) . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s','ztjalali'), $jdate_month_name[$jnext[1]], jdate('Y', mktime(0, 0, 0, $next->month, 1, $next->year)))) . '">' . $jdate_month_name[$jnext[1]] . ' &raquo;</a></td>';
211
+ else
212
+ $calendar_output .= "\n\t\t" . '<td colspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s','ztjalali'), $jdate_month_name[$jnext[1]], jdate('Y', mktime(0, 0, 0, $next->month, 1, $next->year)))) . '">' . $jdate_month_name[$jnext[1]] . ' &raquo;</a></td>';
213
+ } else {
214
+ $calendar_output .= "\n\t\t" . '<td colspan="3" id="next" class="pad">&nbsp;</td>';
215
+ }
216
+
217
+ $calendar_output .= '
218
+ </tr>
219
+ </tfoot>
220
+
221
+ <tbody>
222
+ <tr>';
223
+
224
+ // Get days with posts
225
+ $dayswithposts = $wpdb->get_results("SELECT DISTINCT post_date
226
+ FROM $wpdb->posts WHERE post_date >= '$startdate 00:00:00'
227
+ AND post_type = 'post' AND post_status = 'publish'
228
+ AND post_date <= '$enddate 23:59:59'", ARRAY_N);
229
+ if ($dayswithposts) {
230
+ foreach ((array) $dayswithposts as $daywith) {
231
+ $jdaywithpost[] = jdate('j', strtotime($daywith[0]),FALSE,FALSE);
232
+ }
233
+ } else {
234
+ $jdaywithpost = array();
235
+ }
236
+
237
+ if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
238
+ $ak_title_separator = "\n";
239
+ else
240
+ $ak_title_separator = ', ';
241
+
242
+ $ak_titles_for_day = array();
243
+ $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, post_date as dom "
244
+ . "FROM $wpdb->posts "
245
+ . "WHERE post_date >= '$startdate 00:00:00' "
246
+ . "AND post_date <= '$enddate 23:59:59' "
247
+ . "AND post_type = 'post' AND post_status = 'publish'"
248
+ );
249
+ if ($ak_post_titles) {
250
+ foreach ((array) $ak_post_titles as $ak_post_title) {
251
+
252
+ /** This filter is documented in wp-includes/post-template.php */
253
+ $post_title = esc_attr(apply_filters('the_title', $ak_post_title->post_title, $ak_post_title->ID));
254
+ $jdom = $jdaywithpost[] = jdate('j', strtotime( $ak_post_title->dom),FALSE,FALSE);
255
+ if (empty($ak_titles_for_day['day_' . $jdom]))
256
+ $ak_titles_for_day['day_' . $jdom] = '';
257
+ if (empty($ak_titles_for_day["$jdom"])) // first one
258
+ $ak_titles_for_day["$jdom"] = $post_title;
259
+ else
260
+ $ak_titles_for_day["$jdom"] .= $ak_title_separator . $post_title;
261
+ }
262
+ }
263
+ // See how much we should pad in the beginning
264
+ $pad = calendar_week_mod(jdate('w', $unixmonth, false, false) - $week_begins);
265
+ $pad--;
266
+ if ($pad < 0)
267
+ $pad = 6;
268
+
269
+ if (0 != $pad)
270
+ $calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr($pad) . '" class="pad">&nbsp;</td>';
271
+
272
+ $jdaysinmonth = (int)(jdate('t', $unixmonth,FALSE,FALSE));
273
+ for ($jday = 1; $jday <= $jdaysinmonth; ++$jday) {
274
+ if (isset($newrow) && $newrow)
275
+ $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
276
+ $newrow = false;
277
+ if ($jday == jdate('j', time(),FALSE,FALSE) && $jthismonth == jdate('m', time(),FALSE,FALSE) && $jthisyear == jdate('Y', time(),FALSE,FALSE))
278
+ $calendar_output .= '<td id="today">';
279
+ else
280
+ $calendar_output .= '<td>';
281
+
282
+ if (in_array($jday, $jdaywithpost)){ // any posts today?
283
+ $day = jalali_to_gregorian($jthisyear, $jthismonth, $jday);
284
+ if ($ztjalali_option['change_url_date_to_jalali'])
285
+ $calendar_output .= '<a href="' . get_day_link($jthisyear, $jthismonth, $jday) . '" title="' . esc_attr($ak_titles_for_day[$jday]) . "\">$jday</a>";
286
+ else
287
+ $calendar_output .= '<a href="' . get_day_link($day[0], $day[1], $day[2]) . '" title="' . esc_attr($ak_titles_for_day[$jday]) . "\">$jday</a>";
288
+ }else
289
+ $calendar_output .= $jday;
290
+ $calendar_output .= '</td>';
291
+ jdate('w', jmktime(0, 0, 0, $jthismonth, $jday, $jthisyear),FALSE,FALSE);
292
+ if (6 == calendar_week_mod(date('w', jmktime(0, 0, 0, $jthismonth, $jday, $jthisyear)) - $week_begins))
293
+ $newrow = true;
294
+ }
295
+
296
+ $pad = 7 - calendar_week_mod(date('w', jmktime(0, 0, 0, $jthismonth, $jday, $jthisyear)) - $week_begins);
297
+ if ($pad != 0 && $pad != 7)
298
+ $calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr($pad) . '">&nbsp;</td>';
299
+
300
+ $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
301
+
302
+ $cache[$key] = $calendar_output;
303
+ wp_cache_set('ztjalali_calendar', $cache, 'calendar');
304
+
305
+ if ($echo) {
306
+ /**
307
+ * Filter the HTML calendar output.
308
+ *
309
+ * @since 3.0.0
310
+ *
311
+ * @param string $calendar_output HTML output of the calendar.
312
+ */
313
+ echo apply_filters('ztjalali_calendar', $calendar_output);
314
+ } else {
315
+ /** This filter is documented in wp-includes/general-template.php */
316
+ return apply_filters('ztjalali_calendar', $calendar_output);
317
+ }
318
+ }
319
+
320
+ ?>
wp-jalali-config.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * set default plugin options
4
+ * this config use in install moment.
5
+ */
6
+ return array(
7
+ 'force_locale' => FALSE,
8
+ 'force_timezone' => FALSE, //doing: test
9
+
10
+ 'change_date_to_jalali' => TRUE,
11
+ 'change_jdate_number_to_persian' => TRUE,
12
+ 'change_url_date_to_jalali' => FALSE,
13
+ 'afghan_month_name' => FALSE,
14
+
15
+ 'change_title_number_to_persian' => TRUE,
16
+ 'change_content_number_to_persian' => TRUE,
17
+ 'change_excerpt_number_to_persian' => TRUE,
18
+ 'change_comment_number_to_persian' => TRUE,
19
+ 'change_commentcount_number_to_persian' => FALSE,
20
+ 'change_category_number_to_persian' => FALSE,
21
+ 'change_point_to_persian' => TRUE,
22
+
23
+ 'change_arabic_to_persian' => FALSE,
24
+ 'change_archive_title' => TRUE,
25
+
26
+ 'save_changes_in_db' => FALSE,
27
+
28
+ 'ztjalali_admin_style' => FALSE,
29
+ 'persian_planet' => TRUE,
30
+ );
wp-jalali-functions.php ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * preg_replace callback for convert number to farsi
5
+ * @global array $ztjalali_option
6
+ * @param string $matches
7
+ * @return string
8
+ * @since 5.0.0
9
+ */
10
+ function ztjalali_convertToFarsi($matches) {
11
+ global $ztjalali_option;
12
+ if ($ztjalali_option['change_point_to_persian'])
13
+ $farsi_array = array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", "٫");
14
+ else
15
+ $farsi_array = array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", ".");
16
+
17
+ $english_array = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".");
18
+
19
+ $out = '';
20
+ if (isset($matches[1])) {
21
+ return str_replace($english_array, $farsi_array, $matches[1]);
22
+ }
23
+ return $matches[0];
24
+ }
25
+ /* =================================================================== */
26
+
27
+ /**
28
+ * preg_replace for convert number to farsi
29
+ * @param string $content
30
+ * @return string
31
+ * @since 5.0.0
32
+ */
33
+ function ztjalali_ch_number_to_persian($content) {
34
+ return preg_replace_callback('/(?:&#\d{2,4};)|(\d+[\.\d]*)|(?:[a-z](?:[\x00-\x3B\x3D-\x7F]|<\s*[^>]+>)*)|<\s*[^>]+>/i', 'ztjalali_convertToFarsi', $content);
35
+ }
36
+ /* =================================================================== */
37
+
38
+ /**
39
+ * convert persian number to latin number
40
+ * @global array $ztjalali_option
41
+ * @param string $str
42
+ * @return string
43
+ * @since 5.0.0
44
+ */
45
+ function ztjalali_english_num($str) {
46
+ global $ztjalali_option;
47
+ if ($ztjalali_option['change_point_to_persian'])
48
+ $farsi_array = array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", "٫");
49
+ else
50
+ $farsi_array = array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", ".");
51
+
52
+ $english_array = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".");
53
+
54
+ return str_replace($farsi_array, $english_array, $str);
55
+ }
56
+ /* =================================================================== */
57
+
58
+ /**
59
+ * convert latin number to persin number
60
+ * @global array $ztjalali_option
61
+ * @param string $str
62
+ * @return string
63
+ * @since 5.0.0
64
+ */
65
+ function ztjalali_persian_num($str) {
66
+ global $ztjalali_option;
67
+ if ($ztjalali_option['change_point_to_persian'])
68
+ $farsi_array = array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", "٫");
69
+ else
70
+ $farsi_array = array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", ".");
71
+
72
+ $english_array = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".");
73
+
74
+ return str_replace($english_array, $farsi_array, $str);
75
+ }
76
+ /* =================================================================== */
77
+
78
+ /**
79
+ * convert arabic char to persian
80
+ * @param string $content
81
+ * @return string
82
+ * @since 5.0.0
83
+ */
84
+ function ztjalali_ch_arabic_to_persian($content) {
85
+ return str_replace(array('ي', 'ك', '٤', '٥', '٦', 'ة'), array('ی', 'ک', '۴', '۵', '۶', 'ه'), $content);
86
+ }
87
+ /* =================================================================== */
88
+
89
+ /**
90
+ * return week name
91
+ * @param int $gWeek
92
+ * @return string
93
+ * @since 5.0.0
94
+ */
95
+ function ztjalali_get_week_name($gWeek = 0) {
96
+ static $jdate_week_name = array('شنبه', 'یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنج شنبه', 'جمعه');
97
+ $jWeek = $gWeek + 1;
98
+ if ($jWeek >= 7)
99
+ $jWeek = 0;
100
+ return $jdate_week_name[$jWeek];
101
+ }
102
+ /* =================================================================== */
103
+
104
+ /**
105
+ * return short week name
106
+ * @param int $gWeek
107
+ * @return string
108
+ * @since 5.0.0
109
+ */
110
+ function ztjalali_get_short_week_name($gWeek = 0) {
111
+ static $jdate_short_week_name = array("ش", "ی", "د", "س", "چ", "پ", "ج");
112
+ $jWeek = $gWeek + 1;
113
+ if ($jWeek >= 7)
114
+ $jWeek = 0;
115
+ return $jdate_short_week_name[$jWeek];
116
+ }
117
+ /* =================================================================== */
118
+
119
+ /**
120
+ * return link of jalali year
121
+ * @param int $year year
122
+ * @return string
123
+ * @since 5.0.0
124
+ */
125
+ function ztjalali_year_link($year) {
126
+ global $ztjalali_option;
127
+ if ($ztjalali_option['change_url_date_to_jalali']) {
128
+ $jdate = gregorian_to_jalali($year, 6, 15);
129
+ return get_year_link($jdate[0]);
130
+ }
131
+ return get_year_link($year);
132
+ }
133
+ /* =================================================================== */
134
+
135
+ /**
136
+ * return link of jalali month
137
+ * @param int $year year
138
+ * @param int $month month
139
+ * @return string
140
+ * @since 5.0.0
141
+ */
142
+ function ztjalali_month_link($year, $month) {
143
+ global $ztjalali_option;
144
+ if ($ztjalali_option['change_url_date_to_jalali']) {
145
+ $jdate = gregorian_to_jalali($year, $month, 15);
146
+ return get_month_link($jdate[0], $jdate[1]);
147
+ }
148
+ return get_month_link($year, $month);
149
+ }
150
+ /* =================================================================== */
151
+
152
+ /**
153
+ * return link of jalali day
154
+ * @param int $year year
155
+ * @param int $month month
156
+ * @param int $day day
157
+ * @return string
158
+ * @since 5.0.0
159
+ */
160
+ function ztjalali_day_link($year, $month, $day) {
161
+ global $ztjalali_option;
162
+ if ($ztjalali_option['change_url_date_to_jalali']) {
163
+ $jdate = gregorian_to_jalali($year, $month, $day);
164
+ return get_month_link($jdate[0], $jdate[1], $jdate[2]);
165
+ }
166
+ return get_month_link($year, $month, $day);
167
+ }
168
+ /* =================================================================== */
wp-jalali-init.php ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * plugin installer
5
+ */
6
+ function ztjalali_installer() {
7
+ $options = get_option('ztjalali_options');
8
+ if (empty($options)) {
9
+ if (!($options = ztjalali_get_old_options()))
10
+ $options = include JALALI_DIR . 'wp-jalali-config.php';
11
+ add_option('ztjalali_options', json_encode($options));
12
+ }
13
+ add_option('ztjalali_do_activation_redirect', true);
14
+
15
+ }
16
+
17
+ /* =================================================================== */
18
+
19
+ function ztjalali_get_old_options() {
20
+ $old_versions = array('4.1', '4.0', '3.9', '3.8', '3.7', '3.6', '3.5');
21
+ foreach ($old_versions as $old_ver) {
22
+ $mps_jd_optionsDB = get_option('mps_jd_options_' . $old_ver);
23
+ if (!empty($mps_jd_optionsDB))
24
+ break;
25
+ }
26
+ if (empty($mps_jd_optionsDB))
27
+ return false;
28
+ /* ------------------------------------------------------ */
29
+ return array(
30
+ 'force_locale' => FALSE,
31
+ 'force_timezone' => FALSE, //doing: test
32
+ 'change_date_to_jalali' => ($mps_jd_optionsDB['mps_jd_autodate']) ? TRUE : FALSE,
33
+ 'change_jdate_number_to_persian' => ($mps_jd_optionsDB['mps_jd_farsinum_date']) ? TRUE : FALSE,
34
+ 'change_url_date_to_jalali' => ($mps_jd_optionsDB['mps_jd_jperma']) ? TRUE : FALSE,
35
+ 'afghan_month_name' => ($mps_jd_optionsDB['mps_jd_country'] == 'AF') ? TRUE : FALSE,
36
+ 'change_title_number_to_persian' => ($mps_jd_optionsDB['mps_jd_farsinum_title']) ? TRUE : FALSE,
37
+ 'change_content_number_to_persian' => ($mps_jd_optionsDB['mps_jd_farsinum_content']) ? TRUE : FALSE,
38
+ 'change_excerpt_number_to_persian' => ($mps_jd_optionsDB['mps_jd_farsinum_content']) ? TRUE : FALSE,
39
+ 'change_comment_number_to_persian' => ($mps_jd_optionsDB['mps_jd_farsinum_comment']) ? TRUE : FALSE,
40
+ 'change_commentcount_number_to_persian' => ($mps_jd_optionsDB['mps_jd_farsinum_commentnum']) ? TRUE : FALSE,
41
+ 'change_category_number_to_persian' => ($mps_jd_optionsDB['mps_jd_farsinum_category']) ? TRUE : FALSE,
42
+ 'change_point_to_persian' => TRUE,
43
+ 'change_arabic_to_persian' => ($mps_jd_optionsDB['mps_jd_autoyk']) ? TRUE : FALSE,
44
+ 'change_archive_title' => ($mps_jd_optionsDB['mps_jd_farsinum_title']) ? TRUE : FALSE,
45
+ 'save_changes_in_db' => FALSE,
46
+ 'ztjalali_admin_style' => FALSE,
47
+ 'persian_planet' => TRUE,
48
+ );
49
+ }
50
+
51
+ /**
52
+ * init function
53
+ * @global type $ztjalali_option
54
+ * @global type $jdate_month_name
55
+ * @global array $ztjalali_wpoption
56
+ */
57
+ function ztjalali_init() {
58
+ /**
59
+ * define global variables
60
+ */
61
+ global $ztjalali_option;
62
+ global $jdate_month_name;
63
+
64
+ /**
65
+ * load options
66
+ */
67
+ $OPT = get_option('ztjalali_options');
68
+ $ztjalali_option = json_decode($OPT, TRUE);
69
+ /* =================================================================== */
70
+
71
+ /**
72
+ * set global variables value
73
+ */
74
+ if (isset($ztjalali_option['afghan_month_name']) && $ztjalali_option['afghan_month_name'])
75
+ $jdate_month_name = array("", "حمل", "ثور", "جوزا", "سرطان", "اسد", "سنبله", "میزان", "عقرب", "قوس", "جدی", "دلو", "حوت");
76
+ else
77
+ $jdate_month_name = array('', 'فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند');
78
+ }
79
+
80
+ /* =================================================================== */
81
+
82
+ /**
83
+ * Setup language text domain
84
+ */
85
+ load_plugin_textdomain('ztjalali', false, basename(dirname(__FILE__)).'/languages');
86
+ /* =================================================================== */
87
+
88
+
89
+ /**
90
+ * Setup plugin page option link
91
+ */
92
+ function ztjalali_add_settings_link( $links ) {
93
+ $settings_link = '<a href="'.menu_page_url('ztjalali_admin_page',FALSE).'">'.__('setting','ztjalali').'</a>';
94
+ Array_unshift( $links, $settings_link );
95
+ return $links;
96
+ }
97
+
98
+ /* =================================================================== */
99
+
100
+
101
+
102
+ /**
103
+ * Enqueue styles & scripts
104
+ */
105
+ // site -------------------------
106
+ //add_action('wp_enqueue_scripts', 'ztjalali_reg_css_and_js');
107
+ //function ztjalali_reg_css_and_js() {
108
+ // wp_register_style('ztjalali_reg_style', plugins_url('assets/css/style.css', __FILE__));
109
+ // wp_enqueue_style('ztjalali_reg_style');
110
+ // wp_enqueue_script('ztjalali_reg_js', plugins_url('assets/js/js.js', __FILE__), array('jquery'));
111
+ //}
112
+ //admin -------------------------
113
+ add_action('admin_enqueue_scripts', 'ztjalali_reg_admin_css_and_js');
114
+
115
+ function ztjalali_reg_admin_css_and_js() {
116
+ global $ztjalali_option;
117
+ wp_register_style('ztjalali_reg_admin_style', plugins_url('assets/css/admin.css', __FILE__));
118
+ wp_enqueue_style('ztjalali_reg_admin_style');
119
+
120
+ if (isset($ztjalali_option['ztjalali_admin_style']) && $ztjalali_option['ztjalali_admin_style']){
121
+ wp_register_style('ztjalali_reg_custom_admin_style', plugins_url('assets/css/admin_style.css', __FILE__));
122
+ wp_enqueue_style('ztjalali_reg_custom_admin_style');
123
+ }
124
+
125
+ add_editor_style(plugins_url('assets/css/wysiwyg.css', __FILE__));
126
+ wp_enqueue_script('ztjalali_reg_date_js', plugins_url('assets/js/date.js', __FILE__));
127
+ if (isset($ztjalali_option['afghan_month_name']) && $ztjalali_option['afghan_month_name'])
128
+ wp_enqueue_script('ztjalali_reg_admin_js', plugins_url('assets/js/admin-af.js', __FILE__), array('jquery'));
129
+ else
130
+ wp_enqueue_script('ztjalali_reg_admin_js', plugins_url('assets/js/admin-ir.js', __FILE__), array('jquery'));
131
+ }
132
+
133
+ //theme editiong style -----------------
134
+ add_action('admin_print_styles-plugin-editor.php', 'ztjalali_reg_theme_editor_css_and_js', 11);
135
+ add_action('admin_print_styles-theme-editor.php', 'ztjalali_reg_theme_editor_css_and_js', 11);
136
+
137
+ function ztjalali_reg_theme_editor_css_and_js() {
138
+ wp_register_style('ztjalali_reg_theme_editor_style', plugins_url('assets/css/theme_editing.css', __FILE__));
139
+ wp_enqueue_style('ztjalali_reg_theme_editor_style');
140
+ }
141
+
142
+ /* =================================================================== */
143
+
144
+ /**
145
+ * Login Form modifiers
146
+ */
147
+ //add_filter('login_headerurl', 'ztjalali_login_url', 111);
148
+ add_filter('login_headertitle', 'ztjalali_login_text', 111);
149
+ //add_action('login_head', 'ztjalali_login_img', 111);
150
+
151
+ function ztjalali_login_url() {
152
+ return 'http://wp-persian.com';
153
+ }
154
+
155
+ function ztjalali_login_text() {
156
+ return __('Powered BY persian wordpress', 'ztjalali');
157
+ }
158
+
159
+ function ztjalali_login_img() {
160
+ echo '<style>#login h1 a {background: transparent url(' . plugins_url('assets/img/wp-jalali-80x80.png', __FILE__) . ') no-repeat scroll center top}</style>';
161
+ }
162
+
163
+ /* =================================================================== */
wp-jalali.php CHANGED
@@ -1,1443 +1,87 @@
1
- <?php
2
- /*
3
- Plugin Name: wp-jalali
4
- Plugin URI: http://wp-persian.com/plugins/wp-jalali/
5
- Description: Full Jalali Date and Persian(Farsi) Support Package for wordpress, Full posts' and comments' dates convertion , Jalali Archive , Magic(Jalali/Gregorian) Calendar and Jalali/Gregorian Compaitables Permalinks, TinyMCE RTL/LTR activation, TinyMCE Persian Improvement, Cross browser Perisan keyboard support, Jalali Archive/Calendar widgets and Persian numbers, Great tool for Persian(Iranian) Users of WordPress, part of <a href="http://wp-persian.com" title="پروژه وردپرس فارسی">Persian Wordpress Project</a>.
6
- Version: 4.5.3
7
- Author: Mani Monajjemi
8
- Author URI: http://www.manionline.org/
9
- */
10
-
11
- /* Copyright 2005-2013 Wordpress Persian Project (email : info@wp-persian.com)
12
-
13
- This program is free software; you can redistribute it and/or modify
14
- it under the terms of the GNU General Public License as published by
15
- the Free Software Foundation; either version 2 of the License, or
16
- (at your option) any later version.
17
-
18
- This program is distributed in the hope that it will be useful,
19
- but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
- GNU General Public License for more details.
22
-
23
- You should have received a copy of the GNU General Public License
24
- along with this program; if not, write to the Free Software
25
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
- */
27
-
28
- /*
29
- Special Thanks to :
30
- * Wordpress Persian Team members (wp-persian.com)
31
- * Farsiweb.info for J2G and G2J Converstion Functions
32
- * Milad Raastian (miladmovie.com) for JDF (jdf.farsiprojects.com)
33
- * Nima Shyanfar (phpmystery.com) for Fast Farsi Number Conversion Method
34
- * Gonahkar (gonahkar.com) for WP-Jalali widgets plugin (gonahkar.com/archives/2007/02/26/wp-jalali-widgets-plugin/ ), edit jalali timestamp in write/edit panel and [arabic] writing shortcode.
35
- * Kaveh Ahmadi (ashoob.net/kaveh) for his valuable Farsi Keyboard Script (ashoob.net/farsitype)
36
- * Ali Sattari(corelist.net) for great support
37
- * Ali Farhadi (farhadi.ir) for improving Farsi Number Convertor.
38
- * Reza Moallemi (moallemi.ir) for Jalali date in tables.
39
- */
40
-
41
- define("MPS_JD_VER","4.1");
42
- define('MPS_JD_OPTIONS_NAME', "mps_jd_options"."_".MPS_JD_VER); // Name of the Option stored in the DB
43
- define('MPS_JD_DIR', dirname(__FILE__));
44
- define('MPS_JD_URI', get_option('siteurl').'/wp-content/plugins/wp-jalali');
45
-
46
- require_once(MPS_JD_DIR.'/inc/jalali-core.php');
47
- require_once(MPS_JD_DIR.'/inc/deprecated.php');
48
- require_once(MPS_JD_DIR.'/inc/yk-core.php');
49
- require_once(MPS_JD_DIR.'/inc/farsinum-core.php');
50
- require_once(MPS_JD_DIR.'/inc/dashboard-core.php');
51
- require_once(MPS_JD_DIR.'/inc/widgets-core.php');
52
- require_once(MPS_JD_DIR.'/inc/editjalali-core.php');
53
- //require_once(MPS_JD_DIR.'/inc/tables-date.php');
54
- //require_once(MPS_JD_DIR.'/inc/tinymce-button.php');
55
-
56
- /* Menu Init */
57
-
58
- function mps_jd_menu(){
59
- /*
60
- mps_jd_farsinum_XXX :: Toggle Persian numbers in dates
61
- mps_jd_mcertl :: Toggle TinyMCE Editor RTL / LTR
62
- mps_jd_jperma :: Toggle Jalali Permalinks on/off (For posts)
63
-
64
- */
65
- if(function_exists('add_options_page')) {
66
- //add_options_page("تنظیمات وردپرس فارسی", "وردپرس فارسی", 10, __FILE__,'mps_jd_optionpage');
67
- //add_menu_page("تنظیمات وردپرس فارسی", "وردپرس فارسی", 10, 'wp-jalali','mps_jd_optionpage', plugins_url('wp-jalali/images/logo.png'));
68
- add_menu_page("تنظیمات وردپرس فارسی", "وردپرس فارسی", 'manage_options','wp-jalali','mps_jd_optionpage', plugins_url('wp-jalali/images/logo.png'));
69
- }
70
-
71
- $mps_jd_optionsDB = get_option(MPS_JD_OPTIONS_NAME);
72
-
73
- if (empty($mps_jd_optionsDB)) {
74
- //echo "init";
75
- $mps_jd_optionsDB['mps_jd_autodate'] = $mps_jd_autodate = true;
76
- $mps_jd_optionsDB['mps_jd_farsinum_content'] = $mps_jd_farsinum_content = true;
77
- $mps_jd_optionsDB['mps_jd_farsinum_comment'] = $mps_jd_farsinum_comment = true;
78
- $mps_jd_optionsDB['mps_jd_farsinum_commentnum'] = $mps_jd_farsinum_commentnum = true;
79
- $mps_jd_optionsDB['mps_jd_farsinum_title'] = $mps_jd_farsinum_title = true;
80
- $mps_jd_optionsDB['mps_jd_farsinum_category'] = $mps_jd_farsinum_category = true;
81
- $mps_jd_optionsDB['mps_jd_farsinum_date'] = $mps_jd_farsinum_date = true;
82
- $mps_jd_optionsDB['mps_jd_decimal'] = $mps_jd_decimal = true;
83
- $mps_jd_optionsDB['mps_jd_mcertl'] = $mps_jd_mcertl = true;
84
- $mps_jd_optionsDB['mps_jd_jperma'] = $mps_jd_jperma = true;
85
- $mps_jd_optionsDB['mps_jd_autoyk'] = $mps_jd_autoyk = true;
86
- $mps_jd_optionsDB['mps_jd_editjalali'] = $mps_jd_editjalali = true;
87
- $mps_jd_optionsDB['mps_jd_dashboard'] = $mps_jd_dashboard = 0;
88
- $mps_jd_optionsDB['mps_jd_country'] = $mps_jd_country = 'IR';
89
- update_option(MPS_JD_OPTIONS_NAME,$mps_jd_optionsDB);
90
- }
91
- }
92
-
93
- function mps_jd_optionpage(){
94
- global $user_level;
95
- global $j_day_name;
96
-
97
- $_wp_version = get_bloginfo("version");
98
-
99
- if ( version_compare($_wp_version, 2.1, '<' )) {
100
- get_currentuserinfo();
101
- $enable_options = ($user_level >= 8);
102
- } else {
103
- $enable_options = current_user_can('manage_options');
104
- }
105
-
106
- if (!$enable_options) { //MUST BE ADMIN
107
- ?>
108
- <div class="wrap">
109
- <h2>خطا</h2>
110
- <br /><?php _e("<div style=\"color:#770000;\">شما دارای اختیارات کافی نمی باشید.</div>"); ?><br />
111
- </div>
112
- <?php
113
- return;
114
- }
115
-
116
- if ( (isset($_POST['action'])) && ($_POST['action'] == 'update')) {
117
- $mps_jd_optionsDB['mps_jd_autodate'] = $mps_jd_autodate = $_POST['mps_jd_autodate'];
118
- $mps_jd_optionsDB['mps_jd_farsinum_content'] = $mps_jd_farsinum_content = $_POST['mps_jd_farsinum_content'];
119
- $mps_jd_optionsDB['mps_jd_farsinum_comment'] = $mps_jd_farsinum_comment = $_POST['mps_jd_farsinum_comment'];
120
- $mps_jd_optionsDB['mps_jd_farsinum_commentnum'] = $mps_jd_farsinum_commentnum = $_POST['mps_jd_farsinum_commentnum'];
121
- $mps_jd_optionsDB['mps_jd_farsinum_title'] = $mps_jd_farsinum_title = $_POST['mps_jd_farsinum_title'];
122
- $mps_jd_optionsDB['mps_jd_farsinum_category'] = $mps_jd_farsinum_category = $_POST['mps_jd_farsinum_category'];
123
- $mps_jd_optionsDB['mps_jd_farsinum_date'] = $mps_jd_farsinum_date = $_POST['mps_jd_farsinum_date'];
124
- $mps_jd_optionsDB['mps_jd_decimal'] = $mps_jd_decimal = $_POST['mps_jd_decimal'];
125
- $mps_jd_optionsDB['mps_jd_mcertl'] = $mps_jd_mcertl = $_POST['mps_jd_mcertl'];
126
- $mps_jd_optionsDB['mps_jd_jperma'] = $mps_jd_jperma = $_POST['mps_jd_jperma'];
127
- $mps_jd_optionsDB['mps_jd_autoyk'] = $mps_jd_autoyk = $_POST['mps_jd_autoyk'];
128
- $mps_jd_optionsDB['mps_jd_editjalali'] = $mps_jd_editjalali = $_POST['mps_jd_editjalali'];
129
- $mps_jd_optionsDB['mps_jd_country'] = $mps_jd_country = $_POST['mps_jd_country'];
130
- $old_options = get_option(MPS_JD_OPTIONS_NAME);
131
- if ($old_options['mps_jd_dashboard'] != $_POST['mps_jd_dashboard']) {
132
- // Dashboard wigdets updating ... Needs to reset some terms
133
- if ( $widget_options = get_option( 'dashboard_widget_options' ) ) {
134
- unset($widget_options['dashboard_primary']);
135
- unset($widget_options['dashboard_secondary']);
136
- update_option( 'dashboard_widget_options', $widget_options );
137
- }
138
- }
139
- $mps_jd_optionsDB['mps_jd_dashboard'] = $mps_jd_dashboard = $_POST['mps_jd_dashboard'];
140
- update_option(MPS_JD_OPTIONS_NAME,$mps_jd_optionsDB);
141
- update_option('gmt_offset',$_POST['gmt_offset']);
142
- update_option('date_format',$_POST['date_format']);
143
- update_option('time_format',$_POST['time_format']);
144
- update_option('start_of_week',$_POST['start_of_week']);
145
- $mps_ERR = "تغییرات با موفقیت ثبت شد.";
146
- }
147
-
148
- $mps_jd_optionsDB = get_option(MPS_JD_OPTIONS_NAME);
149
- $mps_jd_autodate = $mps_jd_optionsDB['mps_jd_autodate'];
150
- $mps_jd_farsinum_content = $mps_jd_optionsDB['mps_jd_farsinum_content'];
151
- $mps_jd_farsinum_comment = $mps_jd_optionsDB['mps_jd_farsinum_comment'];
152
- $mps_jd_farsinum_commentnum = $mps_jd_optionsDB['mps_jd_farsinum_commentnum'];
153
- $mps_jd_farsinum_title = $mps_jd_optionsDB['mps_jd_farsinum_title'];
154
- $mps_jd_farsinum_category = $mps_jd_optionsDB['mps_jd_farsinum_category'];
155
- $mps_jd_farsinum_date = $mps_jd_optionsDB['mps_jd_farsinum_date'];
156
- $mps_jd_decimal = $mps_jd_optionsDB['mps_jd_decimal'];
157
- $mps_jd_mcertl = $mps_jd_optionsDB['mps_jd_mcertl'];
158
- $mps_jd_jperma = $mps_jd_optionsDB['mps_jd_jperma'];
159
- $mps_jd_autoyk = $mps_jd_optionsDB['mps_jd_autoyk'];
160
- $mps_jd_editjalali = $mps_jd_optionsDB['mps_jd_editjalali'];
161
- $mps_jd_country = $mps_jd_optionsDB['mps_jd_country'];
162
- $mps_jd_dashboard = $mps_jd_optionsDB['mps_jd_dashboard'];
163
-
164
- if((isset($mps_ERR)) && (!empty($mps_ERR))) {
165
- ?>
166
- <br clear="all" />
167
- <div style="background-color: rgb(255, 251, 204);" id="message" class="updated fade" style="direction: rtl"><p><strong><?php _e($mps_ERR); ?></strong></p></div>
168
- <?php
169
- }
170
- ?>
171
-
172
- <?php
173
- $logo_uri = MPS_JD_URI.'/images/wp-fa-logo.png';
174
- ?>
175
- <div id="wpbody-content" style="direction:rtl; text-align: right">
176
- <div class="wrap" style="direction:rtl; text-align: right">
177
- <p style="text-align:center">
178
- <a href="http://wp-persian.com" style="border:none" title="وردپرس فارسی"><img src="<?php echo $logo_uri?>" alt="Persian Wordpress Logo" border="0"/></a>
179
- </p>
180
- <form method="post">
181
- <input type="hidden" name="action" value="update" />
182
- <?php if (version_compare($_wp_version, '2.4', '<')) : ?>
183
- <h2>اخبار وردپرس فارسی</h2>
184
- <h3>وبلاگ توسعه وردپرس فارسی</h3>
185
-
186
- <?php
187
- $rss = @fetch_rss('http://wp-persian.com/feed/');
188
- if ( isset($rss->items) && 0 != count($rss->items) ) {
189
- ?>
190
- <?php
191
- $rss->items = array_slice($rss->items, 0, 3);
192
- foreach ($rss->items as $item ) {
193
- ?>
194
- <h4 dir="rtl" style="color:gray; margin-right:25px; "><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a> &#8212; <?php printf(__('%s ago'), human_time_diff(strtotime($item['pubdate'], time() ) ) ); ?></h4>
195
- <?php
196
- }
197
- }
198
- ?>
199
- <div id="planetnews" style="direction:rtl; text-align: right">
200
- <h3>سیاره وردپرس فارسی <a href="http://planet.wp-persian.com/">بیشتر »</a></h3>
201
- <?php
202
- $rss = @fetch_rss('http://planet.wp-persian.com/feed/');
203
- if ( isset($rss->items) && 0 != count($rss->items) ) {
204
- ?>
205
-
206
- <ul>
207
- <?php
208
- $rss->items = array_slice($rss->items, 0, 10);
209
- foreach ($rss->items as $item ) {
210
-
211
- ?>
212
- <li><?php echo wp_specialchars($item['dc']['creator']); ?>: <a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a><?php// printf(__('%s ago'), human_time_diff(strtotime($item['pubdate'], time() ) ) ); ?></li>
213
- <?php
214
- }
215
- ?>
216
- </ul><br style="clear:both;"/>
217
- <?php
218
- }
219
- ?>
220
- </div>
221
- <?php else: //Wordpress 2.5 Dashboard widget API ?>
222
- <h2>اخبار وردپرس فارسی</h2>
223
- <table class="form-table">
224
- <tr valign="top">
225
- <th scope="row">چگونگی نمایش اخبار در پیش‌خوان</th>
226
- <td>
227
- <select name="mps_jd_dashboard" id="mps_jd_dashboard">
228
- <option value="0" <?php echo $mps_jd_dashboard==0? 'selected="selected"':'' ?>>بر اساس تنظیمات زبان</option>
229
- <option value="1" <?php echo $mps_jd_dashboard==1? 'selected="selected"':'' ?>>نمایش اخبار اصلی وردپرس به زبان انگلیسی</option>
230
- <option value="2" <?php echo $mps_jd_dashboard==2?'selected="selected"':'' ?>>نمایش اخبار وردپرس فارسی</option>
231
- </select>
232
- </td>
233
- </tr>
234
- </table>
235
- <?php endif; ?>
236
-
237
- <h2>تنظیمات وردپرس فارسی</h2>
238
-
239
- <table class="form-table">
240
- <tr valign="top">
241
- <th scope="row">تبدیل خودکار تاریخ نوشته‌ها و نظرات به تاریخ خورشیدی(شمسی)</th>
242
- <td>
243
- <select name="mps_jd_autodate" id="mps_jd_autodate">
244
- <option value="1" <?php echo $mps_jd_autodate==true? 'selected="selected"':'' ?>>فعال (پیشنهاد می‌شود)</option>
245
- <option value="0" <?php echo $mps_jd_autodate==false?'selected="selected"':'' ?>>غیر فعال</option>
246
- </select>
247
- </td>
248
- </tr>
249
- <tr valign="top">
250
- <th scope="row">تبدیل اعداد به فارسی</th>
251
- <td>
252
- <table border="0" cellpadding="2" cellspacing="2">
253
- <tr>
254
- <td style="border-bottom-width: 0">متن نوشته‌ها</td>
255
- <td style="border-bottom-width: 0"><input type="checkbox" name="mps_jd_farsinum_content" <?php echo $mps_jd_farsinum_content==true? 'checked="checked"':'' ?> /></td>
256
- <td style="border-bottom-width: 0">متن نظر‌ها</td>
257
- <td style="border-bottom-width: 0"><input type="checkbox" name="mps_jd_farsinum_comment" <?php echo $mps_jd_farsinum_comment==true? 'checked="checked"':'' ?> /></td>
258
- <td style="border-bottom-width: 0">تعداد نظر‌ها</td>
259
- <td style="border-bottom-width: 0"><input type="checkbox" name="mps_jd_farsinum_commentnum" <?php echo $mps_jd_farsinum_commentnum==true? 'checked="checked"':'' ?> /></td>
260
- </tr>
261
- <tr>
262
- <td style="border-bottom-width: 0">عنوان نوشته‌ها</td>
263
- <td style="border-bottom-width: 0"><input type="checkbox" name="mps_jd_farsinum_title" <?php echo $mps_jd_farsinum_title==true? 'checked="checked"':'' ?> /></td>
264
- <td style="border-bottom-width: 0">تاریخ‌ها</td>
265
- <td style="border-bottom-width: 0"><input type="checkbox" name="mps_jd_farsinum_date" <?php echo $mps_jd_farsinum_date==true? 'checked="checked"':'' ?> /></td>
266
- <td style="border-bottom-width: 0">فهرست دسته‌ها</td>
267
- <td style="border-bottom-width: 0"><input type="checkbox" name="mps_jd_farsinum_category" <?php echo $mps_jd_farsinum_category==true? 'checked="checked"':'' ?> /></td>
268
- </tr>
269
- </table>
270
-
271
- </td>
272
- </tr>
273
- <tr>
274
- <th scope="row">استفاده از <code>٫</code> به‌جای نقطه به‌عنوان نشانه‌ی اعداد اعشاری</th>
275
- <td>
276
- <select name="mps_jd_decimal" id="mps_jd_decimal">
277
- <option value="1" <?php echo $mps_jd_decimal==true? 'selected="selected"':'' ?>>بله</option>
278
- <option value="0" <?php echo $mps_jd_decimal==false?'selected="selected"':'' ?>>خیر</option>
279
- </select>
280
- <br />
281
- <strong>مثال:</strong> استفاده از ۲٫۶ به‌جای ۲<span>.</span>۶
282
- <br />
283
- <strong>توضیح:</strong> همان‌طور که می‌دانیم نشانه‌ی اعشار در فارسی (٫) است٬ اما به‌دلیل ناسازگاری برخی مرورگرها با اعداد ممیزدار٬ این گزینه را به‌انتخاب کاربران گذاشتیم.
284
- </td>
285
- </tr>
286
- <tr valign="top">
287
- <th scope="row">جهت ویرایشگر متنی صفحه نوشتن</th>
288
- <td>
289
- <select name="mps_jd_mcertl" id="mps_jd_mcertl">
290
- <option value="1" <?php echo $mps_jd_mcertl==true? 'selected="selected"':'' ?>>راست به چپ</option>
291
- <option value="0" <?php echo $mps_jd_mcertl==false?'selected="selected"':'' ?>>چپ به راست</option>
292
- </select>
293
- <br />
294
- در نگارش‌های بالاتر از وردپرس ۲٫۳ در صورتی که زبان وردپرس خود را فارسی انتخاب کنید، جهت ویرایشگر به صورت خودکار راست به چپ خواهد بود. در این نگارش‌ها تنها در صورتی از این گزینه استفاده کنید که زبان وردپرس خود را انگلیسی انتخاب کرده باشید.
295
- </td>
296
- </tr>
297
- <tr valign="top">
298
- <th scope="row">تبدیل خودکار تاریخ در نشانی (URI) نوشته‌ها</th>
299
- <td>
300
- <select name="mps_jd_jperma" id="mps_jd_jperma">
301
- <option value="1" <?php echo $mps_jd_jperma==true? 'selected="selected"':'' ?>>بله</option>
302
- <option value="0" <?php echo $mps_jd_jperma==false?'selected="selected"':'' ?>>خیر</option>
303
- </select>
304
- <br />
305
- تبدیل خودکار تاریخ در نشانی نوشته‌ها، مثلا از yourblog.ir/2008/04/02/post به yourblog.ir/1387/01/13/post
306
- </td>
307
- </tr>
308
- <tr valign="top">
309
- <th scope="row">تبدیل هوشمند حروف عربی به فارسی</th>
310
- <td>
311
- <select name="mps_jd_autoyk" id="mps_jd_autoyk">
312
- <option value="1" <?php echo $mps_jd_autoyk==true? 'selected="selected"':'' ?>>بله</option>
313
- <option value="0" <?php echo $mps_jd_autoyk==false?'selected="selected"':'' ?>>خیر</option>
314
- </select>
315
- <br />
316
- تبدیل خودکار حروف (ي) و (ك) عربی به (ی) و (ک) فارسی در هنگام نمایش و جستجوی هوشمند برای تمامی ترکیب‌های ممکن در هنگام جستجو.
317
- </td>
318
- </tr>
319
- <tr valign="top">
320
- <th scope="row">ویرایش تاریخ نوشته‌ها و برگه‌ها</th>
321
- <td>
322
- <select name="mps_jd_editjalali" id="mps_jd_editjalali">
323
- <option value="1" <?php echo $mps_jd_editjalali==true? 'selected="selected"':'' ?>>خورشیدی (شمسی)</option>
324
- <option value="0" <?php echo $mps_jd_editjalali==false?'selected="selected"':'' ?>>میلادی</option>
325
- </select>
326
- <br />
327
- در نگارش‌های بالاتر از وردپرس ۲/۵ می توانید نحوه ویرایش تاریخ نوشته‌ها و برگه‌ها را تنظیم کنید.
328
- </td>
329
- </tr>
330
- <tr>
331
- <th>نام ماه‌ها مطابق با کشور</th>
332
- <td>
333
- <select name="mps_jd_country" id="mps_jd_country">
334
- <option value="IR" <?php echo $mps_jd_country == 'IR' ? 'selected="selected"':'' ?>>ایران</option>
335
- <option value="AF" <?php echo $mps_jd_country == 'AF' ?'selected="selected"':'' ?>>افغانستان</option>
336
- </select>
337
- <br />
338
- نام ماه‌های ایران: فروردین٬ اردیبهشت و... / نام ماه‌های افغانستان: حمل٬ ثور و...
339
- </td>
340
- </tr>
341
- </table>
342
- <br />
343
- <h2>تنظیمات ساعت و تاریخ</h2>
344
- <table class="form-table">
345
- <tr>
346
- <th scope="row" width="33%">ساعت به وقت <abbr title="Coordinated Universal Time">UTC</abbr>:</th>
347
- <td><code>
348
- <?php
349
- $m = gmdate('YmdHis');
350
- $gmt = mktime(substr($m,8,2),substr($m,10,2),substr($m,12,2),substr($m,4,2),substr($m,6,2),substr($m,0,4));
351
- ?>
352
- <?php echo jdate('l Y-m-d g:i:s a',$gmt); ?></code></td>
353
- </tr>
354
- <tr>
355
- <th scope="row">اختلاف ساعت محلی :</th>
356
- <td><input style="direction:rtl; text-align:left" name="gmt_offset" type="text" id="gmt_offset" size="2" value="<?php form_option('gmt_offset'); ?>" />
357
- ساعت </td>
358
- </tr>
359
- <tr>
360
- <th scope="row">&nbsp;</th>
361
- <td>ساختار‌های زیر مانند <a href="http://php.net/date">تابع <code>date()</code> PHP</a> است. برای نمایش تغییرات این صفحه را به روز کنید.</td>
362
- </tr>
363
- <tr>
364
- <th scope="row">ساختار تاریخ پیش‌فرض</th>
365
- <td><input style="direction:rtl; text-align:left" name="date_format" type="text" id="date_format" size="30" value="<?php form_option('date_format'); ?>" /><br />
366
- خروجی : <strong><?php echo jdate(get_option('date_format'), $gmt + (get_option('gmt_offset') * 3600)); ?></strong></td>
367
- </tr>
368
- <tr>
369
- <th scope="row">ساختار زمان پیش‌فرض</th>
370
- <td><input style="direction:rtl; text-align:left" name="time_format" type="text" id="time_format" size="30" value="<?php form_option('time_format'); ?>" /><br />
371
- خروجی : <strong><?php echo jdate(get_option('time_format'), $gmt + (get_option('gmt_offset') * 3600)) ; ?></strong></td>
372
- </tr>
373
- <tr>
374
- <th scope="row">روز شروع هفته در تقویم</th>
375
- <td><select name="start_of_week" id="start_of_week">
376
- <?php
377
- for ($day_index = 0; $day_index <= 6; $day_index++) :
378
- if ($day_index == get_option('start_of_week')) $selected = " selected='selected'";
379
- else $selected = '';
380
- echo "\n\t<option value='$day_index' $selected>$j_day_name[$day_index]</option>";
381
- endfor;
382
- ?>
383
- </select></td>
384
- </tr>
385
-
386
- </table>
387
-
388
-
389
-
390
- <p class="submit">
391
- <input class="button-primary" type="submit" name="Submit" value="به روز رسانی &raquo;" />
392
- </p>
393
- </form>
394
-
395
- <br />
396
- </div>
397
- <div id="wp-bookmarklet" class="wrap" style="direction:rtl; text-align:right">
398
- <h3>پروژه وردپرس فارسی</h3>
399
- <p>این افزونه، بخشی از <a href="http://wp-persian.com/">پروژه وردپرس فارسی</a> است. برای اطلاعات بیشتر در مورد این افزونه می‌توانید <a href="http://wp-persian.com/wp-jalali/">صفحه مخصوص این افزونه</a> را مشاهده کنید.</p>
400
- </div>
401
- </div>
402
-
403
- <?php
404
-
405
- }
406
-
407
-
408
- /* Wordpress Convert Functions */
409
-
410
- function jmysql2date($dateformatstring, $mysqlstring, $translate = true) {
411
- global $month, $weekday, $month_abbrev, $weekday_abbrev;
412
- $m = $mysqlstring;
413
- if ( empty($m) ) {
414
- return false;
415
- }
416
- $i = mktime(substr($m,11,2),substr($m,14,2),substr($m,17,2),substr($m,5,2),substr($m,8,2),substr($m,0,4));
417
-
418
- if ( -1 == $i || false == $i )
419
- $i = 0;
420
-
421
- $j = @jdate($dateformatstring, $i);
422
- return $j;
423
- }
424
-
425
- function mps_maketimestamp($m) {
426
- return mktime(substr($m,11,2),substr($m,14,2),substr($m,17,2),substr($m,5,2),substr($m,8,2),substr($m,0,4));
427
- }
428
-
429
-
430
- function comment_jdate($d='') {
431
- global $comment;
432
- $m = $comment->comment_date;
433
- $timestamp = mps_maketimestamp($m);
434
- if ('' == $d) {
435
- echo jdate(get_option('date_format'), $timestamp);
436
- } else {
437
- echo jdate($d, $timestamp);
438
- }
439
-
440
- }
441
-
442
- function comment_jtime($d='') {
443
- global $comment;
444
- $m = $comment->comment_date;
445
- $timestamp = mps_maketimestamp($m);
446
- if ($d == '') {
447
- echo jdate(get_option('time_format'), $timestamp);
448
- } else {
449
- echo jdate($d, $timestamp);
450
- }
451
- }
452
-
453
- function mps_the_jdate($input,$d='',$before='', $after='') {
454
- global $id, $post, $day, $previousday, $newday;
455
- $result = '';
456
- if ($d == "") $d = get_option('time_format');
457
- //if ($day != $previousday) {
458
- if (strlen($input) > 0) { //Because $previousday is overwritten before reaching here , nice trick ;)
459
- $m = $post->post_date;
460
- $timestamp = mps_maketimestamp($m);
461
- $result .= $before;
462
- $result .= jdate($d,$timestamp);
463
- $result .= $after;
464
- $previousday = $day;
465
- }
466
- return $result;
467
- }
468
-
469
- function mps_the_jtime($input,$d='') {
470
- global $id, $post;
471
- if (!empty($input)){
472
- if ($d == "") $d = get_option('time_format');
473
- $m = $post->post_date;
474
- $timestamp = mps_maketimestamp($m);
475
- $the_time = jdate($d, $timestamp);
476
- return $the_time;
477
- }
478
-
479
- }
480
-
481
- function mps_comment_jdate($input, $d = '') {
482
- global $comment;
483
- $result = '';
484
- $m = $comment->comment_date;
485
- $timestamp = mps_maketimestamp($m);
486
- if ( '' == $d )
487
- $result = jdate(get_option('date_format'), $timestamp);
488
- else
489
- $result = jdate($d, $timestamp);
490
- return $result;
491
- }
492
-
493
- function mps_comment_jtime($input, $d = '') {
494
- global $comment;
495
- $result = '';
496
- $m = $comment->comment_date;
497
- $timestamp = mps_maketimestamp($m);
498
- if ( '' == $d )
499
- $result = jdate(get_option('time_format'), $timestamp);
500
- else
501
- $result = jdate($d, $timestamp);
502
- return $result;
503
- }
504
-
505
- function mps_the_jweekday($input) {
506
- global $weekday, $id, $post;
507
- $m = $post->post_date;
508
- $timestamp = mps_maketimestamp($m);
509
- $the_weekday = jdate('w', $timestamp);
510
- return $the_weekday;
511
- }
512
-
513
-
514
- function mps_the_jweekday_date($input, $before, $after) {
515
- global $weekday, $id, $post, $day, $previousweekday;
516
- $the_weekday_date = '';
517
- $m = $post->post_date;
518
- $timestamp = mps_maketimestamp($m);
519
- if (strlen($input) > 0) {
520
- $the_weekday_date .= $before;
521
- $the_weekday_date .= jdate('w', $timestamp);
522
- $the_weekday_date .= $after;
523
- }
524
- return $the_weekday_date;
525
- }
526
-
527
-
528
- function mps_jalali_query($where) {
529
- if (is_admin()) {
530
- // Skip admin pages
531
- return $where;
532
- }
533
- $_wp_version = get_bloginfo("version");
534
-
535
- /* Wordpress 1.6+ */
536
- global $wp_query, $wpdb;
537
- global $j_days_in_month;
538
-
539
- // $m = $wp_query->query_vars['m'];
540
- // $hour = $wp_query->query_vars['hour'];
541
- // $minute = $wp_query->query_vars['minute'];
542
- // $second = $wp_query->query_vars['second'];
543
- // $year = $wp_query->query_vars['year'];
544
- // $monthnum = $wp_query->query_vars['monthnum'];
545
- // $day = $wp_query->query_vars['day'];
546
-
547
- $m = (isset($wp_query->query_vars['m'])) ? $wp_query->query_vars['m'] : '';
548
- $hour = (isset($wp_query->query_vars['hour'])) ? $wp_query->query_vars['hour'] : '';
549
- $minute = (isset($wp_query->query_vars['minute'])) ? $wp_query->query_vars['minute'] : '';
550
- $second = (isset($wp_query->query_vars['second'])) ? $wp_query->query_vars['second'] : '';
551
- $year = (isset($wp_query->query_vars['year'])) ? $wp_query->query_vars['year'] : '';
552
- $monthnum = (isset($wp_query->query_vars['monthnum'])) ? $wp_query->query_vars['monthnum'] : '';
553
- $day = (isset($wp_query->query_vars['day'])) ? $wp_query->query_vars['day'] : '';
554
-
555
- $j_monthnum = 1;
556
- $j_day = 1;
557
- $j_hour = 0;
558
- $j_minute = 0;
559
- $j_second = 0;
560
- $j_monthnum_next = 1;
561
- $j_day_next = 1;
562
- $j_hour_next = 0;
563
- $j_minute_next = 0;
564
- $j_second_next = 0;
565
- $j_doit = false;
566
-
567
- if ($m != '') {
568
- $m = '' . preg_replace('|[^0-9]|', '', $m);
569
- $j_year = substr($m,0,4);
570
- if ($j_year < 1700) { // Wow ! It's a Jalali Date!
571
- $j_doit = true;
572
- $j_year_next = $j_year + 1;
573
-
574
- if (strlen($m)>5) {
575
- $j_monthnum = substr($m, 4, 2);
576
- $j_year_next = $j_year;
577
- $j_monthnum_next = $j_monthnum + 1;
578
- }
579
-
580
- if (strlen($m)>7) {
581
- $j_day = substr($m, 6, 2);
582
- $j_monthnum_next = $j_monthnum;
583
- $j_day_next = $j_day + 1;
584
- }
585
- if (strlen($m)>9) {
586
- $j_hour = substr($m, 8, 2);
587
- $j_day_next = $j_day;
588
- $j_hour_next = $j_hour + 1;
589
- }
590
- if (strlen($m)>11) {
591
- $j_minute = substr($m, 10, 2);
592
- $j_hour_next = $j_hour;
593
- $j_minute_next = $j_minute + 1;
594
- }
595
- if (strlen($m)>13) {
596
- $j_second = substr($m, 12, 2);
597
- $j_minute_next = $j_minute;
598
- $j_second_next = $j_second + 1;
599
- }
600
- }
601
- } else if (($year != '') && ($year < 1700)) {
602
- $j_doit = true;
603
- $j_year = $year;
604
- $j_year_next = $j_year + 1;
605
-
606
- if ($monthnum != '') {
607
- $j_monthnum = $monthnum;
608
- $j_year_next = $j_year;
609
- $j_monthnum_next = $j_monthnum + 1;
610
- }
611
- if ($day != '') {
612
- $j_day = $day;
613
- $j_monthnum_next = $j_monthnum;
614
- $j_day_next = $j_day + 1;
615
- }
616
- if ($hour != '') {
617
- $j_hour = $hour;
618
- $j_day_next = $j_day;
619
- $j_hour_next = $j_hour + 1;
620
- }
621
- if ($minute != '') {
622
- $j_minute = $minute;
623
- $j_hour_next = $j_hour;
624
- $j_minute_next = $j_minute + 1;
625
- }
626
- if ($second != '') {
627
- $j_second = $second;
628
- $j_minute_next = $j_minute;
629
- $j_second_next = $j_second + 1;
630
- }
631
- }
632
-
633
- if ($j_doit) {
634
- /* WP 1.5+ NEEDS THIS :: CLEANING PREV. TIMINGS*/
635
- $tablename_prefix = $wpdb->prefix.'posts.';
636
- $sna = (strpos($where, $tablename_prefix) === false) ? '' : $tablename_prefix;
637
- // TODO: Remove above line and improve the regex
638
- if (version_compare($_wp_version, '3.7', '<')) {
639
- $patterns = array(
640
- "YEAR\(".$sna."post_date\)='*[0-9]{4}'*",
641
- "DAYOFMONTH\(".$sna."post_date\)='*[0-9]{1,}'*",
642
- "MONTH\(".$sna."post_date\)='*[0-9]{1,}'*",
643
- "HOUR\(".$sna."post_date\)='*[0-9]{1,}'*",
644
- "MINUTE\(".$sna."post_date\)='*[0-9]{1,}'*",
645
- "SECOND\(".$sna."post_date\)='*[0-9]{1,}'*"
646
- );
647
- } else {
648
- $patterns = array(
649
- "YEAR\(\s*.*post_date\s*\)\s*=\s*'*[0-9]{4}'*",
650
- "DAYOFMONTH\(\s*.*post_date\s*\)\s*=\s*'*[0-9]{1,}'*",
651
- "MONTH\(\s*.*post_date\s*\)\s*=\s*'*[0-9]{1,}'*",
652
- "HOUR\(\s*.*post_date\s*\)\s*=\s*'*[0-9]{1,}'*",
653
- "MINUTE\(\s*.*post_date\s*\)\s*=\s*'*[0-9]{1,}'*",
654
- "SECOND\(\s*.*post_date\s*\)\s*=\s*'*[0-9]{1,}'*"
655
- );
656
- }
657
-
658
- foreach ($patterns as $pattern){
659
- $where = preg_replace('/'.$pattern.'/',"1=1",$where); // :D good idea ! isn't it ?
660
- }
661
- if ($j_second_next > 59) {
662
- $j_second_next = 0;
663
- $j_minute_next++;
664
- }
665
- if ($j_minute_next > 59) {
666
- $j_minute_next = 0;
667
- $j_hour_next++;
668
- }
669
- if ($j_hour_next > 23) {
670
- $j_hour_next = 0;
671
- $j_day_next++;
672
- }
673
- if ($j_day_next > $j_days_in_month[$j_monthnum-1]){
674
- $j_day_next = 1;
675
- $j_monthnum_next++;
676
- }
677
- if ($j_monthnum_next > 12) {
678
- $j_monthnum_next = 1;
679
- $j_year_next++;
680
- }
681
-
682
- $g_startdate = date("Y:m:d 00:00:00",jmaketime($j_hour,$j_minute,$j_second,$j_monthnum,$j_day,$j_year));
683
- $g_enddate = date("Y:m:d 00:00:00",jmaketime($j_hour_next,$j_minute_next,$j_second_next,$j_monthnum_next,$j_day_next,$j_year_next));
684
-
685
- $where .= " AND ".$sna."post_date >= '$g_startdate' AND ".$sna."post_date < '$g_enddate' ";
686
- }
687
- return $where;
688
- }
689
-
690
- function mps_get_jarchives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
691
- //Added in 3.5 for backward compability
692
- $_wp_version = get_bloginfo("version");
693
- if (version_compare($_wp_version, 2.1, '>=') ) {
694
- $_query_add = " post_type='post' ";
695
- } else {
696
- $_query_add = " 1 = 1 "; // =)) 11-5-2007 0:38
697
- }
698
- global $month, $wpdb;
699
- global $j_month_name;
700
-
701
- if ('' == $type) {
702
- $type = 'monthly';
703
- }
704
-
705
- if ('' != $limit && 0 != $limit) {
706
- $limit = (int) $limit;
707
- if("daily" == $type || "postbypost" == $type) $limit = ' LIMIT '.$limit;
708
- }
709
-
710
-
711
- // this is what will separate dates on weekly archive links
712
- $archive_week_separator = '&#8211;';
713
-
714
- // archive link url
715
- $archive_link_m = get_option('siteurl') . '/?m='; # monthly archive;
716
- $archive_link_p = get_option('siteurl') . '/?p='; # post-by-post archive;
717
-
718
- // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
719
- $archive_date_format_over_ride = 0;
720
-
721
- // options for daily archive (only if you over-ride the general date format)
722
- $archive_day_date_format = 'Y/m/d';
723
-
724
- // options for weekly archive (only if you over-ride the general date format)
725
- $archive_week_start_date_format = 'Y/m/d';
726
- $archive_week_end_date_format = 'Y/m/d';
727
-
728
- if (!$archive_date_format_over_ride) {
729
- $archive_day_date_format = get_option('date_format');
730
- $archive_week_start_date_format = get_option('date_format');
731
- $archive_week_end_date_format = get_option('date_format');
732
- }
733
-
734
- $add_hours = intval(get_option('gmt_offset'));
735
- $add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours));
736
-
737
- if ("yearly" == $type) {
738
- $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_date < NOW() AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC");
739
- if ($arcresults) {
740
- //$afterafter = $after;
741
- $jal_years_array = array();
742
- foreach ($arcresults as $arcresult) {
743
- list($jal_year,$jal_month,$jal_dayofmonth) = gregorian_to_jalali($arcresult->year,$arcresult->month,$arcresult->dayofmonth);
744
- $jal_years_array[] = $jal_year;
745
- }
746
-
747
- $jal_years = array_unique($jal_years_array);
748
- $i = 1;
749
- foreach($jal_years as $jal_year) {
750
- $gre_start = date("Y-m-d H:i:s",jmaketime(0,0,0,1,1,$jal_year));
751
- $gre_end = date("Y-m-d H:i:s",jmaketime(0,0,0,1,1,$jal_year+1));
752
- $count_query = $wpdb->get_results("SELECT count(ID) as 'post_count' FROM $wpdb->posts WHERE post_date < NOW() AND post_type = 'post' AND post_status = 'publish' AND post_date >= '$gre_start' AND post_date < '$gre_end' ORDER BY post_date DESC");
753
- $count_posts = farsi_num($count_query[0]->post_count);
754
- $url = get_year_link($jal_year);
755
- $text = farsi_num($jal_year);
756
- if ($show_post_count)
757
- $after = '&nbsp;('.$count_posts.')' . $afterafter;
758
- echo get_archives_link($url, $text, $format, $before, $after);
759
- if($i == $limit) break;
760
- $i++;
761
- }
762
- }
763
- } elseif ("monthly" == $type) {
764
- $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) as 'day',count(ID) as 'posts' FROM $wpdb->posts WHERE ".$_query_add." AND post_date < NOW() AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC ");
765
- if ($arcresults) {
766
- $afterafter = $after;
767
- $len = count($arcresults)-1;
768
-
769
- list($jal_startyear,$jal_startmonth,$jal_startday) = gregorian_to_jalali($arcresults[$len]->year,$arcresults[$len]->month,$arcresults[$len]->day);
770
- list($jal_endyear,$jal_endmonth,$jal_endday) = gregorian_to_jalali($arcresults[0]->year,$arcresults[0]->month,$arcresults[0]->day);
771
- //$jal_year = $jal_startyear;
772
- //$jal_month = $jal_startmonth;
773
- $jal_year = $jal_endyear;
774
- $jal_month = $jal_endmonth + 1;
775
- if ($jal_month > 12) {
776
- $jal_month = 1;
777
- $jal_year++;
778
- }
779
- $i = 1;
780
- while (jmaketime(0,0,0,$jal_month,1,$jal_year) >= jmaketime(0,0,0,$jal_startmonth,1,$jal_startyear)){
781
- $jal_nextmonth = $jal_month-1;
782
- $jal_nextyear = $jal_year;
783
- if ($jal_nextmonth < 1) {
784
- $jal_nextmonth = 12;
785
- $jal_nextyear--;
786
- }
787
- $gre_end = date("Y:m:d H:i:s",jmaketime(0,0,0,$jal_month,1,$jal_year));
788
- $gre_start = date("Y:m:d H:i:s",jmaketime(0,0,0,$jal_nextmonth,1,$jal_nextyear));
789
-
790
- $jal_post_count = $wpdb->get_results("SELECT COUNT(id) as 'post_count' FROM $wpdb->posts WHERE ".$_query_add." AND post_date < NOW() AND post_status = 'publish' AND post_date >= '$gre_start' AND post_date < '$gre_end'");
791
- $jal_posts = $jal_post_count[0]->post_count;
792
- if ($jal_posts > 0){
793
-
794
- $url = get_month_link($jal_nextyear, $jal_nextmonth);
795
-
796
- $mps_jd_optionsDB = get_option(MPS_JD_OPTIONS_NAME);
797
- $mps_jd_farsinum_date = $mps_jd_optionsDB['mps_jd_farsinum_date'];
798
-
799
- if ($mps_jd_farsinum_date) {
800
- $jal_year_text = farsi_num($jal_nextyear);
801
- $jal_posts = farsi_num($jal_posts);
802
- } else {
803
- $jal_year_text = $jal_nextyear;
804
- }
805
-
806
- $text = sprintf('%s %s', $j_month_name[$jal_nextmonth], $jal_year_text);
807
- if ($show_post_count)
808
- $after = '&nbsp;('.$jal_posts.')' . $afterafter;
809
- echo get_archives_link($url, $text, $format, $before, $after);
810
- }
811
- $jal_month = $jal_nextmonth;
812
- $jal_year = $jal_nextyear;
813
- if($i == $limit) break;
814
- $i++;
815
- }
816
- }
817
- } elseif ("daily" == $type) {
818
- $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE ".$_query_add." AND post_date < NOW() AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
819
- if ($arcresults) {
820
- foreach ($arcresults as $arcresult) {
821
- list($jal_year,$jal_month,$jal_dayofmonth) = gregorian_to_jalali($arcresult->year,$arcresult->month,$arcresult->dayofmonth);
822
- $url = get_day_link($jal_year, $jal_month, $jal_dayofmonth);
823
- //$date = sprintf("%d-%02d-%02d 00:00:00", $jal_year, $jal_month, $jal_dayofmonth);
824
- //$text = mysql2date($archive_day_date_format, $date);
825
- $date = jmaketime(0,0,0,$jal_month,$jal_dayofmonth,$jal_year);
826
- $text = jdate($archive_day_date_format,$date);
827
- echo get_archives_link($url, $text, $format, $before, $after);
828
- }
829
- }
830
- } elseif ('postbypost' == $type) {
831
- $arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM $wpdb->posts WHERE ".$_query_add." AND post_date < NOW() AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
832
- if ($arcresults) {
833
- foreach ($arcresults as $arcresult) {
834
- if ($arcresult->post_date != '0000-00-00 00:00:00') {
835
- $url = get_permalink($arcresult->ID);
836
- $arc_title = $arcresult->post_title;
837
- if ($arc_title) {
838
- $text = strip_tags($arc_title);
839
- } else {
840
- $text = $arcresult->ID;
841
- }
842
- echo get_archives_link($url, $text, $format, $before, $after);
843
- }
844
- }
845
- }
846
- }
847
- }
848
-
849
- function wp_get_jarchives($args = '') {
850
- parse_str($args, $r);
851
- if (!isset($r['type'])) $r['type'] = '';
852
- if (!isset($r['limit'])) $r['limit'] = '';
853
- if (!isset($r['format'])) $r['format'] = 'html';
854
- if (!isset($r['before'])) $r['before'] = '';
855
- if (!isset($r['after'])) $r['after'] = '';
856
- if (!isset($r['show_post_count'])) $r['show_post_count'] = false;
857
- mps_get_jarchives($r['type'], $r['limit'], $r['format'], $r['before'], $r['after'], $r['show_post_count']);
858
- }
859
-
860
-
861
- function get_jcalendar() {
862
- global $wpdb, $m, $monthnum, $year, $timedifference, $month, $day, $posts;
863
- global $j_month_name , $j_day_name , $jday_abbrev;
864
-
865
- $_wp_version = get_bloginfo("version");
866
- if (version_compare($_wp_version, '2.1', '>=')) {
867
- $_query_add = " post_type='post' ";
868
- } else {
869
- $_query_add = " 1 = 1 "; // =)) 11-5-2007 0:38
870
- }
871
-
872
- if (!$posts) {
873
- $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE ".$_query_add." AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
874
- if (!$gotsome) return;
875
- }
876
-
877
- $week_begins = intval(get_option('start_of_week'));
878
- $add_hours = intval(get_option('gmt_offset'));
879
- $add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours));
880
-
881
- $input_is_gregorian = false;
882
-
883
- if (!empty($monthnum) && !empty($year)) {
884
- $thismonth = ''.zeroise(intval($monthnum), 2);
885
- $thisyear = ''.intval($year);
886
- } elseif (!empty($m)) {
887
- $calendar = substr($m, 0, 6);
888
- $thisyear = ''.intval(substr($m, 0, 4));
889
- if (strlen($m) < 6) {
890
- $thismonth = '01';
891
- } else {
892
- $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
893
- }
894
- } else {
895
- $input_is_gregorian = true;
896
- $thisyear = gmdate('Y', current_time('timestamp') + get_option('gmt_offset') * 3600);
897
- $thismonth = gmdate('m', current_time('timestamp') + get_option('gmt_offset') * 3600);
898
- $thisday = gmdate('d', current_time('timestamp') + get_option('gmt_offset') * 3600);
899
- }
900
-
901
- if ($input_is_gregorian) {
902
- list($jthisyear,$jthismonth,$jthisday) = gregorian_to_jalali($thisyear,$thismonth,$thisday);
903
- $unixmonth = jmaketime(0, 0 , 0, $jthismonth, 1, $jthisyear);
904
- } else {
905
- $unixmonth = jmaketime(0, 0 , 0, $thismonth, 1, $thisyear);
906
- $jthisyear = $thisyear;
907
- $jthismonth = $thismonth;
908
-
909
- }
910
-
911
-
912
-
913
- $jnextmonth = $jthismonth + 1;
914
- $jnextyear = $jthisyear;
915
- if ($jnextmonth > 12) {
916
- $jnextmonth = 1;
917
- $jnextyear++;
918
- }
919
- //This is so important to change the table dir to RTL and keep it
920
- echo '<table id="wp-calendar" style="direction: rtl">
921
- <caption>' . $j_month_name[(int) $jthismonth ] . ' ' . jdate('Y', $unixmonth) . '</caption>
922
- <thead>
923
- <tr>';
924
-
925
- $day_abbrev = $weekday_initial;
926
-
927
- $myweek = array();
928
-
929
- for ($wdcount=0; $wdcount<=6; $wdcount++) {
930
- $myweek[]=$jday_abbrev[($wdcount+$week_begins)%7];
931
- }
932
-
933
- foreach ($myweek as $wd) {
934
- echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">" . $wd . '</th>';
935
- }
936
-
937
- echo '
938
- </tr>
939
- </thead>
940
-
941
- <tfoot>
942
- <tr>';
943
- $g_startdate = date("Y:m:d H:i:s",jmaketime(0,0,0,$jthismonth,1,$jthisyear));
944
- $g_enddate = date("Y:m:d H:i:s",jmaketime(0,0,0,$jnextmonth,1,$jnextyear));
945
- $prev = $wpdb->get_results("SELECT count(id) AS prev FROM $wpdb->posts
946
- WHERE $_query_add
947
- AND post_date < '$g_startdate'
948
- AND post_status = 'publish'
949
- AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
950
-
951
- $next = $wpdb->get_results("SELECT count(id) AS next FROM $wpdb->posts
952
- WHERE $_query_add
953
- AND post_date > '$g_enddate'
954
- AND post_status = 'publish'
955
- AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
956
- if ($prev[0][0] != 0) $is_prev = true; else $is_prev = false;
957
- if ($next[0][0] != 0) $is_next = true; else $is_next = false;
958
-
959
- if ($is_prev) {
960
- $previous_month = $jthismonth - 1;
961
- $previous_year = $jthisyear;
962
- if ($previous_month == 0) {
963
- $previous_month = 12;
964
- $previous_year --;
965
- }
966
- }
967
- if ($is_next) {
968
- $next_month = $jthismonth + 1;
969
- $next_year = $jthisyear;
970
- if ($next_month == 13) {
971
- $next_month = 1;
972
- $next_year ++;
973
- }
974
- }
975
-
976
- if ($is_prev) {
977
- echo "\n\t\t".'<td abbr="' . $j_month_name[previous_month] . '" colspan="3" id="prev"><a href="' .
978
- get_month_link($previous_year, $previous_month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $j_month_name[$previous_month], jdate('Y', jmaketime(0, 0 , 0, $previous_month, 1, $previous_year))) . '">&laquo; ' . $j_month_name[$previous_month] . '</a></td>';
979
- } else {
980
- echo "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
981
- }
982
-
983
-
984
- echo "\n\t\t".'<td class="pad">&nbsp;</td>';
985
-
986
- if ($is_next) {
987
- echo "\n\t\t".'<td abbr="' . $j_month_name[$next_month] . '" colspan="3" id="next"><a href="' .
988
- get_month_link($next_year, $next_month) . '" title="View posts for ' . $j_month_name[$next_month] . ' ' .
989
- jdate('Y', jmaketime(0, 0 , 0, $next_month, 1, $next_year)) . '">' . $j_month_name[$next_month] . ' &raquo;</a></td>';
990
- } else {
991
- echo "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
992
- }
993
-
994
- echo '
995
- </tr>
996
- </tfoot>
997
-
998
- <tbody>
999
- <tr>';
1000
-
1001
- $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date),MONTH(post_date),YEAR(post_date)
1002
- FROM $wpdb->posts
1003
- WHERE $_query_add
1004
- AND post_date > '$g_startdate' AND post_date < '$g_enddate'
1005
- AND post_status = 'publish'
1006
- AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
1007
- if ($dayswithposts) {
1008
- foreach ($dayswithposts as $daywith) {
1009
- //$daywithpost[] = $daywith[0];
1010
- $daywithpost[] = jdate("j",mktime(0,0,0,$daywith[1],$daywith[0],$daywith[2]),true);
1011
- }
1012
- } else {
1013
- $daywithpost = array();
1014
- }
1015
-
1016
- if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') ||
1017
- strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') ||
1018
- strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari')) {
1019
- $ak_title_separator = "\n";
1020
- } else {
1021
- $ak_title_separator = ', ';
1022
- }
1023
-
1024
- $ak_titles_for_day = array();
1025
- $ak_post_titles = $wpdb->get_results(
1026
- "SELECT post_title, DAYOFMONTH(post_date) as dom, MONTH(post_date) as month, YEAR(post_date) as year "
1027
- ."FROM $wpdb->posts "
1028
- ."WHERE ".$_query_add." AND post_date > '$g_startdate' AND post_date < '$g_enddate' "
1029
- ."AND 1=1 "
1030
- ."AND post_date < '".current_time('mysql')."' "
1031
- ."AND post_status = 'publish'"
1032
- );
1033
-
1034
-
1035
-
1036
- if ($ak_post_titles) {
1037
- $i = 0;
1038
- while ($ak_post_titles[$i]){
1039
- $ak_post_titles[$i] -> dom = jdate("j",mktime(0,0,0,$ak_post_titles[$i] ->month,$ak_post_titles[$i] ->dom,$ak_post_titles[$i] ->year),true);
1040
- $i++;
1041
- }
1042
- foreach ($ak_post_titles as $ak_post_title) {
1043
- if (empty($ak_titles_for_day['day_'.$ak_post_title->dom])) {
1044
- $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
1045
- }
1046
- if (empty($ak_titles_for_day["$ak_post_title->dom"])) { // first one
1047
- $ak_titles_for_day["$ak_post_title->dom"] = str_replace('"', '&quot;', wptexturize($ak_post_title->post_title));
1048
- } else {
1049
- $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . str_replace('"', '&quot;', wptexturize($ak_post_title->post_title));
1050
- }
1051
- }
1052
- }
1053
-
1054
- // See how much we should pad in the beginning
1055
- $pad = calendar_week_mod(jdate('w', $unixmonth,true)-$week_begins);
1056
- if (0 != $pad) echo "\n\t\t".'<td colspan="'.$pad.'" class="pad">&nbsp;</td>';
1057
-
1058
- $daysinmonth = intval(jdate('t', $unixmonth,true));
1059
- for ($day = 1; $day <= $daysinmonth; ++$day) {
1060
- list($thiyear,$thismonth,$thisday) = jalali_to_gregorian($jthisyear,$jthismonth,$day);
1061
- if (isset($newrow) && $newrow)
1062
- echo "\n\t</tr>\n\t<tr>\n\t\t";
1063
- $newrow = false;
1064
- 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)))
1065
- echo '<td id="today">';
1066
- else
1067
- echo '<td>';
1068
-
1069
- $mps_jd_optionsDB = get_option(MPS_JD_OPTIONS_NAME);
1070
- $mps_jd_farsinum_date = $mps_jd_optionsDB['mps_jd_farsinum_date'];
1071
-
1072
- if ($mps_jd_farsinum_date)
1073
- $day_text = farsi_num($day);
1074
- else
1075
- $day_text = $day;
1076
-
1077
- if (in_array($day, $daywithpost)) { // any posts today?
1078
- echo '<a href="' . get_day_link($jthisyear, $jthismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day_text</a>";
1079
- } else {
1080
- echo $day_text;
1081
- }
1082
- echo '</td>';
1083
-
1084
- if (6 == calendar_week_mod(date('w', jmaketime(0, 0 , 0, $jthismonth, $day, $jthisyear))-$week_begins))
1085
- $newrow = true;
1086
- }
1087
-
1088
- $pad = 7 - calendar_week_mod(date('w', jmaketime(0, 0 , 0, $jthismonth, $day, $jthisyear))-$week_begins);
1089
- if ($pad != 0 && $pad != 7)
1090
- echo "\n\t\t".'<td class="pad" colspan="'.$pad.'">&nbsp;</td>';
1091
-
1092
- echo "\n\t</tr>\n\t</tbody>\n\t</table>";
1093
-
1094
- }
1095
-
1096
- function mps_calendar() {
1097
- global $m,$year;
1098
-
1099
- if ($m != '') {
1100
- $m = '' . preg_replace('|[^0-9]|', '', $m);
1101
- $i_year = substr($m,0,4);
1102
- } else if ($year != '') {
1103
- $i_year = $year;
1104
- }
1105
-
1106
- if ($i_year > 1700) get_calendar(); else get_jcalendar();
1107
-
1108
- }
1109
-
1110
- function get_jpermalink($old_perma, $post) {
1111
- /* Detecting $leavename 2.5+ */
1112
- $leavename = ((strpos($old_perma, '%postname%') !== false) || (strpos($old_perma, '%pagename%') !== false));
1113
-
1114
- $_wp_version = get_bloginfo("version");
1115
- $rewritecode = array(
1116
- '%year%',
1117
- '%monthnum%',
1118
- '%day%',
1119
- '%hour%',
1120
- '%minute%',
1121
- '%second%',
1122
- $leavename? '' : '%postname%',
1123
- '%post_id%',
1124
- '%category%',
1125
- '%author%',
1126
- $leavename? '' : '%pagename%',
1127
- );
1128
-
1129
-
1130
- if ( empty($post->ID) ) return FALSE;
1131
-
1132
- if (( $post->post_status == 'static' ) || ( $post->post_type == 'page' ))
1133
- return get_page_link($post->ID);
1134
- elseif (($post->post_status == 'object') || ($post->post_type == 'attachment'))
1135
- return get_subpost_link($post->ID);
1136
-
1137
- $permalink = get_option('permalink_structure');
1138
-
1139
- if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft')) ) {
1140
- $unixtime = strtotime($post->post_date);
1141
-
1142
- $category = '';
1143
- if ( strpos($permalink, '%category%') !== false ) {
1144
- $cats = get_the_category($post->ID);
1145
- if ( $cats )
1146
- usort($cats, '_usort_terms_by_ID'); // order by ID
1147
- $category = (version_compare($_wp_version, '2.4', '<')) ? $cats[0]->category_nicename : $category = $cats[0]->slug;
1148
- if ( $parent=$cats[0]->category_parent )
1149
- $category = get_category_parents($parent, FALSE, '/', TRUE) . $category;
1150
- }
1151
-
1152
- if ( empty($category) ) {
1153
- $default_category = get_category( get_option( 'default_category' ) );
1154
- $category = is_wp_error( $default_category)? '' : $default_category->slug;
1155
- }
1156
-
1157
- $author = '';
1158
- if ( strpos($permalink, '%author%') !== false ) {
1159
- $authordata = get_userdata($post->post_author);
1160
- $author = $authordata->user_nicename;
1161
- }
1162
-
1163
- $rewritereplace =
1164
- array(
1165
- jdate('Y', $unixtime,true),
1166
- jdate('m', $unixtime,true),
1167
- jdate('d', $unixtime,true),
1168
- jdate('H', $unixtime,true),
1169
- jdate('i', $unixtime,true),
1170
- jdate('s', $unixtime,true),
1171
- $post->post_name,
1172
- $post->ID,
1173
- $category,
1174
- $author,
1175
- $post->post_name,
1176
- );
1177
- $permalink = get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink);
1178
- $permalink = user_trailingslashit($permalink, 'single');
1179
- return $permalink;
1180
- } else { // if they're not using the fancy permalink option
1181
- $permalink = get_option('home') . '/?p=' . $post->ID;
1182
- return $permalink;
1183
- }
1184
- }
1185
-
1186
- function mps_comments_number($input){
1187
- $input = farsi_num($input);
1188
- return $input;
1189
- }
1190
-
1191
- function mps_fixmonthnames() {
1192
- global $month;
1193
- if($mps_jd_optionsDB['mps_jd_country'] == 'AF') {
1194
- $month['01'] = "حمل";
1195
- $month['02'] = "ثور";
1196
- $month['03'] = "جوزا";
1197
- $month['04'] = "سرطان";
1198
- $month['05'] = "اسد";
1199
- $month['06'] = "سنبله";
1200
- $month['07'] = "میزان";
1201
- $month['08'] = "عقرب";
1202
- $month['09'] = "قوس";
1203
- $month['10'] = "جدی";
1204
- $month['11'] = "دلو";
1205
- $month['12'] = "حوت";
1206
- } else {
1207
- $month['01'] = "فروردین";
1208
- $month['02'] = "اردیبهشت";
1209
- $month['03'] = "خرداد";
1210
- $month['04'] = "تیر";
1211
- $month['05'] = "مرداد";
1212
- $month['06'] = "شهریور";
1213
- $month['07'] = "مهر";
1214
- $month['08'] = "آبان";
1215
- $month['09'] = "آذر";
1216
- $month['10'] = "دی";
1217
- $month['11'] = "بهمن";
1218
- $month['12'] = "اسفند";
1219
- }
1220
-
1221
- }
1222
-
1223
- function mps_fixmonthnames_restore() {
1224
- global $month;
1225
- $month['01'] = __('January');
1226
- $month['02'] = __('February');
1227
- $month['03'] = __('March');
1228
- $month['04'] = __('April');
1229
- $month['05'] = __('May');
1230
- $month['06'] = __('June');
1231
- $month['07'] = __('July');
1232
- $month['08'] = __('August');
1233
- $month['09'] = __('September');
1234
- $month['10'] = __('October');
1235
- $month['11'] = __('November');
1236
- $month['12'] = __('December');
1237
- }
1238
-
1239
- function mps_fixtitle($title, $sep=null){
1240
- global $month,$j_month_name;
1241
- global $wp_query;
1242
-
1243
- $m = $wp_query->query_vars['m'];
1244
-
1245
- if ($m != '') {
1246
- $m = '' . preg_replace('|[^0-9]|', '', $m);
1247
- $year = substr($m,0,4);
1248
- } else {
1249
- $year = $wp_query->query_vars['year'];
1250
- }
1251
-
1252
- if ((isset($year)) && ($year < 1700) && (is_archive())) {
1253
- unset($j_month_name[0]);
1254
- $g_months_name = array();
1255
- foreach ($month as $key=>$val){
1256
- $g_month_name[(int) $key] = $val;
1257
- }
1258
-
1259
- $title = str_replace($g_month_name, $j_month_name, $title);
1260
- }
1261
-
1262
- return $title;
1263
- }
1264
-
1265
- function mps_fixMCEdir(){
1266
- echo "directionality : \"rtl\" ,";
1267
- }
1268
-
1269
- function mps_mce_plugins($input){
1270
- $input[] = "directionality";
1271
- return $input;
1272
- }
1273
- function mps_mce_buttons($input){
1274
- $new_buttons = array();
1275
- if (!in_array("rtl",$input)) {
1276
- $new_buttons = array("separator","ltr","rtl");
1277
- }
1278
- return array_merge($input,$new_buttons);
1279
- }
1280
-
1281
-
1282
- function mps_mce_set_direction( $input ) {
1283
- global $wp_locale;
1284
-
1285
- // The paradox is logical, because we just do this in the case that Wordpress is in LTR Mode
1286
- if (!( 'rtl' == $wp_locale->text_direction )) {
1287
- $input['directionality'] = 'rtl';
1288
- $input['plugins'] .= ',directionality';
1289
- $input['theme_advanced_buttons1'] .= ',ltr';
1290
- }
1291
- return $input;
1292
- }
1293
-
1294
-
1295
- function mps_farsikeyboard() {
1296
- /* Simple API for adding farsitype.js to themes */
1297
- if (!file_exists(MPS_JD_DIR . '/inc/js/farsitype.js') ) return;
1298
- $script_uri = MPS_JD_URI.'/inc/js/farsitype.js';
1299
- echo "<script language=\"javascript\" src=\"$script_uri\" type=\"text/javascript\"></script>";
1300
-
1301
- }
1302
-
1303
-
1304
- $_wp_version = get_bloginfo("version");
1305
-
1306
- add_action('admin_menu', 'mps_jd_menu');
1307
-
1308
- if (version_compare($_wp_version, '2', '<')) {
1309
- add_action('init', 'mps_fixmonthnames');
1310
- add_action('wp_head', 'mps_fixmonthnames_restore');
1311
- } else {
1312
- //add_filter('wp_title', 'mps_fixtitle',2);
1313
- $mps_jd_optionsDB = get_option(MPS_JD_OPTIONS_NAME);
1314
- $mps_jd_mcertl = $mps_jd_optionsDB['mps_jd_mcertl'];
1315
-
1316
- if (version_compare($_wp_version, '2.4', '<')) { // Older Versions of Wordpress < 2.5
1317
- add_filter("mce_plugins","mps_mce_plugins");
1318
- add_filter("mce_buttons","mps_mce_buttons");
1319
- if ((isset($mps_jd_mcertl) && ($mps_jd_mcertl == true))) {
1320
- add_action('mce_options','mps_fixMCEdir');
1321
- }
1322
- } else { // 2.5 and above
1323
- if ((isset($mps_jd_mcertl) && ($mps_jd_mcertl == true))) { // Using Wordpress API for tinymce RTL
1324
- add_filter('tiny_mce_before_init', 'mps_mce_set_direction');
1325
- }
1326
- }
1327
- }
1328
-
1329
- /* Login Form Functions */
1330
- function login_url() {
1331
- return 'http://wp-persian.com';
1332
- }
1333
- function login_text() {
1334
- return 'با نیروی وردپرس فارسی';
1335
- }
1336
-
1337
- function login_img() {
1338
- echo '<style>#login h1 a {background: transparent url(wp-content/plugins/wp-jalali/images/wp-fa-logo.png) no-repeat scroll center top}</style>';
1339
- }
1340
-
1341
- /* Tags */
1342
-
1343
- /*
1344
- function mps_loadjs() {
1345
- //wp_enqueue_script( 'jalalitags', MPS_JD_URI . '/inc/js/tags.js', array('jquery'), '1.1');
1346
- }
1347
- */
1348
-
1349
- /* Core changes */
1350
- update_option('rss_language', 'fa'); // change rss language to fa for some rss reader like IE7 to understand that the direction is RTL.
1351
- @define('WP_MEMORY_LIMIT', '64M'); // Increse memory limit because of translation pressure.
1352
-
1353
- add_filter("posts_where","mps_jalali_query");
1354
-
1355
- $mps_jd_optionsDB = get_option(MPS_JD_OPTIONS_NAME);
1356
-
1357
- $mps_jd_autodate = $mps_jd_optionsDB['mps_jd_autodate'];
1358
- $mps_jd_farsinum_content = $mps_jd_optionsDB['mps_jd_farsinum_content'];
1359
- $mps_jd_farsinum_comment = $mps_jd_optionsDB['mps_jd_farsinum_comment'];
1360
- $mps_jd_farsinum_commentnum = $mps_jd_optionsDB['mps_jd_farsinum_commentnum'];
1361
- $mps_jd_farsinum_title = $mps_jd_optionsDB['mps_jd_farsinum_title'];
1362
- $mps_jd_farsinum_category = $mps_jd_optionsDB['mps_jd_farsinum_category'];
1363
- $mps_jd_jperma = $mps_jd_optionsDB['mps_jd_jperma'];
1364
- $mps_jd_autoyk = $mps_jd_optionsDB['mps_jd_autoyk'];
1365
- $mps_jd_editjalali = $mps_jd_optionsDB['mps_jd_editjalali'];
1366
-
1367
-
1368
- if ($mps_jd_autodate) {
1369
- add_filter("the_date","mps_the_jdate",10,4);
1370
- add_filter("the_time","mps_the_jtime",10,4);
1371
- //add_filter("get_the_date","mps_the_jdate",10,4);
1372
- //add_filter("get_the_time","mps_the_jtime",10,4);
1373
- add_filter("get_comment_date","mps_comment_jdate",10,2); //works only in wp > 1.5.1
1374
- add_filter("get_comment_time","mps_comment_jtime",10,2); //works only in wp > 1.5.1
1375
- add_filter("the_weekday","mps_the_jweekday");
1376
- add_filter("the_weekday_date","mps_the_jweekday_date",10,3);
1377
- }
1378
-
1379
- if ($mps_jd_farsinum_content) add_filter("the_content","farsi_num",10);
1380
- if ($mps_jd_farsinum_comment) add_filter("comment_text","farsi_num",10);
1381
- if ($mps_jd_farsinum_commentnum) add_filter("comments_number","farsi_num",10);
1382
- if ($mps_jd_farsinum_title) add_filter("the_title","farsi_num",10,3);
1383
- if ($mps_jd_farsinum_category) add_filter("wp_list_categories","farsi_num",10,1);
1384
-
1385
- if ($mps_jd_jperma) add_filter("post_link","get_jpermalink",10,3);
1386
-
1387
- /* Y-K Solve */
1388
-
1389
- if ($mps_jd_autoyk) {
1390
- add_filter( 'posts_request', 'mps_yk_solve_search' );
1391
-
1392
- add_filter('the_content','mps_yk_solve_persian',10,1);
1393
- add_filter('get_the_content','mps_yk_solve_persian',10,1);
1394
- add_filter('the_excerpt','mps_yk_solve_persian',10,1);
1395
- add_filter('get_the_excerpt','mps_yk_solve_persian',10,1);
1396
- add_filter('link_title','mps_yk_solve_persian',10,1);
1397
- add_filter('wp_title','mps_yk_solve_persian',10,1);
1398
- add_filter('the_title','mps_yk_solve_persian',10,1);
1399
- add_filter('the_title_rss','mps_yk_solve_persian',10,1);
1400
- add_filter('get_the_title','mps_yk_solve_persian',10,1);
1401
- add_filter('get_the_title_rss','mps_yk_solve_persian',10,1);
1402
- add_filter('get_comment_excerpt','mps_yk_solve_persian',10,1);
1403
- add_filter('get_comment_text','mps_yk_solve_persian',10,1);
1404
- add_filter('get_comment_author','mps_yk_solve_persian',10,1);
1405
- add_filter('the_author','mps_yk_solve_persian',10,1);
1406
- //To Do : Bookmarks & Tags - get_bookmarks & get_tags
1407
- }
1408
-
1409
-
1410
-
1411
- if (!version_compare($_wp_version, '2.4', '<')) { //Wordpress 2.5+ Only
1412
- /* Dashboard Widgets */
1413
-
1414
- add_filter('dashboard_primary_link', 'mps_dashboard_primary_link',10,1);
1415
- add_filter('dashboard_primary_feed', 'mps_dashboard_primary_feed',10,1);
1416
- add_filter('dashboard_primary_title', 'mps_dashboard_primary_title',10,1);
1417
-
1418
- add_filter('dashboard_secondary_link', 'mps_dashboard_secondary_link',10,1);
1419
- add_filter('dashboard_secondary_feed', 'mps_dashboard_secondary_feed',10,1);
1420
- add_filter('dashboard_secondary_title', 'mps_dashboard_secondary_title',10,1);
1421
-
1422
- /* Edit Jalali timestamp in Write Page */
1423
-
1424
- if ($mps_jd_editjalali) {
1425
- add_action('edit_form_advanced', 'jalali_timestamp_admin'); // for posts
1426
- add_action('edit_page_form', 'jalali_timestamp_admin'); // for pages
1427
- }
1428
-
1429
- }
1430
-
1431
- /* Login Form */
1432
-
1433
- add_filter('login_headerurl', 'login_url',999);
1434
- add_filter('login_headertitle', 'login_text',999);
1435
- //add_action('login_head', 'login_img',999);
1436
-
1437
- /* Theme Widgets */
1438
-
1439
- add_action('widgets_init', 'widget_jarchive_init');
1440
- add_action('widgets_init', 'widget_mps_calendar_init');
1441
-
1442
- // add_action('wp_print_scripts', 'mps_loadjs');
1443
- ?>
1
+ <?php
2
+ /*
3
+ Plugin Name: wp-jalali
4
+ Plugin URI: http://wp-persian.com/wp-jalali
5
+ Description: Full Jalali calendar support for Wordpress and localization improvements for Persian/Afghan/Tajik users.
6
+ Version: 5.0.0-RC
7
+ Author: Zakrot Web Solutions (in collaboration with WP-Persian team)
8
+ Author URI: http://zakrot.com/
9
+ Text Domain: ztjalali
10
+ Domain Path: /languages
11
+ */
12
+
13
+ # Copyright 2005-2014 Wordpress Persian Project (email : info@wp-persian.com)
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of the GNU General Public License as published by
17
+ # the Free Software Foundation; either version 2 of the License, or
18
+ # (at your option) any later version.
19
+ #
20
+ # This program is distributed in the hope that it will be useful,
21
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ # GNU General Public License for more details.
24
+ #
25
+ # You should have received a copy of the GNU General Public License
26
+ # along with this program; if not, write to the Free Software
27
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28
+ #
29
+ #
30
+ # Contributors:
31
+ #
32
+ # Since 5.0:
33
+ # Zakrot Web Solutions
34
+ # Mani Monajjemi
35
+ #
36
+ # 3.x, 4.x:
37
+ # Mani Monajjemi
38
+ # Gonahkar
39
+ # Reza Moallemi
40
+ #
41
+ # Special Thanks to :
42
+ # Ali Farhadi (farhadi.ir) for improving Farsi Number Convertor and js jalali date lib.
43
+ # Vahid Sohrablu (iranphp.org) for pdate lib.
44
+ #
45
+
46
+ /*
47
+ * define plugin dir
48
+ */
49
+ defined('JALALI_DIR') or define('JALALI_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR);
50
+ /* =================================================================== */
51
+
52
+ /**
53
+ * include structor
54
+ */
55
+ include JALALI_DIR.'wp-jalali-functions.php';
56
+ include JALALI_DIR.'wp-jalali-config.php';
57
+ include JALALI_DIR.'wp-jalali-init.php';
58
+ /* =================================================================== */
59
+
60
+ /**
61
+ * include libs
62
+ */
63
+ include JALALI_DIR.'lib'.DIRECTORY_SEPARATOR.'date.php';
64
+ include JALALI_DIR.'lib'.DIRECTORY_SEPARATOR.'deprecated_fns.php';
65
+ /* =================================================================== */
66
+
67
+ /**
68
+ * initialize...
69
+ */
70
+ ztjalali_init();
71
+ register_activation_hook(__FILE__, 'ztjalali_installer');
72
+ add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'ztjalali_add_settings_link' );
73
+ /* =================================================================== */
74
+
75
+ /**
76
+ * include admin stuff and filter handlers
77
+ */
78
+ include JALALI_DIR.'inc'.DIRECTORY_SEPARATOR.'wp-jalali-admin.php';
79
+ include JALALI_DIR.'inc'.DIRECTORY_SEPARATOR.'wp-jalali-filters.php';
80
+ /* =================================================================== */
81
+
82
+ /**
83
+ * include widgets (include low important libs here)
84
+ */
85
+ include JALALI_DIR.'widget'.DIRECTORY_SEPARATOR.'widget_archive.php';
86
+ include JALALI_DIR.'widget'.DIRECTORY_SEPARATOR.'widget_calendar.php';
87
+ /* =================================================================== */