Skip to content

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-25 at 21 44 31

Screenshot 2025-04-25 at 21 44 47

@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 ☺️


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.

@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
@cbravobernal cbravobernal self-assigned this Apr 25, 2025
@cbravobernal cbravobernal marked this pull request as ready for review April 25, 2025 08:38
<p><?php esc_html_e( 'No beta features are currently available.', 'secure-custom-fields' ); ?></p>
</div>
<?php else : ?>
<form method="post" action="">
Copy link
Member

Choose a reason for hiding this comment

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

Action is missing here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can be more explicit, leaving it empty was using the current admin url page.

declare global {
interface Window {
acf: ACF;
acfExperiments?: ExperimentsData; // Variable created by wp_localize_script in admin-experiments.php L150.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I don't think exact line reference will age well. It could be also the case with the file name, so if you want to provide more context, you can list the PR instead.

@priethor priethor changed the title Experiments: Boilerplate to add future experiments to the project. Add initial experiment sample with no use case yet. Framework and admin screen to add new features as opt-in Apr 25, 2025
@cbravobernal cbravobernal marked this pull request as ready for review April 25, 2025 19:43
@cbravobernal
Copy link
Contributor Author

Made a huge refactor:

  • Removed al TS and JS involved.
  • Renamed everything to "Beta features"

@cbravobernal cbravobernal requested review from gziolo and priethor April 28, 2025 09:02
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.

Let's update the since versions before merging 😅

Not a blocker, but could we make more functions private and minimize the amount of public functions exposed as an API?

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.

Let's update the since versions before merging 😅

Not a blocker, but could we make more functions private and minimize the amount of public functions exposed as an API?

@cbravobernal cbravobernal requested a review from priethor April 29, 2025 15:59
@cbravobernal
Copy link
Contributor Author

cbravobernal commented Apr 29, 2025

Not a blocker, but could we make more functions private and minimize the amount of public functions exposed as an API?

I made everything as private as possible. But the approach of each experiment having its custom class, extending the main one, needs to be public 🤔

Maybe we can move that approach to a different one, where every experiment is inside that class. That way we could avoid external devs from creating experiments. Less modular, but less extensible too.

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.

But the approach of each experiment having its custom class, extending the main one, needs to be public 🤔

Yep, and the same goes with the hooks. I was just surprised by the amount of "Since version X" I found 😅

This is good to merge and start using, in my opinion. While these beta features are not meant for extenders of the plugin, I still think it would be good to have a short readme to explain SCF contributors how to add new beta features. Not a blocker, though!

@cbravobernal
Copy link
Contributor Author

cbravobernal commented Apr 30, 2025

While these beta features are not meant for extenders of the plugin, I still think it would be good to have a short readme to explain SCF contributors how to add new beta features. Not a blocker, though!

I prefer to start with a couple of experiments to test and iterate and then, when we are 100% sure, add the readme. 😅

Thee easiest and fastest way to check for an experiment to exist is just to check the option, so we may save some functions.

@cbravobernal cbravobernal merged commit 99303b4 into trunk Apr 30, 2025
5 checks passed
@cbravobernal cbravobernal deleted the add/new-experiments-menu branch April 30, 2025 08:25
@priethor priethor added this to the 6.5.0 milestone May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants