Skip to content

Commit

Permalink
removing unecesery migration
Browse files Browse the repository at this point in the history
  • Loading branch information
iruzevic committed Dec 21, 2023
1 parent fe3e0e2 commit b77d806
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 102 deletions.
2 changes: 1 addition & 1 deletion eightshift-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Description: Eightshift Forms is a complete form builder plugin that utilizes modern Block editor features with multiple third-party integrations, bringing your project to a new level.
* Author: WordPress team @Infinum
* Author URI: https://eightshift.com/
* Version: 4.0.117
* Version: 4.0.118
* Text Domain: eightshift-forms
*
* @package EightshiftForms
Expand Down
1 change: 0 additions & 1 deletion src/Hooks/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ class Filters
'twoToThreeGeneral',
'twoToThreeForms',
'twoToThreeLocale',
'twoToThreeLabels',
],
];

Expand Down
25 changes: 0 additions & 25 deletions src/Migration/SettingsMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ class SettingsMigration implements SettingGlobalInterface, ServiceInterface
*/
public const VERSION_2_3_LOCALE = '2-3-locale';

/**
* Version 2-3 labels key.
*/
public const VERSION_2_3_LABELS = '2-3-labels';

/**
* Register all the hooks
*
Expand Down Expand Up @@ -171,26 +166,6 @@ public function getSettingsGlobalData(): array
],
],
],
[
'component' => 'divider',
'dividerExtraVSpacing' => true,
],
[
'component' => 'card-inline',
'cardInlineTitle' => \__('Version 2 → Version 3 - labels', 'eightshift-forms'),
'cardInlineSubTitle' => \__('Small changes to field labels.', 'eightshift-forms'),
'cardInlineRightContent' => [
[
'component' => 'submit',
'submitValue' => \__('Migrate', 'eightshift-forms'),
'submitVariant' => 'ghost',
'submitAttrs' => [
Helper::getStateAttribute('migrationType') => self::VERSION_2_3_LABELS,
],
'additionalClass' => Helper::getStateSelectorAdmin('migration'),
],
],
],
],
],
[
Expand Down
64 changes: 0 additions & 64 deletions src/Rest/Routes/Settings/MigrationRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ public function routeCallback(WP_REST_Request $request)
return $this->getMigration2To3Forms();
case SettingsMigration::VERSION_2_3_LOCALE:
return $this->getMigration2To3Locale();
case SettingsMigration::VERSION_2_3_LABELS:
return $this->getMigration2To3Labels();
default:
return $this->getApiErrorOutput(
\__('Migration version type key was not provided or not valid.', 'eightshift-forms'),
Expand Down Expand Up @@ -519,66 +517,4 @@ private function getMigration2To3Locale(): array
$output
);
}

/**
* Migration version 2-3 labels.
*
* @return array<string, mixed>
*/
private function getMigration2To3Labels(): array
{
$output = [];

$theQuery = new WP_Query([
'post_type' => Forms::POST_TYPE_SLUG,
'no_found_rows' => true,
'update_post_term_cache' => false,
'post_status' => 'any',
'nopaging' => true,
'posts_per_page' => 5000, // phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page
]);

// Fields to update.
$fields = [
'inputInputFieldHideLabel',
'textareaTextareaFieldHideLabel',
'countryCountryFieldHideLabel',
'dateDateFieldHideLabel',
'phonePhoneFieldHideLabel',
'selectSelectFieldHideLabel',
];

$forms = $theQuery->posts;
\wp_reset_postdata();

if ($forms) {
foreach ($forms as $form) {
$formId = (int) $form->ID;
$content = $form->post_content; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps

if (!$formId || !$content) {
continue;
}

foreach ($fields as $field) {
$content = \str_replace("\"{$field}\":true", "\"{$field}\":false", $content);
}

$output[] = \wp_update_post([
'ID' => $formId,
'post_content' => $content,
]);
}
}

$actionName = Filters::getFilterName(['migration', 'twoToThreeLabels']);
if (\has_action($actionName)) {
\do_action($actionName, SettingsMigration::VERSION_2_3_LABELS);
}

return $this->getApiSuccessOutput(
\__('Migration version 2 to 3 labels finished with success.', 'eightshift-forms'),
$output
);
}
}
11 changes: 0 additions & 11 deletions testFilters/testFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ public function register(): void
// Validation actions.
'es_forms_migration_two_to_three_general' => ['runMigration2To3General'],
'es_forms_migration_two_to_three_forms' => ['runMigration2To3Forms'],
'es_forms_migration_two_to_three_labels' => ['runMigration2To3Labels'],
'es_forms_migration_two_to_three_locale' => ['runMigration2To3Locale'],
// ---------------------------------------------------------------------------------------------------------
];
Expand Down Expand Up @@ -914,14 +913,4 @@ public function runMigration2To3Locale(): void
{
error_log(print_r(('Action hook activated 2-3 locale'), true)); // phpcs:ignore
}

/**
* Run custom action after migration from verson 2 to 3 - labels.
*
* @return void
*/
public function runMigration2To3Labels(): void
{
error_log(print_r(('Action hook activated 2-3 labels'), true)); // phpcs:ignore
}
}

0 comments on commit b77d806

Please sign in to comment.