Commit 1e4f26cd authored by Cyrille37's avatar Cyrille37

admin list projects columns categories budget #69

parent 8d911316
......@@ -11,10 +11,17 @@ class ProjectCustomTypeCreator
add_action( 'add_meta_boxes', array( $this, 'custom_field_meta_box' ) );
add_filter( 'wp_insert_post_data', array( $this, 'default_comments_on') );
// https://codex.wordpress.org/Plugin_API/Filter_Reference/manage_$post_type_posts_columns
add_filter('manage_project_posts_columns', array( $this, 'manage_project_posts_columns'));
// https://codex.wordpress.org/Plugin_API/Action_Reference/manage_$post_type_posts_custom_column
add_action('manage_project_posts_custom_column', array( $this, 'manage_project_posts_custom_column'), 1, 2);
}
/**
* Activate comments on post
* Force permits comments on CPT 'project' post.
* https://framagit.org/Artefacts/bpe-univ-tours/issues/42
*
* @param unknown $data
......@@ -22,8 +29,10 @@ class ProjectCustomTypeCreator
*/
function default_comments_on( $data )
{
if( $data['post_type'] == self::CPT ) {
$data['comment_status'] = 'open';
if( $data['post_type'] == self::CPT )
{
if( $data['post_status'] == 'publish' )
$data['comment_status'] = 'open';
}
return $data;
}
......@@ -60,6 +69,35 @@ class ProjectCustomTypeCreator
echo ob_get_clean();
}
function manage_project_posts_columns($defaults)
{
//$defaults['categories'] = 'Categorie';
//error_log( __METHOD__.' defaults: '. print_r($defaults,true) );
return array_merge( $defaults,
array(
'comproj_categories' => __( 'Categories' ),
'comproj_budget' => __( 'Budget' ),
)
);
}
function manage_project_posts_custom_column($column_name, $post_ID)
{
//error_log( __METHOD__.' column_name: '. $column_name);
switch($column_name )
{
case 'comproj_categories' :
echo the_terms($post_ID, 'category_projects');
break;
case 'comproj_budget' :
echo get_post_meta( $post_ID, 'budget', true );
break;
}
}
function create_project_post_type()
{
register_post_type( self::CPT,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment