Commit realizado el 12:13:52 08-04-2024

This commit is contained in:
Pagina Web Monito
2024-04-08 12:13:55 -04:00
commit 0c33094de9
7815 changed files with 1365694 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
<?php
/**
* Class Add_Media_Source_Editor
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
use Google\Web_Stories\Media\Media_Source_Taxonomy;
/**
* Class Add_Media_Source
*/
abstract class Add_Media_Source extends Migrate_Base {
/**
* Media_Source_Taxonomy instance.
*
* @var Media_Source_Taxonomy Experiments instance.
*/
protected Media_Source_Taxonomy $media_source_taxonomy;
/**
* Add_Media_Source constructor.
*
* @since 1.12.0
*
* @param Media_Source_Taxonomy $media_source_taxonomy Media_Source_Taxonomy instance.
*/
public function __construct( Media_Source_Taxonomy $media_source_taxonomy ) {
$this->media_source_taxonomy = $media_source_taxonomy;
}
/**
* Add the editor term, to make sure it exists.
*
* @since 1.9.0
*/
public function migrate(): void {
wp_insert_term( $this->get_term(), $this->media_source_taxonomy->get_taxonomy_slug() );
}
/**
* Override this method.
*
* @since 1.9.0
*/
abstract protected function get_term(): string;
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* Class Add_Media_Source_Editor
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
/**
* Class Add_Media_Source_Editor
*/
class Add_Media_Source_Editor extends Add_Media_Source {
/**
* Term name.
*
* @since 1.9.0
*/
protected function get_term(): string {
return $this->media_source_taxonomy::TERM_EDITOR;
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* Class Add_Media_Source_Gif_Conversion
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
/**
* Class Add_Media_Source_Gif_Conversion
*/
class Add_Media_Source_Gif_Conversion extends Add_Media_Source {
/**
* Term name.
*
* @since 1.9.0
*/
protected function get_term(): string {
return $this->media_source_taxonomy::TERM_GIF_CONVERSION;
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* Class Add_Media_Source_Page_Template
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
/**
* Class Add_Media_Source_Page_Template
*/
class Add_Media_Source_Page_Template extends Add_Media_Source {
/**
* Term name.
*
* @since 1.14.0
*/
protected function get_term(): string {
return $this->media_source_taxonomy::TERM_PAGE_TEMPLATE;
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* Class Add_Media_Source_Recording
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2022 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
/**
* Class Add_Media_Source_Recording
*/
class Add_Media_Source_Recording extends Add_Media_Source {
/**
* Term name.
*
* @since 1.23.0
*/
protected function get_term(): string {
return $this->media_source_taxonomy::TERM_RECORDING;
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* Class Add_Media_Source_Source_Video
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
/**
* Class Add_Media_Source_Source_Video
*/
class Add_Media_Source_Source_Image extends Add_Media_Source {
/**
* Term name.
*
* @since 1.9.0
*/
protected function get_term(): string {
return $this->media_source_taxonomy::TERM_SOURCE_IMAGE;
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* Class Add_Media_Source_Source_Video
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
/**
* Class Add_Media_Source_Source_Video
*/
class Add_Media_Source_Source_Video extends Add_Media_Source {
/**
* Term name.
*
* @since 1.9.0
*/
protected function get_term(): string {
return $this->media_source_taxonomy::TERM_SOURCE_VIDEO;
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* Class Add_Media_Source_Video_Optimization
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
/**
* Class Add_Media_Source_Video_Optimization
*/
class Add_Media_Source_Video_Optimization extends Add_Media_Source {
/**
* Term name.
*
* @since 1.9.0
*/
protected function get_term(): string {
return $this->media_source_taxonomy::TERM_VIDEO_OPTIMIZATION;
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* Class Add_Poster_Generation_Media_Source
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
use Google\Web_Stories\Media\Video\Poster;
/**
* Class Add_Poster_Generation_Media_Source
*/
class Add_Poster_Generation_Media_Source extends Migration_Meta_To_Term {
/**
* Migration media post meta to taxonomy term.
*
* @since 1.7.0
*/
public function migrate(): void {
wp_insert_term( $this->get_term_name(), $this->media_source_taxonomy->get_taxonomy_slug() );
parent::migrate();
}
/**
* Get name of meta key to be used in migration.
*
* @since 1.7.2
*/
protected function get_post_meta_key(): string {
return Poster::POSTER_POST_META_KEY;
}
}

View File

@@ -0,0 +1,63 @@
<?php
/**
* Class Add_Stories_Caps
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
use Google\Web_Stories\User\Capabilities;
/**
* Class Add_Stories_Caps
*/
class Add_Stories_Caps extends Migrate_Base {
/**
* Capabilities instance.
*
* @var Capabilities Experiments instance.
*/
private Capabilities $capabilities;
/**
* Add_Stories_Caps constructor.
*
* @since 1.7.0
*
* @param Capabilities $capabilities Capabilities instance.
*/
public function __construct( Capabilities $capabilities ) {
$this->capabilities = $capabilities;
}
/**
* Adds story capabilities to default user roles.
*
* @since 1.7.0
*/
public function migrate(): void {
$this->capabilities->add_caps_to_roles();
}
}

View File

@@ -0,0 +1,45 @@
<?php
/**
* Class Add_VideoPress_Poster_Generation_Media_Source
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
use Google\Web_Stories\Integrations\Jetpack;
/**
* Class Add_VideoPress_Poster_Generation_Media_Source
*/
class Add_VideoPress_Poster_Generation_Media_Source extends Migration_Meta_To_Term {
/**
* Get name of meta key to be used in migration.
*
* @since 1.7.2
*/
protected function get_post_meta_key(): string {
return Jetpack::VIDEOPRESS_POSTER_META_KEY;
}
}

View File

@@ -0,0 +1,40 @@
<?php
/**
* Class Migrate_Base
*
* Base class for other classes to extend.
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
use Google\Web_Stories\Interfaces\Migration;
/**
* Class Migrate_Base
*/
abstract class Migrate_Base implements Migration {
}

View File

@@ -0,0 +1,102 @@
<?php
/**
* Class Migration_Meta_To_Term
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
use Google\Web_Stories\Media\Media_Source_Taxonomy;
/**
* Class Migration_Meta_To_Term
*/
abstract class Migration_Meta_To_Term extends Migrate_Base {
/**
* Media_Source_Taxonomy instance.
*
* @var Media_Source_Taxonomy Experiments instance.
*/
protected Media_Source_Taxonomy $media_source_taxonomy;
/**
* Migration_Meta_To_Term constructor.
*
* @since 1.12.0
*
* @param Media_Source_Taxonomy $media_source_taxonomy Media_Source_Taxonomy instance.
*/
public function __construct( Media_Source_Taxonomy $media_source_taxonomy ) {
$this->media_source_taxonomy = $media_source_taxonomy;
}
/**
* Migration media post meta to taxonomy term.
*
* @since 1.7.2
*
* @global \wpdb $wpdb WordPress database abstraction object.
*/
public function migrate(): void {
global $wpdb;
$post_ids = $wpdb->get_col( // phpcs:ignore WordPress.DB.DirectDatabaseQuery
$wpdb->prepare(
"SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s",
$this->get_post_meta_key()
)
);
if ( \is_array( $post_ids ) && ! empty( $post_ids ) ) {
/**
* Post ID.
*
* @var int|string $post_id
*/
foreach ( $post_ids as $post_id ) {
wp_set_object_terms( (int) $post_id, $this->get_term_name(), $this->media_source_taxonomy->get_taxonomy_slug() );
}
}
}
/**
* Get name of meta key to be used in migration.
* This method is designed for overridden.
*
* @since 1.7.2
*/
abstract protected function get_post_meta_key(): string;
/**
* Get name of term to be used in migration.
* This method is designed for overridden.
*
* @since 1.7.2
*/
protected function get_term_name(): string {
return $this->media_source_taxonomy::TERM_POSTER_GENERATION;
}
}

View File

@@ -0,0 +1,87 @@
<?php
/**
* Class Remove_Broken_Text_Styles
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
use Google\Web_Stories\Story_Post_Type;
/**
* Class Remove_Broken_Text_Styles
*
* @phpstan-type Color array{
* type?: string,
* r?: int,
* g?: int,
* b?: int
* }
* @phpstan-type StylePresets array{
* fillColors: Color[],
* textStyles: array<int, array{
* backgroundColor?: Color,
* color?: Color
* }>,
* textColors: mixed,
* }
*/
class Remove_Broken_Text_Styles extends Migrate_Base {
/**
* Removes broken text styles (with color.r|g|b structure).
*
* @since 1.7.0
*/
public function migrate(): void {
/**
* List of style presets.
*
* @phpstan-var StylePresets|false
*/
$style_presets = get_option( Story_Post_Type::STYLE_PRESETS_OPTION, false );
// Nothing to do if style presets don't exist.
if ( ! \is_array( $style_presets ) ) {
return;
}
$text_styles = [];
if ( ! empty( $style_presets['textStyles'] ) ) {
foreach ( $style_presets['textStyles'] as $preset ) {
if ( isset( $preset['color']['r'] ) ) {
continue;
}
$text_styles[] = $preset;
}
}
$updated_style_presets = [
'fillColors' => $style_presets['fillColors'],
'textColors' => $style_presets['textColors'],
'textStyles' => $text_styles,
];
update_option( Story_Post_Type::STYLE_PRESETS_OPTION, $updated_style_presets );
}
}

View File

@@ -0,0 +1,72 @@
<?php
/**
* Class Remove_Incorrect_Tracking_Id
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2023 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
use Google\Web_Stories\Settings;
use Google\Web_Stories\Tracking;
/**
* Class Remove_Incorrect_Tracking_Id
*/
class Remove_Incorrect_Tracking_Id extends Migrate_Base {
/**
* Settings instance.
*
* @var Settings Settings instance.
*/
private Settings $settings;
/**
* Constructor.
*
* @since 1.30.0
*
* @param Settings $settings Settings instance.
* @return void
*/
public function __construct( Settings $settings ) {
$this->settings = $settings;
}
/**
* Remove incorrect tracking ID.
*
* @since 1.30.0
*/
public function migrate(): void {
$tracking_id = $this->settings->get_setting( $this->settings::SETTING_NAME_TRACKING_ID );
if ( Tracking::TRACKING_ID === $tracking_id ) {
$this->settings->update_setting(
$this->settings::SETTING_NAME_TRACKING_ID,
''
);
}
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* Class Remove_Unneeded_Attachment_Meta
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
use Google\Web_Stories\Media\Video\Poster;
/**
* Class Remove_Unneeded_Attachment_Meta
*/
class Remove_Unneeded_Attachment_Meta extends Migrate_Base {
/**
* Delete old attachment post meta.
*
* @since 1.7.0
*
* @global \wpdb $wpdb WordPress database abstraction object.
*/
public function migrate(): void {
delete_post_meta_by_key( Poster::POSTER_POST_META_KEY );
}
}

View File

@@ -0,0 +1,105 @@
<?php
/**
* Class Replace_Conic_Style_Presets
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
use Google\Web_Stories\Story_Post_Type;
/**
* Class Replace_Conic_Style_Presets
*
* @phpstan-type Color array{
* type?: string
* }
* @phpstan-type StylePresets array{
* fillColors: Color[],
* textStyles: array<int, array{
* backgroundColor?: Color
* }>,
* textColors: mixed,
* }
*/
class Replace_Conic_Style_Presets extends Migrate_Base {
/**
* Replaces conic color type with linear.
*
* @since 1.7.0
*/
public function migrate(): void {
/**
* List of style presets.
*
* @var array|null $style_presets
* @phpstan-var StylePresets|null $style_presets
*/
$style_presets = get_option( Story_Post_Type::STYLE_PRESETS_OPTION, false );
// Nothing to do if style presets don't exist.
if ( ! \is_array( $style_presets ) ) {
return;
}
$fill_colors = [];
$text_styles = [];
if ( ! empty( $style_presets['fillColors'] ) ) {
foreach ( $style_presets['fillColors'] as $color ) {
if ( ! isset( $color['type'] ) || 'conic' !== $color['type'] ) {
$text_styles[] = $color;
continue;
}
$updated_preset = $color;
$updated_preset['type'] = 'linear';
$fill_colors[] = $updated_preset;
}
}
if ( ! empty( $style_presets['textStyles'] ) ) {
foreach ( $style_presets['textStyles'] as $preset ) {
if ( empty( $preset['backgroundColor'] ) ) {
$text_styles[] = $preset;
continue;
}
$bg_color = $preset['backgroundColor'];
if ( ! isset( $bg_color['type'] ) || 'conic' !== $bg_color['type'] ) {
$text_styles[] = $preset;
continue;
}
$updated_preset = $preset;
$updated_preset['backgroundColor']['type'] = 'linear';
$text_styles[] = $updated_preset;
}
}
$updated_style_presets = [
'fillColors' => $fill_colors,
'textColors' => $style_presets['textColors'],
'textStyles' => $text_styles,
];
update_option( Story_Post_Type::STYLE_PRESETS_OPTION, $updated_style_presets );
}
}

View File

@@ -0,0 +1,48 @@
<?php
/**
* Class Rewrite_Flush
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
use const WPCOM_IS_VIP_ENV;
/**
* Class Rewrite_Flush
*/
class Rewrite_Flush extends Migrate_Base {
/**
* Flush rewrite rules.
*
* @since 1.7.0
*/
public function migrate(): void {
if ( ! \defined( '\WPCOM_IS_VIP_ENV' ) || false === WPCOM_IS_VIP_ENV ) {
flush_rewrite_rules( false );
}
}
}

View File

@@ -0,0 +1,67 @@
<?php
/**
* Class Set_Legacy_Analytics_Usage_Flag
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
use Google\Web_Stories\Settings;
/**
* Class Set_Legacy_Analytics_Usage_Flag
*/
class Set_Legacy_Analytics_Usage_Flag extends Migrate_Base {
/**
* Settings instance.
*
* @var Settings Settings instance.
*/
private Settings $settings;
/**
* Migration constructor.
*
* @since 1.12.0
*
* @param Settings $settings Settings instance.
* @return void
*/
public function __construct( Settings $settings ) {
$this->settings = $settings;
}
/**
* Set legacy analytics usage flag.
*
* @since 1.12.0
*/
public function migrate(): void {
$this->settings->update_setting(
$this->settings::SETTING_NAME_USING_LEGACY_ANALYTICS,
! empty( $this->settings->get_setting( $this->settings::SETTING_NAME_TRACKING_ID ) )
);
}
}

View File

@@ -0,0 +1,65 @@
<?php
/**
* Class Unify_Color_Presets
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
use Google\Web_Stories\Story_Post_Type;
/**
* Class Unify_Color_Presets
*/
class Unify_Color_Presets extends Migrate_Base {
/**
* Migration for version 2.0.3.
*
* Color presets: Removes fillColor and textColor and unifies to one color.
*
* @since 1.7.0
*/
public function migrate(): void {
$style_presets = get_option( Story_Post_Type::STYLE_PRESETS_OPTION, false );
// Nothing to do if style presets don't exist.
if ( ! $style_presets || ! \is_array( $style_presets ) ) {
return;
}
// If either of these is not an array, something is incorrect.
if ( ! \is_array( $style_presets['fillColors'] ) || ! \is_array( $style_presets['textColors'] ) ) {
return;
}
$colors = [ ...$style_presets['fillColors'], ...$style_presets['textColors'] ];
// Use only one array of colors for now.
$updated_style_presets = [
'colors' => $colors,
];
update_option( Story_Post_Type::STYLE_PRESETS_OPTION, $updated_style_presets );
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* Class Update_1
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
/**
* Class Update_1
*/
class Update_1 extends Migrate_Base {
/**
* First database migration.
*
* @since 1.7.0
*/
public function migrate(): void {
// Do nothing.
}
}

View File

@@ -0,0 +1,72 @@
<?php
/**
* Class Update_Publisher_Logos
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace Google\Web_Stories\Migrations;
use Google\Web_Stories\Settings;
/**
* Class Update_Publisher_Logos
*/
class Update_Publisher_Logos extends Migrate_Base {
/**
* Settings instance.
*
* @var Settings Settings instance.
*/
private Settings $settings;
/**
* Analytics constructor.
*
* @since 1.12.0
*
* @param Settings $settings Settings instance.
* @return void
*/
public function __construct( Settings $settings ) {
$this->settings = $settings;
}
/**
* Split publisher logos into two options.
*
* @since 1.7.0
*/
public function migrate(): void {
$publisher_logo_id = 0;
$publisher_logo_settings = (array) get_option( $this->settings::SETTING_NAME_PUBLISHER_LOGOS, [] );
if ( ! empty( $publisher_logo_settings['active'] ) ) {
$publisher_logo_id = $publisher_logo_settings['active'];
}
$this->settings->update_setting( $this->settings::SETTING_NAME_ACTIVE_PUBLISHER_LOGO, $publisher_logo_id );
$this->settings->update_setting( $this->settings::SETTING_NAME_PUBLISHER_LOGOS, array_filter( [ $publisher_logo_id ] ) );
}
}