Skip to content

Decouple the localised script data from PDF_TEMPLATE_LOCATION - #1701

Open
jakejackson1 wants to merge 1 commit into
developmentfrom
feat/decouple-pdf-template-location
Open

Decouple the localised script data from PDF_TEMPLATE_LOCATION#1701
jakejackson1 wants to merge 1 commit into
developmentfrom
feat/decouple-pdf-template-location

Conversation

@jakejackson1

Copy link
Copy Markdown
Member

Phase 1 of the 7.0 deprecated code removal plan — non-breaking, ships in 6.17.

Helper_Data::get_localised_script_data() sourced pdfWorkingDir from the v3 PDF_TEMPLATE_LOCATION constant, which is defined inside src/deprecated.php. That made a file slated for deletion in 7.0 load-bearing for the React Template Manager: pdfWorkingDir is what TemplateFooterActions::notCoreTemplate() compares each template path against to decide whether the delete button renders.

The constant is defined as Helper_Templates::get_template_path(), so the helper is now passed into get_localised_script_data() and called directly. The value is byte-identical on both single and multisite, and is no longer frozen at after_setup_theme.

GFPDF_Core::setup_constants() still defines all four v3 constants for third parties — those go in Phase 2 alongside the rest of src/deprecated.php.

Notes

  • get_localised_script_data() gains a third required parameter. The only caller is Router::load_admin_assets(); add-ons extend this data through the documented gfpdf_localised_script_array filter, not by calling the method.
  • PDF_TEMPLATE_LOCATION now has no remaining consumer in src/.

Testing

  • Test_Helper_Data::test_localised_script now asserts pdfWorkingDir resolves to the working directory (multisite-aware) rather than only checking the key exists.
  • Full integration suite green (1569 tests); multisite Test_Helper_Data green.
  • TemplateFooterActions Jest suite green — the JS contract is unchanged.

🤖 Generated with Claude Code

`Helper_Data::get_localised_script_data()` sourced `pdfWorkingDir` from the
v3 `PDF_TEMPLATE_LOCATION` constant, which is defined inside
`src/deprecated.php`. That made a file slated for deletion in 7.0
load-bearing for the React Template Manager: `pdfWorkingDir` is what
`TemplateFooterActions::notCoreTemplate()` compares each template path
against to decide whether the delete button renders.

The constant is defined as `Helper_Templates::get_template_path()`, so pass
that helper in and call it directly. Value is identical on both single and
multisite; as a bonus it is no longer frozen at `after_setup_theme`.

Phase 1 of the 7.0 deprecated code removal plan.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant