-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwpp_dashboard.php
55 lines (55 loc) · 2.66 KB
/
wpp_dashboard.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
<h2>Advance Post Prefix Management Page</h2>
<?php
if (isset ($result)){
if ($result) echo '<div id="message" class="updated"><p>Prefix(s) deleted successfully!</p></div>';
else echo '<div id="message" class="error"><p>' . $respond_msg . '</p></div>';
}
?>
<form name="frm_prefix_manage" method="post" action="" onsubmit="return validateForm();">
<table class="wp-list-table widefat fixed wpp-prefix" cellspacing="0">
<thead>
<tr>
<th scope="col" class="manage-column column-cb check-column" style="text-align: center">#</th>
<th scope="col" class="manage-column column-prefix-name">Prefix Name</th>
<th scope="col" class="manage-column column-prefix-description">Description</th>
<th scope="col" class="manage-column column-prefix-number-post">Number of articles</th>
<th scope="col" class="manage-column column-prefix-date">Date added</th>
<th scope="col" class="manage-column column-prefix-delete">Delete</th>
</tr>
</thead>
<tbody>
<?php $i =1; foreach ($prefix as $key => $value) : ?>
<tr <?php if($i%2==0) echo 'class="alternate"'; ?>>
<th scope="col" class="check-column" style="text-align: center"><?php echo $i; ?></th>
<td class="column-prefix-name"><a href="<?php echo bloginfo ('wpurl'); ?>/wp-admin/admin.php?page=advance-post-prefix&action=edit&id=<?php echo $value['id']; ?>" title="Edit prefix"><?php echo $value['prefix']; ?></a></td>
<td class="column-prefix-description"><?php echo $value['description']; ?></td>
<td class="column-prefix-number-post">
<a href="/wp-admin/edit.php"><?php
$query = $wpdb->get_results ("SELECT COUNT(*) FROM {$wpdb->base_prefix}postmeta WHERE meta_key = 'prefix' AND meta_value = " . $value['id'], ARRAY_A);
$count_post = $query[0]['COUNT(*)'];
echo $count_post;
?></a>
</td>
<td class="column-prefix-date">
<?php
$date = new DateTime($value['date']);
echo $date->format("d/m/Y");
?>
</td>
<td>
<a href="/wp-admin/admin.php?page=advance-post-prefix&prefix_id=<?php echo $value['id']; ?>"
<?php if($count_post>0) echo 'onclick="return confirm(\''.$value['prefix'].' has post, are you sure? \');"' ?> >[Delete]</a>
</td>
</tr>
<?php $i++; endforeach; ?>
</tbody>
</table>
<p> <a href="<?php echo get_bloginfo('wpurl') . '/wp-admin/admin.php?page=add-prefix'; ?>" class="button-primary">Add new</a></p>
</form>
<script type="text/javascript">
function validateForm(){
var confirmBox = confirm("Are you sure delete selected item(s)?");
if (confirmBox) return true;
else return false;
}
</script>