PluginProbe ʕ •ᴥ•ʔ
پارسی دیت – Parsi Date / 4.0.0
پارسی دیت – Parsi Date v4.0.0
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
datepicker-rtl.php 4 years ago gutenberg-jalali-calendar.php 4 years ago lists-fix.php 4 years ago styles-fix.php 4 years ago widgets.php 4 years ago
lists-fix.php
106 lines
1 <?php
2
3 defined( 'ABSPATH' ) or exit( 'No direct script access allowed' );
4
5 /**
6 * Fixes admin lists for dates
7 *
8 * @author Mobin Ghasempoor
9 * @package WP-Parsidate
10 * @subpackage Admin/Lists
11 */
12
13 /**
14 * Enqueues admin scripts
15 *
16 * @return void
17 * @author Ehsaan
18 */
19 function wpp_enqueue_admin_scripts() {
20 wp_register_script( 'wpp_admin', WP_PARSI_URL . 'assets/js/admin.js', false, WP_PARSI_VER );
21 wp_enqueue_script( 'wpp_admin' );
22 }
23
24 add_action( 'admin_enqueue_scripts', 'wpp_enqueue_admin_scripts' );
25
26 /**
27 * Hooks admin functions for restrict posts in edit pages
28 *
29 * @return void
30 */
31 function wpp_backend_init() {
32 add_action( 'restrict_manage_posts', 'wpp_restrict_posts' );
33 add_filter( 'posts_where', 'wpp_admin_posts_where' );
34 }
35
36 add_action( 'load-edit.php', 'wpp_backend_init' );
37
38 /**
39 * Limits posts to a certain date, if date setted
40 *
41 * @param string $where Query pointer
42 *
43 * @return string New Pointer
44 */
45 function wpp_admin_posts_where( $where ) {
46 global $wp_query;
47
48 if ( isset( $_GET['mfa'] ) && $_GET['mfa'] != '0' ) {
49 $wp_query->query_vars['m'] = $_GET['mfa'];
50 $where = wpp_posts_where( $where, $wp_query );
51 }
52
53 return $where;
54 }
55
56 /**
57 * Restrict posts to given date
58 * @return void
59 * @author Parsa Kafi
60 * @author Mobin Ghasempoor
61 */
62 function wpp_restrict_posts() {
63 global $post_type, $post_status, $wpdb, $persian_month_names;
64
65 $post_status_w = "AND post_status <> 'auto-draft'";
66
67 if ( $post_status != "" ) {
68 if ( is_string( $post_status ) ) {
69 $post_status_w .= " AND post_status = '$post_status'";
70 }
71 } else {
72 $post_status_w .= " AND post_status <> 'trash'";
73 }
74
75 $sql = "SELECT DISTINCT date( post_date ) AS date
76 FROM $wpdb->posts
77 WHERE post_type='$post_type' $post_status_w AND date( post_date ) <> '0000-00-00'
78 ORDER BY post_date";
79
80 $list = $wpdb->get_col( $sql );
81
82 if ( empty( $list ) ) {
83 return;
84 }
85
86 $m = isset( $_GET['mfa'] ) ? (int) $_GET['mfa'] : 0;
87 $predate = '';
88
89 echo '<select name="mfa">';
90 echo '<option ' . selected( $m, 0, false ) . ' value="0">' . __( 'Show All Dates', 'wp-parsidate' ) . '</option>' . PHP_EOL;
91
92 foreach ( $list as $date ) {
93 $date = parsidate( 'Ym', $date, 'eng' );
94 $year = substr( $date, 0, 4 );
95 $month = substr( $date, 4, 2 );
96 $month = $persian_month_names[ intval( $month ) ];
97
98 if ( $predate != $date ) {
99 echo sprintf( '<option %s value="%s">%s</option>', selected( $m, $date, false ), $date, $month . ' ' . fix_number( $year ) );
100 }
101
102 $predate = $date;
103 }
104
105 echo '</select>';
106 }