/** * Saves the settings on a given tab. * * @param array $tab The tab we are saving. * @param int $post_id The ID of the post we are saving. * @param WP_Post $post The post (or page) object that is being saved. * @return void * @author Paul Hughes * @since 3.0 */ public function saveMuutPostTab($tab, $post_id, $post) { $muut_tabs_to_save = array(); foreach ($this->defaultTabs as $default_tab) { $muut_tabs_to_save[] = $default_tab['name']; } if (!in_array($tab['name'], $muut_tabs_to_save) || !empty($tab['post_types']) && !in_array($post->post_type, (array) $tab['post_types'])) { return; } switch ($tab['name']) { case 'commenting-tab': $tab_options = array(); if (isset($_POST[$tab['meta_name']])) { $tab_options = $_POST[$tab['meta_name']]; } $boolean_values = array('disable_uploads'); foreach ($boolean_values as $boolean_value) { $tab_options[$boolean_value] = isset($tab_options[$boolean_value]) ? $tab_options[$boolean_value] : '0'; } Muut_Post_Utility::setPostOption($post_id, $tab['meta_name'], $tab_options); break; case 'channel-tab': $tab_options = array(); if (isset($_POST[$tab['meta_name']])) { $tab_options = $_POST[$tab['meta_name']]; $tab_current_options = Muut_Post_Utility::getPostOption($post_id, $tab['meta_name']); } $boolean_values = array('hide_online', 'disable_uploads'); foreach ($boolean_values as $boolean_value) { $tab_options[$boolean_value] = isset($tab_options[$boolean_value]) ? $tab_options[$boolean_value] : '0'; } $channel_path = isset($tab_options['channel_path']) ? $tab_options['channel_path'] : ''; if (!isset($tab_options['channel_path']) || $tab_options['channel_path'] == '' || !$tab_options['channel_path']) { // If no path is saved yet, let's generate one and save it. $path = sanitize_title($post->post_name); $ancestors = get_post_ancestors($post); foreach ($ancestors as $ancestor) { if (Muut_Post_Utility::isMuutChannelPage($ancestor) && Muut_Post_Utility::getChannelRemotePathForPage($ancestor, true)) { $path = Muut_Post_Utility::getChannelRemotePathForPage($ancestor, true) . '/' . $path; } } $channel_path = $path; } elseif (isset($tab_options['channel_path']) && $tab_options['channel_path'] != '') { $channel_path = Muut_Post_Utility::sanitizeMuutPath($tab_options['channel_path']); } $tab_options['channel_path'] = $channel_path; Muut_Post_Utility::setPostOption($post_id, $tab['meta_name'], $tab_options); break; case 'forum-tab': $tab_options = array(); if (isset($_POST[$tab['meta_name']])) { $tab_options = $_POST[$tab['meta_name']]; } $boolean_values = array('hide_online', 'disable_uploads', 'show_comments_in_forum'); foreach ($boolean_values as $boolean_value) { $tab_options[$boolean_value] = isset($tab_options[$boolean_value]) ? $tab_options[$boolean_value] : '0'; } // Remove the default setting for showing comments in forum, if it was copied // over from an older version of the plugin. if (muut()->getOption('show_comments_in_forum_default')) { muut()->setOption('show_comments_in_forum_default', null); } Muut_Post_Utility::setPostOption($post_id, $tab['meta_name'], $tab_options); Muut_Post_Utility::setAsForumPage($post_id); break; } }