Skip to content

Commit

Permalink
Fix appearance of Ninja Forms editor with "Turn Off When Logged In" s…
Browse files Browse the repository at this point in the history
…etting.
  • Loading branch information
kagg-design committed Aug 24, 2024
1 parent d3323a8 commit 6c7a88c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
17 changes: 17 additions & 0 deletions .tests/php/unit/Helpers/PagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,23 @@ public function test_is_formidable_edit_page(): void {
self::assertTrue( Pages::is_formidable_forms_edit_page() );
}

/**
* Test is_is_ninja_edit_page().
*
* @return void
*/
public function test_is_ninja_edit_page(): void {
$this->mock_filter_input();

self::assertFalse( Pages::is_ninja_edit_page() );

$_GET['form_id'] = 'some';
$_SERVER['REQUEST_URI'] = '/wp-admin/admin.php';
$_GET['page'] = 'ninja-forms';

self::assertTrue( Pages::is_ninja_edit_page() );
}

/**
* Test is_wpforms_edit_page().
*
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ Instructions for popular native integrations are below:
* Fixed appearance of Fluent Forms editor with "Turn Off When Logged In" setting.
* Fixed appearance of Forminator editor with "Turn Off When Logged In" setting.
* Fixed appearance of Formidable Forms with "Turn Off When Logged In" setting.
* Fixed appearance of Ninja Forms editor with "Turn Off When Logged In" setting.
* Fixed appearance of WPForms editor with "Turn Off When Logged In" setting.
* Fixed fatal error on Gravity Forms Entries page.
* Fixed Elementor preview.
Expand Down
23 changes: 21 additions & 2 deletions src/php/Helpers/Pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static function is_forminator_edit_page(): bool {
}

/**
* Check if the current page is a Formidable Forms form edit page.
* Check if the current page is a Formidable Forms form edit or settings page.
*
* @return bool
* @noinspection PhpUnused
Expand Down Expand Up @@ -161,7 +161,26 @@ public static function is_formidable_forms_edit_page(): bool {
}

/**
* Check if the current page is a CF7 form create, edit or view page.
* Check if the current page is a Ninja form create, edit or view page.
*
* @return bool
* @noinspection PhpUnused
*/
public static function is_ninja_edit_page(): bool {
$request_uri = Request::filter_input( INPUT_SERVER, 'REQUEST_URI' );
$page = Request::filter_input( INPUT_GET, 'page' );
$admin_request = 0 === strpos( $request_uri, '/wp-admin/admin.php' );

return (
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
isset( $_GET['form_id'] ) &&
$admin_request &&
'ninja-forms' === $page
);
}

/**
* Check if the current page is a WPForms form preview or settings page.
*
* @return bool
* @noinspection PhpUnused
Expand Down
1 change: 1 addition & 0 deletions src/php/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ private function is_edit_page(): bool {
'fluent',
'forminator',
'formidable_forms',
'ninja',
'wpforms',
];

Expand Down

0 comments on commit 6c7a88c

Please sign in to comment.