feat(indesign-export): platform + post types settings, en-dash fix#4725
Open
miguelpeixe wants to merge 9 commits into
Open
feat(indesign-export): platform + post types settings, en-dash fix#4725miguelpeixe wants to merge 9 commits into
miguelpeixe wants to merge 9 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes InDesign Tagged Text exports by making the platform header configurable per export and correcting en-dash conversion.
Changes:
- Adds a
platformconversion option to emit<ASCII-MAC>or<ASCII-WIN>. - Detects platform from the exporting request’s User-Agent and exposes a filter override.
- Corrects en-dash mapping from
<0x2014>to<0x2013>and adds unit coverage.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
includes/optional-modules/class-indesign-exporter.php |
Detects export platform and passes it into conversion. |
includes/optional-modules/indesign-export/class-indesign-converter.php |
Adds platform-aware header output and fixes en-dash conversion. |
tests/unit-tests/indesign-exporter/indesign-exporter.php |
Adds tests for explicit platform headers and dash conversion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This reverts commit 35aa8ec.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (3)
includes/optional-modules/class-indesign-exporter.php:162
- Filtering the saved setting with
post_type_exists()breaks the bulk action for typical plugin-defined post types.InDesign_Exporter::init()is called immediately when this file is included fromincludes/class-newspack.php, before the normalinithook where most CPTs are registered; at that point saved CPT slugs are filtered out, sobulk_actions-edit-{$post_type}and its handler are never registered for those post types.
return array_values(
array_filter(
$value,
static function ( $slug ) {
return is_string( $slug ) && post_type_exists( $slug );
}
includes/optional-modules/class-indesign-exporter.php:132
- Once supported post types come from this setting, the bulk export path still uses the hard-coded
edit_postscapability inhandle_bulk_action(). That rejects users who can edit an enabled CPT with custom capabilities but do not have post editing rights, and it does not align the permission check with the selected post type; use the post type’s capability or per-postedit_postchecks when exporting non-postcontent.
public static function get_supported_post_types() {
$supported_post_types = self::get_post_types_setting();
includes/wizards/newspack/class-print-section.php:108
- The update endpoint accepts any existing post type, including slugs deliberately excluded from the “Available post types” list (such as
attachmentorproduct). A direct REST request can therefore persist a hidden post type and enable export actions for it; validate againstget_available_post_types()(or the same exclusion list) before saving rather than only checkingpost_type_exists().
$post_types = array_values(
array_unique(
array_filter(
$post_types,
static function ( $slug ) {
return is_string( $slug ) && post_type_exists( $slug );
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
Fixes two bugs in the InDesign Tagged Text export and adds two site-level settings under Newspack > Settings > Print > Adobe InDesign.
Platform mismatch on macOS. The exporter hardcoded the
<ASCII-WIN>header on every file, which caused InDesign on Mac to render the tagged-text markup literally instead of interpreting it. A new "Header platform" setting controls the header:<ASCII-MAC>/<ASCII-WIN>header.<ASCII-MAC>.<ASCII-WIN>.A
newspack_indesign_export_platformfilter is available for code-level overrides.En-dash silently converted to em-dash. Every en-dash (
–, U+2013) in post content was being rewritten to an em-dash (U+2014). Each dash now maps to its own code point.Choose which post types are exportable. A new "Available post types" setting lets admins pick which post types show the export action on their list screens. The picker lists every public post type with an admin UI (excluding attachments), so plugins that register custom post types — events, classifieds, etc. — can opt in without code. The default stays at
postto preserve current behavior. The existingnewspack_indesign_export_supported_post_typesfilter still runs after the setting and can extend or restrict the result.Closes NPPM-2813.
How to test the changes in this Pull Request:
Header platform
before – after, before — after, before -- after)..txt. With Auto-detect, the first line should be<ASCII-MAC>on macOS or<ASCII-WIN>on Windows. The body should containbefore <0x2013> afterfor the en-dash andbefore <0x2014> afterfor the em-dash and the double-hyphen.<ASCII-MAC>regardless of your OS. Repeat with Windows and confirm<ASCII-WIN>.Available post types
Other information: