register_shared_location(); } private function register_shared_location() { $post_types = adqs_get_directory_post_types(); if ( empty( $post_types ) ) { return; } $taxonomy_key = 'adqs_location'; $this->slug = $taxonomy_key; // Load taxonomy features AFTER setting the slug $this->load_taxonomy_directory(); $this->load_taxonomy_image(); // Set up hooks for this specific taxonomy add_filter( 'manage_' . $taxonomy_key . '_custom_column', [ $this, 'category_rows' ], 15, 3 ); add_filter( 'manage_edit-' . $taxonomy_key . '_columns', [ $this, 'category_columns' ] ); // Use the base class init method to register the taxonomy $this->init( $taxonomy_key, esc_html__( 'Location', 'adirectory' ), esc_html__( 'Locations', 'adirectory' ), $post_types, [ 'show_admin_column' => true, 'rewrite' => [ 'slug' => 'locations', 'with_front' => false, ], ] ); } /** * Method category_columns * * @param $prev_columns $prev_columns * * @return array */ public function category_columns( $prev_columns ) { $new_columns = $prev_columns ? $prev_columns : []; array_splice( $new_columns, 2 ); // in this way we could place our columns on the first place $new_columns['adqs_image'] = esc_html__( 'Image', 'adirectory' ); $new_columns['adqs_directories'] = esc_html__( 'Directories', 'adirectory' ); unset( $prev_columns['description'] ); return array_merge( $new_columns, $prev_columns ); } /** * Method category_rows * * @param $row $row * @param $column_name $column_name * @param $term_id $term_id * * @return string */ public function category_rows( $row, $column_name, $term_id ) { if ( $column_name === 'adqs_image' ) { $image_id = get_term_meta( $term_id, $this->term_upload_name, true ); $img_url = wp_get_attachment_image_url( $image_id, [ 50, 50 ] ); return ! empty( $img_url ) ? '#' : ''; } if ( $column_name === 'adqs_directories' ) { $directory_names = adqs_get_term_directory_names( $term_id ); return esc_html( $directory_names ); } return $row; } }