type = $type; $this->view_per = (int) $view_per; $this->show_select = is_array( $others ) && isset( $others['show_select'] ) && $others['show_select'] ? true : false; } /** * Method get_columns() * * Combine all columns. * * @return array $columns Array of column names. */ public function get_columns() { $title = ( MAINWP_VIEW_PER_PLUGIN_THEME === $this->view_per || MAINWP_VIEW_PER_GROUP === $this->view_per ) ? esc_html__( 'Website', 'mainwp' ) : ''; if ( MAINWP_VIEW_PER_SITE === $this->view_per ) { $title = ( 'plugin' === $this->type ) ? esc_html__( 'Plugin', 'mainwp' ) : esc_html__( 'Theme', 'mainwp' ); } $columns = array( 'title' => $title, 'login' => '', 'version' => esc_html__( 'Version', 'mainwp' ), 'latest' => esc_html__( 'Latest', 'mainwp' ), 'trusted' => esc_html__( 'Trusted', 'mainwp' ), 'status' => esc_html__( 'Status', 'mainwp' ), 'client' => esc_html__( 'Client', 'mainwp' ), 'action' => '', ); if ( MAINWP_VIEW_PER_PLUGIN_THEME !== $this->view_per ) { unset( $columns['login'] ); unset( $columns['client'] ); } if ( MAINWP_VIEW_PER_PLUGIN_THEME === $this->view_per ) { unset( $columns['trusted'] ); } if ( ! \mainwp_current_user_can( 'dashboard', 'manage_clients' ) ) { unset( $columns['client'] ); } return $columns; } /** * Get column info. */ protected function get_column_info() { if ( isset( $this->columns_info ) ) { return $this->columns_info; } $columns = $this->get_columns(); $sortable = $this->get_sortable_columns(); $collapsing = $this->get_collapsing_columns(); $this->columns_info = apply_filters( 'mainwp_updates_table_columns_header', array( $columns, $sortable, $collapsing ), $this->type, $this->view_per ); return $this->columns_info; } /** * Get sortable columns. * * @return array $sortable_columns Array of sortable column names. */ public function get_sortable_columns() { return array( 'title' => true, 'version' => true, 'trusted' => true, 'status' => true, ); } /** * Get collapsing columns. * * @return array $collapsing_columns Array of collapsing columns. */ public function get_collapsing_columns() { return array( 'login' => true, 'version' => true, 'latest' => true, 'trusted' => true, 'status' => true, 'client' => true, 'action' => true, ); } /** * Echo the column headers. * * @param bool $top true|false. */ public function print_column_headers( $top = true ) { list( $columns_header, $sortable, $collapsing ) = $this->get_column_info(); foreach ( $columns_header as $column_key => $column_display_name ) { $class = array(); if ( ! isset( $sortable[ $column_key ] ) ) { $class[] = 'no-sort'; } if ( isset( $collapsing[ $column_key ] ) ) { $class[] = 'two wide collapsing'; } if ( ! empty( $class ) ) { $class = "class='" . join( ' ', $class ) . "'"; } else { $class = ''; } $column_display_name = apply_filters( 'mainwp_updates_table_header_content', $column_display_name, $column_key, $top, $this ); echo "