/>

/>

'basic-settings', 'support-forum' => 'basic-settings', 'topic-status' => 'topic-management', 'topic-labels' => 'topic-management', 'private-replies' => 'forum-features', 'forum-enhancements' => 'forum-features', 'search-settings' => 'search-seo', 'seo-settings' => 'search-seo', 'additional-features' => 'advanced-features', 'advanced-features' => 'advanced-features' ); $requested_tab = isset($_GET['tab']) ? $_GET['tab'] : 'basic-settings'; $active_tab = isset($tab_mapping[$requested_tab]) ? $tab_mapping[$requested_tab] : 'basic-settings'; ?>

{$section['title']}\n"; } if ($section['callback']) { call_user_func($section['callback'], $section); } if (!isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']])) { continue; } echo ''; do_settings_fields($page, $section['id']); echo ''; break; } } } function bbps_admin_setting_callback_email_fix() { ?> type="checkbox" value="1" />

type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> 'forum', 'post_status' => 'publish', 'posts_per_page' => -1, 'orderby' => 'menu_order title', 'order' => 'ASC' ]); ?>

$value) { $newoptions[sanitize_key($key)] = sanitize_text_field($value); } } return $newoptions; } function bbps_validate_options($input) { $options = get_option("bbps_reply_count", []); if (!is_array($options)) { $options = []; } // 如果选项为空,设置默认参数 if (empty($options)) { $options = bbps_get_default_user_ranking_options(); } if (is_array($input)) { $i = 1; foreach ($input as $array) { if (is_array($array)) { if (!isset($options[$i]) || !is_array($options[$i])) { $options[$i] = []; } foreach ($array as $key => $value) { $options[$i][sanitize_key($key)] = sanitize_text_field( $value ); } } $i++; } } return $options; } /** * 初始化用户等级默认参数 */ function bbps_init_default_user_ranking() { $existing_options = get_option('bbps_reply_count', []); // 如果选项不存在或为空,设置默认值 if (empty($existing_options)) { $default_options = bbps_get_default_user_ranking_options(); update_option('bbps_reply_count', $default_options); } } /** * 获取用户等级的默认参数 */ function bbps_get_default_user_ranking_options() { return [ 1 => [ 'title' => __('新手', 'bbpress-support-toolkit'), 'start' => '1', 'end' => '10' ], 2 => [ 'title' => __('活跃用户', 'bbpress-support-toolkit'), 'start' => '11', 'end' => '50' ], 3 => [ 'title' => __('资深用户', 'bbpress-support-toolkit'), 'start' => '51', 'end' => '100' ], 4 => [ 'title' => __('专家用户', 'bbpress-support-toolkit'), 'start' => '101', 'end' => '200' ], 5 => [ 'title' => __('论坛大师', 'bbpress-support-toolkit'), 'start' => '201', 'end' => '999999' ] ]; } function bbps_admin_setting_callback_ranking_section() { ?>

type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" />


%topic_title% -
%forum_name% -
%site_name% -
%author_name% -

" /> " class="small-text" /> " class="small-text" /> value="1" /> value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" /> type="checkbox" value="1" />


%USERNAME% will be replaced with a username.", "bbpress-support-toolkit" ); ?>
%PASSWORD% will be replaced with the user\'s password.', "bbpress-support-toolkit" ); ?>
%BLOGNAME% will be replaced with the name of your blog.", "bbpress-support-toolkit" ); ?>
%BLOGURL% will be replaced with the url of your blog.", "bbpress-support-toolkit" ); ?>
%BLOGNAME% will be replaced with the name of your blog.", "bbpress-support-toolkit" ); ?>
%BLOGURL% will be replaced with the url of your blog.", "bbpress-support-toolkit" ); ?> '; break; case 2: echo ''; break; case 3: echo ''; break; } if (get_post_meta($post_id, "_bbps_urgent_topic", true)) { echo ' '; } if (get_post_meta($post_id, "_bbps_topic_claimed", true)) { echo ' '; } } if ($column_name == "bbps_forum") { $forum_id = bbp_get_topic_forum_id($post_id); $forum_types = []; if (bbps_is_support_forum($forum_id)) { $forum_types[] = __("Support", "bbpress-support-toolkit"); } if (bbps_is_premium_forum($forum_id)) { $forum_types[] = __("Premium", "bbpress-support-toolkit"); } echo empty($forum_types) ? __("Standard", "bbpress-support-toolkit") : implode(", ", $forum_types); } } function bbps_add_bulk_actions($bulk_actions) { $bulk_actions["bbps_mark_resolved"] = __( "Mark as Resolved", "bbpress-support-toolkit" ); $bulk_actions["bbps_mark_not_resolved"] = __( "Mark as Not Resolved", "bbpress-support-toolkit" ); $bulk_actions["bbps_mark_not_support"] = __( "Mark as Not Support Question", "bbpress-support-toolkit" ); $bulk_actions["bbps_mark_urgent"] = __( "Mark as Urgent", "bbpress-support-toolkit" ); $bulk_actions["bbps_unmark_urgent"] = __( "Remove Urgent Status", "bbpress-support-toolkit" ); return $bulk_actions; } function bbps_handle_bulk_actions($redirect_to, $action, $post_ids) { if ( !in_array($action, [ "bbps_mark_resolved", "bbps_mark_not_resolved", "bbps_mark_not_support", "bbps_mark_urgent", "bbps_unmark_urgent", ]) ) { return $redirect_to; } $count = 0; foreach ($post_ids as $post_id) { switch ($action) { case "bbps_mark_resolved": update_post_meta($post_id, "_bbps_topic_status", 2); delete_post_meta($post_id, "_bbps_urgent_topic"); delete_post_meta($post_id, "_bbps_topic_claimed"); $count++; break; case "bbps_mark_not_resolved": update_post_meta($post_id, "_bbps_topic_status", 1); $count++; break; case "bbps_mark_not_support": update_post_meta($post_id, "_bbps_topic_status", 3); delete_post_meta($post_id, "_bbps_urgent_topic"); delete_post_meta($post_id, "_bbps_topic_claimed"); $count++; break; case "bbps_mark_urgent": update_post_meta($post_id, "_bbps_urgent_topic", 1); $count++; break; case "bbps_unmark_urgent": delete_post_meta($post_id, "_bbps_urgent_topic"); $count++; break; } } $redirect_to = add_query_arg("bbps_bulk_updated", $count, $redirect_to); return $redirect_to; } add_action("admin_notices", "bbps_bulk_action_admin_notice"); function bbps_bulk_action_admin_notice() { if (!empty($_REQUEST["bbps_bulk_updated"])) { $count = intval($_REQUEST["bbps_bulk_updated"]); printf( '

