Skip to content

Add date/time format overrides and query offset#73

Merged
gin0115 merged 5 commits into
trunkfrom
feature/the-pocket-features
May 18, 2026
Merged

Add date/time format overrides and query offset#73
gin0115 merged 5 commits into
trunkfrom
feature/the-pocket-features

Conversation

@tommusrhodus
Copy link
Copy Markdown
Contributor

@tommusrhodus tommusrhodus commented May 15, 2026

Bump plugin to 2.1.1 and add optional date/time format overrides and an offset control for query loops. Expose dateFormat and timeFormat block attributes with editor controls (including live preview and site-default placeholders), thread those values through block rendering (SE_Blocks) into se_event_get_* functions, and apply them in SE_Date_Display_Formatter via new set_date_format/set_time_format methods. Also add an Offset RangeControl to the query-loop-events variation so editors can skip a number of events. Tests and formatting use site defaults when overrides are empty.

Changes proposed in this Pull Request

  • Version bump to 2.1.1
  • Added "offset" option to the event query block variation
  • Added date formatting to the event loop metadata block

Summary by CodeRabbit

  • Chores

    • Version bumped to 2.1.1; added local e2e npm script to start wp-env and run Playwright.
  • New Features

    • Loop Event Info: optional date/time format overrides with live preview and selectable wrapper element.
    • Query Loop: new offset control to skip a configurable number of events.
  • Bug Fixes

    • Editor/front-end parity for Query Loop ordering restored.
    • Removed redundant query cache-buster.
  • Tests

    • Added Playwright end-to-end tests, seeds/fixtures, and environment/config improvements.
  • Documentation

    • Changelog entry added for 2.1.1.

Review Change Stack

Bump plugin to 2.1.1 and add optional date/time format overrides and an offset control for query loops. Expose dateFormat and timeFormat block attributes with editor controls (including live preview and site-default placeholders), thread those values through block rendering (SE_Blocks) into se_event_get_* functions, and apply them in SE_Date_Display_Formatter via new set_date_format/set_time_format methods. Also add an Offset RangeControl to the query-loop-events variation so editors can skip a number of events. Tests and formatting use site defaults when overrides are empty.
@tommusrhodus tommusrhodus requested a review from gin0115 May 15, 2026 11:04
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e424a0c8-528b-4d67-bd12-9e29dfe8b040

📥 Commits

Reviewing files that changed from the base of the PR and between 1b0e20b and 50dda7d.

📒 Files selected for processing (1)
  • src/classes/class-se-block-variations.php

Walkthrough

This release bumps package and plugin versions to 2.1.1, adds optional dateFormat and timeFormat overrides (formatter setters, new parameters on event date helpers, block.json attributes, server render plumbing, and editor inspector inputs with preview), allows selecting the block wrapper tag via tagName, removes the query cache-buster and adds an Offset RangeControl to the query-loop-events variation, and introduces Playwright E2E seeds, specs, and config that auto-discovers WP_BASE_URL.

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add date/time format overrides and query offset' accurately summarizes the main changes: it adds dateFormat/timeFormat attributes to the loop-event-info block and an offset control to query-loop-events, along with supporting infrastructure throughout the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/classes/class-date-display-formatter.php`:
- Around line 193-206: The setters set_date_format and set_time_format currently
store raw user-provided strings which can include HTML/JS and later be rendered;
update both methods (set_date_format and set_time_format) to sanitize the
incoming $format before assigning to $this->date_format and $this->time_format
(e.g., use a WordPress-safe sanitizer like sanitize_text_field() or
wp_strip_all_tags() to strip tags/unsafe characters and optionally validate
against a whitelist/regex of allowed date format characters), so only cleaned
format strings are stored and later rendered.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 67c38ef6-67f1-44cc-ab47-3ccdde2828c1

📥 Commits

Reviewing files that changed from the base of the PR and between bc66c00 and 41981c2.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (8)
  • package.json
  • plugin.php
  • src/blocks/loop-event-info/block.json
  • src/blocks/loop-event-info/index.js
  • src/classes/class-date-display-formatter.php
  • src/classes/class-se-blocks.php
  • src/event-functions.php
  • src/variations/query-loop-events/block.js

Comment on lines +193 to +206
public function set_date_format( string $format ): void {
$this->date_format = $format;
}

/**
* Override the time format used by format_time(). Empty string restores the site default.
*
* @param string $format A PHP date format string.
*
* @return void
*/
public function set_time_format( string $format ): void {
$this->time_format = $format;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Sanitize format overrides before storing to prevent HTML injection in rendered date output.

Line 193 and Line 204 accept raw strings that later flow into frontend-rendered date/time text. A format like <script>... is treated as literal output by date formatting and can be rendered unescaped.

Suggested fix
 public function set_date_format( string $format ): void {
-	$this->date_format = $format;
+	$this->date_format = trim( wp_strip_all_tags( $format ) );
 }
@@
 public function set_time_format( string $format ): void {
-	$this->time_format = $format;
+	$this->time_format = trim( wp_strip_all_tags( $format ) );
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/classes/class-date-display-formatter.php` around lines 193 - 206, The
setters set_date_format and set_time_format currently store raw user-provided
strings which can include HTML/JS and later be rendered; update both methods
(set_date_format and set_time_format) to sanitize the incoming $format before
assigning to $this->date_format and $this->time_format (e.g., use a
WordPress-safe sanitizer like sanitize_text_field() or wp_strip_all_tags() to
strip tags/unsafe characters and optionally validate against a whitelist/regex
of allowed date format characters), so only cleaned format strings are stored
and later rendered.

tommusrhodus and others added 3 commits May 15, 2026 12:54
Introduce a new tagName attribute for the loop-event-info block (enum: div, p, h1-h6; default: div). Add a SelectControl in the block editor to choose the HTML element and pass tagName through block attributes. Update server-side rendering to validate against allowed tags and use the selected tag as the wrapper (instead of always using a div), preserving existing wrapper attributes and classes. This enables better semantic markup control for the block.
@gin0115
Copy link
Copy Markdown
Collaborator

gin0115 commented May 18, 2026

Ive added some additional changes here

I remove the cache busting as this was causing "unsaved changes" issues at times when no changes had been made. In doing this, i patched an issue with the editor in how well it handles date and order changes

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
tests/e2e/specs/editor/query-loop-parity.spec.js (1)

2-3: ⚡ Quick win

Use execFileSync with argument array instead of shell-string execSync.

Replace the shell command string with execFileSync and an arguments array to eliminate shell parsing and reduce command-injection risk.

Affected location: lines 25-28

const out = execFileSync(
	'npx',
	['wp-env', 'run', 'cli', '--env-cwd=wp-content/plugins/simple-events', '--', 'wp', 'eval-file', 'tests/e2e/fixtures/seed-parity.php'],
	{ encoding: 'utf8' }
);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/specs/editor/query-loop-parity.spec.js` around lines 2 - 3, The
test uses child_process.execSync with a shell command string which is unsafe;
replace the use of execSync (and the variable/assignment that captures its
output, e.g., the const out = execSync(...)) with child_process.execFileSync and
pass the command as the executable 'npx' plus an explicit arguments array
(['wp-env','run','cli','--env-cwd=wp-content/plugins/simple-events','--','wp','eval-file','tests/e2e/fixtures/seed-parity.php'])
and preserve the encoding option ({ encoding: 'utf8' }) so the output is
identical but avoids shell parsing and injection risks.
tests/e2e/playwright.config.js (1)

2-3: ⚡ Quick win

Use argv-based process execution instead of shell-string execSync.

This pattern is shell-parsed and avoids shell parsing hazards. Prefer execFileSync('npx', [...]) for more explicit and safer command execution.

Safer invocation pattern
-const { execSync } = require( 'child_process' );
+const { execFileSync } = require( 'child_process' );
...
-		const url = execSync(
-			"npx wp-env run cli --env-cwd='wp-content/plugins/simple-events' -- wp option get home",
-			{ cwd: path.join( __dirname, '../..' ), stdio: [ 'ignore', 'pipe', 'ignore' ] }
-		)
+		const url = execFileSync(
+			'npx',
+			[
+				'wp-env',
+				'run',
+				'cli',
+				'--env-cwd=wp-content/plugins/simple-events',
+				'--',
+				'wp',
+				'option',
+				'get',
+				'home',
+			],
+			{ cwd: path.join( __dirname, '../..' ), stdio: [ 'ignore', 'pipe', 'ignore' ] }
+		)
 			.toString()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/playwright.config.js` around lines 2 - 3, The code currently
requires execSync from child_process and uses shell-string execution; replace
use of execSync with execFileSync to avoid shell parsing hazards: import/require
execFileSync from 'child_process' instead of execSync, and change any
execSync('npx ...') calls to execFileSync('npx', ['<cmd>', '<arg1>', ...], {
stdio: 'inherit' }) (or appropriate args), preserving any environment/options;
update references in this file from execSync to execFileSync and ensure
arguments are passed as an argv array rather than a single shell string.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/classes/class-se-block-variations.php`:
- Around line 127-141: The set_admin_query method currently forces
args['post_type'] to SE_Event_Post_Type::$event_date_post_type for every
rest_se-event_query request; restrict this by first checking the incoming
$request to ensure it targets the Query Loop "events" variation (e.g. check a
variation/blockName/queryLoop-specific request param such as 'variation' or
'blockName' used in your codebase), and only then set args['post_type'] and call
set_event_query_args; otherwise leave $args untouched and return them so
non-Query-Loop REST consumers aren’t affected.

In `@tests/e2e/fixtures/seed-parity.php`:
- Around line 21-39: The seed fixture currently calls get_posts(...) and
wp_delete_post(...) to permanently delete posts (se-event, se-event-date, and
pages matching $prefix) without any environment guard; add a protective check at
the top of this block (e.g., require WP_ENV/test-only, WP_LOCAL_DEV, or an env
var like getenv('WP_ENV') === 'test' or === 'local') and bail out (throw or
return) if the process is not running in a permitted ephemeral environment so
the destructive delete loops (the get_posts + wp_delete_post calls) only run in
safe contexts.

---

Nitpick comments:
In `@tests/e2e/playwright.config.js`:
- Around line 2-3: The code currently requires execSync from child_process and
uses shell-string execution; replace use of execSync with execFileSync to avoid
shell parsing hazards: import/require execFileSync from 'child_process' instead
of execSync, and change any execSync('npx ...') calls to execFileSync('npx',
['<cmd>', '<arg1>', ...], { stdio: 'inherit' }) (or appropriate args),
preserving any environment/options; update references in this file from execSync
to execFileSync and ensure arguments are passed as an argv array rather than a
single shell string.

In `@tests/e2e/specs/editor/query-loop-parity.spec.js`:
- Around line 2-3: The test uses child_process.execSync with a shell command
string which is unsafe; replace the use of execSync (and the variable/assignment
that captures its output, e.g., the const out = execSync(...)) with
child_process.execFileSync and pass the command as the executable 'npx' plus an
explicit arguments array
(['wp-env','run','cli','--env-cwd=wp-content/plugins/simple-events','--','wp','eval-file','tests/e2e/fixtures/seed-parity.php'])
and preserve the encoding option ({ encoding: 'utf8' }) so the output is
identical but avoids shell parsing and injection risks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e5a26b67-f3aa-4653-9827-877c27f7e3cd

📥 Commits

Reviewing files that changed from the base of the PR and between 957d8a1 and 1b0e20b.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (13)
  • .github/workflows/e2e-tests.yml
  • .gitignore
  • README.md
  • package.json
  • src/classes/class-se-block-variations.php
  • src/variations/query-loop-events/block.js
  • tests/e2e/.env.example
  • tests/e2e/fixtures/seed-loop.php
  • tests/e2e/fixtures/seed-parity.php
  • tests/e2e/global-setup.js
  • tests/e2e/playwright.config.js
  • tests/e2e/specs/editor/query-loop-parity.spec.js
  • tests/e2e/specs/frontend/loop-event-info.spec.js
💤 Files with no reviewable changes (1)
  • .github/workflows/e2e-tests.yml
✅ Files skipped from review due to trivial changes (4)
  • .gitignore
  • README.md
  • tests/e2e/fixtures/seed-loop.php
  • tests/e2e/.env.example
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

Comment thread src/classes/class-se-block-variations.php
Comment thread tests/e2e/fixtures/seed-parity.php
Copy link
Copy Markdown
Collaborator

@gin0115 gin0115 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made a few other changes and added tests

@gin0115 gin0115 merged commit 12bb8e8 into trunk May 18, 2026
8 checks passed
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.

2 participants