notCorrectMenuTitle()) {
return $this->errorNotCorrectMenuTitle($this->notCorrectMenuTitle());
}
if ($this->notCorrectMenuPosition()) {
return $this->errorNotCorrectMenuPosition($this->notCorrectMenuPosition());
}
if (!$this->pagesFound()) {
return $this->errorNoPagesFound($this->pagesFound());
}
if ($this->duplicatedFieldNames()) {
return $this->errorDuplicatedFieldNames($this->duplicatedFieldNames());
}
if ($this->duplicatedOptionNames()) {
return $this->errorDuplicatedOptionNames($this->duplicatedOptionNames());
}
if ($this->notCorrectFieldNames()) {
return $this->errorNotCorrectFieldNames($this->notCorrectFieldNames());
}
}
public static function succes($message = '', $delay = false)
{
printf(
'
',
self::$noticeId,
self::$noticeSuccesClass,
$delay === true ? self::$delayClass : '',
self::$noticeMessageClass,
htmlspecialchars($message)
);
wp_add_inline_script(
'aop-app-js',
'var aopNotice=document.getElementById("aop-notice");setTimeout(function(){aopNotice.classList.add("aop-notice--remove")},3e3),setTimeout(function(){aopNotice.outerHTML=""},5e3);',
'after'
);
}
public function errorDuplicatedFieldNames(array $names = [])
{
$names = Collection::make($names);
if ($names->isEmpty()) {
return;
}
printf('', self::$noticeError, self::$dismissible, self::$style);
$names->map(function ($v, $key) {
printf('
Field name %s is already in use on this page.
', $key);
});
print('
');
}
public function errorDuplicatedOptionNames(array $names = [])
{
$names = Collection::make($names);
if ($names->isEmpty()) {
return;
}
printf('', self::$noticeError, self::$dismissible, self::$style);
$names->map(function ($name) {
printf('
Field name %s is already in use as option name.
', $name);
});
print('
');
}
public function errorNotCorrectFieldNames(array $names = [])
{
$names = Collection::make($names);
if ($names->isEmpty()) {
return;
}
printf('', self::$noticeError, self::$dismissible, self::$style);
$names->map(function ($name) {
if ($name) {
printf('
Field name %s is not allowed. Only letters, numbers and underscores are valid caracters.
', htmlspecialchars($name));
print('
Use underscores instead of white spaces.
');
} else {
print('
Field name is not allowed to be empty.
');
}
});
print('
');
}
public function errorNotCorrectMenuPosition($notCorrectNumber)
{
if ($notCorrectNumber === 'no request' || !$notCorrectNumber) {
return;
}
printf('', self::$noticeError, self::$dismissible, self::$style);
if ($notCorrectNumber === 'empty') {
print('
Position can not be empty.');
}
if ($notCorrectNumber !== 'empty') {
printf('
Position has not a correct number. Your input: %s
', $notCorrectNumber);
}
print('
');
}
public function errorNotCorrectMenuTitle($notCorrectTitle)
{
if ($notCorrectTitle === 'no request' || !$notCorrectTitle) {
return;
}
printf('', self::$noticeError, self::$dismissible, self::$style);
if ($notCorrectTitle === 'empty') {
print('
Menutitle can not be empty.');
}
if ($notCorrectTitle !== 'empty') {
// $notCorrectTitle = preg_replace('/\\\/', '', $notCorrectTitle);
printf('
Menutitle has some not valid characters: %s
', $notCorrectTitle);
}
print('
');
}
public function errorNoPagesFound($boolean)
{
if (!$boolean) {
return;
}
printf('There are no pages found.
', self::$noticeError, self::$dismissible, self::$style);
}
}