' . _n( "Updated %s topic.", "Updated %s topics.", $count, "bbpress-support-toolkit" ) . "

", $count ); } } // Additional Features Callback Functions function bbps_admin_setting_callback_additional_section() { echo '

' . __("Additional features to enhance your bbPress forums.", "bbpress-support-toolkit") . '

'; } function bbps_admin_setting_callback_disable_user_page() { $option = get_option("bbps_disable_user_page", 0); echo ''; echo ''; echo '

' . __("This will disable the bbPress user profile pages to prevent spam.", "bbpress-support-toolkit") . '

'; } function bbps_admin_setting_callback_remove_avatars() { $option = get_option("bbps_remove_avatars", 0); echo ''; echo ''; echo '

' . __("This will remove avatars from topics, replies, and user profiles.", "bbpress-support-toolkit") . '

'; } function bbps_admin_setting_callback_redirect_single_replies() { $option = get_option("bbps_redirect_single_replies", 0); echo ''; echo ''; echo '

' . __("This will redirect users from single reply pages to the parent topic page.", "bbpress-support-toolkit") . '

'; } function bbps_admin_setting_callback_custom_notifications() { $option = get_option("bbps_custom_notifications", 0); echo ''; echo ''; echo '

' . __("This will allow you to customize the email notifications sent to forum subscribers.", "bbpress-support-toolkit") . '

'; } // Notification Settings Callback Functions function bbps_admin_setting_callback_notification_settings_section() { echo '

' . __("Customize the email notifications sent to forum and topic subscribers.", "bbpress-support-toolkit") . '

'; } function bbps_admin_setting_callback_topic_notice_title() { $default_title = '[' . get_option('blogname') . '] {title}'; $value = get_option('bbps_topic_notice_title', $default_title); echo ''; echo '

' . __("The subject of the topic notification email. Use {title} for the topic title.", "bbpress-support-toolkit") . '

'; } function bbps_admin_setting_callback_topic_notice_body() { $default = '{author} wrote:\n\n{content}\n\nPost Link: {url}\n\n-----------\n\nYou are receiving this email because you subscribed to the {forum_name} forum.\n\nLogin and visit the forum to unsubscribe from these emails.'; $value = get_option('bbps_topic_notice_body', $default); echo ''; echo '

' . __("Email message sent to forum subscribers when a new topic is posted. Available tokens: {author}, {content}, {url}, {forum_name}", "bbpress-support-toolkit") . '

'; } function bbps_admin_setting_callback_reply_notice_title() { $default_title = '[' . get_option('blogname') . '] {title}'; $value = get_option('bbps_reply_notice_title', $default_title); echo ''; echo '

' . __("The subject of the reply notification email. Use {title} for the topic title.", "bbpress-support-toolkit") . '

