+ /**
+ * Gets the name of the default primary column.
+ *
+ * @since 4.3.0
+ * @access protected
+ *
+ * @return string Name of the default primary column, in this case, an empty string.
+ */
+ protected function get_default_primary_column_name() {
+ $columns = $this->get_columns();
+ $column = '';
+
+ // We need a primary defined so responsive views show something,
+ // so let's fall back to the first non-checkbox column.
+ foreach( $columns as $col => $column_name ) {
+ if ( 'cb' === $col ) {
+ continue;
+ }
+
+ $column = $col;
+ break;
+ }
+
+ return $column;
+ }
+
+ /**
+ * Gets the name of the primary column.
+ *
+ * @since 4.3.0
+ * @access protected
+ *
+ * @return string The name of the primary column.
+ */
+ protected function get_primary_column_name() {
+ $columns = $this->get_columns();
+ $default = $this->get_default_primary_column_name();
+
+ // If the primary column doesn't exist fall back to the
+ // first non-checkbox column.
+ if ( ! isset( $columns[ $default ] ) ) {
+ $default = WP_List_Table::get_default_primary_column_name();
+ }
+
+ /**
+ * Filter the name of the primary column for the current list table.
+ *
+ * @since 4.3.0
+ *
+ * @param string $default Column name default for the specific list table, e.g. 'name'.
+ * @param string $context Screen ID for specific list table, e.g. 'plugins'.
+ */
+ $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
+
+ if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
+ $column = $default;
+ }
+
+ return $column;
+ }
+