ac/column/value add_filter

/**
* @param $value string
* @param $id int
* @param $column AC_Column
*/
function acp_column_value_file_size( $value, $id, $column ) {

if ( 'column-file_size' === $column->get_type() ) {
$file = wp_get_attachment_url( $id );

// Change $abs to get the correct absolute path of the file
$abs = str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $file );

if ( file_exists( $abs ) ) {
$value = ac_helper()->file->get_readable_filesize( filesize( $abs ) );
}
}

return $value;
}

add_filter( 'ac/column/value', 'acp_column_value_file_size', 10, 3 );

Đọc thêm
Thu Gọn