Parsi Date - Version 2.3.0.1

Version Description

Download this release

Release Info

Developer parselearn
Plugin Icon Parsi Date
Version 2.3.0.1
Comparing to
See all releases

Code changes from version 2.2.3 to 2.3.0.1

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