ID; if (!$this->is_links_template($post_id)) { echo '

' . esc_html__('将页面模板设为「AKSRT - 网址导航」后在此配置分类、样式与提交模块。', 'aksrt') . '

'; return; } $s = function_exists('aksrt_get_page_links_settings') ? aksrt_get_page_links_settings($post_id) : []; wp_nonce_field('aksrt_page_links_meta', 'aksrt_page_links_meta_nonce'); $terms = get_terms([ 'taxonomy' => 'link_category', 'hide_empty' => false, ]); if (is_wp_error($terms)) { $terms = []; } $selected_cats = array_map('intval', (array) ($s['category'] ?? [])); $submit_cats = array_map('intval', (array) ($s['submit_cats'] ?? [])); $search_types = (array) ($s['search_types'] ?? []); $engine_options = [ 'self' => __('站内', 'aksrt'), 'baidu' => __('百度', 'aksrt'), 'google' => __('谷歌', 'aksrt'), 'bing' => __('必应', 'aksrt'), 'sogou' => __('搜狗', 'aksrt'), '360' => '360', ]; ?> is_links_template($post_id) && empty($_POST['page_links_category']) && empty($_POST['page_links_submit_s'])) { // Still allow save if user just switched template in same request. $tpl = isset($_POST['page_template']) ? (string) wp_unslash($_POST['page_template']) : ''; if ($tpl !== 'templates/pages/page-links.php') { return; } } $bool_keys = [ 'page_links_content_s', 'page_links_search_s', 'page_links_go_s', 'page_links_blank_s', 'page_links_nofollow_s', 'page_links_submit_s', 'page_links_submit_sign_s', ]; foreach ($bool_keys as $key) { update_post_meta($post_id, $key, isset($_POST[$key]) ? 1 : 0); } $position = isset($_POST['page_links_content_position']) ? sanitize_key((string) wp_unslash($_POST['page_links_content_position'])) : 'top'; if (!in_array($position, ['top', 'bottom'], true)) { $position = 'top'; } update_post_meta($post_id, 'page_links_content_position', $position); $style = isset($_POST['page_links_style']) ? sanitize_key((string) wp_unslash($_POST['page_links_style'])) : 'card'; if (!in_array($style, ['card', 'bigcard', 'image', 'simple'], true)) { $style = 'card'; } update_post_meta($post_id, 'page_links_style', $style); $orderby = isset($_POST['page_links_orderby']) ? sanitize_key((string) wp_unslash($_POST['page_links_orderby'])) : 'name'; if (!in_array($orderby, ['name', 'updated', 'rating', 'rand', 'id', 'length'], true)) { $orderby = 'name'; } update_post_meta($post_id, 'page_links_orderby', $orderby); $order = isset($_POST['page_links_order']) ? strtoupper(sanitize_text_field(wp_unslash((string) $_POST['page_links_order']))) : 'ASC'; update_post_meta($post_id, 'page_links_order', $order === 'DESC' ? 'DESC' : 'ASC'); $limit = isset($_POST['page_links_limit']) ? max(0, (int) $_POST['page_links_limit']) : 0; update_post_meta($post_id, 'page_links_limit', $limit); $cats = isset($_POST['page_links_category']) ? array_values(array_filter(array_map('intval', (array) wp_unslash($_POST['page_links_category'])))) : []; update_post_meta($post_id, 'page_links_category', $cats); $submit_cats = isset($_POST['page_links_submit_cats']) ? array_values(array_filter(array_map('intval', (array) wp_unslash($_POST['page_links_submit_cats'])))) : []; update_post_meta($post_id, 'page_links_submit_cats', $submit_cats); $engines = isset($_POST['page_links_search_types']) ? array_values(array_filter(array_map('sanitize_key', (array) wp_unslash($_POST['page_links_search_types'])))) : []; $allowed = ['self', 'baidu', 'google', 'bing', 'sogou', '360']; $engines = array_values(array_intersect($engines, $allowed)); update_post_meta($post_id, 'page_links_search_types', $engines); $title = isset($_POST['page_links_submit_title']) ? sanitize_text_field(wp_unslash((string) $_POST['page_links_submit_title'])) : ''; update_post_meta($post_id, 'page_links_submit_title', $title); $dec = isset($_POST['page_links_submit_dec']) ? wp_kses_post(wp_unslash((string) $_POST['page_links_submit_dec'])) : ''; update_post_meta($post_id, 'page_links_submit_dec', $dec); } }