Skip to content

Experiments: Boilerplate to add future experiments to the project. Add initial experiment sample with no use case yet. #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 12 commits into
base: trunk
Choose a base branch
from

Conversation

cbravobernal
Copy link
Contributor

@cbravobernal cbravobernal commented Apr 22, 2025

This PRs sets a standard for creating experiments and checking if they are enabled in JavaScript.

As there are no experiments ready yet, I commented all the code that initializes them with a // Temporarily disabled comment.

The PR was getting big, so it is better to land this first and work later on next experiments.

If you want to test this out, just uncomment the lines // Temporarily disabled in admin-experiments.php file and you will have something like this:

Screenshot 2025-04-23 at 12 32 34

Screenshot 2025-04-23 at 12 34 14

Extra stuff:

  • Added TS compatibility.
  • Enabled Prettier config using @wordpress/prettier-config.

@cbravobernal cbravobernal changed the title Experiment: Add a new experiment to use editor sidebar for field filling. Experiments: Boilerplate to add future experiments to the project. Add initial experiment sample with no use case yet. Apr 23, 2025
@cbravobernal cbravobernal force-pushed the add/new-experiments-menu branch from 75511d7 to b4a9587 Compare April 23, 2025 10:41
Copy link
Contributor

@priethor priethor left a comment

Choose a reason for hiding this comment

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

Thanks, Carlos, this is looking good! Since this is still a draft I didn't go too deep, but still left some early feedback ☺️

*/
public function __construct() {
// Temporarily disabled - will be enabled when experiments feature is ready
// add_action( 'admin_menu', array( $this, 'admin_menu' ), 20 );
Copy link
Contributor

Choose a reason for hiding this comment

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

We should check whether $this->experiments is empty to avoid adding the menu if there are no experiments, except for testing purposes.


To add a new experiment:

1. Create a new experiment class in `includes/admin/experiments/`
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a "good practices" recommendation or a requirement? What's the reason to create the experiments in this folder instead of creating them in the place they belong, and just registering?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally, this way it should be easier to find all experiments registered instead of having to dig into the entire codebase. Also, I'm trying to follow the PHP class based plugin structure, which may differ from how we did things in Gutenberg.

Is more a recommendation than a requirement, but this way all the admin interface will be automatically generated on PHP.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's remove the readme to prevent external devs to create more experiments.

*
* @package Secure Custom Fields
* @subpackage Admin
* @since 6.4.2
Copy link
Contributor

Choose a reason for hiding this comment

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

6.4.2 is out, shouldn't it be 6.5?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did this before the update 😅

export {};

// Initialize the SCF namespace if it doesn't exist
if (typeof window.SCF === 'undefined') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we reuse the existing acf namespace until we migrate it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. You are right. Otherwise it will be difficult to differentiate which is inside of each object.

@gziolo
Copy link
Member

gziolo commented Apr 23, 2025

It would be helpful to extract all changes related to code formatting to another PR and land separately, as it makes the review process more complex. What is the reason GitHub reports so massive changes in the lock file?

@cbravobernal
Copy link
Contributor Author

It would be helpful to extract all changes related to code formatting to another PR and land separately, as it makes the review process more complex.

Sure, done in #115

What is the reason GitHub reports so massive changes in the lock file?

It seems it was due to the update of wp-scripts and all its dependencies. I will take a look at it.

@cbravobernal cbravobernal force-pushed the add/new-experiments-menu branch 2 times, most recently from 2acfc24 to 609f95d Compare April 24, 2025 16:47
@cbravobernal cbravobernal force-pushed the add/new-experiments-menu branch from 609f95d to 8636385 Compare April 24, 2025 18:31
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