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 / admin / lists-fix.php
wp-parsidate / includes / admin Last commit date
lists-fix.php 11 years ago other-fix.php 11 years ago styles-fix.php 10 years ago
lists-fix.php
87 lines
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 add_action( 'admin_enqueue_scripts', 'wpp_enqueue_admin_scripts' );
21
22 /**
23 * Hooks admin functions for restrict posts in edit pages
24 *
25 * @return void
26 */
27 function wpp_backend_init() {
28 add_action( 'restrict_manage_posts', 'wpp_restrict_posts' );
29 add_filter( 'posts_where', 'wpp_admin_posts_where' );
30 }
31 add_action( 'load-edit.php', 'wpp_backend_init' );
32
33 /**
34 * Limits posts to a certain date, if date setted
35 *
36 * @param string $where Query pointer
37 * @return string New Pointer
38 */
39 function wpp_admin_posts_where( $where ) {
40 global $wp_query;
41 if ( isset( $_GET['mfa'] ) && $_GET['mfa'] != '0' ) {
42 $wp_query->query_vars['m'] = $_GET['mfa'];
43 $where = wpp_posts_where( $where );
44 }
45
46 return $where;
47 }
48
49 /**
50 * Restrict posts to given date
51 * @author Mobin Ghasempoor
52 * @author Parsa Kafi
53 * @return void
54 */
55 function wpp_restrict_posts() {
56 global $post_type, $post_status, $wpdb, $persian_month_names;
57
58 $post_status_w = "AND post_status <> 'auto-draft'";
59 if($post_status != "") {
60 if(is_string($post_status))
61 $post_status_w .= " AND post_status = '$post_status'";
62 }else
63 $post_status_w .= " AND post_status <> 'trash'";
64
65 $sql = "SELECT DISTINCT date( post_date ) AS date
66 FROM $wpdb->posts
67 WHERE post_type='$post_type' {$post_status_w} AND date( post_date ) <> '0000-00-00'
68 ORDER BY post_date";
69 $list = $wpdb->get_col( $sql );
70 if ( empty( $list ) )
71 return;
72
73 $m = isset( $_GET['mfa'] ) ? (int) $_GET['mfa'] : 0;
74 echo '<select name="mfa">';
75 echo '<option ' . selected( $m, 0, false ) . ' value="0">' . __( 'Show All Dates' , 'wp-parsidate' ) . '</option>' . PHP_EOL;
76 foreach( $list as $date ) {
77 $date = parsidate( 'Ym', $date, 'eng' );
78 $year = substr( $date, 0, 4 );
79 $month = substr( $date, 4, 2 );
80 $month = $persian_month_names[intval( $month )];
81
82 if ( $predate != $date )
83 echo sprintf( '<option %s value="%s">%s</option>', selected( $m, $date, false ), $date, $month . ' ' . fixnumber( $year ) );
84 $predate = $date;
85 }
86 echo '</select>';
87 }