wp-jalali - Version 4.0

Version Description

Download this release

Release Info

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

Code changes from version 3.5.1 to 4.0

wp-fa-logo.png → images/wp-fa-logo.png RENAMED
File without changes
inc/dashboard-core.php ADDED
@@ -0,0 +1,72 @@
1
+ <?php
2
+ $primary_replacement =
3
+ array (
4
+ 1 => array (
5
+ 'link' => 'http://wordpress.org/development/',
6
+ 'feed' => 'http://wordpress.org/development/feed/',
7
+ 'title' => 'WordPress Development Blog'
8
+ ),
9
+ 2 => array (
10
+ 'link' => 'http://wp-persian.com/',
11
+ 'feed' => 'http://wp-persian.com/feed/',
12
+ 'title' => 'اخبار وردپرس فارسی'
13
+ )
14
+ );
15
+ $secondary_replacement =
16
+ array (
17
+ 1 => array (
18
+ 'link' => 'http://planet.wordpress.org/',
19
+ 'feed' => 'http://planet.wordpress.org/feed/',
20
+ 'title' => 'Other WordPress News'
21
+ ),
22
+ 2 => array (
23
+ 'link' => 'http://planet.wp-persian.com/',
24
+ 'feed' => 'http://planet.wp-persian.com/feed/',
25
+ 'title' => 'سیاره وردپرس فارسی'
26
+ )
27
+ );
28
+
29
+ function mps_dashboard_primary_link ($value) {
30
+ global $primary_replacement, $mps_jd_optionsDB;
31
+ $mps_jd_dashboard = $mps_jd_optionsDB['mps_jd_dashboard'];
32
+
33
+ $ret = ($mps_jd_dashboard == 0) ? $value : $primary_replacement[$mps_jd_dashboard]['link'];
34
+ return $ret;
35
+ }
36
+
37
+ function mps_dashboard_primary_feed ($value) {
38
+ global $primary_replacement, $mps_jd_optionsDB;
39
+ $mps_jd_dashboard = $mps_jd_optionsDB['mps_jd_dashboard'];
40
+
41
+ return ($mps_jd_dashboard == 0) ? $value : $primary_replacement[$mps_jd_dashboard]['feed'];
42
+ }
43
+
44
+ function mps_dashboard_primary_title ($value) {
45
+ global $primary_replacement, $mps_jd_optionsDB;
46
+ $mps_jd_dashboard = $mps_jd_optionsDB['mps_jd_dashboard'];
47
+
48
+ return ($mps_jd_dashboard == 0) ? $value : $primary_replacement[$mps_jd_dashboard]['title'];
49
+ }
50
+
51
+ function mps_dashboard_secondary_link ($value) {
52
+ global $secondary_replacement, $mps_jd_optionsDB;
53
+ $mps_jd_dashboard = $mps_jd_optionsDB['mps_jd_dashboard'];
54
+
55
+ return ($mps_jd_dashboard == 0) ? $value : $secondary_replacement[$mps_jd_dashboard]['link'];
56
+ }
57
+
58
+ function mps_dashboard_secondary_feed ($value) {
59
+ global $secondary_replacement, $mps_jd_optionsDB;
60
+ $mps_jd_dashboard = $mps_jd_optionsDB['mps_jd_dashboard'];
61
+
62
+ return ($mps_jd_dashboard == 0) ? $value : $secondary_replacement[$mps_jd_dashboard]['feed'];
63
+ }
64
+
65
+ function mps_dashboard_secondary_title ($value) {
66
+ global $secondary_replacement, $mps_jd_optionsDB;
67
+ $mps_jd_dashboard = $mps_jd_optionsDB['mps_jd_dashboard'];
68
+
69
+ return ($mps_jd_dashboard == 0) ? $value : $secondary_replacement[$mps_jd_dashboard]['title'];
70
+ }
71
+
72
+ ?>
inc/deprecated.php ADDED
@@ -0,0 +1,31 @@
1
+ <?php
2
+ if (!function_exists('fetch_rss')) require_once (ABSPATH . WPINC . '/rss-functions.php');
3
+ if (!function_exists('error')) {
4
+ function error ($errormsg, $lvl=E_USER_WARNING) {
5
+ // append PHP's error message if track_errors enabled
6
+ if ( $php_errormsg ) {
7
+ $errormsg .= " ($php_errormsg)";
8
+ }
9
+ if ( MAGPIE_DEBUG ) {
10
+ trigger_error( $errormsg, $lvl);
11
+ }
12
+ else {
13
+ error_log( $errormsg, 0);
14
+ }
15
+
16
+ $notices = E_USER_NOTICE|E_NOTICE;
17
+ if ( $lvl&$notices ) {
18
+ $this->WARNING = $errormsg;
19
+ } else {
20
+ $this->ERROR = $errormsg;
21
+ }
22
+ }
23
+ }
24
+
25
+ function mps_mce_pretext($input=null){
26
+ $_nbsp = "&nbsp;";
27
+ $_p = "<p dir=\"rtl\">".$_nbsp."</p>";
28
+ return (strlen($input)==0?$_p:$input);
29
+ }
30
+
31
+ ?>
inc/editjalali-core.php ADDED
@@ -0,0 +1,84 @@
1
+ <?php
2
+ function jalali_touch_time( $edit = 1, $for_post = 1 ) {
3
+ global $wp_locale, $post, $comment, $j_month_name;
4
+
5
+ if ( $for_post )
6
+ $edit = ( ('draft' == $post->post_status ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true;
7
+
8
+ $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
9
+ $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
10
+ $jj = ($edit) ? mysql2date( 'd', $post_date ) : gmdate( 'd', $time_adj );
11
+ $mm = ($edit) ? mysql2date( 'm', $post_date ) : gmdate( 'm', $time_adj );
12
+ $aa = ($edit) ? mysql2date( 'Y', $post_date ) : gmdate( 'Y', $time_adj );
13
+ $hh = ($edit) ? mysql2date( 'H', $post_date ) : gmdate( 'H', $time_adj );
14
+ $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj );
15
+ $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj );
16
+
17
+ $jalali_time = gregorian_to_jalali($aa,$mm,$jj);
18
+ $jy = $jalali_time[0];
19
+ $jm = $jalali_time[1];
20
+ $jd = $jalali_time[2];
21
+
22
+ echo "\n<script type=\"text/javascript\" src=\"" . get_option('siteurl') ."/wp-content/plugins/wp-jalali/inc/editjalali.js\"></script>\n";
23
+ ?>
24
+ <style>
25
+ #jmonths {
26
+ direction:rtl;
27
+ text-align: right;
28
+ }
29
+ </style>
30
+ <script type="text/javascript">
31
+ function jalali_timestamp_func() {
32
+ var jd = jQuery('#jd').attr('value');
33
+ var jy = jQuery('#jy').attr('value');
34
+ var jm = jQuery('select#jm_select > option[@selected]').attr('value');
35
+ if(!jd) jd = <?php echo $jd; ?>;
36
+ if(!jm) jm = <?php echo $jm; ?>;
37
+ if(!jy) jy = <?php echo $jy; ?>;
38
+ var j_time_array = new Array(jy,jm,jd);
39
+ var j2g = jalali_to_gregorian(j_time_array);
40
+ var gy = j2g[0];
41
+ var gm = j2g[1];
42
+ var gd = j2g[2];
43
+ jQuery('#jj').attr('value',gd);
44
+ jQuery('#aa').attr('value',gy);
45
+ if(gm<10) gm = "0"+gm;
46
+ jQuery('select[@name=mm] > option[@value='+gm+']').attr('selected','selected');
47
+ }
48
+ function inject_jalali_div() { // injecting jalali input boxes and month list under the default georgian date place
49
+ jQuery("#timestampdiv *").hide();
50
+ jQuery("#timestampdiv").append('<div id="jalalitimestamp"></div>');
51
+ jQuery("#jalalitimestamp").append('<select onchange="jalali_timestamp_func()" name="jm" id="jm_select"></select> ');
52
+ <?php
53
+ for ( $i = 1; $i < 13; $i = $i +1 ) {
54
+ echo "\tjQuery(\"#jm_select\").append('<option value=\"$i\" id=\"jm_$i\">$j_month_name[$i]</option>');\n";
55
+ }
56
+ ?>
57
+ jQuery("#jalalitimestamp").append('<input type="text" id="jd" name="jd" value="<?php echo $jd; ?>" size="2" maxlength="2" onchange="jalali_timestamp_func()"/> ');
58
+ jQuery("#jalalitimestamp").append('<input type="text" id="jy" name="jy" value="<?php echo $jy ?>" size="4" maxlength="5" onchange="jalali_timestamp_func()" />');
59
+ jQuery("#jalalitimestamp").append('<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" onchange="jalali_timestamp_func()" />');
60
+ jQuery("#jalalitimestamp").append('<br />ساعت: <input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" onchange="jalali_timestamp_func()" /> : <input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" onchange="jalali_timestamp_func()" /> دقیقه');
61
+ jQuery("select#jm_select > option[@value=<?php echo $jm; ?>]").attr('selected','selected');
62
+ jQuery("select#mm, input#jj, input#aa").attr("onchange","georgian_timestamp_func()");
63
+ <?php
64
+ if ( $edit ) {
65
+ echo "jQuery(\"a.edit-timestamp\").before('" . farsi_num(sprintf( __('<br /> %2$s %1$s / %3$s در %4$s:%5$s' ), $j_month_name[$jm], $jd, $jy, $hh, $mn )) . " <br />');\n";
66
+ }
67
+ ?>
68
+ }
69
+ </script>
70
+ <script type="text/javascript">
71
+ jQuery(document).ready(function() {
72
+ inject_jalali_div();
73
+ });
74
+ </script>
75
+ <?php
76
+
77
+ }
78
+
79
+ function jalali_timestamp_admin() {
80
+ if ( current_user_can('edit_posts') ) :
81
+ jalali_touch_time(($action == 'edit'));
82
+ endif;
83
+ }
84
+ ?>
inc/editjalali.js ADDED
@@ -0,0 +1 @@
1
+ eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('t=l q(9,Z,9,e,9,e,9,9,e,9,e,9);u=l q(9,9,9,9,9,9,e,e,e,e,e,U);y c(a,b){v W.N(a/b)}y E(g){d 7,k,p;d f,o,n;d 5,6;d z;d i;7=g[0]-I;k=g[1]-1;p=g[2]-1;5=h*7+c((7+3),4)-c((7+P),C)+c((7+Q),B);s(i=0;i<k;++i)5+=t[i];r(k>1&&((7%4==0&&7%C!=0)||(7%B==0)))++5;5+=p;6=5-H;z=c(6,F);6%=F;f=G+A*z+4*c(6,x);6%=x;r(6>=D){f+=c((6-1),h);6=(6-1)%h}s(i=0;i<R&&6>=u[i];++i){6-=u[i]}o=i+1;n=6+1;v l q(f,o,n)}y S(j){d 7,k,p;d f,o,n;d 5,6;d m;d i;f=j[0]-G;o=j[1]-1;n=j[2]-1;6=h*f+c(f,A)*8+c((f%A+3),4);s(i=0;i<o;++i)6+=u[i];6+=n;5=6+H;7=I+B*c(5,J);5=5%J;m=1;r(5>=Y){5--;7+=C*c(5,K);5=5%K;r(5>=h)5++;L m=0}7+=4*c(5,x);5%=x;r(5>=D){m=0;5--;7+=c(5,h);5=5%h}s(i=0;5>=t[i]+(i==1&&m);i++)5-=t[i]+(i==1&&m);k=i+1;p=5+1;v l q(7,k,p)}y M(){w=l T();j=E(l q(w.V(),w.X()+1,w.O()));v j[2]+"/"+j[1]+"/"+j[0]}',62,62,'|||||g_day_no|j_day_no|gy||31|||div|var|30|jy||365|||gm|new|leap|jd|jm|gd|Array|if|for|g_days_in_month|j_days_in_month|return|Today|1461|function|j_np|33|400|100|366|gregorian_to_jalali|12053|979|79|1600|146097|36524|else|jalali_today|floor|getDate|99|399|11|jalali_to_gregorian|Date|29|getFullYear|Math|getMonth|36525|28'.split('|'),0,{}))
inc/farsinum-core.php ADDED
@@ -0,0 +1,20 @@
1
+ <?php
2
+ /* These 2 Functions are new Farsi Num convert implemented in ver 4,
3
+ Originally written by Farhadi , www.farhadi.ir
4
+ */
5
+
6
+ function convertToFarsi($matches) {
7
+ $out = '';
8
+ if (isset($matches[1])) {
9
+ return str_replace(
10
+ array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "."),
11
+ array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", "/"),
12
+ $matches[1]);
13
+ }
14
+ return $matches[0];
15
+ }
16
+
17
+ function farsi_num($num,$fake = null,$fake2=null) {
18
+ return preg_replace_callback('/(?:&#\d{2,4};)|(\d+[\.\d]*)|(?:[a-z](?:[\x00-\x3B\x3D-\x7F]|<\s*[^>]+>)*)|<\s*[^>]+>/i', 'convertToFarsi', $num);
19
+ }
20
+ ?>
farsitype.js → inc/farsitype.js RENAMED
File without changes
inc/jalali-core.php ADDED
@@ -0,0 +1,464 @@
1
+ <?php
2
+
3
+ /* Jalali Core Functions */
4
+
5
+ define("_JDF_USE_PERSIANNUM","0");
6
+ define("_JDF_TZhours","0");
7
+ define("_JDF_TZminute","0");
8
+ define('_JDF_AM_LONG','قبل از ظهر');
9
+ define('_JDF_PM_LONG','بعد از ظهر');
10
+ define('_JDF_AM_SHORT','ق.ظ');
11
+ define('_JDF_PM_SHORT','ب.ظ');
12
+ define('_JDF_Sat_LONG','شنبه');
13
+ define('_JDF_Sun_LONG','یکشنبه');
14
+ define('_JDF_Mon_LONG','دوشنبه');
15
+ define('_JDF_Tue_LONG','سه شنبه');
16
+ define('_JDF_Wed_LONG','چهارشنبه');
17
+ define('_JDF_Thu_LONG','پنجشنبه');
18
+ define('_JDF_Fri_LONG','جمعه');
19
+ define('_JDF_Sat_SHORT','ش');
20
+ define('_JDF_Sun_SHORT','ی');
21
+ define('_JDF_Mon_SHORT','د');
22
+ define('_JDF_Tue_SHORT','س');
23
+ define('_JDF_Wed_SHORT','چ');
24
+ define('_JDF_Thu_SHORT','پ');
25
+ define('_JDF_Fri_SHORT','ج');
26
+ define('_JDF_Suffix','م');
27
+ define('_JDF_Far','فروردین');
28
+ define('_JDF_Ord','اردیبهشت');
29
+ define('_JDF_Kho','خرداد');
30
+ define('_JDF_Tir','تیر');
31
+ define('_JDF_Mor','مرداد');
32
+ define('_JDF_Sha','شهریور');
33
+ define('_JDF_Meh','مهر');
34
+ define('_JDF_Aba','آبان');
35
+ define('_JDF_Aza','آذر');
36
+ define('_JDF_Dey','دی');
37
+ define('_JDF_Bah','بهمن');
38
+ define('_JDF_Esf','اسفند');
39
+ define('_JDF_Num0','۰');
40
+ define('_JDF_Num1','۱');
41
+ define('_JDF_Num2','۲');
42
+ define('_JDF_Num3','۳');
43
+ define('_JDF_Num4','۴');
44
+ define('_JDF_Num5','۵');
45
+ define('_JDF_Num6','۶');
46
+ define('_JDF_Num7','۷');
47
+ define('_JDF_Num8','۸');
48
+ define('_JDF_Num9','۹');
49
+
50
+ $g_days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
51
+ $j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
52
+ $j_month_name = array("", "فروردین", "اردیبهشت", "خرداد", "تیر","مرداد", "شهریور", "مهر", "آبان", "آذر","دی", "بهمن", "اسفند");
53
+ $j_day_name = array("یکشنبه","دوشنبه","سه شنبه","چهارشنبه","پنجشنبه","جمعه","شنبه");
54
+ $jday_abbrev = array("ی","د","س","چ","پ","ج","ش");
55
+
56
+ /* Farsiweb.info Jaladi/Gregorian Convertion Functions */
57
+
58
+ function div($a, $b)
59
+ {
60
+ return (int) ($a / $b);
61
+ }
62
+
63
+ function jalali_to_gregorian($j_y, $j_m, $j_d)
64
+ {
65
+ global $g_days_in_month;
66
+ global $j_days_in_month;
67
+
68
+ $jy = $j_y-979;
69
+ $jm = $j_m-1;
70
+ $jd = $j_d-1;
71
+
72
+ $j_day_no = 365*$jy + div($jy, 33)*8 + div($jy%33+3, 4);
73
+ for ($i=0; $i < $jm; ++$i)
74
+ $j_day_no += $j_days_in_month[$i];
75
+
76
+ $j_day_no += $jd;
77
+
78
+ $g_day_no = $j_day_no+79;
79
+
80
+ $gy = 1600 + 400*div($g_day_no, 146097); /* 146097 = 365*400 + 400/4 - 400/100 + 400/400 */
81
+ $g_day_no = $g_day_no % 146097;
82
+
83
+ $leap = true;
84
+ if ($g_day_no >= 36525) /* 36525 = 365*100 + 100/4 */
85
+ {
86
+ $g_day_no--;
87
+ $gy += 100*div($g_day_no, 36524); /* 36524 = 365*100 + 100/4 - 100/100 */
88
+ $g_day_no = $g_day_no % 36524;
89
+
90
+ if ($g_day_no >= 365)
91
+ $g_day_no++;
92
+ else
93
+ $leap = false;
94
+ }
95
+
96
+ $gy += 4*div($g_day_no, 1461); /* 1461 = 365*4 + 4/4 */
97
+ $g_day_no %= 1461;
98
+
99
+ if ($g_day_no >= 366) {
100
+ $leap = false;
101
+
102
+ $g_day_no--;
103
+ $gy += div($g_day_no, 365);
104
+ $g_day_no = $g_day_no % 365;
105
+ }
106
+
107
+ for ($i = 0; $g_day_no >= $g_days_in_month[$i] + ($i == 1 && $leap); $i++)
108
+ $g_day_no -= $g_days_in_month[$i] + ($i == 1 && $leap);
109
+ $gm = $i+1;
110
+ $gd = $g_day_no+1;
111
+
112
+ return array($gy, $gm, $gd);
113
+ }
114
+
115
+ function jcheckdate($j_m, $j_d, $j_y)
116
+ {
117
+ global $j_days_in_month;
118
+
119
+ if ($j_y < 0 || $j_y > 32767 || $j_m < 1 || $j_m > 12 || $j_d < 1 || $j_d >
120
+ ($j_days_in_month[$j_m-1] + ($j_m == 12 && !(($j_y-979)%33%4))))
121
+ return false;
122
+ return true;
123
+ }
124
+
125
+ function gregorian_week_day($g_y, $g_m, $g_d)
126
+ {
127
+ global $g_days_in_month;
128
+
129
+ $gy = $g_y-1600;
130
+ $gm = $g_m-1;
131
+ $gd = $g_d-1;
132
+
133
+ $g_day_no = 365*$gy+div($gy+3,4)-div($gy+99,100)+div($gy+399,400);
134
+
135
+ for ($i=0; $i < $gm; ++$i)
136
+ $g_day_no += $g_days_in_month[$i];
137
+ if ($gm>1 && (($gy%4==0 && $gy%100!=0) || ($gy%400==0)))
138
+ /* leap and after Feb */
139
+ ++$g_day_no;
140
+ $g_day_no += $gd;
141
+
142
+ return ($g_day_no + 5) % 7 + 1;
143
+ }
144
+
145
+ function jalali_week_day($j_y, $j_m, $j_d)
146
+ {
147
+ global $j_days_in_month;
148
+
149
+ $jy = $j_y-979;
150
+ $jm = $j_m-1;
151
+ $jd = $j_d-1;
152
+
153
+ $j_day_no = 365*$jy + div($jy, 33)*8 + div($jy%33+3, 4);
154
+
155
+ for ($i=0; $i < $jm; ++$i)
156
+ $j_day_no += $j_days_in_month[$i];
157
+
158
+ $j_day_no += $jd;
159
+
160
+ return ($j_day_no + 2) % 7 + 1;
161
+ }
162
+
163
+
164
+ function gregorian_to_jalali($g_y, $g_m, $g_d)
165
+ {
166
+ global $g_days_in_month;
167
+ global $j_days_in_month;
168
+
169
+ $gy = $g_y-1600;
170
+ $gm = $g_m-1;
171
+ $gd = $g_d-1;
172
+
173
+ $g_day_no = 365*$gy+div($gy+3,4)-div($gy+99,100)+div($gy+399,400);
174
+
175
+ for ($i=0; $i < $gm; ++$i)
176
+ $g_day_no += $g_days_in_month[$i];
177
+ if ($gm>1 && (($gy%4==0 && $gy%100!=0) || ($gy%400==0)))
178
+ /* leap and after Feb */
179
+ ++$g_day_no;
180
+ $g_day_no += $gd;
181
+
182
+ $j_day_no = $g_day_no-79;
183
+
184
+ $j_np = div($j_day_no, 12053);
185
+ $j_day_no %= 12053;
186
+
187
+ $jy = 979+33*$j_np+4*div($j_day_no,1461);
188
+
189
+ $j_day_no %= 1461;
190
+
191
+ if ($j_day_no >= 366) {
192
+ $jy += div($j_day_no-1, 365);
193
+ $j_day_no = ($j_day_no-1)%365;
194
+ }
195
+
196
+ for ($i = 0; $i < 11 && $j_day_no >= $j_days_in_month[$i]; ++$i) {
197
+ $j_day_no -= $j_days_in_month[$i];
198
+ }
199
+ $jm = $i+1;
200
+ $jd = $j_day_no+1;
201
+
202
+
203
+ return array($jy, $jm, $jd);
204
+ }
205
+
206
+ /*
207
+ Jalali Date function by Milad Rastian (miladmovie AT yahoo DOT com)
208
+ jdf.farsiprojects.com
209
+ */
210
+
211
+
212
+ function jdate($type,$maket="now",$forcelatinnums=false)
213
+ {
214
+ $result="";
215
+ if($maket=="now"){
216
+ $year=date("Y");
217
+ $month=date("m");
218
+ $day=date("d");
219
+ list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
220
+ $maket=jmaketime(date("h")+_JDF_TZhours,date("i")+_JDF_TZminute,date("s"),$jmonth,$jday,$jyear);
221
+ }else{
222
+ $maket+=_JDF_TZhours*3600+_JDF_TZminute*60;
223
+ $date=date("Y-m-d",$maket);
224
+ list( $year, $month, $day ) = preg_split ( '/-/', $date );
225
+
226
+ list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
227
+ }
228
+
229
+ $need= $maket;
230
+ $year=date("Y",$need);
231
+ $month=date("m",$need);
232
+ $day=date("d",$need);
233
+ $i=0;
234
+ $skipnext = false;
235
+ while($i<strlen($type))
236
+ {
237
+ $subtype=substr($type,$i,1);
238
+
239
+ if ($skipnext) {
240
+ $result .= $subtype;
241
+ $skipnext = false;
242
+ $i++;
243
+ continue;
244
+ }
245
+
246
+
247
+ switch ($subtype)
248
+ {
249
+ case "A":
250
+ $result1=date("a",$need);
251
+ if($result1=="pm")
252
+ $result.=_JDF_PM_LONG;
253
+ else
254
+ $result.=_JDF_AM_LONG;
255
+ break;
256
+
257
+ case "a":
258
+ $result1=date("a",$need);
259
+ if($result1=="pm")
260
+ $result.=_JDF_PM_SHORT;
261
+ else
262
+ $result.=_JDF_AM_SHORT;
263
+ break;
264
+
265
+ case "d":
266
+ list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
267
+ if($jday<10)
268
+ $result1="0".$jday;
269
+ else
270
+ $result1=$jday;
271
+
272
+ $result.=$result1;
273
+ break;
274
+
275
+ case "D":
276
+ $result1=date("D",$need);
277
+ if($result1=="Sat") $result1=_JDF_Sat_SHORT;
278
+ else if($result1=="Sun") $result1=_JDF_Sun_SHORT;
279
+ else if($result1=="Mon") $result1=_JDF_Mon_SHORT;
280
+ else if($result1=="Tue") $result1=_JDF_Tue_SHORT;
281
+ else if($result1=="Wed") $result1=_JDF_Wed_SHORT;
282
+ else if($result1=="Thu") $result1=_JDF_Thu_SHORT;
283
+ else if($result1=="Fri") $result1=_JDF_Fri_SHORT;
284
+ $result.=$result1;
285
+ break;
286
+
287
+ case"F":
288
+ list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
289
+ $result.=monthname($jmonth);
290
+ break;
291
+
292
+ case "g":
293
+ $result1=date("g",$need);
294
+ $result.=$result1;
295
+ break;
296
+
297
+ case "G":
298
+ $result1=date("G",$need);
299
+ $result.=$result1;
300
+ break;
301
+
302
+ case "h":
303
+ $result1=date("h",$need);
304
+ $result.=$result1;
305
+ break;
306
+
307
+ case "H":
308
+ $result1=date("H",$need);
309
+ $result.=$result1;
310
+ break;
311
+
312
+ case "i":
313
+ $result1=date("i",$need);
314
+ $result.=$result1;
315
+ break;
316
+
317
+ case "j":
318
+ list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
319
+ $result1=$jday;
320
+ $result.=$result1;
321
+ break;
322
+
323
+ case "l":
324
+ $result1=date("l",$need);
325
+ if($result1=="Saturday") $result1=_JDF_Sat_LONG;
326
+ else if($result1=="Sunday") $result1=_JDF_Sun_LONG;
327
+ else if($result1=="Monday") $result1=_JDF_Mon_LONG;
328
+ else if($result1=="Tuesday") $result1=_JDF_Tue_LONG;
329
+ else if($result1=="Wednesday") $result1=_JDF_Wed_LONG;
330
+ else if($result1=="Thursday") $result1=_JDF_Thu_LONG;
331
+ else if($result1=="Friday") $result1=_JDF_Fri_LONG;
332
+ $result.=$result1;
333
+ break;
334
+
335
+ case "m":
336
+ list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
337
+ if($jmonth<10)
338
+ $result1="0".$jmonth;
339
+ else
340
+ $result1=$jmonth;
341
+ $result.=$result1;
342
+ break;
343
+
344
+ case "M":
345
+ list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
346
+ $result.=monthname($jmonth);
347
+ break;
348
+
349
+ case "n":
350
+ list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
351
+ $result1=$jmonth;
352
+ $result.=$result1;
353
+ break;
354
+
355
+ case "s":
356
+ $result1=date("s",$need);
357
+ $result.=$result1;
358
+ break;
359
+
360
+ case "S":
361
+ $result.=_JDF_Suffix;
362
+ break;
363
+
364
+ case "t":
365
+ $result.=lastday ($month,$day,$year);
366
+ break;
367
+
368
+ case "w":
369
+ $result1=date("w",$need);
370
+ $result.=$result1;
371
+ break;
372
+
373
+ case "y":
374
+ list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
375
+ $result1=substr($jyear,2,4);
376
+ $result.=$result1;
377
+ break;
378
+
379
+ case "Y":
380
+ list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
381
+ $result1=$jyear;
382
+ $result.=$result1;
383
+ break;
384
+
385
+ case "\\":
386
+ $result.='';
387
+ $skipnext = true;
388
+ break;
389
+
390
+ default:
391
+ $result.=$subtype;
392
+ }
393
+ $i++;
394
+ }
395
+
396
+ $mps_jd_optionsDB = get_option(MPS_JD_OPTIONS_NAME);
397
+ $mps_jd_farsinum_date = $mps_jd_optionsDB['mps_jd_farsinum_date'];
398
+
399
+ if ((!$forcelatinnums) && ($mps_jd_farsinum_date))
400
+ $result = farsi_num($result);
401
+
402
+ return $result;
403
+ }
404
+
405
+
406
+
407
+ function jmaketime($hour,$minute,$second,$jmonth,$jday,$jyear)
408
+ {
409
+ list( $year, $month, $day ) = jalali_to_gregorian($jyear, $jmonth, $jday);
410
+ $i=mktime((int) $hour,(int) $minute,(int) $second, (int) $month, (int) $day, (int) $year, 0);
411
+ return $i;
412
+ }
413
+
414
+
415
+ ///Find Day Begining Of Month
416
+ function mstart($month,$day,$year)
417
+ {
418
+ list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
419
+ list( $year, $month, $day ) = jalali_to_gregorian($jyear, $jmonth, "1");
420
+ $timestamp=mktime(0,0,0,$month,$day,$year);
421
+ return date("w",$timestamp);
422
+ }
423
+
424
+ //Find Number Of Days In This Month
425
+ function lastday ($month,$day,$year)
426
+ {
427
+ $lastdayen=date("d",mktime(0,0,0,$month+1,0,$year));
428
+ list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
429
+ $lastdatep=$jday;
430
+ $jday=$jday2;
431
+ while($jday2!="1")
432
+ {
433
+ if($day<$lastdayen)
434
+ {
435
+ $day++;
436
+ list( $jyear, $jmonth, $jday2 ) = gregorian_to_jalali($year, $month, $day);
437
+ if($jdate2=="1") break;
438
+ if($jdate2!="1") $lastdatep++;
439
+ }
440
+ else
441
+ {
442
+ $day=0;
443
+ $month++;
444
+ if($month==13)
445
+ {
446
+ $month="1";
447
+ $year++;
448
+ }
449
+ }
450
+
451
+ }
452
+ return $lastdatep-1;
453
+ }
454
+
455
+ //translate number of month to name of month
456
+ function monthname($month)
457
+ {
458
+ $month_map = array(1 => _JDF_Far, 2 => _JDF_Ord, 3 => _JDF_Kho, 4 => _JDF_Tir
459
+ , 5 => _JDF_Mor, 6 => _JDF_Sha, 7 => _JDF_Meh, 8 => _JDF_Aba, 9 => _JDF_Aza
460
+ , 10 => _JDF_Dey, 11 => _JDF_Bah, 12 => _JDF_Esf);
461
+ return $month_map[(int) $month];
462
+ }
463
+
464
+ ?>
inc/tags.js ADDED
File without changes
inc/widgets-core.php ADDED
@@ -0,0 +1,105 @@
1
+ <?php
2
+ function widget_mps_calendar_init() {
3
+ if ( !function_exists('mps_calendar') )
4
+ return;
5
+
6
+ if ( !function_exists('register_sidebar_widget') )
7
+ return;
8
+
9
+ function mps_calendar_widget($args) {
10
+ extract($args);
11
+ $options = get_option('mps_calendar_widget');
12
+ $title = $options['title'];
13
+ echo $before_widget;
14
+ echo $before_title . $title . $after_title;
15
+ mps_calendar();
16
+ echo $after_widget;
17
+ }
18
+
19
+ function widget_mps_calendar_control() {
20
+
21
+ $options = get_option('mps_calendar_widget');
22
+ if ( !is_array($options) )
23
+ $options = array('title'=>'');
24
+ if ( $_POST['mps_calendar_submit'] ) {
25
+ $options['title'] = strip_tags(stripslashes($_POST['mps_calendar_title']));
26
+ update_option('mps_calendar_widget', $options);
27
+ }
28
+ $title = htmlspecialchars($options['title'], ENT_QUOTES);
29
+ ?>
30
+ <p style="text-align:right; direction:rtl"><label for="mps_calendar_title">عنوان: <input style="width: 200px;" id="mps_calendar_title" name="mps_calendar_title" type="text" value="<?php echo $title; ?>" /></label></p>
31
+ <input type="hidden" id="mps_calendar_submit" name="mps_calendar_submit" value="1" />
32
+ <?php
33
+ }
34
+
35
+ register_sidebar_widget('Jalali Calendar','mps_calendar_widget');
36
+ register_widget_control('Jalali Calendar', 'widget_mps_calendar_control', 250, 100);
37
+ }
38
+
39
+ function widget_jarchive_init() {
40
+ if ( !function_exists('wp_get_jarchives') )
41
+ return;
42
+
43
+ if ( !function_exists('register_sidebar_widget') )
44
+ return;
45
+
46
+ function jarchive_widget($args) {
47
+ extract($args);
48
+ $options = get_option('jarchive_widget');
49
+ $title = $options['title'];
50
+ if (!isset($options['type'])) {
51
+ $type="monthly";
52
+ } else {
53
+ $type = $options['type'];
54
+ }
55
+ $show_post_count = ($options['show_post_count'] == '1') ? "1" : "0"; // More Safer Way
56
+ $dropdown = ($options['dropdown'] == '1') ? "1" : "0";
57
+ echo $before_widget;
58
+ echo $before_title . $title . $after_title;
59
+ if ($dropdown) {
60
+ echo "<select name=\"jarchive-dropdown\" onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value=\"\">".attribute_escape($title)."</option>";
61
+ wp_get_jarchives("type=$type&format=option&show_post_count=$show_post_count");
62
+ echo "</select>";
63
+ } else {
64
+ echo '<ul>';
65
+ wp_get_jarchives("type=$type"."&show_post_count=".$show_post_count);
66
+ echo '</ul>';
67
+ }
68
+
69
+ echo $after_widget;
70
+ }
71
+
72
+ function widget_jarchive_control() {
73
+
74
+ $options = get_option('jarchive_widget');
75
+ if ( !is_array($options) )
76
+ $options = array('title'=>'');
77
+ if ( $_POST['jarchive_submit'] ) {
78
+ $options['title'] = strip_tags(stripslashes($_POST['jarchive_title']));
79
+ $options['type'] = strip_tags(stripslashes($_POST['jarchive_type']));
80
+ $options['show_post_count'] = strip_tags(stripslashes($_POST['jarchive_show_post_count']));
81
+ $options['dropdown'] = isset($_POST['jarchives_dropdown']);
82
+ update_option('jarchive_widget', $options);
83
+ }
84
+ $title = htmlspecialchars($options['title'], ENT_QUOTES);
85
+ $type = htmlspecialchars($options['type'], ENT_QUOTES);
86
+
87
+ if (empty($options['type']))
88
+ $options['type'] = 'monthly';
89
+ ?>
90
+ <div dir="rtl" align="justify">
91
+ <p style="text-align:right"><label for="jarchive_title">عنوان: <input style="width: 200px;" id="jarchive_title" name="jarchive_title" type="text" value="<?php echo $title; ?>" /></label></p>
92
+ <input name="jarchive_type" type="radio" value="monthly" id="monthly" <?=$options['type']=='monthly' ? 'checked=\"checked\"':'' ?> /> <label for="monthly">ماهیانه</label><br />
93
+ <input name="jarchive_type" type="radio" value="daily" id="daily" <?=$options['type']=='daily' ? 'checked=\"checked\"':'' ?> /> <label for="daily">روزانه</label><br />
94
+ <input name="jarchive_type" type="radio" value="postbypost" id="postbypost" <?=$options['type']=='postbypost' ? 'checked=\"checked\"':'' ?> /> <label for="postbypost">نوشته به نوشته</label><br /><br />
95
+ <input name="jarchive_show_post_count" type="checkbox" value="1" id="show_post_count" <?=$options['show_post_count']=='1' ? 'checked=\"checked\"':'' ?> /> <label for="show_post_count">نمایش تعداد نوشته ها (فقط برای بایگانی ماهیانه)</label><br />
96
+ <input name="jarchives_dropdown" type="checkbox" value="1" id="dropdown" <?=$options['dropdown']=='1' ? 'checked=\"checked\"':'' ?> /> <label for="dropdown">نمایش به صورت لیست بازشو (فقط برای بایگانی ماهیانه)</label>
97
+ <input type="hidden" id="jarchive_submit" name="jarchive_submit" value="1" />
98
+ </div>
99
+ <?php
100
+ }
101
+
102
+ register_sidebar_widget('Jalali Archive','jarchive_widget');
103
+ register_widget_control('Jalali Archive', 'widget_jarchive_control', 300, 150);
104
+ }
105
+ ?>
inc/yk-core.php ADDED
@@ -0,0 +1,42 @@
1
+ <?php
2
+ function mps_yk_solve_callback($matches) {
3
+ $arabic = array("ي", "ك");
4
+ $persian = array("ی", "ک");
5
+
6
+ $clause = $matches[1];
7
+ $phrase = $matches[2];
8
+
9
+ $phrase_persian = str_replace($arabic,$persian,$phrase); //Pure Persian
10
+ $phrase_arabic = str_replace($persian,$arabic,$phrase); //Pure Arabic
11
+
12
+ $clause_persian = str_replace($phrase, $phrase_persian, $clause);
13
+ $clause_arabic = str_replace($phrase, $phrase_arabic, $clause);
14
+
15
+ return "( ".$clause_persian." OR ".$clause_arabic." )";
16
+ }
17
+
18
+ function mps_yk_solve_search($query) {
19
+ $pattern = "/(\([^\)\(]* LIKE '([^']*)'\))/";
20
+
21
+ if (strstr($query,"LIKE")) { //Is Search?
22
+ if (strstr($query,"ی") || strstr($query,"ک") || strstr($query,"ي") || strstr($query,"ك")) {
23
+ $query = preg_replace_callback($pattern, 'mps_yk_solve_callback', $query);
24
+ }
25
+
26
+ }
27
+ //echo "<!--".$query."-->";
28
+ return $query;
29
+ }
30
+ function mps_yk_solve_persian($content) {
31
+ $arabic = array("ي", "ك");
32
+ $persian = array("ی", "ک");
33
+ $content = str_replace($arabic,$persian,$content);
34
+ return $content;
35
+ }
36
+
37
+ function mps_yk_solve_persian_debug($content) {
38
+ print_r($content);
39
+ }
40
+
41
+
42
+ ?>
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
- === WP-Jalali ===
2
Contributors: mani_monaj
3
Donate link: http://www.wishlistr.com/mani_monaj/
4
Tags: Persian, Farsi, Jalali, Date, Calendar, i18n, l10n
5
- Requires at least: 1.5.2
6
- Tested up to: 2.5-RC1
7
- Stable tag: 3.5.1
8
9
Turn you Wordpress into a full featured Persian (Iranian) Blogging Platform.
10
@@ -17,10 +17,12 @@ This plug-in is a "Full Jalali (خورشیدی - شمسی) Date and Persian (Far
17
* Magic (Jalali/Gregorian) Calendar template tag.
18
* Jalali/Gregorian compatible permalinks.
19
* TinyMCE (Wordpress Editor) Persian improvements.
20
* Cross browser Persian keyboard support for themes' comment forms.
21
* Jalali Archive/Calendar **fully customized widgets**.
22
* Auto Persian numbers conversion.
23
* Fully customizable through specific Wordpress admin page.
24
25
This plug-in is now part of [Persian Wordpress Project](http://www.wp-persian.com/ "پروژه وردپرس فارسی")
26
@@ -28,7 +30,7 @@ This plug-in is now part of [Persian Wordpress Project](http://www.wp-persian.co
28
29
1. Extract the downloaded archive into `wp-jalali` folder. If you downloaded the .zip archive it **contains** the `wp-jalali` folder.
30
2. Upload `wp-jalali` to the `/wp-content/plugins/` directory of your wordpress installation.
31
- 3. If you are using older versions of this plug-in, you must deactivate first through the 'Plugins' menu in Wordpress admin.
32
4. Activate the plug-in through the 'Plugins' menu in Wordpress admin.
33
34
== Frequently Asked Questions ==
1
+ === wp-jalali ===
2
Contributors: mani_monaj
3
Donate link: http://www.wishlistr.com/mani_monaj/
4
Tags: Persian, Farsi, Jalali, Date, Calendar, i18n, l10n
5
+ Requires at least: 2.1
6
+ Tested up to: 2.5
7
+ Stable tag: 4.0
8
9
Turn you Wordpress into a full featured Persian (Iranian) Blogging Platform.
10
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
27
This plug-in is now part of [Persian Wordpress Project](http://www.wp-persian.com/ "پروژه وردپرس فارسی")
28
30
31
1. Extract the downloaded archive into `wp-jalali` folder. If you downloaded the .zip archive it **contains** the `wp-jalali` folder.
32
2. Upload `wp-jalali` to the `/wp-content/plugins/` directory of your wordpress installation.
33
+ 3. If you are using older versions of this plug-in, you must deactivate it first through the 'Plugins' menu in Wordpress admin.
34
4. Activate the plug-in through the 'Plugins' menu in Wordpress admin.
35
36
== Frequently Asked Questions ==
screenshot-1.png CHANGED
Binary file
mps-jalalidate351.php → wp-jalali.php RENAMED
@@ -1,14 +1,14 @@
1
<?php
2
/*
3
- Plugin Name: Full Jalali Date & Persian Support Package for Wordpress
4
Plugin URI: http://wp-persian.com/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: 3.5.1
7
Author: Vali Allah(Mani) Monajjemi
8
Author URI: http://www.manionline.org/
9
*/
10
11
- /* Copyright 2005-2007 Vali Allah[Mani] Monajjemi (email : mani.monajjemi@gmail.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
@@ -27,96 +27,32 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
28
/*
29
Special Thanks to :
30
* Farsiweb.info for J2G and G2J Converstion Functions
31
* Milad Raastian (miladmovie.com) for JDF (jdf.farsiprojects.com)
32
* Nima Shyanfar (phpmystery.com) for Fast Farsi Number Conversion Method
33
- * Gonahkar (gonahkar.com) for WP-Jalali widgets plugin (gonahkar.com/archives/2007/02/26/wp-jalali-widgets-plugin/ )
34
* Kaveh Ahmadi (ashoob.net/kaveh) for his valuable Farsi Keyboard Script (ashoob.net/farsitype)
35
* Ali Sattari(corelist.net) for great support
36
- * WP-Persian group members (groups.google.com/group/wp-persian/topics)
37
*/
38
39
- define("MPS_JD_VER","3.5");
40
-
41
- if (!function_exists('fetch_rss')) require_once (ABSPATH . WPINC . '/rss-functions.php');
42
- if (!function_exists('error')) {
43
- function error ($errormsg, $lvl=E_USER_WARNING) {
44
- // append PHP's error message if track_errors enabled
45
- if ( $php_errormsg ) {
46
- $errormsg .= " ($php_errormsg)";
47
- }
48
- if ( MAGPIE_DEBUG ) {
49
- trigger_error( $errormsg, $lvl);
50
- }
51
- else {
52
- error_log( $errormsg, 0);
53
- }
54
-
55
- $notices = E_USER_NOTICE|E_NOTICE;
56
- if ( $lvl&$notices ) {
57
- $this->WARNING = $errormsg;
58
- } else {
59
- $this->ERROR = $errormsg;
60
- }
61
- }
62
- }
63
64
- define("_JDF_USE_PERSIANNUM","0");
65
- define("_JDF_TZhours","0");
66
- define("_JDF_TZminute","0");
67
- define('_JDF_AM_LONG','قبل از ظهر');
68
- define('_JDF_PM_LONG','بعد از ظهر');
69
- define('_JDF_AM_SHORT','ق.ظ');
70
- define('_JDF_PM_SHORT','ب.ظ');
71
- define('_JDF_Sat_LONG','شنبه');
72
- define('_JDF_Sun_LONG','یکشنبه');
73
- define('_JDF_Mon_LONG','دوشنبه');
74
- define('_JDF_Tue_LONG','سه شنبه');
75
- define('_JDF_Wed_LONG','چهارشنبه');
76
- define('_JDF_Thu_LONG','پنجشنبه');
77
- define('_JDF_Fri_LONG','جمعه');
78
- define('_JDF_Sat_SHORT','ش');
79
- define('_JDF_Sun_SHORT','ی');
80
- define('_JDF_Mon_SHORT','د');
81
- define('_JDF_Tue_SHORT','س');
82
- define('_JDF_Wed_SHORT','چ');
83
- define('_JDF_Thu_SHORT','پ');
84
- define('_JDF_Fri_SHORT','ج');
85
- define('_JDF_Suffix','م');
86
- define('_JDF_Far','فروردین');
87
- define('_JDF_Ord','اردیبهشت');
88
- define('_JDF_Kho','خرداد');
89
- define('_JDF_Tir','تیر');
90
- define('_JDF_Mor','مرداد');
91
- define('_JDF_Sha','شهریور');
92
- define('_JDF_Meh','مهر');
93
- define('_JDF_Aba','آبان');
94
- define('_JDF_Aza','آذر');
95
- define('_JDF_Dey','دی');
96
- define('_JDF_Bah','بهمن');
97
- define('_JDF_Esf','اسفند');
98
- define('_JDF_Num0','۰');
99
- define('_JDF_Num1','۱');
100
- define('_JDF_Num2','۲');
101
- define('_JDF_Num3','۳');
102
- define('_JDF_Num4','۴');
103
- define('_JDF_Num5','۵');
104
- define('_JDF_Num6','۶');
105
- define('_JDF_Num7','۷');
106
- define('_JDF_Num8','۸');
107
- define('_JDF_Num9','۹');
108
-
109
- $g_days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
110
- $j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
111
- $j_month_name = array("", "فروردین", "اردیبهشت", "خرداد", "تیر",
112
- "مرداد", "شهریور", "مهر", "آبان", "آذر",
113
- "دی", "بهمن", "اسفند");
114
- $j_day_name = array("یکشنبه","دوشنبه","سه شنبه","چهارشنبه","پنجشنبه","جمعه","شنبه");
115
- $jday_abbrev = array("ی","د","س","چ","پ","ج","ش");
116
117
- /* Menu Init */
118
119
- define('MPS_JD_OPTIONS_NAME', "mps_jd_options"."_".MPS_JD_VER); // Name of the Option stored in the DB
120
121
function mps_jd_menu(){
122
/*
@@ -143,6 +79,9 @@ function mps_jd_menu(){
143
$mps_jd_optionsDB['mps_jd_farsinum_date'] = $mps_jd_farsinum_date = true;
144
$mps_jd_optionsDB['mps_jd_mcertl'] = $mps_jd_mcertl = true;
145
$mps_jd_optionsDB['mps_jd_jperma'] = $mps_jd_jperma = true;
146
update_option(MPS_JD_OPTIONS_NAME,$mps_jd_optionsDB);
147
}
148
}
@@ -153,7 +92,7 @@ function mps_jd_optionpage(){
153
154
$_wp_version = get_bloginfo("version");
155
156
- if ( $_wp_version < 2.1 ) {
157
get_currentuserinfo();
158
$enable_options = ($user_level >= 8);
159
} else {
@@ -180,6 +119,18 @@ function mps_jd_optionpage(){
180
$mps_jd_optionsDB['mps_jd_farsinum_date'] = $mps_jd_farsinum_date = $_POST['mps_jd_farsinum_date'];
181
$mps_jd_optionsDB['mps_jd_mcertl'] = $mps_jd_mcertl = $_POST['mps_jd_mcertl'];
182
$mps_jd_optionsDB['mps_jd_jperma'] = $mps_jd_jperma = $_POST['mps_jd_jperma'];
183
update_option(MPS_JD_OPTIONS_NAME,$mps_jd_optionsDB);
184
update_option('gmt_offset',$_POST['gmt_offset']);
185
update_option('date_format',$_POST['date_format']);
@@ -198,23 +149,29 @@ function mps_jd_optionpage(){
198
$mps_jd_farsinum_date = $mps_jd_optionsDB['mps_jd_farsinum_date'];
199
$mps_jd_mcertl = $mps_jd_optionsDB['mps_jd_mcertl'];
200
$mps_jd_jperma = $mps_jd_optionsDB['mps_jd_jperma'];
201
202
if((isset($mps_ERR)) && (!empty($mps_ERR))) {
203
?>
204
<br clear="all" />
205
- <div id="message" class="updated fade" style="direction: rtl"><p><strong><?php _e($mps_ERR); ?></strong></p></div>
206
<?php
207
}
208
?>
209
210
<?php
211
- $logo_uri = get_settings('siteurl').'/wp-content/plugins/wp-jalali/wp-fa-logo.png';
212
?>
213
-
214
- <div class="wrap" style="direction:rtl">
215
<p style="text-align:center">
216
<a href="http://wp-persian.com" style="border:none" title="وردپرس فارسی"><img src="<?=$logo_uri?>" alt="Persian Wordpress Logo" width="300" height="70" border="0"/></a>
217
</p>
218
<h2>اخبار وردپرس فارسی</h2>
219
<h3>وبلاگ توسعه وردپرس فارسی</h3>
220
@@ -231,7 +188,7 @@ function mps_jd_optionpage(){
231
}
232
}
233
?>
234
- <div id="planetnews" style="direction:rtl;">
235
<h3>سیاره وردپرس فارسی <a href="http://planet.wp-persian.com/">بیشتر »</a></h3>
236
<?php
237
$rss = @fetch_rss('http://planet.wp-persian.com/feed/');
@@ -247,20 +204,35 @@ function mps_jd_optionpage(){
247
<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>
248
<?php
249
}
250
- ?>
251
- </ul><br style="clear:both;"/>
252
- <?php
253
- }
254
- ?>
255
</div>
256
-
257
258
<h2>تنظیمات وردپرس فارسی</h2>
259
- <form method="post">
260
- <input type="hidden" name="action" value="update" />
261
- <table width="100%" cellspacing="2" cellpadding="5" class="editform" border="0">
262
<tr valign="top">
263
- <th width="33%" scope="row">تبدیل خودکار تاریخ نوشته ها و نظرات به تاریخ خورشیدی(شمسی)</th>
264
<td>
265
<select name="mps_jd_autodate" id="mps_jd_autodate">
266
<option value="1" <?=$mps_jd_autodate==true? 'selected=\"selected\"':'' ?>>فعال (پیشنهاد می شود)</option>
@@ -269,59 +241,83 @@ function mps_jd_optionpage(){
269
</td>
270
</tr>
271
<tr valign="top">
272
- <th width="33%" scope="row">نمایش ارقام فارسی</th>
273
<td>
274
<table border="0" cellpadding="2" cellspacing="2">
275
<tr>
276
- <td>متن نوشته ها</td>
277
- <td><input type="checkbox" name="mps_jd_farsinum_content" <?=$mps_jd_farsinum_content==true? 'checked=\"checked\"':'' ?> /></td>
278
- <td>متن نظر ها</td>
279
- <td><input type="checkbox" name="mps_jd_farsinum_comment" <?=$mps_jd_farsinum_comment==true? 'checked=\"checked\"':'' ?> /></td>
280
- <td>تعداد نظر ها</td>
281
- <td><input type="checkbox" name="mps_jd_farsinum_commentnum" <?=$mps_jd_farsinum_commentnum==true? 'checked=\"checked\"':'' ?> /></td>
282
</tr>
283
<tr>
284
- <td>عنوان نوشته ها</td>
285
- <td><input type="checkbox" name="mps_jd_farsinum_title" <?=$mps_jd_farsinum_title==true? 'checked=\"checked\"':'' ?> /></td>
286
- <td>تاریخ ها</td>
287
- <td><input type="checkbox" name="mps_jd_farsinum_date" <?=$mps_jd_farsinum_date==true? 'checked=\"checked\"':'' ?> /></td>
288
- <td>فهرست رسته ها</td>
289
- <td><input type="checkbox" name="mps_jd_farsinum_category" <?=$mps_jd_farsinum_category==true? 'checked=\"checked\"':'' ?> /></td>
290
</tr>
291
</table>
292
293
</td>
294
</tr>
295
<tr valign="top">
296
- <th width="33%" scope="row">جهت ویرایشگر متنی صفحه نوشتن</th>
297
<td>
298
<select name="mps_jd_mcertl" id="mps_jd_mcertl">
299
<option value="1" <?=$mps_jd_mcertl==true? 'selected=\"selected\"':'' ?>>راست به چپ</option>
300
<option value="0" <?=$mps_jd_mcertl==false?'selected=\"selected\"':'' ?>>چپ به راست</option>
301
</select>
302
</td>
303
</tr>
304
<tr valign="top">
305
- <th width="33%" scope="row">تبدیل خودکار تاریخ در آدرس (URI) نوشته ها</th>
306
<td>
307
<select name="mps_jd_jperma" id="mps_jd_jperma">
308
<option value="1" <?=$mps_jd_jperma==true? 'selected=\"selected\"':'' ?>>بله</option>
309
<option value="0" <?=$mps_jd_jperma==false?'selected=\"selected\"':'' ?>>خیر</option>
310
</select>
311
</td>
312
</tr>
313
</table>
314
- <fieldset class="options">
315
- <legend><?php _e('تنظیمات تاریخ و ساعت') ?></legend>
316
- <table width="100%" cellspacing="2" cellpadding="5" class="editform">
317
<tr>
318
<th scope="row" width="33%">ساعت به وقت <abbr title="Coordinated Universal Time">UTC</abbr>:</th>
319
<td><code>
320
<?php
321
$m = gmdate('YmdHis');
322
$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));
323
-
324
-
325
?>
326
<?php echo jdate('l Y-m-d g:i:s a',$gmt); ?></code></td>
327
</tr>
@@ -332,7 +328,7 @@ function mps_jd_optionpage(){
332
</tr>
333
<tr>
334
<th scope="row">&nbsp;</th>
335
- <td>فرمت زیر مانند <a href="http://php.net/date">تابع <code>date()</code> PHP</a> می باشد. برای نمایش تغییرات این صفحه را به روز کنید.</td>
336
</tr>
337
<tr>
338
<th scope="row">فرمت تاریخ پیش فرض</th>
@@ -367,450 +363,17 @@ endfor;
367
</form>
368
369
<br />
370
- </div>
371
<div id="wp-bookmarklet" class="wrap" style="direction:rtl; text-align:right">
372
<h3>پروژه وردپرس فارسی</h3>
373
- <p>این افزونه، بخشی از <a href="http://wp-persian.com/">پروژه وردپرس فارسی</a> می باشد. برای اطلاعات بیشتر در مورد این پلاگ-این می توانید <a href="http://wp-persian.com/wp-jalali/">صفحه مخصوص این پلاگ-این</a> را مشاهده کنید.</p>
374
</div>
375
-
376
377
<?php
378
379
}
380
381
- /* Farsiweb.info Jaladi/Gregorian Convertion Functions */
382
-
383
- function div($a, $b)
384
- {
385
- return (int) ($a / $b);
386
- }
387
-
388
- function jalali_to_gregorian($j_y, $j_m, $j_d)
389
- {
390
- global $g_days_in_month;
391
- global $j_days_in_month;
392
-
393
- $jy = $j_y-979;
394
- $jm = $j_m-1;
395
- $jd = $j_d-1;
396
-
397
- $j_day_no = 365*$jy + div($jy, 33)*8 + div($jy%33+3, 4);
398
- for ($i=0; $i < $jm; ++$i)
399
- $j_day_no += $j_days_in_month[$i];
400
-
401
- $j_day_no += $jd;
402
-
403
- $g_day_no = $j_day_no+79;
404
-
405
- $gy = 1600 + 400*div($g_day_no, 146097); /* 146097 = 365*400 + 400/4 - 400/100 + 400/400 */
406
- $g_day_no = $g_day_no % 146097;
407
-
408
- $leap = true;
409
- if ($g_day_no >= 36525) /* 36525 = 365*100 + 100/4 */
410
- {
411
- $g_day_no--;
412
- $gy += 100*div($g_day_no, 36524); /* 36524 = 365*100 + 100/4 - 100/100 */
413
- $g_day_no = $g_day_no % 36524;
414
-
415
- if ($g_day_no >= 365)
416
- $g_day_no++;
417
- else
418
- $leap = false;
419
- }
420
-
421
- $gy += 4*div($g_day_no, 1461); /* 1461 = 365*4 + 4/4 */
422
- $g_day_no %= 1461;
423
-
424
- if ($g_day_no >= 366) {
425
- $leap = false;
426
-
427
- $g_day_no--;
428
- $gy += div($g_day_no, 365);
429
- $g_day_no = $g_day_no % 365;
430
- }
431
-
432
- for ($i = 0; $g_day_no >= $g_days_in_month[$i] + ($i == 1 && $leap); $i++)
433
- $g_day_no -= $g_days_in_month[$i] + ($i == 1 && $leap);
434
- $gm = $i+1;
435
- $gd = $g_day_no+1;
436
-
437
- return array($gy, $gm, $gd);
438
- }
439
-
440
- function jcheckdate($j_m, $j_d, $j_y)
441
- {
442
- global $j_days_in_month;
443
-
444
- if ($j_y < 0 || $j_y > 32767 || $j_m < 1 || $j_m > 12 || $j_d < 1 || $j_d >
445
- ($j_days_in_month[$j_m-1] + ($j_m == 12 && !(($j_y-979)%33%4))))
446
- return false;
447
- return true;
448
- }
449
-
450
- function gregorian_week_day($g_y, $g_m, $g_d)
451
- {
452
- global $g_days_in_month;
453
-
454
- $gy = $g_y-1600;
455
- $gm = $g_m-1;
456
- $gd = $g_d-1;
457
-
458
- $g_day_no = 365*$gy+div($gy+3,4)-div($gy+99,100)+div($gy+399,400);
459
-
460
- for ($i=0; $i < $gm; ++$i)
461
- $g_day_no += $g_days_in_month[$i];
462
- if ($gm>1 && (($gy%4==0 && $gy%100!=0) || ($gy%400==0)))
463
- /* leap and after Feb */
464
- ++$g_day_no;
465
- $g_day_no += $gd;
466
-
467
- return ($g_day_no + 5) % 7 + 1;
468
- }
469
-
470
- function jalali_week_day($j_y, $j_m, $j_d)
471
- {
472
- global $j_days_in_month;
473
-
474
- $jy = $j_y-979;
475
- $jm = $j_m-1;
476
- $jd = $j_d-1;
477
-
478
- $j_day_no = 365*$jy + div($jy, 33)*8 + div($jy%33+3, 4);
479
-
480
- for ($i=0; $i < $jm; ++$i)
481
- $j_day_no += $j_days_in_month[$i];
482
-
483
- $j_day_no += $jd;
484
-
485
- return ($j_day_no + 2) % 7 + 1;
486
- }
487
-
488
-
489
- function gregorian_to_jalali($g_y, $g_m, $g_d)
490
- {
491
- global $g_days_in_month;
492
- global $j_days_in_month;
493
-
494
- $gy = $g_y-1600;
495
- $gm = $g_m-1;
496
- $gd = $g_d-1;
497
-
498
- $g_day_no = 365*$gy+div($gy+3,4)-div($gy+99,100)+div($gy+399,400);
499
-
500
- for ($i=0; $i < $gm; ++$i)
501
- $g_day_no += $g_days_in_month[$i];
502
- if ($gm>1 && (($gy%4==0 && $gy%100!=0) || ($gy%400==0)))
503
- /* leap and after Feb */
504
- ++$g_day_no;
505
- $g_day_no += $gd;
506
-
507
- $j_day_no = $g_day_no-79;
508
-
509
- $j_np = div($j_day_no, 12053);
510
- $j_day_no %= 12053;
511
-
512
- $jy = 979+33*$j_np+4*div($j_day_no,1461);
513
-
514
- $j_day_no %= 1461;
515
-
516
- if ($j_day_no >= 366) {
517
- $jy += div($j_day_no-1, 365);
518
- $j_day_no = ($j_day_no-1)%365;
519
- }
520
-
521
- for ($i = 0; $i < 11 && $j_day_no >= $j_days_in_month[$i]; ++$i) {
522
- $j_day_no -= $j_days_in_month[$i];
523
- }
524
- $jm = $i+1;
525
- $jd = $j_day_no+1;
526
-
527
-
528
- return array($jy, $jm, $jd);
529
- }
530
-
531
- /* These 2 Functions are new Farsi Num convert implemented in ver 3,
532
- Originally written by Nima Shyanfar , www.phpmystery.com
533
- Thanx Nima ;)
534
- */
535
-
536
- function convertToFarsi($matches) {
537
- $out = '';
538
- if (isset($matches[1])) {
539
- for ($i = 0; $i < strlen($matches[1]); $i++)
540
- if (ereg("([0-9])",$matches[1][$i])) {
541
- $out .= pack("C*", 0xDB, 0xB0 + $matches[1][$i]);
542
- } else {
543
- $out .= $matches[1][$i];
544
- }
545
-
546
- return $out;
547
- }
548
- return $matches[0];
549
- }
550
-
551
- function farsi_num($num,$fake = null,$fake2=null) {
552
- return preg_replace_callback('/(?:&#\d{2,4};)|(\d+[\.\d]*)|<\s*[^>]+>/', 'convertToFarsi', $num);
553
-
554
- }
555
-
556
- /*
557
- Jalali Date function by Milad Rastian (miladmovie AT yahoo DOT com)
558
- jdf.farsiprojects.com
559
- */
560
-
561
-
562
- function jdate($type,$maket="now",$forcelatinnums=false)
563
- {
564
- $result="";
565
- if($maket=="now"){
566
- $year=date("Y");
567
- $month=date("m");
568
- $day=date("d");
569
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
570
- $maket=jmaketime(date("h")+_JDF_TZhours,date("i")+_JDF_TZminute,date("s"),$jmonth,$jday,$jyear);
571
- }else{
572
- $maket+=_JDF_TZhours*3600+_JDF_TZminute*60;
573
- $date=date("Y-m-d",$maket);
574
- list( $year, $month, $day ) = preg_split ( '/-/', $date );
575
-
576
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
577
- }
578
-
579
- $need= $maket;
580
- $year=date("Y",$need);
581
- $month=date("m",$need);
582
- $day=date("d",$need);
583
- $i=0;
584
- $skipnext = false;
585
- while($i<strlen($type))
586
- {
587
- $subtype=substr($type,$i,1);
588
-
589
- if ($skipnext) {
590
- $result .= $subtype;
591
- $skipnext = false;
592
- $i++;
593
- continue;
594
- }
595
-
596
-
597
- switch ($subtype)
598
- {
599
- case "A":
600
- $result1=date("a",$need);
601
- if($result1=="pm")
602
- $result.=_JDF_PM_LONG;
603
- else
604
- $result.=_JDF_AM_LONG;
605
- break;
606
-
607
- case "a":
608
- $result1=date("a",$need);
609
- if($result1=="pm")
610
- $result.=_JDF_PM_SHORT;
611
- else
612
- $result.=_JDF_AM_SHORT;
613
- break;
614
-
615
- case "d":
616
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
617
- if($jday<10)
618
- $result1="0".$jday;
619
- else
620
- $result1=$jday;
621
-
622
- $result.=$result1;
623
- break;
624
-
625
- case "D":
626
- $result1=date("D",$need);
627
- if($result1=="Sat") $result1=_JDF_Sat_SHORT;
628
- else if($result1=="Sun") $result1=_JDF_Sun_SHORT;
629
- else if($result1=="Mon") $result1=_JDF_Mon_SHORT;
630
- else if($result1=="Tue") $result1=_JDF_Tue_SHORT;
631
- else if($result1=="Wed") $result1=_JDF_Wed_SHORT;
632
- else if($result1=="Thu") $result1=_JDF_Thu_SHORT;
633
- else if($result1=="Fri") $result1=_JDF_Fri_SHORT;
634
- $result.=$result1;
635
- break;
636
-
637
- case"F":
638
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
639
- $result.=monthname($jmonth);
640
- break;
641
-
642
- case "g":
643
- $result1=date("g",$need);
644
- $result.=$result1;
645
- break;
646
-
647
- case "G":
648
- $result1=date("G",$need);
649
- $result.=$result1;
650
- break;
651
-
652
- case "h":
653
- $result1=date("h",$need);
654
- $result.=$result1;
655
- break;
656
-
657
- case "H":
658
- $result1=date("H",$need);
659
- $result.=$result1;
660
- break;
661
-
662
- case "i":
663
- $result1=date("i",$need);
664
- $result.=$result1;
665
- break;
666
-
667
- case "j":
668
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
669
- $result1=$jday;
670
- $result.=$result1;
671
- break;
672
-
673
- case "l":
674
- $result1=date("l",$need);
675
- if($result1=="Saturday") $result1=_JDF_Sat_LONG;
676
- else if($result1=="Sunday") $result1=_JDF_Sun_LONG;
677
- else if($result1=="Monday") $result1=_JDF_Mon_LONG;
678
- else if($result1=="Tuesday") $result1=_JDF_Tue_LONG;
679
- else if($result1=="Wednesday") $result1=_JDF_Wed_LONG;
680
- else if($result1=="Thursday") $result1=_JDF_Thu_LONG;
681
- else if($result1=="Friday") $result1=_JDF_Fri_LONG;
682
- $result.=$result1;
683
- break;
684
-
685
- case "m":
686
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
687
- if($jmonth<10)
688
- $result1="0".$jmonth;
689
- else
690
- $result1=$jmonth;
691
- $result.=$result1;
692
- break;
693
-
694
- case "M":
695
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
696
- $result.=monthname($jmonth);
697
- break;
698
-
699
- case "n":
700
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
701
- $result1=$jmonth;
702
- $result.=$result1;
703
- break;
704
-
705
- case "s":
706
- $result1=date("s",$need);
707
- $result.=$result1;
708
- break;
709
-
710
- case "S":
711
- $result.=_JDF_Suffix;
712
- break;
713
-
714
- case "t":
715
- $result.=lastday ($month,$day,$year);
716
- break;
717
-
718
- case "w":
719
- $result1=date("w",$need);
720
- $result.=$result1;
721
- break;
722
-
723
- case "y":
724
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
725
- $result1=substr($jyear,2,4);
726
- $result.=$result1;
727
- break;
728
-
729
- case "Y":
730
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
731
- $result1=$jyear;
732
- $result.=$result1;
733
- break;
734
-
735
- case "\\":
736
- $result.='';
737
- $skipnext = true;
738
- break;
739
-
740
- default:
741
- $result.=$subtype;
742
- }
743
- $i++;
744
- }
745
-
746
- $mps_jd_optionsDB = get_option(MPS_JD_OPTIONS_NAME);
747
- $mps_jd_farsinum_date = $mps_jd_optionsDB['mps_jd_farsinum_date'];
748
-
749
- if ((!$forcelatinnums) && ($mps_jd_farsinum_date))
750
- $result = farsi_num($result);
751
-
752
- return $result;
753
- }
754
-
755
-
756
-
757
- function jmaketime($hour,$minute,$second,$jmonth,$jday,$jyear)
758
- {
759
- list( $year, $month, $day ) = jalali_to_gregorian($jyear, $jmonth, $jday);
760
- $i=mktime((int) $hour,(int) $minute,(int) $second, (int) $month, (int) $day, (int) $year, 0);
761
- return $i;
762
- }
763
-
764
-
765
- ///Find Day Begining Of Month
766
- function mstart($month,$day,$year)
767
- {
768
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
769
- list( $year, $month, $day ) = jalali_to_gregorian($jyear, $jmonth, "1");
770
- $timestamp=mktime(0,0,0,$month,$day,$year);
771
- return date("w",$timestamp);
772
- }
773
-
774
- //Find Number Of Days In This Month
775
- function lastday ($month,$day,$year)
776
- {
777
- $lastdayen=date("d",mktime(0,0,0,$month+1,0,$year));
778
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
779
- $lastdatep=$jday;
780
- $jday=$jday2;
781
- while($jday2!="1")
782
- {
783
- if($day<$lastdayen)
784
- {
785
- $day++;
786
- list( $jyear, $jmonth, $jday2 ) = gregorian_to_jalali($year, $month, $day);
787
- if($jdate2=="1") break;
788
- if($jdate2!="1") $lastdatep++;
789
- }
790
- else
791
- {
792
- $day=0;
793
- $month++;
794
- if($month==13)
795
- {
796
- $month="1";
797
- $year++;
798
- }
799
- }
800
-
801
- }
802
- return $lastdatep-1;
803
- }
804
-
805
- //translate number of month to name of month
806
- function monthname($month)
807
- {
808
- $month_map = array(1 => _JDF_Far, 2 => _JDF_Ord, 3 => _JDF_Kho, 4 => _JDF_Tir
809
- , 5 => _JDF_Mor, 6 => _JDF_Sha, 7 => _JDF_Meh, 8 => _JDF_Aba, 9 => _JDF_Aza
810
- , 10 => _JDF_Dey, 11 => _JDF_Bah, 12 => _JDF_Esf);
811
- return $month_map[(int) $month];
812
- }
813
-
814
815
/* Wordpress Convert Functions */
816
@@ -933,9 +496,10 @@ function mps_the_jweekday_date($input, $before, $after) {
933
934
935
function mps_jalali_query($where) {
936
-
937
/* Wordpress 1.6+ */
938
- global $wp_query;
939
global $j_days_in_month;
940
941
$m = $wp_query->query_vars['m'];
@@ -957,7 +521,7 @@ function mps_jalali_query($where) {
957
$j_minute_next = 0;
958
$j_second_next = 0;
959
$j_doit = false;
960
-
961
if ($m != '') {
962
$m = '' . preg_replace('|[^0-9]|', '', $m);
963
$j_year = substr($m,0,4);
@@ -1026,9 +590,13 @@ function mps_jalali_query($where) {
1026
1027
if ($j_doit) {
1028
/* WP 1.5+ NEEDS THIS :: CLEANING PREV. TIMINGS*/
1029
- $patterns = array("YEAR\(post_date\)='*[0-9]{4}'*","DAYOFMONTH\(post_date\)='*[0-9]{1,}'*"
1030
- ,"MONTH\(post_date\)='*[0-9]{1,}'*","HOUR\(post_date\)='*[0-9]{1,}'*",
1031
- "MINUTE\(post_date\)='*[0-9]{1,}'*","SECOND\(post_date\)='*[0-9]{1,}'*");
1032
foreach ($patterns as $pattern){
1033
$where = ereg_replace($pattern,"1=1",$where); // :D good idea ! isn't it ?
1034
}
@@ -1056,7 +624,7 @@ function mps_jalali_query($where) {
1056
$g_startdate = date("Y:m:d 00:00:00",jmaketime($j_hour,$j_minute,$j_second,$j_monthnum,$j_day,$j_year));
1057
$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));
1058
1059
- $where .= " AND post_date >= '$g_startdate' AND post_date < '$g_enddate' ";
1060
}
1061
return $where;
1062
}
@@ -1064,7 +632,7 @@ function mps_jalali_query($where) {
1064
function mps_get_jarchives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
1065
//Added in 3.5 for backward compability
1066
$_wp_version = get_bloginfo("version");
1067
- if ($_wp_version >= 2.1) {
1068
$_query_add = " post_type='post' ";
1069
} else {
1070
$_query_add = " 1 = 1 "; // =)) 11-5-2007 0:38
@@ -1209,11 +777,17 @@ function wp_get_jarchives($args = '') {
1209
function get_jcalendar() {
1210
global $wpdb, $m, $monthnum, $year, $timedifference, $month, $day, $posts;
1211
global $j_month_name , $j_day_name , $jday_abbrev;
1212
-
1213
if (!$posts) {
1214
- $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
1215
- if (!$gotsome)
1216
- return;
1217
}
1218
1219
$week_begins = intval(get_settings('start_of_week'));
@@ -1285,12 +859,14 @@ function get_jcalendar() {
1285
$g_startdate = date("Y:m:d H:i:s",jmaketime(0,0,0,$jthismonth,1,$jthisyear));
1286
$g_enddate = date("Y:m:d H:i:s",jmaketime(0,0,0,$jnextmonth,1,$jnextyear));
1287
$prev = $wpdb->get_results("SELECT count(id) AS prev FROM $wpdb->posts
1288
- WHERE post_date < '$g_startdate'
1289
AND post_status = 'publish'
1290
AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
1291
1292
$next = $wpdb->get_results("SELECT count(id) AS next FROM $wpdb->posts
1293
- WHERE post_date > '$g_enddate'
1294
AND post_status = 'publish'
1295
AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
1296
if ($prev[0][0] != 0) $is_prev = true; else $is_prev = false;
@@ -1339,7 +915,8 @@ function get_jcalendar() {
1339
<tr>';
1340
1341
$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date),MONTH(post_date),YEAR(post_date)
1342
- FROM $wpdb->posts WHERE 1=1
1343
AND post_date > '$g_startdate' AND post_date < '$g_enddate'
1344
AND post_status = 'publish'
1345
AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
@@ -1361,9 +938,10 @@ function get_jcalendar() {
1361
}
1362
1363
$ak_titles_for_day = array();
1364
- $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom, MONTH(post_date) as month, YEAR(post_date) as year "
1365
."FROM $wpdb->posts "
1366
- ."WHERE post_date > '$g_startdate' AND post_date < '$g_enddate' "
1367
."AND 1=1 "
1368
."AND post_date < '".current_time('mysql')."' "
1369
."AND post_status = 'publish'"
@@ -1445,7 +1023,11 @@ function mps_calendar() {
1445
1446
}
1447
1448
- function _get_permalink($id = 0) {
1449
$rewritecode = array(
1450
'%year%',
1451
'%monthnum%',
@@ -1453,93 +1035,47 @@ function _get_permalink($id = 0) {
1453
'%hour%',
1454
'%minute%',
1455
'%second%',
1456
- '%postname%',
1457
'%post_id%',
1458
'%category%',
1459
'%author%',
1460
- '%pagename%'
1461
);
1462
-
1463
- $post = &get_post($id);
1464
- if ( $post->post_status == 'static' )
1465
return get_page_link($post->ID);
1466
- elseif ($post->post_status == 'object')
1467
return get_subpost_link($post->ID);
1468
1469
$permalink = get_settings('permalink_structure');
1470
1471
- if ( '' != $permalink && 'draft' != $post->post_status ) {
1472
$unixtime = strtotime($post->post_date);
1473
1474
$category = '';
1475
- if ( strstr($permalink, '%category%') ) {
1476
$cats = get_the_category($post->ID);
1477
- $category = $cats[0]->category_nicename;
1478
if ( $parent=$cats[0]->category_parent )
1479
$category = get_category_parents($parent, FALSE, '/', TRUE) . $category;
1480
}
1481
-
1482
- $authordata = get_userdata($post->post_author);
1483
- $author = $authordata->user_nicename;
1484
- $rewritereplace =
1485
- array(
1486
- date('Y', $unixtime),
1487
- date('m', $unixtime),
1488
- date('d', $unixtime),
1489
- date('H', $unixtime),
1490
- date('i', $unixtime),
1491
- date('s', $unixtime),
1492
- $post->post_name,
1493
- $post->ID,
1494
- $category,
1495
- $author,
1496
- $post->post_name,
1497
- );
1498
- return apply_filters('post_link', get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink), $post);
1499
- } else { // if they're not using the fancy permalink option
1500
- $permalink = get_settings('home') . '/?p=' . $post->ID;
1501
- return apply_filters('post_link', $permalink, $post);
1502
- }
1503
- }
1504
-
1505
- function get_jpermalink($old_perma,$post) {
1506
- global $wpdb;
1507
-
1508
- $rewritecode = array(
1509
- '%year%',
1510
- '%monthnum%',
1511
- '%day%',
1512
- '%hour%',
1513
- '%minute%',
1514
- '%second%',
1515
- '%postname%',
1516
- '%post_id%',
1517
- '%category%',
1518
- '%author%',
1519
- '%pagename%'
1520
- );
1521
-
1522
- if ( $post->post_status == 'static' )
1523
- return get_page_link($post->ID);
1524
- elseif ($post->post_status == 'object')
1525
- return get_subpost_link($post->ID);
1526
-
1527
-
1528
- $permalink = get_settings('permalink_structure');
1529
-
1530
- if ( '' != $permalink && 'draft' != $post->post_status ) {
1531
- $unixtime = strtotime($post->post_date);
1532
-
1533
- $category = '';
1534
- if ( strstr($permalink, '%category%') ) {
1535
- $cats = get_the_category($post->ID);
1536
- $category = $cats[0]->category_nicename;
1537
- if ( $parent=$cats[0]->category_parent )
1538
- $category = get_category_parents($parent, FALSE, '/', TRUE) . $category;
1539
}
1540
1541
- $authordata = get_userdata($post->post_author);
1542
- $author = $authordata->user_nicename;
1543
$rewritereplace =
1544
array(
1545
jdate('Y', $unixtime,true),
@@ -1554,10 +1090,12 @@ function get_jpermalink($old_perma,$post) {
1554
$author,
1555
$post->post_name,
1556
);
1557
- return get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink);
1558
} else { // if they're not using the fancy permalink option
1559
- $permalink = get_settings('home') . '/?p=' . $post->ID;
1560
- return $permalink;
1561
}
1562
}
1563
@@ -1629,17 +1167,10 @@ function mps_fixMCEdir(){
1629
echo "directionality : \"rtl\" ,";
1630
}
1631
1632
- function mps_mce_pretext($input=null){
1633
- $_nbsp = "&nbsp;";
1634
- $_p = "<p dir=\"rtl\">".$_nbsp."</p>";
1635
- return (strlen($input)==0?$_p:$input);
1636
- }
1637
-
1638
function mps_mce_plugins($input){
1639
$input[] = "directionality";
1640
return $input;
1641
}
1642
-
1643
function mps_mce_buttons($input){
1644
$new_buttons = array();
1645
if (!in_array("rtl",$input)) {
@@ -1648,104 +1179,24 @@ function mps_mce_buttons($input){
1648
return array_merge($input,$new_buttons);
1649
}
1650
1651
- function widget_mps_calendar_init() {
1652
- if ( !function_exists('mps_calendar') )
1653
- return;
1654
1655
- if ( !function_exists('register_sidebar_widget') )
1656
- return;
1657
-
1658
- function mps_calendar_widget($args) {
1659
- extract($args);
1660
- $options = get_option('mps_calendar_widget');
1661
- $title = $options['title'];
1662
- echo $before_widget;
1663
- echo $before_title . $title . $after_title;
1664
- mps_calendar();
1665
- echo $after_widget;
1666
- }
1667
-
1668
- function widget_mps_calendar_control() {
1669
-
1670
- $options = get_option('mps_calendar_widget');
1671
- if ( !is_array($options) )
1672
- $options = array('title'=>'');
1673
- if ( $_POST['mps_calendar_submit'] ) {
1674
- $options['title'] = strip_tags(stripslashes($_POST['mps_calendar_title']));
1675
- update_option('mps_calendar_widget', $options);
1676
- }
1677
- $title = htmlspecialchars($options['title'], ENT_QUOTES);
1678
- ?>
1679
- <p style="text-align:right; direction:rtl"><label for="mps_calendar_title">عنوان: <input style="width: 200px;" id="mps_calendar_title" name="mps_calendar_title" type="text" value="<?php echo $title; ?>" /></label></p>
1680
- <input type="hidden" id="mps_calendar_submit" name="mps_calendar_submit" value="1" />
1681
- <?php
1682
- }
1683
-
1684
- register_sidebar_widget('Jalali Calendar','mps_calendar_widget');
1685
- register_widget_control('Jalali Calendar', 'widget_mps_calendar_control', 250, 100);
1686
- }
1687
-
1688
- function widget_jarchive_init() {
1689
- if ( !function_exists('wp_get_jarchives') )
1690
- return;
1691
1692
- if ( !function_exists('register_sidebar_widget') )
1693
- return;
1694
-
1695
- function jarchive_widget($args) {
1696
- extract($args);
1697
- $options = get_option('jarchive_widget');
1698
- $title = $options['title'];
1699
- if (!isset($options['type'])) {
1700
- $type="monthly";
1701
- } else {
1702
- $type = $options['type'];
1703
- }
1704
- $show_post_count = ($options['show_post_count'] == '1') ? "1" : "0"; // More Safer Way
1705
- echo $before_widget;
1706
- echo $before_title . $title . $after_title;
1707
- echo '<ul>';
1708
- wp_get_jarchives("type=$type"."&show_post_count=".$show_post_count);
1709
- echo '</ul>';
1710
- echo $after_widget;
1711
- }
1712
-
1713
- function widget_jarchive_control() {
1714
-
1715
- $options = get_option('jarchive_widget');
1716
- if ( !is_array($options) )
1717
- $options = array('title'=>'');
1718
- if ( $_POST['jarchive_submit'] ) {
1719
- $options['title'] = strip_tags(stripslashes($_POST['jarchive_title']));
1720
- $options['type'] = strip_tags(stripslashes($_POST['jarchive_type']));
1721
- $options['show_post_count'] = strip_tags(stripslashes($_POST['jarchive_show_post_count']));
1722
- update_option('jarchive_widget', $options);
1723
- }
1724
- $title = htmlspecialchars($options['title'], ENT_QUOTES);
1725
- $type = htmlspecialchars($options['type'], ENT_QUOTES);
1726
-
1727
- if (empty($options['type']))
1728
- $options['type'] = 'monthly';
1729
- ?>
1730
- <div dir="rtl" align="justify">
1731
- <p style="text-align:right"><label for="jarchive_title">عنوان: <input style="width: 200px;" id="jarchive_title" name="jarchive_title" type="text" value="<?php echo $title; ?>" /></label></p>
1732
- <input name="jarchive_type" type="radio" value="monthly" id="monthly" <?=$options['type']=='monthly' ? 'checked=\"checked\"':'' ?> /> <label for="monthly">ماهیانه</label><br />
1733
- <input name="jarchive_type" type="radio" value="daily" id="daily" <?=$options['type']=='daily' ? 'checked=\"checked\"':'' ?> /> <label for="daily">روزانه</label><br />
1734
- <input name="jarchive_type" type="radio" value="postbypost" id="postbypost" <?=$options['type']=='postbypost' ? 'checked=\"checked\"':'' ?> /> <label for="postbypost">نوشته به نوشته</label><br /><br />
1735
- <input name="jarchive_show_post_count" type="checkbox" value="1" id="show_post_count" <?=$options['show_post_count']=='1' ? 'checked=\"checked\"':'' ?> /> <label for="show_post_count">نمایش تعداد نوشته ها (فقط برای بایگانی ماهیانه)</label>
1736
- <input type="hidden" id="jarchive_submit" name="jarchive_submit" value="1" />
1737
- </div>
1738
- <?php
1739
}
1740
-
1741
- register_sidebar_widget('Jalali Archive','jarchive_widget');
1742
- register_widget_control('Jalali Archive', 'widget_jarchive_control', 300, 150);
1743
}
1744
1745
function mps_farsikeyboard() {
1746
/* Simple API for adding farsitype.js to themes */
1747
- if (!file_exists(dirname(__FILE__) . '/farsitype.js') ) return;
1748
- $script_uri = get_settings('siteurl').'/wp-content/plugins/wp-jalali/farsitype.js';
1749
echo "<script language=\"javascript\" src=\"$script_uri\" type=\"text/javascript\"></script>";
1750
1751
}
@@ -1755,29 +1206,33 @@ $_wp_version = get_bloginfo("version");
1755
1756
add_action('admin_menu', 'mps_jd_menu');
1757
1758
- if ($_wp_version < 2) {
1759
add_action('init', 'mps_fixmonthnames');
1760
add_action('wp_head', 'mps_fixmonthnames_restore');
1761
} else {
1762
add_filter('wp_title', 'mps_fixtitle',2);
1763
1764
- //$richedit = ( 'true' != get_user_option('rich_editing') ) ? false : true;
1765
- $richedit = ($_wp_version < 2.5);
1766
-
1767
- if ($richedit) {
1768
add_filter("mce_plugins","mps_mce_plugins");
1769
add_filter("mce_buttons","mps_mce_buttons");
1770
-
1771
- $mps_jd_optionsDB = get_option(MPS_JD_OPTIONS_NAME);
1772
- $mps_jd_mcertl = $mps_jd_optionsDB['mps_jd_mcertl'];
1773
if ((isset($mps_jd_mcertl) && ($mps_jd_mcertl == true))) {
1774
add_action('mce_options','mps_fixMCEdir');
1775
- //add_filter("richedit_pre","mps_mce_pretext");
1776
- /* The above line commented because of unknown bug of TinyMCE in FireFox */
1777
}
1778
}
1779
}
1780
1781
add_filter("posts_where","mps_jalali_query");
1782
1783
$mps_jd_optionsDB = get_option(MPS_JD_OPTIONS_NAME);
@@ -1789,6 +1244,9 @@ $mps_jd_farsinum_commentnum = $mps_jd_optionsDB['mps_jd_farsinum_commentnum'];
1789
$mps_jd_farsinum_title = $mps_jd_optionsDB['mps_jd_farsinum_title'];
1790
$mps_jd_farsinum_category = $mps_jd_optionsDB['mps_jd_farsinum_category'];
1791
$mps_jd_jperma = $mps_jd_optionsDB['mps_jd_jperma'];
1792
1793
if ($mps_jd_autodate) {
1794
add_filter("the_date","mps_the_jdate",10,4);
@@ -1805,8 +1263,54 @@ if ($mps_jd_farsinum_commentnum) add_filter("comments_number","farsi_num",10);
1805
if ($mps_jd_farsinum_title) add_filter("the_title","farsi_num",10,3);
1806
if ($mps_jd_farsinum_category) add_filter("wp_list_categories","farsi_num",10,1);
1807
1808
- if ($mps_jd_jperma) add_filter("post_link","get_jpermalink",10,2);
1809
1810
add_action('widgets_init', 'widget_jarchive_init');
1811
add_action('widgets_init', 'widget_mps_calendar_init');
1812
- ?>
1
<?php
2
/*
3
+ Plugin Name: wp-jalali
4
Plugin URI: http://wp-persian.com/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.0
7
Author: Vali Allah(Mani) Monajjemi
8
Author URI: http://www.manionline.org/
9
*/
10
11
+ /* Copyright 2005-2008 Vali Allah[Mani] Monajjemi (email : mani.monajjemi@gmail.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
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/ ) and edit jalali timestamp in write/edit panel
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
+
39
*/
40
41
+ define("MPS_JD_VER","4.0");
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_settings('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
54
55
+ /* Menu Init */
56
57
function mps_jd_menu(){
58
/*
79
$mps_jd_optionsDB['mps_jd_farsinum_date'] = $mps_jd_farsinum_date = true;
80
$mps_jd_optionsDB['mps_jd_mcertl'] = $mps_jd_mcertl = true;
81
$mps_jd_optionsDB['mps_jd_jperma'] = $mps_jd_jperma = true;
82
+ $mps_jd_optionsDB['mps_jd_autoyk'] = $mps_jd_autoyk = true;
83
+ $mps_jd_optionsDB['mps_jd_editjalali'] = $mps_jd_editjalali = true;
84
+ $mps_jd_optionsDB['mps_jd_dashboard'] = $mps_jd_dashboard = 0;
85
update_option(MPS_JD_OPTIONS_NAME,$mps_jd_optionsDB);
86
}
87
}
92
93
$_wp_version = get_bloginfo("version");
94
95
+ if ( version_compare($_wp_version, 2.1, '<' )) {
96
get_currentuserinfo();
97
$enable_options = ($user_level >= 8);
98
} else {
119
$mps_jd_optionsDB['mps_jd_farsinum_date'] = $mps_jd_farsinum_date = $_POST['mps_jd_farsinum_date'];
120
$mps_jd_optionsDB['mps_jd_mcertl'] = $mps_jd_mcertl = $_POST['mps_jd_mcertl'];
121
$mps_jd_optionsDB['mps_jd_jperma'] = $mps_jd_jperma = $_POST['mps_jd_jperma'];
122
+ $mps_jd_optionsDB['mps_jd_autoyk'] = $mps_jd_autoyk = $_POST['mps_jd_autoyk'];
123
+ $mps_jd_optionsDB['mps_jd_editjalali'] = $mps_jd_editjalali = $_POST['mps_jd_editjalali'];
124
+ $old_options = get_option(MPS_JD_OPTIONS_NAME);
125
+ if ($old_options['mps_jd_dashboard'] != $_POST['mps_jd_dashboard']) {
126
+ // Dashboard wigdets updating ... Needs to reset some terms
127
+ if ( $widget_options = get_option( 'dashboard_widget_options' ) ) {
128
+ unset($widget_options['dashboard_primary']);
129
+ unset($widget_options['dashboard_secondary']);
130
+ update_option( 'dashboard_widget_options', $widget_options );
131
+ }
132
+ }
133
+ $mps_jd_optionsDB['mps_jd_dashboard'] = $mps_jd_dashboard = $_POST['mps_jd_dashboard'];
134
update_option(MPS_JD_OPTIONS_NAME,$mps_jd_optionsDB);
135
update_option('gmt_offset',$_POST['gmt_offset']);
136
update_option('date_format',$_POST['date_format']);
149
$mps_jd_farsinum_date = $mps_jd_optionsDB['mps_jd_farsinum_date'];
150
$mps_jd_mcertl = $mps_jd_optionsDB['mps_jd_mcertl'];
151
$mps_jd_jperma = $mps_jd_optionsDB['mps_jd_jperma'];
152
+ $mps_jd_autoyk = $mps_jd_optionsDB['mps_jd_autoyk'];
153
+ $mps_jd_editjalali = $mps_jd_optionsDB['mps_jd_editjalali'];
154
+ $mps_jd_dashboard = $mps_jd_optionsDB['mps_jd_dashboard'];
155
156
if((isset($mps_ERR)) && (!empty($mps_ERR))) {
157
?>
158
<br clear="all" />
159
+ <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>
160
<?php
161
}
162
?>
163
164
<?php
165
+ $logo_uri = MPS_JD_URI.'/images/wp-fa-logo.png';
166
?>
167
+ <div id="wpbody" style="direction:rtl; text-align: right">
168
+ <div class="wrap" style="direction:rtl; text-align: right">
169
<p style="text-align:center">
170
<a href="http://wp-persian.com" style="border:none" title="وردپرس فارسی"><img src="<?=$logo_uri?>" alt="Persian Wordpress Logo" width="300" height="70" border="0"/></a>
171
</p>
172
+ <form method="post">
173
+ <input type="hidden" name="action" value="update" />
174
+ <?php if (version_compare($_wp_version, '2.4', '<')) : ?>
175
<h2>اخبار وردپرس فارسی</h2>
176
<h3>وبلاگ توسعه وردپرس فارسی</h3>
177
188
}
189
}
190
?>
191
+ <div id="planetnews" style="direction:rtl; text-align: right">
192
<h3>سیاره وردپرس فارسی <a href="http://planet.wp-persian.com/">بیشتر »</a></h3>
193
<?php
194
$rss = @fetch_rss('http://planet.wp-persian.com/feed/');
204
<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>
205
<?php
206
}
207
+ ?>
208
+ </ul><br style="clear:both;"/>
209
+ <?php
210
+ }
211
+ ?>
212
</div>
213
+ <?php else: //Wordpress 2.5 Dashboard widget API ?>
214
+ <h2>اخبار وردپرس فارسی</h2>
215
+ <table class="form-table">
216
+ <tr valign="top">
217
+ <th scope="row">نحوه نمایش اخبار</th>
218
+ <td>
219
+ <select name="mps_jd_dashboard" id="mps_jd_dashboard">
220
+ <option value="0" <?=$mps_jd_dashboard==0? 'selected=\"selected\"':'' ?>>بر اساس تنظیمات فایل زبان</option>
221
+ <option value="1" <?=$mps_jd_dashboard==1? 'selected=\"selected\"':'' ?>>نمایش اخبار اصلی وردپرس به زبان انگلیسی</option>
222
+ <option value="2" <?=$mps_jd_dashboard==2?'selected=\"selected\"':'' ?>>نمایش اخبار وردپرس فارسی</option>
223
+ </select>
224
+ <br />
225
+ در این نسخه از وردپرس، اخبار وردپرس فارسی در صفحه <a href="<?php echo get_option('siteurl'); ?>/wp-admin/">پیش خوان</a> (Dashboard) نمایش داده می شوند.
226
+ </td>
227
+ </tr>
228
+ </table>
229
+ <?php endif; ?>
230
231
<h2>تنظیمات وردپرس فارسی</h2>
232
+
233
+ <table class="form-table">
234
<tr valign="top">
235
+ <th scope="row">تبدیل خودکار تاریخ نوشته ها و نظرات به تاریخ خورشیدی(شمسی)</th>
236
<td>
237
<select name="mps_jd_autodate" id="mps_jd_autodate">
238
<option value="1" <?=$mps_jd_autodate==true? 'selected=\"selected\"':'' ?>>فعال (پیشنهاد می شود)</option>
241
</td>
242
</tr>
243
<tr valign="top">
244
+ <th scope="row">نمایش ارقام فارسی</th>
245
<td>
246
<table border="0" cellpadding="2" cellspacing="2">
247
<tr>
248
+ <td style="border-bottom-width: 0">متن نوشته ها</td>
249
+ <td style="border-bottom-width: 0"><input type="checkbox" name="mps_jd_farsinum_content" <?=$mps_jd_farsinum_content==true? 'checked=\"checked\"':'' ?> /></td>
250
+ <td style="border-bottom-width: 0">متن نظر ها</td>
251
+ <td style="border-bottom-width: 0"><input type="checkbox" name="mps_jd_farsinum_comment" <?=$mps_jd_farsinum_comment==true? 'checked=\"checked\"':'' ?> /></td>
252
+ <td style="border-bottom-width: 0">تعداد نظر ها</td>
253
+ <td style="border-bottom-width: 0"><input type="checkbox" name="mps_jd_farsinum_commentnum" <?=$mps_jd_farsinum_commentnum==true? 'checked=\"checked\"':'' ?> /></td>
254
</tr>
255
<tr>
256
+ <td style="border-bottom-width: 0">عنوان نوشته ها</td>
257
+ <td style="border-bottom-width: 0"><input type="checkbox" name="mps_jd_farsinum_title" <?=$mps_jd_farsinum_title==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_date" <?=$mps_jd_farsinum_date==true? 'checked=\"checked\"':'' ?> /></td>
260
+ <td style="border-bottom-width: 0">فهرست دسته ها</td>
261
+ <td style="border-bottom-width: 0"><input type="checkbox" name="mps_jd_farsinum_category" <?=$mps_jd_farsinum_category==true? 'checked=\"checked\"':'' ?> /></td>
262
</tr>
263
</table>
264
265
</td>
266
</tr>
267
<tr valign="top">
268
+ <th scope="row">جهت ویرایشگر متنی صفحه نوشتن</th>
269
<td>
270
<select name="mps_jd_mcertl" id="mps_jd_mcertl">
271
<option value="1" <?=$mps_jd_mcertl==true? 'selected=\"selected\"':'' ?>>راست به چپ</option>
272
<option value="0" <?=$mps_jd_mcertl==false?'selected=\"selected\"':'' ?>>چپ به راست</option>
273
</select>
274
+ <br />
275
+ در نگارش های بالاتر از وردپرس ۲/۳ در صورتی که زبان وردپرس خود را فارسی انتخاب کنید، جهت ویرایشگر به صورت خودکار راست به چپ خواهد بود. در این نگارش ها تنها در صورتی از این گزینه استفاده کنید که زبان وردپرس خود را انگلیسی انتخاب کرده باشید.
276
</td>
277
</tr>
278
<tr valign="top">
279
+ <th scope="row">تبدیل خودکار تاریخ در آدرس (URI) نوشته ها</th>
280
<td>
281
<select name="mps_jd_jperma" id="mps_jd_jperma">
282
<option value="1" <?=$mps_jd_jperma==true? 'selected=\"selected\"':'' ?>>بله</option>
283
<option value="0" <?=$mps_jd_jperma==false?'selected=\"selected\"':'' ?>>خیر</option>
284
</select>
285
+ <br />
286
+ تبدیل خودکار تاریخ در آدرس نوشته ها، مثلا از yourblog.ir/2008/04/02/post به yourblog.ir/1387/01/13/post
287
+ </td>
288
+ </tr>
289
+ <tr valign="top">
290
+ <th scope="row">تبدیل هوشمند کاراکترهای عربی به فارسی</th>
291
+ <td>
292
+ <select name="mps_jd_autoyk" id="mps_jd_autoyk">
293
+ <option value="1" <?=$mps_jd_autoyk==true? 'selected=\"selected\"':'' ?>>بله</option>
294
+ <option value="0" <?=$mps_jd_autoyk==false?'selected=\"selected\"':'' ?>>خیر</option>
295
+ </select>
296
+ <br />
297
+ تبدیل خودکار کاراکترهای (ي) و (ك) عربی به (ی) و (ک) فارسی در هنگام نمایش و جستجوی هوشمند برای تمامی ترکیب های ممکن در هنگام جستجو.
298
+ </td>
299
+ </tr>
300
+ <tr valign="top">
301
+ <th scope="row">ویرایش تاریخ نوشته ها و برگه ها</th>
302
+ <td>
303
+ <select name="mps_jd_editjalali" id="mps_jd_editjalali">
304
+ <option value="1" <?=$mps_jd_editjalali==true? 'selected=\"selected\"':'' ?>>خورشیدی (شمسی)</option>
305
+ <option value="0" <?=$mps_jd_editjalali==false?'selected=\"selected\"':'' ?>>میلادی</option>
306
+ </select>
307
+ <br />
308
+ در نگارش های بالاتر از وردپرس ۲/۵ می توانید نحوه ویرایش تاریخ نوشته ها و برگه ها را تنظیم کنید.
309
</td>
310
</tr>
311
</table>
312
+ <br />
313
+ <h2>تنظیمات ساعت و تاریخ</h2>
314
+ <table class="form-table">
315
<tr>
316
<th scope="row" width="33%">ساعت به وقت <abbr title="Coordinated Universal Time">UTC</abbr>:</th>
317
<td><code>
318
<?php
319
$m = gmdate('YmdHis');
320
$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));
321
?>
322
<?php echo jdate('l Y-m-d g:i:s a',$gmt); ?></code></td>
323
</tr>
328
</tr>
329
<tr>
330
<th scope="row">&nbsp;</th>
331
+ <td>فرمت های زیر مانند <a href="http://php.net/date">تابع <code>date()</code> PHP</a> می باشد. برای نمایش تغییرات این صفحه را به روز کنید.</td>
332
</tr>
333
<tr>
334
<th scope="row">فرمت تاریخ پیش فرض</th>
363
</form>
364
365
<br />
366
+ </div>
367
<div id="wp-bookmarklet" class="wrap" style="direction:rtl; text-align:right">
368
<h3>پروژه وردپرس فارسی</h3>
369
+ <p>این افزونه، بخشی از <a href="http://wp-persian.com/">پروژه وردپرس فارسی</a> می باشد. برای اطلاعات بیشتر در مورد این افزونه می توانید <a href="http://wp-persian.com/wp-jalali/">صفحه مخصوص این افزونه</a> را مشاهده کنید.</p>
370
+ </div>
371
</div>
372
373
<?php
374
375
}
376