-
Notifications
You must be signed in to change notification settings - Fork 2
/
wp-govescuta-custom_edit.php
75 lines (63 loc) · 2.04 KB
/
wp-govescuta-custom_edit.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
<?php
function add_new_contrib_govescuta_columns($columns) {
$new_columns['cb'] = '<input type="checkbox" />';
$new_columns['title'] = __('Title');
$new_columns['ativa'] = __('Ativa');
$new_columns['author'] = __('Author');
$new_columns['categories'] = __('Categories');
$new_columns['comments'] = __('Comments');
$new_columns['date'] = __('Date');
return $new_columns;
}
function manage_contrib_govescuta_columns($column, $id_post) {
switch ($column) {
case 'ativa':
$ativa = get_post_meta( $id_post , 'wp_govescuta_ativa' , true );
switch($ativa)
{
case 'n':
echo 'Inativa';
break;
case 's':
echo 'Ativa';
break;
default:
break;
}
break;
}
}
function manage_contrib_govescuta_sortable_columns( $columns ) {
$columns['ativa'] = 'ativa';
return $columns;
}
function govescuta_request( $vars ) {
if ( isset( $vars['orderby'] ) ) {
switch ( $vars['orderby'] ) {
case 'ativa' :
$vars = array_merge( $vars, array(
'meta_key' => 'wp_govescuta_ativa',
'orderby' => 'meta_value'
) );
break;
}
}
return $vars;
}
add_filter('manage_edit-audiencia_govesc_columns', 'add_new_contrib_govescuta_columns');
add_action('manage_audiencia_govesc_posts_custom_column', 'manage_contrib_govescuta_columns', 10, 2);
add_filter( 'manage_edit-audiencia_govesc_sortable_columns', 'manage_contrib_govescuta_sortable_columns' );
add_filter( 'request', 'govescuta_request' );
add_filter( 'parse_query', 'wp_govescuta_restrict_manage_posts_cutom_field_filter' );
function wp_govescuta_restrict_manage_posts_cutom_field_filter( $query ){
global $pagenow;
$type = 'audiencia_govesc';
if (isset($_GET['post_type'])) {
$type = $_GET['post_type'];
}
if ( 'audiencia_govesc' == $type && is_admin() && $pagenow=='edit.php' && isset($_GET['wp_govescuta_ativa']) && $_GET['wp_govescuta_ativa'] != '') {
$query->query_vars['meta_key'] = 'wp_govescuta_ativa';
$query->query_vars['meta_value'] = $_GET['wp_govescuta_ativa'];
}
}
?>