From c55cfebac26291707cb0600d6ab2ec836bbd6e32 Mon Sep 17 00:00:00 2001 From: Anderson Martins Date: Wed, 23 Oct 2024 15:41:50 -0300 Subject: [PATCH] Fix some code style issues --- legacy/deprecated-functions.php | 2 + .../Controllers/BlockEditorController.php | 15 ++++++-- .../Controllers/BulkEditController.php | 37 +++++++++++++------ .../ScheduledActionsController.php | 10 ++++- .../Migrations/V30104ArgsColumnLength.php | 5 ++- .../Tables/ScheduledActionsTable.php | 10 +++-- 6 files changed, 59 insertions(+), 20 deletions(-) diff --git a/legacy/deprecated-functions.php b/legacy/deprecated-functions.php index 9aedce85d..00a0122d6 100644 --- a/legacy/deprecated-functions.php +++ b/legacy/deprecated-functions.php @@ -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); diff --git a/src/Modules/Expirator/Controllers/BlockEditorController.php b/src/Modules/Expirator/Controllers/BlockEditorController.php index 3c4869be2..c4fd579b6 100644 --- a/src/Modules/Expirator/Controllers/BlockEditorController.php +++ b/src/Modules/Expirator/Controllers/BlockEditorController.php @@ -148,14 +148,20 @@ 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. @@ -163,7 +169,10 @@ public function enqueueBlockEditorAssets() // 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'), diff --git a/src/Modules/Expirator/Controllers/BulkEditController.php b/src/Modules/Expirator/Controllers/BulkEditController.php index 7dec920c8..575d2e47d 100644 --- a/src/Modules/Expirator/Controllers/BulkEditController.php +++ b/src/Modules/Expirator/Controllers/BulkEditController.php @@ -182,7 +182,10 @@ 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. @@ -190,7 +193,10 @@ public function enqueueScripts() 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) diff --git a/src/Modules/Expirator/Controllers/ScheduledActionsController.php b/src/Modules/Expirator/Controllers/ScheduledActionsController.php index bce46c479..6429dd6f8 100644 --- a/src/Modules/Expirator/Controllers/ScheduledActionsController.php +++ b/src/Modules/Expirator/Controllers/ScheduledActionsController.php @@ -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 .= '
'; $screenSettings .= '' . esc_html__('Log format', 'post-expirator') . ''; $screenSettings .= '