PluginProbe ʕ •ᴥ•ʔ
پارسی دیت – Parsi Date / 2.1.6
پارسی دیت – Parsi Date v2.1.6
6.1 5.1.6 5.1.7 5.1.8 5.1.8.2 6.0 trunk 1.0 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.0.0-alpha 2.1 2.1.1 2.1.2 2.1.3 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0.1 2.3.0.2 2.3.1 2.3.2 2.3.3 2.3.4 3.0.1 3.0.2 3.0.3 4.0.0 4.0.1 4.0.2 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5
wp-parsidate / includes / fixes-get_archives.php
wp-parsidate / includes Last commit date
admin 10 years ago plugins 11 years ago widget 10 years ago fixes-archive.php 11 years ago fixes-dates.php 11 years ago fixes-get_archives.php 11 years ago fixes-get_calendar.php 11 years ago fixes-misc.php 11 years ago fixes-permalinks.php 11 years ago general.php 10 years ago install.php 11 years ago parsidate.php 11 years ago settings.php 10 years ago
fixes-get_archives.php
175 lines
1 <?php
2
3 /**
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 {
25 if($type=='yearly')
26 {
27 $old_date=parsidate('Y',$results[0]->date,'eng');
28 $count=$results[0]->count;
29 $c=count($results);
30 for($i=1;$i<$c;$i++)
31 {
32 $dt=$results[$i];
33 $date=parsidate('Y',$dt->date,'eng');
34 if($date==$old_date)
35 $count+=$dt->count;
36 else
37 {
38 echo_yarchive($old_date,$format,$before,$count,$show_post_count);
39 $old_date=$date;
40 $count=$dt->count;
41 }
42 }
43 echo_yarchive($old_date,$format,$before,$count,$show_post_count);
44 }
45 elseif($type=='monthly')
46 {
47 $old_date=parsidate('Ym',$results[0]->date,'eng');
48 $count=$results[0]->count;
49 $c=count($results);
50 for($i=1;$i<$c;$i++)
51 {
52 $dt=$results[$i];
53 $date=parsidate('Ym',$dt->date,'eng');
54 if($date==$old_date)
55 $count+=$dt->count;
56 else
57 {
58 echo_marchive($old_date,$format,$before,$count,$show_post_count);
59 $old_date=$date;
60 $count=$dt->count;
61 }
62 }
63 echo_marchive($old_date,$format,$before,$count,$show_post_count);
64 }
65 elseif($type=='daily')
66 {
67 foreach($results as $row)
68 {
69 $date = parsidate('Y,m,d',$row->date,'eng');
70 $date=explode(',',$date);
71 if($show_post_count)
72 $count='&nbsp;('.fixnumber($row->count).')';
73 else
74 $count = '';
75 $text = fixnumber($date[2]).' '.$persian_month_names[intval($date[1])].' '.fixnumber($date[0]);
76 echo get_archives_link(get_day_link($date[0],$date[1],$date[2]),$text,$format, $before, $count);
77 }
78 }
79 }
80 }
81
82 function echo_yarchive($year,$format,$before,$count,$show_post_count)
83 {
84 if($show_post_count)
85 $count='&nbsp;('.fixnumber($count).')';
86 else
87 $count='';
88 echo get_archives_link(get_year_link($year),fixnumber($year), $format, $before,$count);
89 }
90
91 function echo_marchive($old_date,$format,$before,$count,$show_post_count)
92 {
93 global $persian_month_names;
94 $year=substr($old_date,0,4);
95 $month=substr($old_date,4,2);
96 if($show_post_count)
97 $count='&nbsp;('.fixnumber($count).')';
98 else
99 $count='';
100 echo get_archives_link(get_month_link($year,$month),$persian_month_names[intval($month)].' '.fixnumber($year), $format, $before,$count);
101 }
102
103 function wp_get_parchives($args='')
104 {
105 global $wpdb, $wp_locale,$persian_month_names;
106 $defaults = array(
107 'type' => 'monthly', 'limit' => '',
108 'format' => 'html', 'before' => '',
109 'after' => '', 'show_post_count' => false,
110 'echo' => 1, 'order' => 'DESC');
111
112 $r = wp_parse_args( $args, $defaults );
113 extract( $r, EXTR_SKIP );
114 $archive_link_m =home_url("'?m='");
115
116 $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");
117 if(!empty($results))
118 {
119 if($type=='yearly')
120 {
121 $old_date=parsidate('Y',$results[0]->date,'eng');
122 $count=$results[0]->count;
123 $c=count($results);
124 for($i=1;$i<$c;$i++)
125 {
126 $dt=$results[$i];
127 $date=parsidate('Y',$dt->date,'eng');
128 if($date==$old_date)
129 $count+=$dt->count;
130 else
131 {
132 echo_yarchive($old_date,$format,$before,$count,$show_post_count);
133 $old_date=$date;
134 $count=$dt->count;
135 }
136 }
137 echo_yarchive($old_date,$format,$before,$count,$show_post_count);
138 }
139 elseif($type=='monthly')
140 {
141 $old_date=parsidate('Ym',$results[0]->date,'eng');
142 $count=$results[0]->count;
143 $c=count($results);
144 for($i=1;$i<$c;$i++)
145 {
146 $dt=$results[$i];
147 $date=parsidate('Ym',$dt->date,'eng');
148 if($date==$old_date)
149 $count+=$dt->count;
150 else
151 {
152 echo_marchive($old_date,$format,$before,$count,$show_post_count);
153 $old_date=$date;
154 $count=$dt->count;
155 }
156 }
157 echo_marchive($old_date,$format,$before,$count,$show_post_count);
158 }
159 elseif($type=='daily')
160 {
161 foreach($results as $row)
162 {
163 $date = parsidate('Y,m,d',$row->date,'eng');
164 $date=explode(',',$date);
165 if($show_post_count)
166 $count='&nbsp;('.fixnumber($row->count).')';
167 else
168 $count = '';
169 $text = fixnumber($date[2]).' '.$persian_month_names[intval($date[1])].' '.fixnumber($date[0]);
170 echo get_archives_link(get_day_link($date[0],$date[1],$date[2]),$text,$format, $before, $count);
171 }
172 }
173 }
174 }
175 ?>