esc_html__( 'Add company', 'accounts-buddy-accounting' ), 'singular_name' => esc_html__( 'Company', 'accounts-buddy-accounting' ), 'menu_name' => esc_html__( 'Companies', 'accounts-buddy-accounting' ), 'all_items' => esc_html__( 'Companies', 'accounts-buddy-accounting' ), 'edit_item' => esc_html__( 'Edit Company', 'accounts-buddy-accounting' ), 'new_item' => esc_html__( 'New Company', 'accounts-buddy-accounting' ), 'view_item' => esc_html__( 'View Company', 'accounts-buddy-accounting' ), 'search_items' => esc_html__( 'Search Company', 'accounts-buddy-accounting' ), 'not_found' => esc_html__( 'No compnay Related to your search', 'accounts-buddy-accounting' ), 'not_found_in_trash' => esc_html__( 'No company in trash', 'accounts-buddy-accounting' ) ); $args = array( 'labels' => $labels, 'label' => esc_html__( 'Manage Companies', 'accounts-buddy-accounting' ), 'description' => esc_html__( 'Admin can access all companies while other users can only access companies they have access to.', 'accounts-buddy-accounting' ), 'supports' => array ( 'title' ), 'public' => false, 'publicly_queryable' => false, 'show_ui' => true, 'show_in_menu' => false, 'query_var' => true, 'rewrite' => array('slug' => 'company' ), 'capability_type' => 'post', 'has_archive' => true, 'menu_icon' => 'dashicons-clipboard', 'menu_position' => 30, 'register_meta_box_cb' => 'abas_company_features', ); register_post_type ( 'abas_company', $args ); } add_action ( 'init', 'abas_company_post_type_init' ); endif; //registeration of post type ends here. if ( ! function_exists( 'abas_company_features' ) ) : function abas_company_features() { $screens = array ( 'abas_company' ); foreach ( $screens as $screen ) { add_meta_box( 'myplugin_sectionid', esc_html__ ( "Company Details", "accounts-buddy-accounting" ), 'abas_companys_features_callback', $screen ); } } //Parts features post. add_action( 'add_meta_boxes', 'abas_company_features' ); endif; if ( ! function_exists( 'abas_companys_features_callback' ) ) : function abas_companys_features_callback( $post ) { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'accounts-buddy-accounting' ) ); } wp_nonce_field ( 'abas_meta_box_nonce', 'abas_companys_features_sub' ); settings_errors (); $content = ''; $content = ''; $content .= ''; $value = get_post_meta ( $post->ID, '_company_manual_id', true ); $content .= ''; $value = get_post_meta ( $post->ID, '_business_type', true ); $content .= ''; $value = get_post_meta ( $post->ID, '_address_1', true ); $content .= ''; $value = get_post_meta ( $post->ID, '_address_2', true ); $content .= ''; $value = get_post_meta ( $post->ID, '_city', true ); $content .= ''; $value = get_post_meta ( $post->ID, '_state', true ); $content .= ''; $value = get_post_meta ( $post->ID, '_country', true ); $content .= ''; $value = get_post_meta ( $post->ID, '_zip_code', true ); $content .= ''; $value = get_post_meta ( $post->ID, '_phone', true ); $content .= ''; $value = get_post_meta ( $post->ID, '_email', true ); $content .= ''; $value = get_post_meta ( $post->ID, '_currency', true ); $content .= ''; $value = get_post_meta( $post->ID, '_about_company', true ); $content .= ''; $content .= '
'; $image_id = get_post_meta ( $post->ID, '_company-logo', true ); $content .= '
'; if( $image = wp_get_attachment_image_url ( $image_id, 'Large' ) ) { $content .= ' '; $content .= ' ' . esc_html__( 'Remove Company Logo', 'accounts-buddy-accounting' ) . ''; $content .= ''; } else { $content .= '' . esc_html__( 'Add Company Logo', 'accounts-buddy-accounting' ) . ''; $content .= ''; $content .= ''; } $content .= '
'; $content .= ''; $content .= ''; $content .= ''; $content .= '
'; $content .= ''; $content .= ''; $content .= ''; $content .= '
'; $content .= ''; $content .= ''; $content .= ''; $content .= '
'; $content .= ''; $content .= ''; $content .= ''; $content .= '
'; $content .= ''; $content .= ''; $content .= ''; $content .= '
'; $content .= ''; $content .= ''; $content .= ''; $content .= '
'; $allowedHTML = ( function_exists( 'abas_return_allowed_tags' ) ) ? abas_return_allowed_tags() : ''; echo wp_kses( $content, $allowedHTML ); } endif; /** * Save infor. * * @param int $post_id The ID of the post being saved. */ function abas_companys_features_save_box ( $post_id ) { if ( !current_user_can ( 'manage_options' ) ) { wp_die ( __ ( 'You do not have sufficient permissions to access this page.' ) ); } // Verify that the nonce is valid. if ( ! isset( $_POST['abas_companys_features_sub'] ) || ! wp_verify_nonce( sanitize_key( $_POST['abas_companys_features_sub']), 'abas_meta_box_nonce' ) ) { return; } // If this is an autosave, our form has not been submitted, so we don't want to do anything. if ( defined ('DOING_AUTOSAVE') && DOING_AUTOSAVE ) { return; } // Check the user's permissions. if ( isset ( $_POST['post_type'] ) ) { if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } } //Form PRocessing $submission_values = array( "company-logo", "company_manual_id", "business_type", "address_1", "address_2", "city", "state", "country", "zip_code", "phone", "email", "currency", "about_company", ); foreach ( $submission_values as $submit_value ) { $my_value = sanitize_text_field ( $_POST [$submit_value] ); update_post_meta( $post_id, '_' .$submit_value, $my_value ); } } add_action ( 'save_post', 'abas_companys_features_save_box' ); //Add filter to show Meta Data in front end of post! add_filter ( 'manage_edit-abas_company_columns', 'abas_table_list_company_columns' ) ; function abas_table_list_company_columns ( $columns ) { $columns = array( 'cb' => '', 'title' => esc_html__('company Name', "accounts-buddy-accounting"), 'company_manual_id' => esc_html__('Company Manual Id', "accounts-buddy-accounting"), 'business_type' => esc_html__('Business Type', "accounts-buddy-accounting"), 'city' => esc_html__('City', "accounts-buddy-accounting"), 'phone' => esc_html__('Phone', "accounts-buddy-accounting"), 'email' => esc_html__('Email', "accounts-buddy-accounting"), 'logo' => esc_html__('Logo', "accounts-buddy-accounting"), 'currency' => esc_html__('currency', "accounts-buddy-accounting"), 'accounts' => esc_html__('accounts', "accounts-buddy-accounting"), ); return $columns; } add_action ( 'manage_abas_company_posts_custom_column', 'abas_table_company_list_meta_data', 10, 2 ); function abas_table_company_list_meta_data ($column, $post_id ) { global $post; switch ( $column ) { case 'company_manual_id' : $company_manual_id = get_post_meta ( $post_id, '_company_manual_id', true ); if ( isset ( $company_manual_id ) && !empty ( $company_manual_id ) ) { echo esc_html ( $company_manual_id ); } break; case 'business_type' : $business_type = get_post_meta ( $post_id, '_business_type', true ); if( isset ( $business_type ) && !empty ( $business_type ) ) { echo esc_html($business_type); } break; case 'city' : $city = get_post_meta ( $post_id, '_city', true ); if(isset ($city) && !empty ($city) ) { echo esc_html($city); } break; case 'phone' : $phone = get_post_meta ( $post_id, '_phone', true ); if ( isset ( $phone ) && !empty ( $phone ) ) { echo esc_html($phone); } break; case 'email' : $email = get_post_meta ( $post_id, '_email', true ); if ( isset ( $email ) && !empty ( $email ) ) { echo esc_html($email); } break; case 'logo' : $image_id = get_post_meta ( $post->ID, '_company-logo', true ); if ( $image = wp_get_attachment_image_url ( $image_id, 'thumbnail' ) ) { echo ''; } break; case 'currency' : $currency = get_post_meta ( $post_id, '_currency', true ); if ( isset ( $currency ) && !empty ( $currency ) ) { echo esc_html ( $currency ); } break; case 'accounts' : $company_id = abas_active_company_id (); $arr_params = array ( 'company_select' => $post_id, 'company_selection' => 'true' ); if ( isset ( $company_id ) && ( $company_id ) == $post_id ) { $company_select_btn = ''.esc_html__("Selected Company", "accounts-buddy-accounting").''; } else { $company_select_btn = ''.esc_html__("Select", "accounts-buddy-accounting").''; } $allowedHTML = ( function_exists( 'abas_return_allowed_tags' ) ) ? abas_return_allowed_tags() : ''; echo wp_kses( $company_select_btn, $allowedHTML ); break; //Break for everything else to show default things. default : break; } }