Skip to main content

Write a Content Calendar content types file a podcaster can load

Premium Intermediate Content Calendar

The Content Types panel’s Export Types writes, and Import Types reads, a JSON file: { "format": "benecaster-content-calendar-types", "version": 1, "types": [ { "key", "built_in", "name", "color", "enabled", "uses_content", "content_limit" } ] }. Use it to ship a starter set of types with your own add-on or service.

  • A built-in type carries its key (tweet, truth, blog_post, newsletter, episode, other) and built_in: true.
  • A podcaster’s own type carries key: "" and built_in: false, and is matched by name on import.
  • name is 1–40 characters, color is #rrggbb, and content_limit is 1–100,000 or null. A file holds 1 to 40 types.
  • A file with another format, a higher version or a value out of range is refused whole.

Loading a file merges and never removes: built-in types are matched by key and the podcaster’s own by name, ignoring case, and types only on the receiving show are kept. The result is unsaved edits, which the podcaster saves with Save Types; nothing is sent to the server until then. Saving goes through PUT …/types and its checks (see Read or change a show’s Content Calendar content types).

Code

<?php
$file = [
    'format'  => 'benecaster-content-calendar-types',
    'version' => 1,
    'types'   => [
        [ 'key' => 'tweet', 'built_in' => true, 'name' => 'Post on X', 'color' => '#000000', 'enabled' => true, 'uses_content' => true, 'content_limit' => 280 ],
        [ 'key' => '', 'built_in' => false, 'name' => 'Podcast Clip', 'color' => '#db2777', 'enabled' => true, 'uses_content' => true, 'content_limit' => 280 ],
    ],
];
file_put_contents( 'starter-types.json', wp_json_encode( $file, JSON_PRETTY_PRINT ) );

View on GitHub →

Need this built rather than just documented? See our services →