Diff: STRATO-apps/wordpress_03/app/wp-content/themes/blocksy/inc/classes/db-versioning/v2-0-92.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
3
+
namespace Blocksy\DbVersioning;
4
+
5
+
class V2092 {
6
+
public function migrate() {
7
+
$this->copy_blog_pagination_settings_to_search();
8
+
}
9
+
10
+
public function copy_blog_pagination_settings_to_search() {
11
+
$reveal_options = blocksy_get_options('general/cards-reveal-effect', [
12
+
'prefix' => 'blog',
13
+
]);
14
+
15
+
$pagination_options = blocksy_get_options('general/pagination', [
16
+
'prefix' => 'blog',
17
+
]);
18
+
19
+
$options_to_copy = array_merge(
20
+
$this->get_options_ids($reveal_options),
21
+
$this->get_options_ids($pagination_options)
22
+
);
23
+
24
+
$archive_prefixes = blocksy_manager()->screen->get_archive_prefixes([
25
+
'has_search' => true,
26
+
'has_woocommerce' => true,
27
+
'has_blog' => false
28
+
]);
29
+
30
+
foreach ($archive_prefixes as $archive_prefix) {
31
+
$options_to_copy = $this->get_options_ids($pagination_options);
32
+
33
+
if ($archive_prefix === 'search') {
34
+
$options_to_copy = array_merge(
35
+
$this->get_options_ids($reveal_options),
36
+
$this->get_options_ids($pagination_options)
37
+
);
38
+
}
39
+
40
+
foreach ($options_to_copy as $option_id) {
41
+
if (strpos($option_id, 'blog_') !== 0) {
42
+
continue;
43
+
}
44
+
45
+
$option_value = get_theme_mod($option_id, '__default__');
46
+
47
+
// blog value was not set
48
+
if ($option_value === '__default__') {
49
+
continue;
50
+
}
51
+
52
+
$new_option_id = implode('_', [
53
+
$archive_prefix,
54
+
ltrim($option_id, 'blog_')
55
+
]);
56
+
57
+
$new_option_value = get_theme_mod($new_option_id, '__default__');
58
+
59
+
// local value was already set
60
+
if ($new_option_value !== '__default__') {
61
+
continue;
62
+
}
63
+
64
+
set_theme_mod($new_option_id, $option_value);
65
+
}
66
+
}
67
+
}
68
+
69
+
private function get_options_ids($options) {
70
+
$collected_options = [];
71
+
72
+
blocksy_collect_options(
73
+
$collected_options,
74
+
$options,
75
+
[
76
+
'limit_option_types' => false,
77
+
'limit_level' => 1,
78
+
'include_container_types' => true,
79
+
'info_wrapper' => true,
80
+
]
81
+
);
82
+
83
+
$options_to_copy = [];
84
+
85
+
foreach ($collected_options as &$option) {
86
+
if ('container' === $option['group']) {
87
+
$options_to_copy = array_merge(
88
+
$options_to_copy,
89
+
$this->get_options_ids($option['option']['options'])
90
+
);
91
+
}
92
+
93
+
if ('option' === $option['group']) {
94
+
if (isset($option['option']['inner-options'])) {
95
+
$options_to_copy = array_merge(
96
+
$options_to_copy,
97
+
$this->get_options_ids($option['option']['inner-options'])
98
+
);
99
+
}
100
+
101
+
$options_to_copy[] = $option['id'];
102
+
}
103
+
}
104
+
105
+
return $options_to_copy;
106
+
}
107
+
}
108
+
109
+