From 1d894cfbada4702b3795ee9d37cae2826d97c743 Mon Sep 17 00:00:00 2001 From: otrok7 <50595291+otrok7@users.noreply.github.com> Date: Fri, 13 Dec 2024 20:52:09 +0100 Subject: [PATCH] move preview --- admin/class-bread-admin.php | 157 ++++++++++++++++++++++ admin/partials/bread-admin-display.php | 173 ++----------------------- includes/class-bread.php | 1 + 3 files changed, 168 insertions(+), 163 deletions(-) diff --git a/admin/class-bread-admin.php b/admin/class-bread-admin.php index cb8ef41..a0bb4c7 100644 --- a/admin/class-bread-admin.php +++ b/admin/class-bread-admin.php @@ -542,4 +542,161 @@ function pwsix_process_settings_admin() $this->bread->getConfigurationForSettingId($id); } } + function process_customize_form() + { + $this->bread->getConfigurationForSettingId($this->bread->getRequestedSetting()); + if (!isset($_POST['bmltmeetinglistsave'])) { + $_POST['bmltmeetinglistsave'] = false; + } + if (!isset($_POST['bmltmeetinglistpreview'])) { + $_POST['bmltmeetinglistpreview'] = false; + } + if ($_POST['bmltmeetinglistsave'] || $_POST['bmltmeetinglistpreview']) { + if (!wp_verify_nonce($_POST['_wpnonce'], 'bmltmeetinglistupdate-options')) { + die('Whoops! There was a problem with the data you posted. Please go back and try again.'); + } + $this->bread->setOption('bread_version', sanitize_text_field($_POST['bread_version'])); + $this->bread->setOption('front_page_content', wp_kses_post($_POST['front_page_content'])); + $this->bread->setOption('front_page_line_height', $_POST['front_page_line_height']); + $this->bread->setOption('front_page_font_size', floatval($_POST['front_page_font_size'])); + $this->bread->setOption('content_font_size', floatval($_POST['content_font_size'])); + $this->bread->setOption('suppress_heading', floatval($_POST['suppress_heading'])); + $this->bread->setOption('header_font_size', floatval($_POST['header_font_size'])); + $this->bread->setOption('header_text_color', sanitize_hex_color($_POST['header_text_color'])); + $this->bread->setOption('header_background_color', sanitize_hex_color($_POST['header_background_color'])); + $this->bread->setOption('header_uppercase', intval($_POST['header_uppercase'])); + $this->bread->setOption('header_bold', intval($_POST['header_bold'])); + $this->bread->setOption('sub_header_shown', sanitize_text_field($_POST['sub_header_shown'])); + $this->bread->setOption('cont_header_shown', intval($_POST['cont_header_shown'])); + $this->bread->setOption( + 'column_gap', + isset($_POST['column_gap']) ? + intval($_POST['column_gap']) : 5 + ); + $this->bread->setOption('margin_right', intval($_POST['margin_right'])); + $this->bread->setOption('margin_left', intval($_POST['margin_left'])); + $this->bread->setOption('margin_bottom', intval($_POST['margin_bottom'])); + $this->bread->setOption('margin_top', intval($_POST['margin_top'])); + $this->bread->setOption('margin_header', intval($_POST['margin_header'])); + $this->bread->setOption( + 'margin_footer', + isset($_POST['margin_footer']) ? + intval($_POST['margin_footer']) : 5 + ); + $this->bread->setOption('pageheader_fontsize', floatval($_POST['pageheader_fontsize'])); + $this->bread->setOption('pageheader_textcolor', sanitize_hex_color($_POST['pageheader_textcolor'])); + $this->bread->setOption('pageheader_backgroundcolor', sanitize_hex_color($_POST['pageheader_backgroundcolor'])); + $this->bread->setOption('pageheader_content', wp_kses_post($_POST['pageheader_content'])); + $this->bread->setOption('watermark', sanitize_text_field($_POST['watermark'])); + $this->bread->setOption('page_size', sanitize_text_field($_POST['page_size'])); + $this->bread->setOption('page_orientation', sanitize_text_field($_POST['page_orientation'])); + $this->bread->setOption('page_fold', sanitize_text_field($_POST['page_fold'])); + $this->bread->setOption( + 'booklet_pages', + isset($_POST['booklet_pages']) ? + boolval($_POST['booklet_pages']) : false + ); + $this->bread->setOption('meeting_sort', sanitize_text_field($_POST['meeting_sort'])); + $this->bread->setOption('main_grouping', sanitize_text_field($_POST['main_grouping'])); + $this->bread->setOption('subgrouping', sanitize_text_field($_POST['subgrouping'])); + $this->bread->setOption('borough_suffix', sanitize_text_field($_POST['borough_suffix'])); + $this->bread->setOption('county_suffix', sanitize_text_field($_POST['county_suffix'])); + $this->bread->setOption('neighborhood_suffix', sanitize_text_field($_POST['neighborhood_suffix'])); + $this->bread->setOption('city_suffix', sanitize_text_field($_POST['city_suffix'])); + $this->bread->setOption('meeting_template_content', wp_kses_post($_POST['meeting_template_content'])); + $this->bread->setOption('additional_list_template_content', wp_kses_post($_POST['additional_list_template_content'])); + $this->bread->setOption( + 'column_line', + isset($_POST['column_line']) ? + boolval($_POST['column_line']) : 0 + ); + $this->bread->setOption( + 'col_color', + isset($_POST['col_color']) ? + sanitize_hex_color($_POST['col_color']) : '#bfbfbf' + ); + $this->bread->setOption('custom_section_content', wp_kses_post($_POST['custom_section_content'])); + $this->bread->setOption('custom_section_line_height', floatval($_POST['custom_section_line_height'])); + $this->bread->setOption('custom_section_font_size', floatval($_POST['custom_section_font_size'])); + $this->bread->setOption( + 'pagenumbering_font_size', + isset($_POST['pagenumbering_font_size']) ? + floatval($_POST['pagenumbering_font_size']) : '9' + ); + $this->bread->setOption('used_format_1', sanitize_text_field($_POST['used_format_1'])); + $this->bread->setOption('recurse_service_bodies', isset($_POST['recurse_service_bodies']) ? 1 : 0); + $this->bread->setOption('extra_meetings_enabled', isset($_POST['extra_meetings_enabled']) ? intval($_POST['extra_meetings_enabled']) : 0); + $this->bread->setOption('include_protection', boolval($_POST['include_protection'])); + $this->bread->setOption('weekday_language', sanitize_text_field($_POST['weekday_language'])); + $this->bread->setOption('additional_list_language', sanitize_text_field($_POST['additional_list_language'])); + $this->bread->setOption('weekday_start', sanitize_text_field($_POST['weekday_start'])); + $this->bread->setOption( + 'meeting1_footer', + isset($_POST['meeting1_footer']) ? + sanitize_text_field($_POST['meeting1_footer']) : '' + ); + $this->bread->setOption( + 'meeting2_footer', + isset($_POST['meeting2_footer']) ? + sanitize_text_field($_POST['meeting2_footer']) : '' + ); + $this->bread->setOption( + 'nonmeeting_footer', + isset($_POST['nonmeeting_footer']) ? + sanitize_text_field($_POST['nonmeeting_footer']) : '' + ); + $this->bread->setOption('include_additional_list', boolval($_POST['include_additional_list'])); + $this->bread->setOption('additional_list_format_key', sanitize_text_field($_POST['additional_list_format_key'])); + $this->bread->setOption('additional_list_sort_order', sanitize_text_field($_POST['additional_list_sort_order'])); + $this->bread->setOption('base_font', sanitize_text_field($_POST['base_font'])); + $this->bread->setOption('colorspace', sanitize_text_field($_POST['colorspace'])); + $this->bread->setOption('wheelchair_size', sanitize_text_field($_POST['wheelchair_size'])); + $this->bread->setOption('protection_password', sanitize_text_field($_POST['protection_password'])); + $this->bread->setOption('time_clock', sanitize_text_field($_POST['time_clock'])); + $this->bread->setOption('time_option', intval($_POST['time_option'])); + $this->bread->setOption('remove_space', boolval($_POST['remove_space'])); + $this->bread->setOption('content_line_height', floatval($_POST['content_line_height'])); + $this->bread->setOption('root_server', sanitize_url($_POST['root_server'])); + $this->bread->setOption('service_body_1', sanitize_text_field($_POST['service_body_1'])); + $this->bread->setOption('service_body_2', sanitize_text_field($_POST['service_body_2'])); + $this->bread->setOption('service_body_3', sanitize_text_field($_POST['service_body_3'])); + $this->bread->setOption('service_body_4', sanitize_text_field($_POST['service_body_4'])); + $this->bread->setOption('service_body_5', sanitize_text_field($_POST['service_body_5'])); + $this->bread->setOption('cache_time', intval($_POST['cache_time'])); + $this->bread->setOption('custom_query', sanitize_text_field($_POST['custom_query'])); + $this->bread->setOption('additional_list_custom_query', sanitize_text_field($_POST['additional_list_custom_query'])); + $this->bread->setOption('user_agent', isset($_POST['user_agent']) ? sanitize_text_field($_POST['user_agent']) : 'None'); + $this->bread->setOption('sslverify', isset($_POST['sslverify']) ? '1' : '0'); + $this->bread->setOption('extra_meetings', array()); + if (isset($_POST['extra_meetings'])) { + foreach ($_POST['extra_meetings'] as $extra) { + $this->bread->setOption('extra_meetings', wp_kses_post($extra)); + } + } + $authors = isset($_POST['author_chosen']) ? $_POST['author_chosen'] : []; + $this->bread->setOption('authors', array()); + foreach ($authors as $author) { + $this->bread->appendOption('authors', intval($author)); + } + $user = wp_get_current_user(); + if (!is_array($this->bread->getOption('authors'))) { + $this->bread->setOption('authors', array($this->bread->getOption('authors'))); + } + if (!in_array($user->ID, $this->bread->getOption('authors'))) { + $this->bread->setOption('authors', $user->ID); + } + if ($_POST['bmltmeetinglistpreview']) { + session_start(); + $_SESSION['bread_preview_settings'] = $this->bread->getOptions(); + wp_redirect(home_url() . "?preview-meeting-list=1"); + exit(); + } + } elseif (isset($_REQUEST['pwsix_action']) && $_REQUEST['pwsix_action'] == "import_settings") { + echo '
Your file was successfully imported!
Your default settings were successfully updated!
You do not have permission to save this configuation!
'; - } else { - $this->admin->save_admin_options(); - echo 'Your changes were successfully saved!
'; - $num = delete_transient($this->bread->get_TransientKey($this->bread->getRequestedSetting())); - if ($num > 0) { - echo "$num Cache entries deleted
"; - } - } - echo 'Your file was successfully imported!
Your default settings were successfully updated!
You do not have permission to save this configuation!
'; + } else { + $this->admin->save_admin_options(); + echo 'Your changes were successfully saved!
'; $num = delete_transient($this->bread->get_TransientKey($this->bread->getRequestedSetting())); + if ($num > 0) { + echo "$num Cache entries deleted
"; + } } + echo '