Skip to content

Rock gated content#3088

Draft
truongwp wants to merge 50 commits intomasterfrom
rock-gated-content
Draft

Rock gated content#3088
truongwp wants to merge 50 commits intomasterfrom
rock-gated-content

Conversation

@truongwp
Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7f077c09-8d79-4e5f-b1ac-abb3108b1b62

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rock-gated-content

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@deepsource-io
Copy link
Copy Markdown

deepsource-io Bot commented Apr 27, 2026

DeepSource Code Review

We reviewed changes in 1d27050...6cd6c74 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

Important

Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
PHP May 11, 2026 7:46a.m. Review ↗
JavaScript May 11, 2026 7:46a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Comment thread js/src/admin/admin.js
*/
function frmGcFilterFileFields( formSelect ) {
const typeDiv = formSelect.closest( '.frm-gc-type-settings' );
const fieldSelect = typeDiv && typeDiv.querySelector( '[data-frm-gc-field="id"]' );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Prefer using an optional chain expression instead, as it's more concise and easier to read


The optional chaining operator can be used to perform null checks before accessing a property, or calling a function.

Comment thread js/src/admin/admin.js Outdated

// If the currently selected field option is now hidden, reset the select.
const selected = fieldSelect.options[ fieldSelect.selectedIndex ];
if ( selected && selected.hidden ) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Prefer using an optional chain expression instead, as it's more concise and easier to read


The optional chaining operator can be used to perform null checks before accessing a property, or calling a function.

Comment thread js/src/admin/admin.js
const copyBtn = event.target.closest( '.frm_gc_copy_shortcode' );
if ( copyBtn ) {
const text = copyBtn.dataset.frmCopy;
if ( navigator.clipboard && navigator.clipboard.writeText ) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Prefer using an optional chain expression instead, as it's more concise and easier to read


The optional chaining operator can be used to perform null checks before accessing a property, or calling a function.

* @param array $atts Shortcode attributes.
* @return string Shortcode output, or empty string when no token is available.
*/
public static function shortcode( $atts ) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

`shortcode` has a cyclomatic complexity of 19 with "High" risk


A function with high cyclomatic complexity can be hard to understand and
maintain. Cyclomatic complexity is a software metric that measures the number of
independent paths through a function. A higher cyclomatic complexity indicates
that the function has more decision points and is more complex.

* @param string $type Item type slug.
* @param string $raw_token Raw access token.
*/
$base_url = (string) apply_filters( 'frm_gated_content_item_url', '', (int) $item_id, $type, $raw_token );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Function apply_filters invoked with 5 parameters, 2 required


The function call is not valid, which will result in a fatal runtime error.

Comment thread classes/helpers/FrmGatedTokenHelper.php Outdated
* @param int $item_id Content item ID being checked.
* @param string $item_type Content item type being checked.
*/
return (bool) apply_filters( 'frm_gated_content_validate', $is_valid, $row, $item_id, $item_type );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Function apply_filters invoked with 5 parameters, 2 required


The function call is not valid, which will result in a fatal runtime error.

Comment thread classes/helpers/FrmGatedTokenHelper.php Outdated
}

/** This filter is documented in classes/helpers/FrmGatedTokenHelper.php */
return (bool) apply_filters( 'frm_gated_content_validate', $is_valid, $row, $item_id, $item_type );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Function apply_filters invoked with 5 parameters, 2 required


The function call is not valid, which will result in a fatal runtime error.

Comment thread classes/helpers/FrmGatedTokenHelper.php Outdated
FrmFormActionsController::trigger_actions( 'payment-success', $form_id, $entry_id );

$raw_token = FrmGatedTokenHelper::get_raw_token_for_action( $action_id );
$this->assertNotNull(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmGatedContentController::assertNotNull()


The method you are trying to call is not defined, which can result in a fatal error.

$raw_token,
'payment-success event must trigger token generation for a gated content action.'
);
$this->assertSame( 48, strlen( $raw_token ) );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmGatedContentController::assertSame()


The method you are trying to call is not defined, which can result in a fatal error.

* @covers FrmGatedContentController::trigger
*/
public function test_payment_success_event_skips_non_matching_action() {
$form_id = $this->factory->form->create();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Access to an undefined property test_FrmGatedContentController::$factory


The property you are trying to access is not defined and will cause unexpected behavior when used.

*/
public function test_payment_success_event_skips_non_matching_action() {
$form_id = $this->factory->form->create();
$entry_id = $this->factory->entry->create( array( 'form_id' => $form_id ) );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Access to an undefined property test_FrmGatedContentController::$factory


The property you are trying to access is not defined and will cause unexpected behavior when used.


FrmFormActionsController::trigger_actions( 'payment-success', $form_id, $entry_id );

$this->assertNull(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmGatedContentController::assertNull()


The method you are trying to call is not defined, which can result in a fatal error.

* @param array $atts Shortcode attributes.
* @return string Shortcode output, or empty string when no token is available.
*/
public static function shortcode( $atts ) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

`shortcode` has a cyclomatic complexity of 19 with "High" risk


A function with high cyclomatic complexity can be hard to understand and
maintain. Cyclomatic complexity is a software metric that measures the number of
independent paths through a function. A higher cyclomatic complexity indicates
that the function has more decision points and is more complex.

* @param string $type Item type slug.
* @param string $raw_token Raw access token.
*/
$base_url = (string) apply_filters( 'frm_gated_content_item_url', '', $item_id, $type, $raw_token );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Function apply_filters invoked with 5 parameters, 2 required


The function call is not valid, which will result in a fatal runtime error.

Comment thread classes/helpers/FrmGatedTokenHelper.php Outdated
* @param int $item_id Content item ID being checked.
* @param string $item_type Content item type being checked.
*/
return (bool) apply_filters( 'frm_gated_content_validate', $is_valid, $row, $item_id, $item_type );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Function apply_filters invoked with 5 parameters, 2 required


The function call is not valid, which will result in a fatal runtime error.

Comment thread classes/helpers/FrmGatedTokenHelper.php Outdated
}

/** This filter is documented in classes/helpers/FrmGatedTokenHelper.php */
return (bool) apply_filters( 'frm_gated_content_validate', $is_valid, $row, $item_id, $item_type );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Function apply_filters invoked with 5 parameters, 2 required


The function call is not valid, which will result in a fatal runtime error.

* from the token row); cookie and IP paths are skipped.
* @return string|null Token hash, or null if no valid token could be resolved.
*/
public static function obtain_token( $action_id = 0 ) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

`obtain_token` has a cyclomatic complexity of 17 with "High" risk


A function with high cyclomatic complexity can be hard to understand and
maintain. Cyclomatic complexity is a software metric that measures the number of
independent paths through a function. A higher cyclomatic complexity indicates
that the function has more decision points and is more complex.

FrmFormActionsController::trigger_actions( 'payment-success', $form_id, $entry_id );

$raw_token = FrmGatedTokenHelper::get_raw_token_for_action( $action_id );
$this->assertNotNull(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmGatedContentController::assertNotNull()


The method you are trying to call is not defined, which can result in a fatal error.

$raw_token,
'payment-success event must trigger token generation for a gated content action.'
);
$this->assertSame( 48, strlen( $raw_token ) );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmGatedContentController::assertSame()


The method you are trying to call is not defined, which can result in a fatal error.

* @covers FrmGatedContentController::trigger
*/
public function test_payment_success_event_skips_non_matching_action() {
$form_id = $this->factory->form->create();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Access to an undefined property test_FrmGatedContentController::$factory


The property you are trying to access is not defined and will cause unexpected behavior when used.

*/
public function test_payment_success_event_skips_non_matching_action() {
$form_id = $this->factory->form->create();
$entry_id = $this->factory->entry->create( array( 'form_id' => $form_id ) );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Access to an undefined property test_FrmGatedContentController::$factory


The property you are trying to access is not defined and will cause unexpected behavior when used.


FrmFormActionsController::trigger_actions( 'payment-success', $form_id, $entry_id );

$this->assertNull(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmGatedContentController::assertNull()


The method you are trying to call is not defined, which can result in a fatal error.

* from the token row); cookie path is skipped.
* @return string|null Token hash, or null if no valid token could be resolved.
*/
public static function obtain_token( $action_id = 0 ) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

`obtain_token` has a cyclomatic complexity of 16 with "High" risk


A function with high cyclomatic complexity can be hard to understand and
maintain. Cyclomatic complexity is a software metric that measures the number of
independent paths through a function. A higher cyclomatic complexity indicates
that the function has more decision points and is more complex.

FrmGatedTokenHelper::generate( $this->action_id, 1 );

$cached = FrmGatedTokenHelper::get_raw_token_for_action( $this->action_id );
$this->assertNotNull( $cached, 'Token transient not set after generate().' );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmGatedTokenHelper::assertNotNull()


The method you are trying to call is not defined, which can result in a fatal error.

* from the token row); cookie path is skipped.
* @return string|null Token hash, or null if no valid token could be resolved.
*/
public static function obtain_token( $action_id = 0 ) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

`obtain_token` has a cyclomatic complexity of 17 with "High" risk


A function with high cyclomatic complexity can be hard to understand and
maintain. Cyclomatic complexity is a software metric that measures the number of
independent paths through a function. A higher cyclomatic complexity indicates
that the function has more decision points and is more complex.

$is_valid = self::action_contains_item( $action, $item_id, $item_type );

/** This filter is documented in classes/helpers/FrmGatedTokenHelper.php */
return (bool) apply_filters( 'frm_gated_content_validate', $is_valid, compact( 'row', 'item_id', 'item_type' ) );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Function apply_filters invoked with 3 parameters, 2 required


The function call is not valid, which will result in a fatal runtime error.

}

$row = FrmGatedTokenHelper::get_row_by_token( $candidate );
if ( $row
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Method FrmGatedContentController::resolve_raw_token() should return string|null but return statement is missing


This issue is raised if a method with a return type does not have a return statement of an appropriate type.

* @type string $raw_token Raw access token.
* }
*/
$base_url = (string) apply_filters( 'frm_gated_content_item_url', $base_url, compact( 'item_id', 'type', 'raw_token' ) );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Function apply_filters invoked with 3 parameters, 2 required


The function call is not valid, which will result in a fatal runtime error.

* @type string $type Item type slug.
* }
*/
return (string) apply_filters( 'frm_gated_content_item_title', $title, compact( 'item_id', 'type' ) );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Function apply_filters invoked with 3 parameters, 2 required


The function call is not valid, which will result in a fatal runtime error.

Comment thread js/src/admin/admin.js

// Show/hide "Keep old token when entry is updated" when the event multi-select changes.
jQuery( document ).on( 'frm-multiselect-changed', 'select[id^="event_"]', function() {
const section = document.querySelector( '.frm_gc_update_section[data-frm-gc-event-id="' + this.id + '"]' );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unexpected string concatenation


In ES2015 (ES6), we can use template literals instead of string concatenation.

@truongwp truongwp added the deploy Deploy website on push label Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deploy Deploy website on push

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant