Skip to content

Conversation

@aristath
Copy link
Member

Context

Summary

This PR can be summarized in the following changelog entry:

Relevant technical choices:

Test instructions

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Block/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Documentation

  • I have written documentation for this change.

Quality assurance

  • I have tested this code to the best of my abilities.
  • I have added unit tests to verify the code works as intended.
  • I have checked that the base branch is correctly set.

Fixes #

@aristath aristath requested a review from Copilot January 20, 2026 11:01
@github-actions
Copy link
Contributor

github-actions bot commented Jan 20, 2026

Test merged PR on Playground
Test this pull request on the Playground
or download the zip

@github-actions
Copy link
Contributor

github-actions bot commented Jan 20, 2026

✅ Code Coverage Report

Metric Value
Total Coverage 31.61% 📉
Base Coverage 31.60%
Difference 📈 0.01%

⚠️ Coverage below recommended 40% threshold

🎉 Great job maintaining/improving code coverage!

📊 File-level Coverage Changes (1 files)

📈 Coverage Improved

Class Before After Change
Progress_Planner\Admin\Editor 3.85% 4.76% +0.91%
ℹ️ About this report
  • All tests run in a single job with Xdebug coverage
  • Security tests excluded from coverage to prevent output issues
  • Coverage calculated from line coverage percentages

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enables the Progress Planner editor sidebar to work in the WordPress site editor by removing a PHP-level bailout and adding JavaScript-level detection to hide the sidebar only when editing templates (wp_template/wp_template_part). The changes include extensive defensive programming improvements to handle edge cases with null values, NaN results, and array operations.

Changes:

  • Removed PHP server-side check that prevented script loading in site-editor.php
  • Added JavaScript client-side detection to hide sidebar when editing templates (not posts/pages)
  • Implemented defensive null/undefined checks and NaN handling throughout the codebase
  • Added backwards compatibility layer for openGeneralSidebar API across WordPress versions
  • Fixed array handling to prevent empty string elements and avoid mutation of original data

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
classes/admin/class-editor.php Removed bailout condition that prevented editor script from loading on site-editor.php page
assets/js/editor.js Updated dependency from wp-edit-post to wp-editor, added template detection logic to conditionally render sidebar, extensive defensive programming improvements for null safety and array handling, added API compatibility layer for WordPress 6.6+
Comments suppressed due to low confidence (1)

assets/js/editor.js:68

  • Similar to the issue with 'progressPlannerEditor.defaultPageType', this code accesses 'progressPlannerEditor.pageTypes' without verifying that 'progressPlannerEditor' exists. Add a check for 'typeof progressPlannerEditor !== "undefined"' at the beginning of the function to prevent potential ReferenceErrors.
	// Bail early if the page types are not set.
	if (
		! progressPlannerEditor.pageTypes ||
		0 === progressPlannerEditor.pageTypes.length
	) {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

aristath and others added 2 commits January 20, 2026 13:29
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (2)

assets/js/editor.js:86

  • The early return check for progressPlannerEditor.pageTypes on lines 81-86 happens after the useSelect hook on lines 72-78. According to the Rules of Hooks, all hooks must be called in the same order on every render. This early return should be moved before the useSelect call, or the check should be done differently to avoid conditional hook execution.
	// Bail early if the page types are not set.
	if (
		! progressPlannerEditor.pageTypes ||
		0 === progressPlannerEditor.pageTypes.length
	) {
		return el( 'div', {}, '' );
	}

assets/js/editor.js:228

  • The early return check on lines 222-228 happens after two useSelect hooks on lines 207 and 214. According to the Rules of Hooks, all hooks must be called in the same order on every render. Early returns that happen after hooks can cause issues. The conditional check should be moved after all hook calls, or the check should be done inside the hook callbacks to maintain proper hook execution order.
	// Bail early if the page type or lessons are not set.
	// Check if progressPlannerEditor exists before accessing its properties.
	if (
		! pageType ||
		typeof progressPlannerEditor === 'undefined' ||
		! progressPlannerEditor.lessons ||
		0 === progressPlannerEditor.lessons.length
	) {
		return el( 'div', {}, '' );

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@aristath aristath marked this pull request as ready for review January 21, 2026 09:35
@aristath aristath requested a review from ilicfilip January 21, 2026 09:35
@aristath aristath merged commit e861de1 into develop Jan 21, 2026
20 of 21 checks passed
@aristath aristath deleted the ari/site-editor-sidebar branch January 21, 2026 11:42
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.

3 participants