You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: includes/collections/README.md
+47-15Lines changed: 47 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,31 +44,47 @@ The Collections system is built around a custom post type (`newspack_collection`
44
44
45
45
## Backend components
46
46
47
-
### 1. Anatomy of a collection
47
+
### Anatomy of a collection
48
48
49
49
A collection is a post of the `newspack_collection` CPT and a term of the `newspack_collection_taxonomy` at the same time. Both entities are linked together and share the same name.
50
50
51
51
A post is assigned to a collection via the `newspack_collection_taxonomy` taxonomy. Posts can also be organized in the `newspack_collection_section` taxonomy. When visiting the Collections page (single template for the collection CPT), posts will be listed and organized by the Sections taxonomy.
52
52
53
53
The collections themselves can also be categorized using the `newspack_collection_category` taxonomy. This will allow us to not only have one archive to list all the collections, but additional archives for each Collection category.
54
54
55
-
### 2. Collection custom post type ([`class-post-type.php`](class-post-type.php))
55
+
### Global settings ([`class-settings.php`](class-settings.php))
56
+
57
+
Collections can be configured globally via the Newspack settings.
58
+
The following nested options are available as properties of the `newspack_collections_settings` option array:
|`custom_name`| String | Custom plural name for collections. Only affects the reader-facing nomenclature | Text (e.g., "Issues") |
64
+
|`custom_singular_name`| String | Custom singular name for collections. Only affects the reader-facing nomenclature | Text (e.g., "Issue") |
65
+
|`custom_slug`| String | Custom URL slug for collections. | Text (e.g., "issue") |
66
+
|`subscribe_link`| String | Global subscription URL displayed on collection pages | Valid URL |
67
+
|`order_link`| String | Global order URL for purchasing physical copies | Valid URL |
68
+
69
+
The `subscribe_link` and `order_link` settings provide defaults that can be overridden at the collection category level (via term meta) or collection level (via post meta).
70
+
71
+
### Collection custom post type ([`class-post-type.php`](class-post-type.php))
56
72
- Defined as a `newspack_collection` CPT.
57
73
- Supports: `title`, `editor`, `thumbnail`, `custom-fields`, and `page-attributes`.
58
74
- Includes custom ordering functionality via `menu_order`.
59
75
- Provides admin interface customizations.
60
76
61
-
### 3. Collection post meta fields ([`class-collection-meta.php`](class-collection-meta.php))
77
+
### Collection post meta fields ([`class-collection-meta.php`](class-collection-meta.php))
62
78
63
79
The following table details all available meta fields for collections:
64
80
65
81
| Meta Field | Type | Description | Format |
66
-
|------------|------|-------------|---------|
82
+
|------------|------|-------------|--------|
67
83
|`newspack_collection_volume`| String | Collection volume information | Text (e.g., "IV") |
68
84
|`newspack_collection_number`| String | Collection number | Text (e.g., "#22") |
69
85
|`newspack_collection_period`| String | Collection period | Text (e.g., "Spring 2025") |
70
-
|`newspack_collection_subscribe_link`| String |A link to subscribe that will be displayed as a button on the collection page| Valid URL |
71
-
|`newspack_collection_order_link`| String |A link to order the physical version of that collection | Valid URL |
86
+
|`newspack_collection_subscribe_link`| String |Override global/category subscription link for this specific collection | Valid URL |
87
+
|`newspack_collection_order_link`| String |Override global/category order link for this specific collection | Valid URL |
72
88
|`newspack_collection_ctas`| Array | An array of CTAs (Call-to-Action buttons) | Array of objects with `label`, `type`, `id` and `url` properties |
73
89
74
90
Sample `newspack_collection_ctas` post meta structure:
@@ -89,36 +105,50 @@ Sample `newspack_collection_ctas` post meta structure:
89
105
90
106
Where `type` can either be `link` or `attachment`, and `id` is the attachment ID.
91
107
92
-
### 4. Data management ([`class-enqueuer.php`](class-enqueuer.php))
108
+
### Data management ([`class-enqueuer.php`](class-enqueuer.php))
93
109
- Manages JavaScript data localization.
94
110
- Provides a common interface for adding/retrieving collection data dynamically.
95
111
- Dynamically handles styles and scripts enqueuing in a single place if data is localized and passed to the frontend.
96
112
97
-
### 5. Taxonomies
113
+
### Taxonomies
98
114
The system includes multiple taxonomy classes for organizing collections:
- Special internal taxonomy (`newspack_collection_taxonomy`) for associating collections with posts.
140
+
- Special internal taxonomy for associating collections with posts.
115
141
- It's a copy of the collection post title and slug to allow regular posts to be tagged with collections.
116
142
- Not publicly queryable.
117
143
- Hidden from the admin UI.
118
144
- Adds a new "Collection" column to the post list.
119
-
- Terms can be deactivated via an internal `_newspack_collection_inactive` term meta. Used when trashing posts, as terms don't manage status.
145
+
- Term meta fields:
146
+
147
+
| Meta Field | Type | Description | Format |
148
+
|------------|------|-------------|--------|
149
+
|`_newspack_collection_inactive`| Boolean | Internal. Whether the section is inactive. Used when trashing posts, as terms don't manage status. | Boolean |
help={__('Global URL where readers can subscribe to collections.','newspack-plugin')}
98
+
help={__(
99
+
'URL for the "Subscribe" button that will be displayed in the Collections archive pages when no subscription URL is set for the Collection or its parent category.',
'URL for the "Order" button that will be displayed in the Collections archive pages when no order URL is set for the Collection or its parent category.',
0 commit comments