ID ); printf( ' %s', esc_attr__( 'Number of downloads', 'wp-attachments' ), esc_html( number_format_i18n( $downloads ) ) ); } } /** * Make the Downloads column sortable. */ public function register_sortable_column( $columns ) { $columns['wpa-download'] = 'wpa-download'; return $columns; } /** * Handle sorting by Downloads column. */ public function handle_column_orderby( $vars ) { if ( isset( $vars['orderby'] ) && $vars['orderby'] === 'wpa-download' ) { $vars = array_merge( $vars, [ 'meta_key' => 'wpa-download', 'orderby' => 'meta_value_num', ] ); } return $vars; } /** * Output custom CSS for the Downloads column in admin. */ public function admin_column_css() { $screen = function_exists('get_current_screen') ? get_current_screen() : null; if (!$screen || $screen->base !== 'upload') { return; } echo ''; } } // Initialize the class. new WPA_Download_Counter(); } ?>