'; } function bbps_admin_setting_callback_reply_notice_body() { $default = '{author} wrote:\n\n{content}\n\nPost Link: {url}\n\n-----------\n\nYou are receiving this email because you subscribed to a forum topic.\n\nLogin and visit the topic to unsubscribe from these emails.'; $value = get_option('bbps_reply_notice_body', $default); echo ''; echo '

' . __("Email message sent to topic subscribers when a new reply is posted. Available tokens: {author}, {content}, {url}", "bbpress-support-toolkit") . '

'; } // Ajax处理函数 function bbps_ajax_save_settings() { // 验证nonce if (!isset($_POST['_ajax_nonce']) || !wp_verify_nonce($_POST['_ajax_nonce'], 'bbps_settings_nonce')) { wp_send_json_error(__('Invalid security token. Please refresh the page and try again.', 'bbpress-support-toolkit')); } // 检查权限 if (!current_user_can('manage_options')) { wp_send_json_error(__('You do not have permission to perform this action.', 'bbpress-support-toolkit')); } // 获取表单数据 $form_data = isset($_POST['form_data']) ? $_POST['form_data'] : array(); if (empty($form_data)) { wp_send_json_error(__('No settings data provided.', 'bbpress-support-toolkit')); } // 解析表单数据 parse_str($form_data, $parsed_data); // 保存设置 $saved_count = 0; // 获取所有已注册的设置 global $wp_settings_fields; $settings_to_save = array(); if (isset($wp_settings_fields['bbpress-support-toolkit'])) { foreach ($wp_settings_fields['bbpress-support-toolkit'] as $section => $fields) { foreach ($fields as $field_id => $field) { if (strpos($field_id, 'bbps_') === 0) { $settings_to_save[] = $field_id; } } } } foreach ($settings_to_save as $setting_name) { // 对于复选框类型的设置,如果没有在表单数据中,说明未选中,应该设为0 if (strpos($setting_name, '_enable') !== false) { $value = isset($parsed_data[$setting_name]) ? 1 : 0; } else { $value = isset($parsed_data[$setting_name]) ? $parsed_data[$setting_name] : ''; // 基本验证 if (strpos($setting_name, '_count') !== false) { $value = intval($value); } else { $value = sanitize_text_field($value); } } update_option($setting_name, $value); $saved_count++; } wp_send_json_success(array( 'message' => __('Settings saved successfully!', 'bbpress-support-toolkit'), 'saved_count' => $saved_count )); } // 加载管理脚本 function bbps_enqueue_admin_scripts($hook) { if ($hook !== 'settings_page_bbpress-support-toolkit') { return; } wp_enqueue_script('jquery'); wp_localize_script('jquery', 'bbps_ajax', array( 'ajax_url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('bbps_settings_nonce'), 'saving_text' => __('Saving...', 'bbpress-support-toolkit'), 'saved_text' => __('Settings saved successfully!', 'bbpress-support-toolkit'), 'error_text' => __('Error saving settings. Please try again.', 'bbpress-support-toolkit') )); } // Advanced Features Callback Functions function bbps_admin_setting_callback_advanced_section() { echo '

' . __('Advanced features to enhance your bbPress forums with additional functionality.', 'bbpress-support-toolkit') . '

'; } function bbps_admin_setting_callback_admin_notes() { $option = get_option('bbps_enable_admin_notes', 0); echo ''; echo ''; echo '

' . __('Allows administrators to add private notes to topics and replies that are only visible to other administrators.', 'bbpress-support-toolkit') . '

'; } function bbps_admin_setting_callback_live_preview() { $option = get_option('bbps_enable_live_preview', 0); echo ''; echo ''; echo '

' . __('Allows users to preview their posts in real-time before submitting.', 'bbpress-support-toolkit') . '

'; } function bbps_admin_setting_callback_mark_as_read() { $option = get_option('bbps_enable_mark_as_read', 0); echo ''; echo ''; echo '

' . __('Allows users to mark topics as read/unread and track their reading progress.', 'bbpress-support-toolkit') . '

'; } function bbps_admin_setting_callback_canned_replies() { $option = get_option('bbps_enable_canned_replies', 0); echo ''; echo ''; echo '

' . __('Allows administrators and moderators to create and use pre-written reply templates.', 'bbpress-support-toolkit') . '

'; } function bbps_admin_setting_callback_report_content() { $option = get_option('bbps_enable_report_content', 0); echo ''; echo ''; echo '

' . __('Allows users to report inappropriate topics and replies to administrators.', 'bbpress-support-toolkit') . '

'; } function bbps_admin_setting_callback_topic_lock() { $option = get_option('bbps_enable_topic_lock', 0); echo ''; echo ''; echo '

' . __('Warns moderators when another moderator is currently viewing the same topic to prevent conflicts.', 'bbpress-support-toolkit') . '

'; }