forked from SadeghPM/xmenplayer-wordpress
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlist_videos.php
132 lines (128 loc) · 5.04 KB
/
list_videos.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
trait list_videos
{
public function videos_list_page()
{
if ( isset( $_GET['message'] ) && $_GET['message'] == 'video-created' ) {
printf(
'<div class="updated notice is-dismissible"><p>%s</p></div>',
esc_html__( 'Video created successfully.', 'xmenplayer' )
);
}
?>
<div class="wrap">
<h1 class="wp-heading-inline"><?php echo __("Your Videos", "xmenplayer"); ?></h1>
<?php
$current_page = isset($_GET["paged"]) ? absint($_GET["paged"]) : 1;
$search_query = isset($_GET["q"]) ? sanitize_text_field($_GET["q"]) : "";
$response_body = $this->request("/videos?page=" . $current_page . "&q=" . urlencode($search_query));
?>
<a href="https://wordpress.test/wp-admin/admin.php?page=xmenplayer-plugin-create" class="page-title-action"><?php echo __("New Video", "xmenplayer"); ?></a>
<hr class="wp-header-end">
<form method="get" action="<?php echo admin_url("admin.php"); ?>">
<p class="search-box">
<input type="hidden" name="page" value="xmenplayer-videos-list">
<input type="search" name="q" value="<?php echo esc_attr($search_query); ?>" placeholder="<?php echo __("Search by title", "xmenplayer"); ?>">
<input type="submit" class="button" value="<?php echo __("Search", "xmenplayer"); ?>">
</p>
</form>
<div class="tablenav top"></div>
<?php
if (is_array($response_body) && !empty($response_body["data"])) {
$pagination = $response_body;
$videos = $response_body["data"];
?>
<table class="wp-list-table widefat fixed striped table-view-list media">
<thead>
<tr>
<th class="manage-column column-cb check-column" scope="col"></th>
<th class="manage-column column-title column-primary"><?php echo __("Title", "xmenplayer"); ?></th>
<th class="manage-column column-status"><?php echo __("Status", "xmenplayer"); ?></th>
<th class="manage-column column-duration"><?php echo __("Duration", "xmenplayer"); ?></th>
<th class="manage-column column-shortcode"><?php echo __("Shortcode", "xmenplayer"); ?></th>
<th class="manage-column column-date"><?php echo __("Created At", "xmenplayer"); ?></th>
</tr>
</thead>
<tbody id='the-list'>
<?php
foreach ($videos as $video) {
$date_created = wp_date(
get_option("date_format"),
strtotime($video["created_at"])
);
?>
<tr class='author-self status-inherit'>
<th class="check-column" scope="row"></th>
<td class="title column-title has-row-actions column-primary">
<strong class="has-media-icon">
<a href="<?php echo esc_url(
add_query_arg(
[
"page" => "xmenplayer-plugin-video-detail",
"id" => $video["id"],
],
admin_url("admin.php")
)
); ?>">
<span class="media-icon video-icon">
<img width="48" height="64" src="<?php echo esc_url(
$video["thumbnail_url"] ??
"/wp-includes/images/media/video.png"
); ?>" class="attachment-60x60 size-60x60" alt="" decoding="async" loading="lazy">
</span>
<?php echo esc_html($video["title"]); ?>
</a>
</strong>
<p class="filename"><?php echo esc_html($video["original_file"]["name"] ?? ""); ?></p>
<div class="row-actions">
<span class="edit">
<a href="<?php echo esc_url(
add_query_arg(
[
"page" => "xmenplayer-plugin-video-detail",
"id" => $video["id"],
],
admin_url("admin.php")
)
); ?>">
<?php _e("View", "xmenplayer"); ?>
</a>
</span>
|
<span class="trash">
<a href="#" onclick="my_plugin_delete_video(<?php echo $video["id"]; ?>)">
<?php _e("Delete", "xmenplayer"); ?>
</a>
</span>
</div>
</td>
<td class="column-status"><?php echo esc_html($video["status"]); ?></td>
<td class="column-duration"><?php echo esc_html($video["duration_formatted"]); ?></td>
<td class="shortcode column-shortcode" dir="ltr">
<span class="shortcode">
<input type="text" onfocus="this.select();" readonly="readonly" value="[xmenplayer video='<?php echo esc_html($video["id"]); ?>']" class=" code">
</span>
</td>
<td class="date column-date"><?php echo esc_html($date_created); ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<div class="tablenav bottom">
<div class="tablenav-pages" style="margin: 1em 0">
<?php echo
paginate_links([
"base" => add_query_arg("paged", "%#%"),
"format" => "",
"prev_text" => __("«"),
"next_text" => __("»"),
"total" => $pagination["last_page"],
"current" => $pagination["current_page"],
]);
?>
</div>
</div>
<?php
}
}
}