From dce802fae8b9c09a6ab640edf7a472911f11562f Mon Sep 17 00:00:00 2001 From: lucha <lucha@paranoici.org> Date: Thu, 26 Aug 2021 13:35:53 +0200 Subject: [PATCH] added copy-custom-css command See https://git.autistici.org/noblogs/noblogs-composer/-/issues/28 --- bin/noblogs.in | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/bin/noblogs.in b/bin/noblogs.in index 5ea6b39..c0138d2 100755 --- a/bin/noblogs.in +++ b/bin/noblogs.in @@ -90,6 +90,10 @@ Known commands: wp-piwik-clear-config BLOG Clear the configuration for wp-piwik plugin. + copy-custom-css BLOG + Copies the Custom CSS config to the standard Wordpress Customizer config, + then removes the old (options). + <?php exit(1); } @@ -594,6 +598,30 @@ function do_uninstall_plugin($args){ } } +function do_copy_custom_css($args){ + foreach ($args as $arg) { + $blog = noblogs_get_blog($arg); + if (!$blog) { + echo "{$arg}: blog not found.\n"; + continue; + } + switch_to_blog($blog->blog_id); + + $custom_css = get_option('custom-css'); + + if (!$custom_css){ + $wp_css = wp_get_custom_css(); + + wp_update_custom_css_post($wp_css . "\n" . $custom_css); + + delete_option('custom-css'); + delete_option('custom_css_setting'); + } + + restore_current_blog(); + } +} + // Command-line parsing. $cmd = $argv[1]; if (!$cmd) { -- GitLab