__( "Invite Codes", "all_in_one_invite_codes" ), "singular_name" => __( "Invite Code", "all_in_one_invite_codes" ), ); $args = array( "label" => __( "Invite Codes", "all_in_one_invite_codes" ), "labels" => $labels, "description" => "", "public" => false, "publicly_queryable" => false, "show_ui" => true, "delete_with_user" => false, "show_in_rest" => true, "rest_base" => "", "rest_controller_class" => "WP_REST_Posts_Controller", "has_archive" => false, "show_in_menu" => true, "show_in_nav_menus" => false, "exclude_from_search" => true, "capability_type" => "post", "map_meta_cap" => true, "hierarchical" => true, "rewrite" => array( "slug" => "tk_invite_codes", "with_front" => false ), "query_var" => true, "supports" => false, ); register_post_type( "tk_invite_codes", $args ); } add_action( 'init', 'all_in_one_invite_codes_register_post_type' ); /** * * Add the actions to list table * * @param $actions * @param $post * * @return mixed */ function all_in_one_invite_codes_add_action_buttons( $actions, $post ) { if ( get_post_type() === 'tk_invite_codes' ) { // No quick edit please unset( $actions['inline hide-if-no-js'] ); // Add resent and disable links as list actions $actions['disable'] = 'Disable'; //$actions['resent'] = 'Resent Invitation'; } return $actions; } add_filter( 'page_row_actions', 'all_in_one_invite_codes_add_action_buttons', 10, 2 ); /** * * Generate the table header for the invite code columns * * @param $columns * @param $post_id * * @return array */ function tk_invite_codes_columns( $columns, $post_id = false ) { unset( $columns['date'] ); unset( $columns['title'] ); $columns['code'] = __( 'Code', 'all-in-one-invite-codes' ); $columns['code_status'] = __( 'Status', 'all-in-one-invite-codes' ); $columns['email'] = __( 'eMail', 'all-in-one-invite-codes' ); $columns['code_parent'] = __( 'Parent', 'all-in-one-invite-codes' ); $columns['generate_codes'] = __( 'Generate new codes after account activation', 'all-in-one-invite-codes' ); return $columns; } add_action( 'manage_tk_invite_codes_posts_columns', 'tk_invite_codes_columns', 102, 2 ); /** * * Display the invite code meta data as columns * * @param $columns * @param $post_id * * @return array */ function custom_tk_invite_codes_columns( $columns, $post_id = false ) { $all_in_one_invite_codes_options = get_post_meta( $post_id, 'all_in_one_invite_codes_options', true ); switch ( $columns ) { case 'code' : echo get_post_meta( $post_id, 'tk_all_in_one_invite_code', true ); break; case 'code_status' : echo all_in_one_invite_codes_get_status( $post_id ); break; case 'email' : echo isset( $all_in_one_invite_codes_options['email'] ) ? $all_in_one_invite_codes_options['email'] : '--'; break; case 'generate_codes' : echo isset( $all_in_one_invite_codes_options['generate_codes'] ) ? $all_in_one_invite_codes_options['generate_codes'] : '--'; break; case 'code_parent' : echo wp_get_post_parent_id( $post_id ); break; } return $columns; } add_action( 'manage_tk_invite_codes_posts_custom_column', 'custom_tk_invite_codes_columns', 10, 2 ); /** * * Adds a metabox to the main column on the Code edit screen * */ function all_in_one_invite_codes_hide_publishing_actions() { global $post; // The edit screen of custom post types coes with for our solution unneeded information or actions. // So lets hide and remove not relevant functionality and keep the UI simple! if ( get_post_type( $post ) == 'tk_invite_codes' ) { ?>
Invite Code:
ID ?>