PluginProbe ʕ •ᴥ•ʔ
پارسی دیت – Parsi Date / 2.3.1
پارسی دیت – Parsi Date v2.3.1
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 9 years ago styles-fix.php 9 years ago widgets.php 9 years ago
lists-fix.php
97 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
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 }