Documentation
Documentation
Graphic_Data_Transfer_Tsv_Exporter
in package
Class Graphic_Data_Transfer_Tsv_Exporter.
Tags
Table of Contents
Constants
- EXCEL_CELL_LIMIT : mixed = 32767
- Longest cell Excel can hold.
- MAX_LONG_CELLS : mixed = 10
- List at most this many cells that are too long for Excel.
Properties
- $built : bool
- Whether build() has run.
- $collected : array<string|int, mixed>
- What build() collected (see Graphic_Data_Transfer_Exporter::get_collected()).
- $embedded_files : array<string|int, string>
- Titles of the items whose formatted text links to files in uploads.
- $exporter : Graphic_Data_Transfer_Exporter
- Package exporter that collects the content.
- $files : array<string, string>
- Files to add to the zip: zip path => local path.
- $long_cells : array<string|int, string>
- Cells too long for Excel: file, row and column.
- $media_by_url : array<string, array<string|int, mixed>>
- Media entry of each exported address.
- $media_extras : array<string, array<string, true>>
- Media columns that have alt text or a caption, by content type.
- $post_refs : array<int, string>
- Ref of each exported post, by source ID.
- $rows : array<string, array<string|int, array<string|int, mixed>>>
- Rows of each TSV file (column name => cell), by content type.
- $term_refs : array<int, string>
- Ref of each exported Instance Type, by term ID.
- $warnings : array<string|int, string>
- Problems the export is shown with.
Methods
- __construct() : mixed
- Constructor.
- build() : true|WP_Error
- Collect the content and turn it into rows.
- get_file_name() : string
- Suggested download file name, for example graphic-data-spreadsheets-instances-2026-11-21.zip.
- get_summary() : array<string|int, mixed>
- What the spreadsheets will contain, for the preview: the package summary without the pages and About content, with this format's files and warnings.
- write_zip() : true|WP_Error
- Write the zip: the TSV files (every content type, so that rows can be added to any of them), README.tsv, and the media and data files.
- add_row() : void
- Add a row, noting cells that are too long for Excel.
- add_warnings() : void
- Warn about what these spreadsheets lose compared with a package.
- escape() : string
- Double the backslashes in a text cell, which the import reads as escapes.
- get_data_cell() : string
- A figure's data file: its GeoJSON file, its CSV file if that converts to exactly the JSON the figure uses (an older CSV may be left over from before a JSON file was uploaded), otherwise its JSON file.
- get_header() : array<string|int, string>
- Header row of a TSV file: the template's columns, with the alt text and caption columns of any image that has them.
- get_link_cell() : string
- Link to another post: ref:<ref> if it is exported, slug:<slug> if it is not (so that the import can find it on this or another site).
- get_media_cells() : array<string, string>
- Cells of an image: media/<file> for a file in the export (with its alt text and caption), otherwise the address as it is.
- get_post_row() : array<string, string>
- Cells of a post's row.
- get_uploads_url_pattern() : string
- Regular expression matching addresses in this site's uploads folder.
- list_titles() : string
- Quoted titles, shortened after five.
Constants
EXCEL_CELL_LIMIT
Longest cell Excel can hold.
public
mixed
EXCEL_CELL_LIMIT
= 32767
MAX_LONG_CELLS
List at most this many cells that are too long for Excel.
public
mixed
MAX_LONG_CELLS
= 10
Properties
$built
Whether build() has run.
private
bool
$built
= \false
$collected
What build() collected (see Graphic_Data_Transfer_Exporter::get_collected()).
private
array<string|int, mixed>
$collected
= array()
$embedded_files
Titles of the items whose formatted text links to files in uploads.
private
array<string|int, string>
$embedded_files
= array()
$exporter
Package exporter that collects the content.
private
Graphic_Data_Transfer_Exporter
$exporter
$files
Files to add to the zip: zip path => local path.
private
array<string, string>
$files
= array()
$long_cells
Cells too long for Excel: file, row and column.
private
array<string|int, string>
$long_cells
= array()
$media_by_url
Media entry of each exported address.
private
array<string, array<string|int, mixed>>
$media_by_url
= array()
$media_extras
Media columns that have alt text or a caption, by content type.
private
array<string, array<string, true>>
$media_extras
= array()
$post_refs
Ref of each exported post, by source ID.
private
array<int, string>
$post_refs
= array()
$rows
Rows of each TSV file (column name => cell), by content type.
private
array<string, array<string|int, array<string|int, mixed>>>
$rows
= array()
$term_refs
Ref of each exported Instance Type, by term ID.
private
array<int, string>
$term_refs
= array()
$warnings
Problems the export is shown with.
private
array<string|int, string>
$warnings
= array()
Methods
__construct()
Constructor.
public
__construct(Graphic_Data_Transfer_Exporter $exporter) : mixed
Parameters
- $exporter : Graphic_Data_Transfer_Exporter
-
Exporter for the selection.
build()
Collect the content and turn it into rows.
public
build() : true|WP_Error
Return values
true|WP_Errorget_file_name()
Suggested download file name, for example graphic-data-spreadsheets-instances-2026-11-21.zip.
public
get_file_name() : string
Return values
stringget_summary()
What the spreadsheets will contain, for the preview: the package summary without the pages and About content, with this format's files and warnings.
public
get_summary() : array<string|int, mixed>
Return values
array<string|int, mixed>write_zip()
Write the zip: the TSV files (every content type, so that rows can be added to any of them), README.tsv, and the media and data files.
public
write_zip(string $zip_path) : true|WP_Error
Parameters
- $zip_path : string
-
Zip to create (overwritten).
Return values
true|WP_Erroradd_row()
Add a row, noting cells that are too long for Excel.
private
add_row(string $type, array<string|int, mixed> $row, string $title) : void
Parameters
- $type : string
-
Content type.
- $row : array<string|int, mixed>
-
Cells by column name.
- $title : string
-
Title of the item, for messages.
add_warnings()
Warn about what these spreadsheets lose compared with a package.
private
add_warnings(array<string, int> $skipped) : void
Parameters
- $skipped : array<string, int>
-
Items left out, by post type.
escape()
Double the backslashes in a text cell, which the import reads as escapes.
private
static escape(string $value) : string
Parameters
- $value : string
-
Text.
Return values
stringget_data_cell()
A figure's data file: its GeoJSON file, its CSV file if that converts to exactly the JSON the figure uses (an older CSV may be left over from before a JSON file was uploaded), otherwise its JSON file.
private
get_data_cell(int $source_id) : string
Parameters
- $source_id : int
-
Figure ID.
Return values
string —data/
get_header()
Header row of a TSV file: the template's columns, with the alt text and caption columns of any image that has them.
private
get_header(string $type) : array<string|int, string>
Parameters
- $type : string
-
Content type.
Return values
array<string|int, string>get_link_cell()
Link to another post: ref:<ref> if it is exported, slug:<slug> if it is not (so that the import can find it on this or another site).
private
get_link_cell(string $value, string $target_type) : string
Parameters
- $value : string
-
Stored post ID.
- $target_type : string
-
Post type linked to.
Return values
stringget_media_cells()
Cells of an image: media/<file> for a file in the export (with its alt text and caption), otherwise the address as it is.
private
get_media_cells(string $type, string $name, string $value) : array<string, string>
Parameters
- $type : string
-
Content type.
- $name : string
-
Column name.
- $value : string
-
Stored address.
Return values
array<string, string>get_post_row()
Cells of a post's row.
private
get_post_row(int $source_id, array<string|int, mixed> $entry) : array<string, string>
Parameters
- $source_id : int
-
Post ID.
- $entry : array<string|int, mixed>
-
Post entry.
Return values
array<string, string>get_uploads_url_pattern()
Regular expression matching addresses in this site's uploads folder.
private
get_uploads_url_pattern() : string
Return values
stringlist_titles()
Quoted titles, shortened after five.
private
static list_titles(array<string|int, string> $titles) : string
Parameters
- $titles : array<string|int, string>
-
Titles.