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

Fix function line breaks #446

Merged
merged 27 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fb89f86
fix: Fix function line breaks - __(
kryswoj Aug 4, 2023
1ff53f8
fix: Fix function line breaks - trigger_error
kryswoj Aug 4, 2023
4e076e1
Merge branch 'major' into feature/CU-862k7r4f2
kryswoj Aug 7, 2023
aa0bd4e
Merge branch 'major' into feature/CU-862k7r4f2
kryswoj Aug 9, 2023
1bb33d6
refactor: line breaks for __(
kryswoj Aug 9, 2023
6dc90cc
refactor: line breaks for setDescription(
kryswoj Aug 9, 2023
04c5ce3
refactor: line breaks for Register::recipient(
kryswoj Aug 9, 2023
042ffb8
refactor: line breaks for do_action(
kryswoj Aug 9, 2023
059c6d3
refactor: line breaks for add_action(
kryswoj Aug 9, 2023
a5da286
refactor: line breaks for apply_filters(
kryswoj Aug 9, 2023
2459956
refactor: line breaks for sprintf(
kryswoj Aug 9, 2023
2638550
refactor: line breaks for addComponent(
kryswoj Aug 9, 2023
97d1ff9
refactor: line breaks for get_post_meta(
kryswoj Aug 9, 2023
13b0633
refactor: line breaks for method_exists(
kryswoj Aug 9, 2023
9e23f6c
refactor: line breaks for wp_list_pluck(
kryswoj Aug 9, 2023
50f8aae
refactor: line breaks for in_array(
kryswoj Aug 9, 2023
97cc5c5
refactor: line breaks for implode and explode
kryswoj Aug 9, 2023
38fdbda
refactor: line breaks for ifs
kryswoj Aug 14, 2023
58551c5
refactor: line breaks for addGroup and addSection
kryswoj Aug 14, 2023
9f26da8
refactor: sprintf trigger returns for some Comment mergetags
kryswoj Aug 14, 2023
a9845d2
refactor: mostly linebreaks + few sprintfs
kryswoj Aug 14, 2023
8380156
refactor: phpcbf
kryswoj Aug 14, 2023
15a491d
refactor: linebreaks for setFieldData
kryswoj Aug 14, 2023
e562601
refactor: linebreaks for NotificationAdaptFrom + some minors
kryswoj Aug 14, 2023
a352689
refactor: fields concatenation into sprintf
kryswoj Aug 14, 2023
eeab05e
refactor: final clean up
kryswoj Aug 14, 2023
49a9d85
fix: phpstan
kryswoj Aug 14, 2023
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
25 changes: 8 additions & 17 deletions src/Abstracts/Carrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,14 @@ public function addFormField(Interfaces\Fillable $field)
{

if (
in_array(
$field->getRawName(),
$this->restrictedFields,
true
)
in_array($field->getRawName(), $this->restrictedFields, true)
kryswoj marked this conversation as resolved.
Show resolved Hide resolved
) {
throw new \Exception(
'You cannot use restricted field name. Restricted names: ' . implode(
', ',
$this->restrictedFields
sprintf(
'%s %s, %s',
'You cannot use restricted field name.',
'Restricted names:',
implode(', ', $this->restrictedFields)
)
);
}
Expand Down Expand Up @@ -435,10 +433,7 @@ protected function resolveValue($value, Triggerable $trigger)
return $resolved;
}

$value = apply_filters(
'notification/carrier/field/resolving',
$value
);
$value = apply_filters('notification/carrier/field/resolving', $value);

$resolved = Resolver::resolve(
$value,
Expand Down Expand Up @@ -476,11 +471,7 @@ protected function resolveValue($value, Triggerable $trigger)
$resolved
);

return apply_filters(
'notification/carrier/field/value/resolved',
$resolved,
null
);
return apply_filters('notification/carrier/field/value/resolved', $resolved, null);
}

/**
Expand Down
11 changes: 2 additions & 9 deletions src/Abstracts/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ public function __construct($params = [])
{

if (!isset($params['label'], $params['name'])) {
trigger_error(
'Field requires label and name',
E_USER_ERROR
);
trigger_error('Field requires label and name', E_USER_ERROR);
}

$this->fieldTypeHtml = substr(
Expand Down Expand Up @@ -204,11 +201,7 @@ public function getValue()
$value = is_string($this->value)
? stripslashes($this->value)
: $this->value;
return apply_filters(
'notification/field/' . $this->getRawName() . '/value',
$value,
$this
);
return apply_filters('notification/field/' . $this->getRawName() . '/value', $value, $this);
}

/**
Expand Down
20 changes: 4 additions & 16 deletions src/Abstracts/MergeTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@ public function __construct($params = [])
{

if (!isset($params['slug'], $params['name'], $params['resolver'])) {
trigger_error(
'Merge tag requires resolver',
E_USER_ERROR
);
trigger_error('Merge tag requires resolver', E_USER_ERROR);
}

if (!empty($params['slug'])) {
Expand Down Expand Up @@ -166,20 +163,14 @@ public function resolve()
);
} catch (\Throwable $t) {
$value = null;
trigger_error(
esc_html($t->getMessage()),
E_USER_NOTICE
);
trigger_error(esc_html($t->getMessage()), E_USER_NOTICE);
}

if (!empty($value) && !$this->validate($value)) {
$errorType = (defined('WP_DEBUG') && WP_DEBUG)
? E_USER_ERROR
: E_USER_NOTICE;
trigger_error(
'Resolved value is a wrong type',
$errorType
);
trigger_error('Resolved value is a wrong type', $errorType);
}

$this->resolved = true;
Expand Down Expand Up @@ -251,10 +242,7 @@ public function setResolver($resolver)
{

if (!is_callable($resolver)) {
trigger_error(
'Merge tag resolver has to be callable',
E_USER_ERROR
);
trigger_error('Merge tag resolver has to be callable', E_USER_ERROR);
}

$this->resolver = $resolver;
Expand Down
5 changes: 1 addition & 4 deletions src/Abstracts/Recipient.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ public function __construct($params = [])
}

if (!isset($params['default_value'])) {
trigger_error(
'Recipient requires default_value',
E_USER_ERROR
);
trigger_error('Recipient requires default_value', E_USER_ERROR);
}

$this->defaultValue = $params['default_value'];
Expand Down
15 changes: 3 additions & 12 deletions src/Abstracts/Trigger.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ public function setupMergeTags()

$this->mergeTagsAdded = true;

do_action(
'notification/trigger/merge_tags',
$this
);
do_action('notification/trigger/merge_tags', $this);
}

/**
Expand Down Expand Up @@ -141,10 +138,7 @@ public function clearMergeTags()
public function addAction($tag, $priority = 10, $acceptedArgs = 1)
{
if (empty($tag)) {
trigger_error(
'Action tag cannot be empty',
E_USER_ERROR
);
trigger_error('Action tag cannot be empty', E_USER_ERROR);
}

array_push(
Expand All @@ -169,10 +163,7 @@ public function removeAction($tag, $priority = 10, $deprecated = null)
{

if (empty($tag)) {
trigger_error(
'Action tag cannot be empty',
E_USER_ERROR
);
trigger_error('Action tag cannot be empty', E_USER_ERROR);
}

foreach ($this->actions as $actionIndex => $action) {
Expand Down
96 changes: 27 additions & 69 deletions src/Admin/Debugging.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,51 +28,33 @@ public function debuggingSettings($settings)
{

$debugging = $settings->addSection(
__(
'Debugging',
'notification'
),
__('Debugging', 'notification'),
'debugging'
);

$debugging->addGroup(
__(
'Settings',
'notification'
),
__('Settings', 'notification'),
'settings'
)
->addField(
[
'name' => __(
'Notification log',
'notification'
),
'name' => __('Notification log', 'notification'),
'slug' => 'debug_log',
'default' => false,
'addons' => [
'label' => __(
'Enable Notification logging',
'notification'
),
'label' => __('Enable Notification logging', 'notification'),
],
'render' => [new CoreFields\Checkbox(), 'input'],
'sanitize' => [new CoreFields\Checkbox(), 'sanitize'],
]
)
->addField(
[
'name' => __(
'Suppress Notifications',
'notification'
),
'name' => __('Suppress Notifications', 'notification'),
'slug' => 'debug_suppressing',
'default' => 'true',
'addons' => [
'label' => __(
'Suppress Notifications while logging is active',
'notification'
),
'label' => __('Suppress Notifications while logging is active', 'notification'),
],
'description' => __(
'While suppressing is active, no notifications are sent',
Expand All @@ -84,46 +66,37 @@ public function debuggingSettings($settings)
)
->addField(
[
'name' => __(
'Error log',
'notification'
),
'name' => __('Error log', 'notification'),
'slug' => 'error_log',
'default' => false,
'addons' => [
'label' => __(
'Enable error logging',
'notification'
),
'label' => __('Enable error logging', 'notification'),
],
'render' => [new CoreFields\Checkbox(), 'input'],
'sanitize' => [new CoreFields\Checkbox(), 'sanitize'],
]
)
->addField(
[
'name' => __(
'Clear',
'notification'
),
'name' => __('Clear', 'notification'),
'slug' => 'clear',
'default' => false,
'addons' => [
'message' => '
<a href="' . admin_url(
'admin-post.php?action=notification_clear_logs&log_type=notification&nonce=' .
wp_create_nonce(
'notification_clear_log_notification'
)
wp_create_nonce(
'notification_clear_log_notification'
)
kryswoj marked this conversation as resolved.
Show resolved Hide resolved
) . '" class="button button-secondary">' . esc_html__('Clear Notification logs') .
'</a>
'</a>
<a href="' . admin_url(
'admin-post.php?action=notification_clear_logs&log_type=error&nonce=' .
wp_create_nonce(
'notification_clear_log_error'
)
) . '" class="button button-secondary">' . esc_html__('Clear Error logs') .
'</a>
'admin-post.php?action=notification_clear_logs&log_type=error&nonce=' .
wp_create_nonce(
'notification_clear_log_error'
)
) . '" class="button button-secondary">' . esc_html__('Clear Error logs') .
kryswoj marked this conversation as resolved.
Show resolved Hide resolved
'</a>
',
],
'render' => [new CoreFields\Message(), 'input'],
Expand All @@ -132,37 +105,25 @@ public function debuggingSettings($settings)
);

$debugging->addGroup(
__(
'Notification Log',
'notification'
),
__('Notification Log', 'notification'),
'notification_log'
)
->addField(
[
'name' => __(
'Log',
'notification'
),
'name' => __('Log', 'notification'),
'slug' => 'log',
'render' => [new SpecificFields\NotificationLog(), 'input'],
'sanitize' => '__return_null',
]
);

$debugging->addGroup(
__(
'Error Log',
'notification'
),
__('Error Log', 'notification'),
'error_log'
)
->addField(
[
'name' => __(
'Log',
'notification'
),
'name' => __('Log', 'notification'),
'slug' => 'log',
'render' => [new SpecificFields\ErrorLog(), 'input'],
'sanitize' => '__return_null',
Expand All @@ -181,9 +142,9 @@ public function debuggingSettings($settings)
public function debugWarning()
{
if (
get_post_type() !== 'notification' || !notificationGetSetting(
'debugging/settings/debug_log'
) || !notificationGetSetting('debugging/settings/debug_suppressing')
get_post_type() !== 'notification' ||
!notificationGetSetting('debugging/settings/debug_log') ||
!notificationGetSetting('debugging/settings/debug_suppressing')
) {
return;
}
Expand All @@ -194,10 +155,7 @@ public function debugWarning()
);
$debugLogLink = '<a href="' . admin_url(
'edit.php?post_type=notification&page=settings&section=debugging'
) . '">' . esc_html__(
'See debug log',
'notification'
) . '</a>';
) . '">' . esc_html__('See debug log', 'notification') . '</a>';
kryswoj marked this conversation as resolved.
Show resolved Hide resolved

echo wp_kses_post('<div class="notice notice-warning"><p>' . $message . ' ' . $debugLogLink . '</p></div>');
}
Expand Down
Loading
Loading