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

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 +
3 + namespace Blocksy\DbVersioning;
4 +
5 + class V2031 {
6 + public function migrate() {
7 + $this->migrate_share_box_title();
8 + $this->migrate_share_box_title_products();
9 + $this->migrate_post_types_extra_filters();
10 + }
11 +
12 + public function migrate_share_box_title() {
13 + $prefixes = blocksy_manager()->screen->get_single_prefixes([
14 + 'has_bbpress' => true,
15 + 'has_buddy_press' => true
16 + ]);
17 +
18 + foreach ($prefixes as $prefix) {
19 + $has_share_box_title = get_theme_mod(
20 + $prefix . '_has_share_box_title',
21 + 'no'
22 + );
23 +
24 + $share_box_title = get_theme_mod(
25 + $prefix . '_share_box_title',
26 + __('Share your love', 'blocksy')
27 + );
28 +
29 + if ($has_share_box_title === 'no') {
30 + set_theme_mod($prefix . '_share_box_title', '');
31 + }
32 + }
33 + }
34 +
35 + public function migrate_share_box_title_products() {
36 + $woo_single_layout = get_theme_mod(
37 + 'woo_single_layout',
38 + []
39 + );
40 +
41 + if (! empty($woo_single_layout)) {
42 + $descriptor = $this->migrate_share_box_in_layout($woo_single_layout);
43 +
44 + if ($descriptor['changed']) {
45 + set_theme_mod('woo_single_layout', $descriptor['layout']);
46 + }
47 + }
48 +
49 + $woo_single_split_layout = get_theme_mod(
50 + 'woo_single_split_layout',
51 + [
52 + 'left' => [],
53 + 'right' => []
54 + ]
55 + );
56 +
57 + $split_changed = false;
58 +
59 + if (! empty($woo_single_split_layout['left'])) {
60 + $descriptor = $this->migrate_share_box_in_layout(
61 + $woo_single_split_layout['left']
62 + );
63 +
64 + if ($descriptor['changed']) {
65 + $split_changed = true;
66 + $woo_single_split_layout['left'] = $descriptor['layout'];
67 + }
68 + }
69 +
70 + if (! empty($woo_single_split_layout['right'])) {
71 + $descriptor = $this->migrate_share_box_in_layout(
72 + $woo_single_split_layout['right']
73 + );
74 +
75 + if ($descriptor['changed']) {
76 + $split_changed = true;
77 + $woo_single_split_layout['right'] = $descriptor['layout'];
78 + }
79 + }
80 +
81 + if ($split_changed) {
82 + set_theme_mod('woo_single_split_layout', $woo_single_split_layout);
83 + }
84 + }
85 +
86 + public function migrate_share_box_in_layout($layout) {
87 + $changed = false;
88 +
89 + foreach ($layout as $index => $element) {
90 + if ($element['id'] !== 'product_sharebox') {
91 + continue;
92 + }
93 +
94 + $has_share_box_title = blocksy_akg(
95 + 'has_share_box_title',
96 + $element,
97 + 'no'
98 + );
99 +
100 + $share_box_title = get_theme_mod(
101 + 'share_box_title',
102 + $element,
103 + __('Share your love', 'blocksy')
104 + );
105 +
106 + if ($has_share_box_title === 'no') {
107 + $layout[$index]['share_box_title'] = '';
108 + $changed = true;
109 + }
110 + }
111 +
112 + return [
113 + 'layout' => $layout,
114 + 'changed' => $changed
115 + ];
116 + }
117 +
118 + public function migrate_post_types_extra_filters() {
119 + $prefixes = blocksy_manager()->screen->get_archive_prefixes();
120 +
121 + foreach ($prefixes as $prefix) {
122 + $has_archive_filtering = get_theme_mod(
123 + $prefix . '_has_archive_filtering',
124 + 'no'
125 + );
126 +
127 + if ($has_archive_filtering !== 'yes') {
128 + continue;
129 + }
130 +
131 + $filter_font_color = get_theme_mod(
132 + $prefix . '_filter_font_color',
133 + '__empty__'
134 + );
135 +
136 + if ($filter_font_color === '__empty__') {
137 + continue;
138 + }
139 +
140 + $filter_type = get_theme_mod(
141 + $prefix . '_filter_type',
142 + '__empty__'
143 + );
144 +
145 + if ($filter_type !== 'buttons') {
146 + continue;
147 + }
148 +
149 + if (
150 + isset($filter_font_color['default_2'])
151 + ||
152 + isset($filter_font_color['hover_2'])
153 + ||
154 + ! isset($filter_font_color['default'])
155 + ||
156 + ! isset($filter_font_color['hover'])
157 + ) {
158 + continue;
159 + }
160 +
161 + $filter_font_color['default_2'] = $filter_font_color['default'];
162 + $filter_font_color['hover_2'] = $filter_font_color['hover'];
163 +
164 + set_theme_mod($prefix . '_filter_font_color', $filter_font_color);
165 + }
166 + }
167 + }
168 +
169 +