Skip to content
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

54309 Script Loading issue for onoffice-captchacontrol.min.js when form is placed in the footer #963

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions plugin/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,18 @@ public function getFormId()
}


/**
*
* @return string
*
*/

public function getFormType()
{
return esc_html($this->getDataFormConfiguration()->getFormType());
}


/**
*
* @return bool
Expand Down
23 changes: 23 additions & 0 deletions plugin/ScriptLoader/IncludeFileModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class IncludeFileModel
/** @var string */
private $_loadAsynchronous = '';

/** @var bool */
private $_loadBeforeRenderingTemplate = false;

/**
*
Expand Down Expand Up @@ -175,4 +177,25 @@ public function setLoadAsynchronous(string $loadAsynchronous): self
$this->_loadAsynchronous = $loadAsynchronous;
return $this;
}

/**
* @return bool
*/
public function getLoadBeforeRenderingTemplate(): bool
{
return $this->_loadBeforeRenderingTemplate;
}

/**
*
* @param bool $loadBeforeRenderingTemplate
* @return $this
*
*/

public function setLoadBeforeRenderingTemplate(bool $loadBeforeRenderingTemplate): self
{
$this->_loadBeforeRenderingTemplate = $loadBeforeRenderingTemplate;
return $this;
}
}
12 changes: 8 additions & 4 deletions plugin/ScriptLoader/ScriptLoaderGeneric.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@ public function enqueue()
{
/* @var $pIncludeModel IncludeFileModel */
foreach ($this->getModelByType(IncludeFileModel::TYPE_SCRIPT) as $pIncludeModel) {
wp_enqueue_script($pIncludeModel->getIdentifier());
wp_script_add_data($pIncludeModel->getIdentifier(), $pIncludeModel->getLoadAsynchronous(), true);
if ($pIncludeModel->getLoadBeforeRenderingTemplate()){
wp_enqueue_script($pIncludeModel->getIdentifier());
}
}
foreach ($this->getModelByType(IncludeFileModel::TYPE_STYLE) as $pIncludeModel) {
wp_enqueue_style($pIncludeModel->getIdentifier());
if ($pIncludeModel->getLoadBeforeRenderingTemplate()){
wp_enqueue_style($pIncludeModel->getIdentifier());
}
}
}

Expand All @@ -78,7 +81,8 @@ public function register()
/* @var $pIncludeModel IncludeFileModel */
foreach ($this->getModelByType(IncludeFileModel::TYPE_SCRIPT) as $pIncludeModel) {
wp_register_script($pIncludeModel->getIdentifier(), $pIncludeModel->getFilePath(),
$pIncludeModel->getDependencies(), false, $pIncludeModel->getLoadInFooter());
$pIncludeModel->getDependencies(), false, array('strategy' => $pIncludeModel->getLoadAsynchronous(), 'in_footer' => $pIncludeModel->getLoadInFooter()));
$this->_pConfiguration->localizeScript($pIncludeModel->getIdentifier());
}
foreach ($this->getModelByType(IncludeFileModel::TYPE_STYLE) as $pIncludeModel) {
wp_register_style($pIncludeModel->getIdentifier(), $pIncludeModel->getFilePath(),
Expand Down
7 changes: 7 additions & 0 deletions plugin/ScriptLoader/ScriptLoaderGenericConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@ interface ScriptLoaderGenericConfiguration
*/

public function getScriptLoaderGenericConfiguration(): array;

/**
* @param string $scriptIdentifier
* @return void
*/

public function localizeScript(string $scriptIdentifier);
}
Loading
Loading