Diff: STRATO-apps/wordpress_03/app/wp-content/themes/blocksy/inc/classes/db-versioning/v2-0-72.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 +
3 + namespace Blocksy\DbVersioning;
4 +
5 + class V2072 {
6 + public function migrate() {
7 + $cleaner = new DefaultValuesCleaner();
8 + $cleaner->clean_whole_customizer_recursively();
9 +
10 + $default_enabled = [
11 + 'facebook',
12 + 'twitter',
13 + 'pinterest',
14 + 'linkedin',
15 + ];
16 +
17 + $old_share_options = [
18 + 'reddit',
19 + 'hacker_news',
20 + 'vk',
21 + 'ok',
22 + 'telegram',
23 + 'viber',
24 + 'whatsapp',
25 + 'flipboard',
26 + 'line',
27 + 'threads',
28 + 'email',
29 + 'clipboard',
30 + ];
31 +
32 + $old_share_options = array_merge($default_enabled, $old_share_options);
33 +
34 + $default_value_for_new_option = [];
35 +
36 + foreach ($default_enabled as $option) {
37 + $default_value_for_new_option[] = [
38 + 'id' => $option,
39 + 'enabled' => true
40 + ];
41 + }
42 +
43 + $prefixes = [];
44 +
45 + foreach (blocksy_manager()->screen->get_single_prefixes() as $prefix) {
46 + $prefixes[] = $prefix;
47 + }
48 +
49 + foreach ($prefixes as $prefix) {
50 + $new_option_value = [];
51 +
52 + foreach ($old_share_options as $old_share_option) {
53 + $option_key = $prefix . '_share_' . $old_share_option;
54 +
55 + $old_value = get_theme_mod($option_key, '__empty__');
56 +
57 + if ($old_value === '__empty__') {
58 + if (in_array($old_share_option, $default_enabled)) {
59 + $new_option_value[] = [
60 + 'id' => $old_share_option,
61 + 'enabled' => true
62 + ];
63 + }
64 +
65 + continue;
66 + }
67 +
68 + remove_theme_mod($option_key);
69 +
70 + if ($old_value === 'no') {
71 + continue;
72 + }
73 +
74 + $new_option_value[] = [
75 + 'id' => $old_share_option,
76 + 'enabled' => true
77 + ];
78 + }
79 +
80 + if ($new_option_value != $default_value_for_new_option) {
81 + set_theme_mod(
82 + $prefix . '_' . 'share_networks',
83 + $new_option_value
84 + );
85 + }
86 + }
87 + }
88 +
89 + public function migrate_compare_table_layers() {
90 + $old_render_layout_config = blocksy_get_theme_mod('product_compare_layout', [
91 + [
92 + 'id' => 'product_main',
93 + 'enabled' => true,
94 + ],
95 + [
96 + 'id' => 'product_description',
97 + 'enabled' => true,
98 + ],
99 + [
100 + 'id' => 'product_attributes',
101 + 'enabled' => true,
102 + 'product_attributes_source' => 'all',
103 + ],
104 + [
105 + 'id' => 'product_availability',
106 + 'enabled' => true,
107 + ],
108 + ]);
109 +
110 + $missing_rows = [
111 + [
112 + 'id' => 'product_price',
113 + 'enabled' => true,
114 + ],
115 + [
116 + 'id' => 'product_add_to_cart',
117 + 'enabled' => true,
118 + ],
119 + ];
120 +
121 + $index_of_product_price = array_search(
122 + 'product_price',
123 + array_column($old_render_layout_config, 'id')
124 + );
125 +
126 + $index_of_product_add_to_cart = array_search(
127 + 'product_add_to_cart',
128 + array_column($old_render_layout_config, 'id')
129 + );
130 +
131 + if (
132 + $index_of_product_price !== false
133 + ||
134 + $index_of_product_add_to_cart !== false
135 + ) {
136 + return;
137 + }
138 +
139 + $index_of_product_main = array_search(
140 + 'product_main',
141 + array_column($old_render_layout_config, 'id')
142 + );
143 +
144 + if ($index_of_product_main !== false) {
145 + array_splice(
146 + $old_render_layout_config,
147 + $index_of_product_main + 1,
148 + 0,
149 + $missing_rows
150 + );
151 + }
152 +
153 + set_theme_mod('product_compare_layout', $old_render_layout_config);
154 + }
155 + }
156 +