Skip to content

Commit

Permalink
Fix some code style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
andergmartins committed Oct 23, 2024
1 parent c55ddb3 commit c55cfeb
Showing 6 changed files with 59 additions and 20 deletions.
2 changes: 2 additions & 0 deletions legacy/deprecated-functions.php
Original file line number Diff line number Diff line change
@@ -119,6 +119,7 @@ function expirationdate_get_blog_url()
*/
function postexpirator_schedule_event($postId, $timestamp, $opts)
{
// phpcs:ignore Generic.Files.LineLength.TooLong
_deprecated_function(__FUNCTION__, '2.8.0', 'Use the PublishPress\Future\Modules\Expirator\HooksAbstract::ACTION_SCHEDULE_POST_EXPIRATION hook instead');

do_action(ExpiratorHooks::ACTION_SCHEDULE_POST_EXPIRATION, $postId, $timestamp, $opts);
@@ -136,6 +137,7 @@ function postexpirator_schedule_event($postId, $timestamp, $opts)
*/
function postexpirator_unschedule_event($postId)
{
// phpcs:ignore Generic.Files.LineLength.TooLong
_deprecated_function(__FUNCTION__, '2.8.0', 'Use the PublishPress\Future\Modules\Expirator\HooksAbstract::ACTION_UNSCHEDULE_POST_EXPIRATION hook instead');

do_action(ExpiratorHooks::ACTION_UNSCHEDULE_POST_EXPIRATION, $postId);
15 changes: 12 additions & 3 deletions src/Modules/Expirator/Controllers/BlockEditorController.php
Original file line number Diff line number Diff line change
@@ -148,22 +148,31 @@ public function enqueueBlockEditorAssets()
'showCalendar' => __('Show Calendar', 'post-expirator'),
'hideCalendar' => __('Hide Calendar', 'post-expirator'),
// translators: the text between {} is the link to the settings page.
'timezoneSettingsHelp' => __('Timezone is controlled by the {WordPress Settings}.', 'post-expirator'),
'timezoneSettingsHelp' => __(
'Timezone is controlled by the {WordPress Settings}.',
'post-expirator'
),
// translators: %s is the name of the taxonomy in plural form.
'noTermsFound' => sprintf(
// translators: %s is the name of the taxonomy in plural form.
__('No %s found.', 'post-expirator'),
strtolower($taxonomyPluralName)
),
'noTaxonomyFound' => __('You must assign a taxonomy to this post type to use this feature.', 'post-expirator'),
'noTaxonomyFound' => __(
'You must assign a taxonomy to this post type to use this feature.',
'post-expirator'
),
// translators: %s is the name of the taxonomy in plural form.
'newTerms' => __('New %s', 'post-expirator'),
// translators: %s is the name of the taxonomy in plural form.
'removeTerms' => __('%s to remove', 'post-expirator'),
// translators: %s is the name of the taxonomy in plural form.
'addTerms' => __('%s to add', 'post-expirator'),
// translators: %s is the name of the taxonomy in singular form.
'addTermsPlaceholder' => sprintf(__('Search for %s', 'post-expirator'), strtolower($taxonomyPluralName)),
'addTermsPlaceholder' => sprintf(
__('Search for %s', 'post-expirator'),
strtolower($taxonomyPluralName)
),
'errorActionRequired' => __('Select an action', 'post-expirator'),
'errorDateRequired' => __('Select a date', 'post-expirator'),
'errorDateInPast' => __('Date cannot be in the past', 'post-expirator'),
37 changes: 26 additions & 11 deletions src/Modules/Expirator/Controllers/BulkEditController.php
Original file line number Diff line number Diff line change
@@ -182,15 +182,21 @@ public function enqueueScripts()
'hideCalendar' => __('Hide Calendar', 'post-expirator'),
'loading' => __('Loading', 'post-expirator'),
// translators: the text between {{}} is the link to the settings page.
'timezoneSettingsHelp' => __('Timezone is controlled by the {WordPress Settings}.', 'post-expirator'),
'timezoneSettingsHelp' => __(
'Timezone is controlled by the {WordPress Settings}.',
'post-expirator'
),
// translators: %s is the name of the taxonomy in plural form.
'noTermsFound' => sprintf(
// translators: %s is the name of the taxonomy in plural form.
__('No %s found.', 'post-expirator'),
strtolower($taxonomyPluralName)
),
'futureActionUpdate' => __('Future Action Update', 'post-expirator'),
'noTaxonomyFound' => __('You must assign a taxonomy to this post type to use this feature.', 'post-expirator'),
'noTaxonomyFound' => __(
'You must assign a taxonomy to this post type to use this feature.',
'post-expirator'
),
'noChange' => __('— No Change —', 'post-expirator'),
'changeAdd' => __('Add or update action for posts', 'post-expirator'),
'addOnly' => __('Add action if none exists for posts', 'post-expirator'),
@@ -203,7 +209,10 @@ public function enqueueScripts()
// translators: %s is the name of the taxonomy in plural form.
'addTerms' => __('%s to add', 'post-expirator'),
// translators: %s is the name of the taxonomy in singular form.
'addTermsPlaceholder' => sprintf(__('Search for %s', 'post-expirator'), strtolower($taxonomyPluralName)),
'addTermsPlaceholder' => sprintf(
__('Search for %s', 'post-expirator'),
strtolower($taxonomyPluralName)
),
'errorActionRequired' => __('Select an action', 'post-expirator'),
'errorDateRequired' => __('Select a date', 'post-expirator'),
'errorDateInPast' => __('Date cannot be in the past', 'post-expirator'),
@@ -278,14 +287,17 @@ public function processBulkEditUpdate()
$this->request->checkAdminReferer('bulk-posts');

$this->saveBulkEditData();
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
// phpcs:enable
}

private function updateScheduleForPostFromBulkEditData(ExpirablePostModel $postModel)
{
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$expireType = isset($_REQUEST['future_action_bulk_action']) ? $this->sanitization->sanitizeTextField($_REQUEST['future_action_bulk_action']) : '';
$newStatus = isset($_REQUEST['future_action_bulk_new_status']) ? $this->sanitization->sanitizeTextField($_REQUEST['future_action_bulk_new_status']) : 'draft';
// phpcs:disable WordPress.Security.NonceVerification.Recommended
// phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$expireType = isset($_REQUEST['future_action_bulk_action']) ?
$this->sanitization->sanitizeTextField($_REQUEST['future_action_bulk_action']) : '';
$newStatus = isset($_REQUEST['future_action_bulk_new_status']) ?
$this->sanitization->sanitizeTextField($_REQUEST['future_action_bulk_new_status']) : 'draft';

if ($expireType === ExpirationActionsAbstract::POST_STATUS_TO_DRAFT) {
$expireType = ExpirationActionsAbstract::CHANGE_POST_STATUS;
@@ -305,8 +317,10 @@ private function updateScheduleForPostFromBulkEditData(ExpirablePostModel $postM
$opts = [
'expireType' => $expireType,
'newStatus' => $newStatus,
'category' => isset($_REQUEST['future_action_bulk_terms']) ? $this->sanitization->sanitizeTextField($_REQUEST['future_action_bulk_terms']) : '',
'categoryTaxonomy' => isset($_REQUEST['future_action_bulk_taxonomy']) ? $this->sanitization->sanitizeTextField($_REQUEST['future_action_bulk_taxonomy']) : '',
'category' => isset($_REQUEST['future_action_bulk_terms']) ?
$this->sanitization->sanitizeTextField($_REQUEST['future_action_bulk_terms']) : '',
'categoryTaxonomy' => isset($_REQUEST['future_action_bulk_taxonomy']) ?
$this->sanitization->sanitizeTextField($_REQUEST['future_action_bulk_taxonomy']) : '',
];

if (! empty($opts['category'])) {
@@ -324,7 +338,8 @@ private function updateScheduleForPostFromBulkEditData(ExpirablePostModel $postM
$opts['category'] = [];
}

$date = isset($_REQUEST['future_action_bulk_date']) ? sanitize_text_field($_REQUEST['future_action_bulk_date']) : '0';
$date = isset($_REQUEST['future_action_bulk_date']) ?
sanitize_text_field($_REQUEST['future_action_bulk_date']) : '0';
$date = strtotime($date);

$this->hooks->doAction(
@@ -333,7 +348,7 @@ private function updateScheduleForPostFromBulkEditData(ExpirablePostModel $postM
$date,
$opts
);
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
// phpcs:enable
}

private function changeStrategyChangeOnly(ExpirablePostModel $postModel)
10 changes: 8 additions & 2 deletions src/Modules/Expirator/Controllers/ScheduledActionsController.php
Original file line number Diff line number Diff line change
@@ -185,11 +185,17 @@ public function filterScreenSettings($screenSettings, $screen)
}

// Add nonce field
$screenSettings .= wp_nonce_field('publishpressfuture_actions_log_format', 'publishpressfuture_actions_log_format_nonce', true, false);
$screenSettings .= wp_nonce_field(
'publishpressfuture_actions_log_format',
'publishpressfuture_actions_log_format_nonce',
true,
false
);

$screenSettings .= '<fieldset class="metabox-prefs">';
$screenSettings .= '<legend>' . esc_html__('Log format', 'post-expirator') . '</legend>';
$screenSettings .= '<label for="' . $screen->id . '_log_format_list">';
// phpcs:ignore Generic.Files.LineLength.TooLong
$screenSettings .= '<input type="radio" id="' . $screen->id . '_log_format_list" name="publishpressfuture_actions_log_format" value="list" ' . checked(
$userLogFormat,
'list',
@@ -199,6 +205,7 @@ public function filterScreenSettings($screenSettings, $screen)
$screenSettings .= '</label>';
$screenSettings .= '&nbsp;';
$screenSettings .= '<label for="' . $screen->id . '_log_format_popup">';
// phpcs:ignore Generic.Files.LineLength.TooLong
$screenSettings .= '<input type="radio" id="' . $screen->id . '_log_format_popup" name="publishpressfuture_actions_log_format" value="popup" ' . checked(
$userLogFormat,
'popup',
@@ -267,7 +274,6 @@ public function filterActionSchedulerAdminNotice($html, $action, $notification)
$args = $action->get_args();

if (isset($args['postId']) && isset($args['workflow']) && 'expire' === $args['workflow']) {

$transientName = 'post-expirator-notice-' . (int) $args['postId'];
$noticeMessage = get_transient($transientName);
delete_transient($transientName);
5 changes: 4 additions & 1 deletion src/Modules/Expirator/Migrations/V30104ArgsColumnLength.php
Original file line number Diff line number Diff line change
@@ -59,7 +59,10 @@ public function migrate()
public function formatLogActionColumn($text, $row)
{
if ($row['hook'] === self::HOOK) {
return __('Change args column length to 1000 in the table _ppfuture_actions_args after v3.1.4', 'publishpress-future');
return __(
'Change args column length to 1000 in the table _ppfuture_actions_args after v3.1.4',
'publishpress-future'
);
}

return $text;
10 changes: 7 additions & 3 deletions src/Modules/Expirator/Tables/ScheduledActionsTable.php
Original file line number Diff line number Diff line change
@@ -25,7 +25,9 @@ class ScheduledActionsTable extends \ActionScheduler_ListTable
private $hooks;

/**
* Array of seconds for common time periods, like week or month, alongside an internationalised string representation, i.e. "Day" or "Days"
* Array of seconds for common time periods, like week or month,
* alongside an internationalised string representation, i.e.
* "Day" or "Days".
*
* @var array
*/
@@ -327,11 +329,13 @@ public function column_action(array $row)
public function column_status(array $row)
{
$icons = [
\ActionScheduler_Store::STATUS_COMPLETE => 'dashicons dashicons-yes-alt action-scheduler-status-icon-complete',
\ActionScheduler_Store::STATUS_COMPLETE =>
'dashicons dashicons-yes-alt action-scheduler-status-icon-complete',
\ActionScheduler_Store::STATUS_PENDING => 'dashicons dashicons-clock action-scheduler-status-icon-pending',
\ActionScheduler_Store::STATUS_RUNNING => 'dashicons dashicons-update action-scheduler-status-icon-running',
\ActionScheduler_Store::STATUS_FAILED => 'dashicons dashicons-warning action-scheduler-status-icon-failed',
\ActionScheduler_Store::STATUS_CANCELED => 'dashicons dashicons-marker action-scheduler-status-icon-canceled',
\ActionScheduler_Store::STATUS_CANCELED =>
'dashicons dashicons-marker action-scheduler-status-icon-canceled',
];

$iconClass = 'dashicons dashicons-editor-help';

0 comments on commit c55cfeb

Please sign in to comment.