| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.2/wp-content/themes/blocksy/inc/classes/db-versioning/ |
Upload File : |
<?php
namespace Blocksy\DbVersioning;
class V2092 {
public function migrate() {
$this->copy_blog_pagination_settings_to_search();
}
public function copy_blog_pagination_settings_to_search() {
$reveal_options = blocksy_get_options('general/cards-reveal-effect', [
'prefix' => 'blog',
]);
$pagination_options = blocksy_get_options('general/pagination', [
'prefix' => 'blog',
]);
$options_to_copy = array_merge(
$this->get_options_ids($reveal_options),
$this->get_options_ids($pagination_options)
);
$archive_prefixes = blocksy_manager()->screen->get_archive_prefixes([
'has_search' => true,
'has_woocommerce' => true,
'has_blog' => false
]);
foreach ($archive_prefixes as $archive_prefix) {
$options_to_copy = $this->get_options_ids($pagination_options);
if ($archive_prefix === 'search') {
$options_to_copy = array_merge(
$this->get_options_ids($reveal_options),
$this->get_options_ids($pagination_options)
);
}
foreach ($options_to_copy as $option_id) {
if (strpos($option_id, 'blog_') !== 0) {
continue;
}
$option_value = get_theme_mod($option_id, '__default__');
// blog value was not set
if ($option_value === '__default__') {
continue;
}
$new_option_id = implode('_', [
$archive_prefix,
ltrim($option_id, 'blog_')
]);
$new_option_value = get_theme_mod($new_option_id, '__default__');
// local value was already set
if ($new_option_value !== '__default__') {
continue;
}
set_theme_mod($new_option_id, $option_value);
}
}
}
private function get_options_ids($options) {
$collected_options = [];
blocksy_collect_options(
$collected_options,
$options,
[
'limit_option_types' => false,
'limit_level' => 1,
'include_container_types' => true,
'info_wrapper' => true,
]
);
$options_to_copy = [];
foreach ($collected_options as &$option) {
if ('container' === $option['group']) {
$options_to_copy = array_merge(
$options_to_copy,
$this->get_options_ids($option['option']['options'])
);
}
if ('option' === $option['group']) {
if (isset($option['option']['inner-options'])) {
$options_to_copy = array_merge(
$options_to_copy,
$this->get_options_ids($option['option']['inner-options'])
);
}
$options_to_copy[] = $option['id'];
}
}
return $options_to_copy;
}
}