Skip to content

Commit

Permalink
JS and Css admin otims (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
iruzevic authored Nov 26, 2024
1 parent 792be2a commit 113824b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/).

## [5.4.1]

### Updated

- Admin JS and CSS scripts are now loaded only on the forms page.

## [5.4.0]

### Updated
Expand Down Expand Up @@ -780,6 +786,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a

- Initial production release.

[5.4.1]: https://github.com/infinum/eightshift-forms/compare/5.4.0...5.4.1
[5.4.0]: https://github.com/infinum/eightshift-forms/compare/5.3.2...5.4.0
[5.3.2]: https://github.com/infinum/eightshift-forms/compare/5.3.1...5.3.2
[5.3.1]: https://github.com/infinum/eightshift-forms/compare/5.3.0...5.3.1
Expand Down
2 changes: 1 addition & 1 deletion eightshift-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Description: Eightshift Forms is a complete form builder plugin that utilizes modern Block editor features with multiple third-party integrations, bringing your project to a new level.
* Author: WordPress team @Infinum
* Author URI: https://eightshift.com/
* Version: 5.4.0
* Version: 5.4.1
* Text Domain: eightshift-forms
*
* @package EightshiftForms
Expand Down
26 changes: 14 additions & 12 deletions src/Enqueue/Admin/EnqueueAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class EnqueueAdmin extends AbstractEnqueueAdmin
*/
public function register(): void
{
if (!UtilsGeneralHelper::isEightshiftFormsAdminPages()) {
return;
}

\add_action('admin_enqueue_scripts', [$this, 'enqueueStyles'], 50);
\add_action('admin_enqueue_scripts', [$this, 'enqueueScripts']);
}
Expand Down Expand Up @@ -73,18 +77,16 @@ public function enqueueScripts(string $hook): void

$output = [];

if (UtilsGeneralHelper::isEightshiftFormsAdminPages()) {
$output = \array_merge(
$this->getEnqueueSharedInlineCommonItems(false),
[
'nonce' => \wp_create_nonce('wp_rest'),
'uploadConfirmMsg' => \__('Are you sure you want to contine?', 'eighshift-forms'),
'importErrorMsg' => \__('There is an error with your data, please try again.', 'eighshift-forms'),
'isAdmin' => true,
'redirectionTimeout' => 100,
],
);
}
$output = \array_merge(
$this->getEnqueueSharedInlineCommonItems(false),
[
'nonce' => \wp_create_nonce('wp_rest'),
'uploadConfirmMsg' => \__('Are you sure you want to contine?', 'eighshift-forms'),
'importErrorMsg' => \__('There is an error with your data, please try again.', 'eighshift-forms'),
'isAdmin' => true,
'redirectionTimeout' => 100,
],
);

$output = \wp_json_encode($output);
\wp_add_inline_script($this->getAdminScriptHandle(), "const esFormsLocalization = {$output}", 'before');
Expand Down

0 comments on commit 113824b

Please sign in to comment.