为[东正教香]创建SEO标题。 要求标题中包含以下任意一个或多个词:{2024,1~9,如何,方法,什么,哪一个,哪里,什么时候,为什么,最佳,简单,最新,流行,简便,有效,终极,快速,顶级,评测,概览,反馈,骗局,方式,方法,策略,选择,选项,解决方案,实践,方法,分析,亮点,洞察,细节,事实,计划,秘密,益处,好处,步骤,提示,更新,新的,指南}, 然后按拆分方式逐一生成内容, 最后再将多个指令合并。

2025年9月11日 by 一个老不正经

请将下面内容翻译成中文:【Create seo titles about [eastern orthodox incense]. Requirement title contains one word or more words in {2024,1~9,how,How-To,what,which,where,when,why,best,easy,latest,popular,simple,effective,ultimate,quick,top,review,overview,feedback,scam,ways,approaches,strategies,choices,options,solutions,practices,methods,analysis,highlights,insight,details,facts,plans,secrets,benefits,advantages,steps,tips,update,new,guide}, then I content is split way, one by one to generate Then combine, multiple instructions.】

2025年9月11日 by 一个老不正经

请问以下代码【 _x(‘产品’, ‘post type general name’, ‘my-theme’), ‘singular_name’ => _x(‘产品’, ‘post type singular name’, ‘my-theme’), ‘menu_name’ => _x(‘产品’, ‘admin menu’, ‘my-theme’), ‘name_admin_bar’ => _x(‘产品’, ‘add new on admin bar’, ‘my-theme’), ‘add_new’ => _x(‘添加新商品’, ‘product’, ‘my-theme’), ‘add_new_item’ => __(‘添加新商品’, ‘my-theme’), ‘new_item’ => __(‘新商品’, ‘my-theme’), ‘edit_item’ => __(‘编辑商品’, ‘my-theme’), ‘view_item’ => __(‘查看商品’, ‘my-theme’), ‘all_items’ => __(‘所有商品’, ‘my-theme’), ‘search_items’ => __(‘搜索商品’, ‘my-theme’), ‘parent_item_colon’ => __(‘父级商品:’, ‘my-theme’), ‘not_found’ => __(‘未找到商品。’, ‘my-theme’), ‘not_found_in_trash’ => __(‘回收站中未找到商品。’, ‘my-theme’) ); $args = array( ‘labels’ => $labels, ‘public’ => true, ‘publicly_queryable’ => true, ‘show_ui’ => true, ‘show_in_menu’ => true, ‘menu_icon’ => ‘dashicons-cart’, ‘query_var’ => true, ‘rewrite’ => array(‘slug’ => ‘products’, ‘with_front’ => false), ‘capability_type’ => ‘post’, ‘has_archive’ => true, ‘hierarchical’ => false, ‘menu_position’ => 5, ‘supports’ => array(‘title’, ‘editor’, ‘author’, ‘thumbnail’, ‘excerpt’, ‘comments’, ‘revisions’), ‘taxonomies’ => array(‘product_category’, ‘product_tag’), ‘show_in_rest’ => true, ‘rest_base’ => ‘products’, ‘rest_controller_class’ => ‘WP_REST_Posts_Controller’, ); register_post_type(‘product’, $args); } add_action(‘init’, ‘custom_post_type_product’, 11); // 3. 注册产品分类法 – 产品类别 function custom_taxonomy_product_category() { $labels = array( ‘name’ => _x(‘产品类别’, ‘taxonomy general name’, ‘my-theme’), ‘singular_name’ => _x(‘产品类别’, ‘taxonomy singular name’, ‘my-theme’), ‘search_items’ => __(‘搜索类别’, ‘my-theme’), ‘all_items’ => __(‘所有类别’, ‘my-theme’), ‘parent_item’ => __(‘父类别’, ‘my-theme’), ‘parent_item_colon’ => __(‘父类别:’, ‘my-theme’), ‘edit_item’ => __(‘编辑类别’, ‘my-theme’), ‘update_item’ => __(‘更新类别’, ‘my-theme’), ‘add_new_item’ => __(‘添加新类别’, ‘my-theme’), ‘new_item_name’ => __(‘新类别名称’, ‘my-theme’), ‘menu_name’ => __(‘产品类别’, ‘my-theme’), ); $args = array( ‘hierarchical’ => true, // 支持层级管理,URL为扁平 ‘labels’ => $labels, ‘show_ui’ => true, ‘show_admin_column’ => true, ‘query_var’ => true, ‘rewrite’ => array( ‘slug’ => ‘product-category’, ‘with_front’ => false, ‘hierarchical’ => false // 关键:禁用层级URL ), ‘show_in_rest’ => true, ); register_taxonomy(‘product_category’, array(‘product’), $args); } add_action(‘init’, ‘custom_taxonomy_product_category’, 0); // 4. 注册产品标签 function custom_taxonomy_product_tag() { $labels = array( ‘name’ => _x(‘产品标签’, ‘taxonomy general name’, ‘my-theme’), ‘singular_name’ => _x(‘产品标签’, ‘taxonomy singular name’, ‘my-theme’), ‘search_items’ => __(‘搜索标签’, ‘my-theme’), ‘all_items’ => __(‘所有标签’, ‘my-theme’), ‘parent_item’ => null, ‘parent_item_colon’ => null, ‘edit_item’ => __(‘编辑标签’, ‘my-theme’), ‘update_item’ => __(‘更新标签’, ‘my-theme’), ‘add_new_item’ => __(‘添加新标签’, ‘my-theme’), ‘new_item_name’ => __(‘新标签名称’, ‘my-theme’), ‘menu_name’ => __(‘产品标签’, ‘my-theme’), ); $args = array( ‘hierarchical’ => false, ‘labels’ => $labels, ‘show_ui’ => true, ‘show_admin_column’ => true, ‘query_var’ => true, ‘rewrite’ => array(‘slug’ => ‘product-tag’, ‘with_front’ => false), ‘show_in_rest’ => true, ); register_taxonomy(‘product_tag’, array(‘product’), $args); } add_action(‘init’, ‘custom_taxonomy_product_tag’, 0); // 5. 添加产品列表页的自定义列 function add_product_columns($columns) { $new_columns = array(); foreach ($columns as $key => $value) { if ($key == ‘title’) { $new_columns[‘thumbnail’] = __(‘缩略图’, ‘my-theme’); } $new_columns[$key] = $value; } $new_columns[‘categories’] = __(‘产品类别’, ‘my-theme’); return $new_columns; } add_filter(‘manage_product_posts_columns’, ‘add_product_columns’); // 6. 显示产品列表页自定义列内容 function display_product_columns($column, $post_id) { switch ($column) { case ‘thumbnail’: echo get_the_post_thumbnail($post_id, array(60, 60)); break; case ‘categories’: $terms = get_the_terms($post_id, ‘product_category’); if (!empty($terms) && !is_wp_error($terms)) { $output = array(); foreach ($terms as $term) { $output[] = sprintf( ‘%s‘, esc_url(admin_url(‘edit.php?product_category=’ . $term->slug . ‘&post_type=product’)), esc_html($term->name) ); } echo join(‘, ‘, $output); } else { echo ‘—’; } break; } } add_action(‘manage_product_posts_custom_column’, ‘display_product_columns’, 10, 2); // 7. 重写规则管理 – 主题激活时刷新 function theme_activation_flush_rewrite() { custom_taxonomy_product_category(); custom_taxonomy_product_tag(); custom_post_type_product(); flush_rewrite_rules(); update_option(‘product_rewrite_flushed’, false); } add_action(‘after_switch_theme’, ‘theme_activation_flush_rewrite’); // 8. 后台通知 function product_category_rewrite_notice() { $screen = get_current_screen(); if (strpos($screen->id, ‘product’) === false && $screen->id !== ‘options-permalink’) { return; } $rewrite_flushed = get_option(‘product_rewrite_flushed’, false); if (!$rewrite_flushed) { echo ‘

‘ . __(‘产品URL结构已更新,请前往’, ‘my-theme’) . ‘ ‘ . __(‘固定链接设置’, ‘my-theme’) . ‘ ‘ . __(‘并点击”保存更改”以刷新重写规则。’, ‘my-theme’) . ‘

‘; } } add_action(‘admin_notices’, ‘product_category_rewrite_notice’); // 9. 记录重写规则刷新状态 function mark_rewrite_flushed_on_save() { update_option(‘product_rewrite_flushed’, true); } add_action(‘update_option_permalink_structure’, ‘mark_rewrite_flushed_on_save’); // 10. 注册查询变量 function product_category_query_vars($vars) { $vars[] = ‘product_category’; return $vars; } add_filter(‘query_vars’, ‘product_category_query_vars’); // 11. 产品分类添加编辑器(添加页面) function add_product_category_editor_field() { ?>
‘product_category_content’, ‘media_buttons’ => true, ‘textarea_rows’ => 10, ‘tinymce’ => array( ‘theme_advanced_buttons1’ => ‘bold,italic,strikethrough,separator,bullist,numlist,separator,blockquote,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,separator,spellchecker,wp_fullscreen,wp_adv’, ), ); wp_editor(”, ‘product_category_content’, $settings); ?>

term_id, ‘product_category_content’, true); $content = wpautop($content, false); ?> ‘product_category_content’, ‘media_buttons’ => true, ‘textarea_rows’ => 10, ‘tinymce’ => array( ‘theme_advanced_buttons1’ => ‘bold,italic,strikethrough,separator,bullist,numlist,separator,blockquote,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,separator,spellchecker,wp_fullscreen,wp_adv’, ), ); wp_editor($content, ‘product_category_content’, $settings); ?>

post_type) { $permalink = str_replace(‘/product-category’, ”, $permalink); } return $permalink; } // 18. 为每个分类动态生成扁平化rewrite规则(只用自身slug,无父级层级) function rws_custom_rewrite_rules($rules) { $new_rules = array(); // 取出所有 product_category(包含隐藏和空的) $terms = get_terms(array( ‘taxonomy’ => ‘product_category’, ‘hide_empty’ => false, )); if (!is_wp_error($terms) && !empty($terms)) { // 分类页和Feed规则 foreach ($terms as $term) { $slug = $term->slug; // 只用自身slug,扁平结构 $safe_slug = preg_quote($slug, ‘/’); // 分类列表页面规则 $new_rules[“^{$safe_slug}/?$”] = “index.php?product_category={$term->slug}”; // 分类Feed规则 $new_rules[“^{$safe_slug}/(feed|rdf|rss|rss2|atom)/?$”] = “index.php?product_category={$term->slug}&feed=$matches[1]”; // 产品详情页规则 (分类slug + 产品slug) $new_rules[“^{$safe_slug}/([^/]+)/?$”] = “index.php?product=$matches[1]”; // 产品详情页分页规则 $new_rules[“^{$safe_slug}/([^/]+)/page/([0-9]+)/?$”] = “index.php?product=$matches[1]&paged=$matches[2]”; } } // 新规则排在最前面(优先于默认规则) return $new_rules + $rules; } function custom_product_post_link($post_link, $post) { if ($post->post_type == ‘product’ && $post->post_status == ‘publish’) { return home_url(‘/’ . $post->post_name . ‘/’); } return $post_link; } add_filter(‘post_type_link’, ‘custom_product_post_link’, 10, 2); function custom_product_rewrite_rules() { add_rewrite_rule( ‘^([^/]+)/?$’, ‘index.php?post_type=product&name=$matches[1]’, ‘top’ ); } add_action(‘init’, ‘custom_product_rewrite_rules’);】有什么问题?

2025年8月26日 by 一个老不正经

请问以下代码有什么问题:【 _x(‘产品’, ‘post type general name’, ‘my-theme’), ‘singular_name’ => _x(‘产品’, ‘post type singular name’, ‘my-theme’), ‘menu_name’ => _x(‘产品’, ‘admin menu’, ‘my-theme’), ‘name_admin_bar’ => _x(‘产品’, ‘add new on admin bar’, ‘my-theme’), ‘add_new’ => _x(‘添加新商品’, ‘product’, ‘my-theme’), ‘add_new_item’ => __(‘添加新商品’, ‘my-theme’), ‘new_item’ => __(‘新商品’, ‘my-theme’), ‘edit_item’ => __(‘编辑商品’, ‘my-theme’), ‘view_item’ => __(‘查看商品’, ‘my-theme’), ‘all_items’ => __(‘所有商品’, ‘my-theme’), ‘search_items’ => __(‘搜索商品’, ‘my-theme’), ‘parent_item_colon’ => __(‘父级商品:’, ‘my-theme’), ‘not_found’ => __(‘未找到商品。’, ‘my-theme’), ‘not_found_in_trash’ => __(‘回收站中未找到商品。’, ‘my-theme’) ); $args = array( ‘labels’ => $labels, ‘public’ => true, ‘publicly_queryable’ => true, ‘show_ui’ => true, ‘show_in_menu’ => true, ‘menu_icon’ => ‘dashicons-cart’, ‘query_var’ => true, ‘rewrite’ => array(‘slug’ => ‘products’, ‘with_front’ => false), ‘capability_type’ => ‘post’, ‘has_archive’ => true, ‘hierarchical’ => false, ‘menu_position’ => 5, ‘supports’ => array(‘title’, ‘editor’, ‘author’, ‘thumbnail’, ‘excerpt’, ‘comments’, ‘revisions’), ‘taxonomies’ => array(‘product_category’, ‘product_tag’), ‘show_in_rest’ => true, ‘rest_base’ => ‘products’, ‘rest_controller_class’ => ‘WP_REST_Posts_Controller’, ); register_post_type(‘product’, $args); } add_action(‘init’, ‘custom_post_type_product’, 11); // 3. 注册产品分类法 – 产品类别 function custom_taxonomy_product_category() { $labels = array( ‘name’ => _x(‘产品类别’, ‘taxonomy general name’, ‘my-theme’), ‘singular_name’ => _x(‘产品类别’, ‘taxonomy singular name’, ‘my-theme’), ‘search_items’ => __(‘搜索类别’, ‘my-theme’), ‘all_items’ => __(‘所有类别’, ‘my-theme’), ‘parent_item’ => __(‘父类别’, ‘my-theme’), ‘parent_item_colon’ => __(‘父类别:’, ‘my-theme’), ‘edit_item’ => __(‘编辑类别’, ‘my-theme’), ‘update_item’ => __(‘更新类别’, ‘my-theme’), ‘add_new_item’ => __(‘添加新类别’, ‘my-theme’), ‘new_item_name’ => __(‘新类别名称’, ‘my-theme’), ‘menu_name’ => __(‘产品类别’, ‘my-theme’), ); $args = array( ‘hierarchical’ => true, // 支持层级管理,URL为扁平 ‘labels’ => $labels, ‘show_ui’ => true, ‘show_admin_column’ => true, ‘query_var’ => true, ‘rewrite’ => array( ‘slug’ => ‘product-category’, ‘with_front’ => false, ‘hierarchical’ => false // 关键:禁用层级URL ), ‘show_in_rest’ => true, ); register_taxonomy(‘product_category’, array(‘product’), $args); } add_action(‘init’, ‘custom_taxonomy_product_category’, 0); // 4. 注册产品标签 function custom_taxonomy_product_tag() { $labels = array( ‘name’ => _x(‘产品标签’, ‘taxonomy general name’, ‘my-theme’), ‘singular_name’ => _x(‘产品标签’, ‘taxonomy singular name’, ‘my-theme’), ‘search_items’ => __(‘搜索标签’, ‘my-theme’), ‘all_items’ => __(‘所有标签’, ‘my-theme’), ‘parent_item’ => null, ‘parent_item_colon’ => null, ‘edit_item’ => __(‘编辑标签’, ‘my-theme’), ‘update_item’ => __(‘更新标签’, ‘my-theme’), ‘add_new_item’ => __(‘添加新标签’, ‘my-theme’), ‘new_item_name’ => __(‘新标签名称’, ‘my-theme’), ‘menu_name’ => __(‘产品标签’, ‘my-theme’), ); $args = array( ‘hierarchical’ => false, ‘labels’ => $labels, ‘show_ui’ => true, ‘show_admin_column’ => true, ‘query_var’ => true, ‘rewrite’ => array(‘slug’ => ‘product-tag’, ‘with_front’ => false), ‘show_in_rest’ => true, ); register_taxonomy(‘product_tag’, array(‘product’), $args); } add_action(‘init’, ‘custom_taxonomy_product_tag’, 0); // 5. 添加产品列表页的自定义列 function add_product_columns($columns) { $new_columns = array(); foreach ($columns as $key => $value) { if ($key == ‘title’) { $new_columns[‘thumbnail’] = __(‘缩略图’, ‘my-theme’); } $new_columns[$key] = $value; } $new_columns[‘categories’] = __(‘产品类别’, ‘my-theme’); return $new_columns; } add_filter(‘manage_product_posts_columns’, ‘add_product_columns’); // 6. 显示产品列表页自定义列内容 function display_product_columns($column, $post_id) { switch ($column) { case ‘thumbnail’: echo get_the_post_thumbnail($post_id, array(60, 60)); break; case ‘categories’: $terms = get_the_terms($post_id, ‘product_category’); if (!empty($terms) && !is_wp_error($terms)) { $output = array(); foreach ($terms as $term) { $output[] = sprintf( ‘%s‘, esc_url(admin_url(‘edit.php?product_category=’ . $term->slug . ‘&post_type=product’)), esc_html($term->name) ); } echo join(‘, ‘, $output); } else { echo ‘—’; } break; } } add_action(‘manage_product_posts_custom_column’, ‘display_product_columns’, 10, 2); // 7. 重写规则管理 – 主题激活时刷新 function theme_activation_flush_rewrite() { custom_taxonomy_product_category(); custom_taxonomy_product_tag(); custom_post_type_product(); flush_rewrite_rules(); update_option(‘product_rewrite_flushed’, false); } add_action(‘after_switch_theme’, ‘theme_activation_flush_rewrite’); // 8. 后台通知 function product_category_rewrite_notice() { $screen = get_current_screen(); if (strpos($screen->id, ‘product’) === false && $screen->id !== ‘options-permalink’) { return; } $rewrite_flushed = get_option(‘product_rewrite_flushed’, false); if (!$rewrite_flushed) { echo ‘

‘ . __(‘产品URL结构已更新,请前往’, ‘my-theme’) . ‘ ‘ . __(‘固定链接设置’, ‘my-theme’) . ‘ ‘ . __(‘并点击”保存更改”以刷新重写规则。’, ‘my-theme’) . ‘

‘; } } add_action(‘admin_notices’, ‘product_category_rewrite_notice’); // 9. 记录重写规则刷新状态 function mark_rewrite_flushed_on_save() { update_option(‘product_rewrite_flushed’, true); } add_action(‘update_option_permalink_structure’, ‘mark_rewrite_flushed_on_save’); // 10. 注册查询变量 function product_category_query_vars($vars) { $vars[] = ‘product_category’; return $vars; } add_filter(‘query_vars’, ‘product_category_query_vars’); // 11. 产品分类添加编辑器(添加页面) function add_product_category_editor_field() { ?>
‘product_category_content’, ‘media_buttons’ => true, ‘textarea_rows’ => 10, ‘tinymce’ => array( ‘theme_advanced_buttons1’ => ‘bold,italic,strikethrough,separator,bullist,numlist,separator,blockquote,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,separator,spellchecker,wp_fullscreen,wp_adv’, ), ); wp_editor(”, ‘product_category_content’, $settings); ?>

term_id, ‘product_category_content’, true); $content = wpautop($content, false); ?> ‘product_category_content’, ‘media_buttons’ => true, ‘textarea_rows’ => 10, ‘tinymce’ => array( ‘theme_advanced_buttons1’ => ‘bold,italic,strikethrough,separator,bullist,numlist,separator,blockquote,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,separator,spellchecker,wp_fullscreen,wp_adv’, ), ); wp_editor($content, ‘product_category_content’, $settings); ?>

post_type) { $permalink = str_replace(‘/product-category’, ”, $permalink); } return $permalink; } // 18. 为每个分类动态生成扁平化rewrite规则(只用自身slug,无父级层级) function rws_custom_rewrite_rules($rules) { $new_rules = array(); // 取出所有 product_category(包含隐藏和空的) $terms = get_terms(array( ‘taxonomy’ => ‘product_category’, ‘hide_empty’ => false, )); if (!is_wp_error($terms) && !empty($terms)) { // 分类页和Feed规则 foreach ($terms as $term) { $slug = $term->slug; // 只用自身slug,扁平结构 $safe_slug = preg_quote($slug, ‘/’); // 分类列表页面规则 $new_rules[“^{$safe_slug}/?$”] = “index.php?product_category={$term->slug}”; // 分类Feed规则 $new_rules[“^{$safe_slug}/(feed|rdf|rss|rss2|atom)/?$”] = “index.php?product_category={$term->slug}&feed=$matches[1]”; // 产品详情页规则 (分类slug + 产品slug) $new_rules[“^{$safe_slug}/([^/]+)/?$”] = “index.php?product=$matches[1]”; // 产品详情页分页规则 $new_rules[“^{$safe_slug}/([^/]+)/page/([0-9]+)/?$”] = “index.php?product=$matches[1]&paged=$matches[2]”; } } // 新规则排在最前面(优先于默认规则) return $new_rules + $rules; } function custom_product_post_link($post_link, $post) { if ($post->post_type == ‘product’ && $post->post_status == ‘publish’) { return home_url(‘/’ . $post->post_name . ‘/’); } return $post_link; } add_filter(‘post_type_link’, ‘custom_product_post_link’, 10, 2); function custom_product_rewrite_rules() { add_rewrite_rule( ‘^([^/]+)/?$’, ‘index.php?post_type=product&name=$matches[1]’, ‘top’ ); } add_action(‘init’, ‘custom_product_rewrite_rules’);】

2025年8月25日 by 一个老不正经

以下是wp主题里面的自定义分类法代码:【 _x(‘产品’, ‘帖子类型通用名称’, ‘my-theme’), ‘singular_name’ => _x(‘产品’, ‘帖子类型单数名称’, ‘my-theme’), ‘menu_name’ => _x(‘产品’, ‘管理菜单’, ‘my-theme’), ‘name_admin_bar’ => _x(‘产品’, ‘在管理栏添加新品’, ‘my-theme’), ‘add_new’ => _x(‘添加新商品’, ‘product’, ‘my-theme’), ‘add_new_item’ => __(‘添加新商品’, ‘my-theme’), ‘new_item’ => __(‘新商品’, ‘我的主题’), ‘edit_item’ => __(‘编辑商品’, ‘我的主题’), ‘view_item’ => __(‘查看商品’, ‘我的主题’), ‘all_items’ => __(‘所有商品’, ‘我的主题’), ‘search_items’ => __(‘搜索商品’, ‘我的主题’), ‘parent_item_colon’ => __(‘父级商品:’, ‘my-theme’), ‘not_found’ => __(‘未找到商品。’, ‘my-theme’), ‘not_found_in_trash’ => __(‘回收站中未找到商品。’, ‘my-theme’) ); $args = array( ‘labels’ => $labels, ‘public’ => true, ‘publicly_queryable’ => true, ‘show_ui’ => true, ‘show_in_menu’ => true, ‘menu_icon’ => ‘dashicons-cart’, ‘query_var’ => true, ‘rewrite’ => array(‘slug’ => ‘products’, ‘with_front’ => false), ‘capability_type’ => ‘post’, ‘has_archive’ => true, ‘hierarchical’ => false, ‘menu_position’ => 5, ‘supports’ => array(‘title’, ‘editor’, ‘author’, ‘thumbnail’, ‘excerpt’, ‘comments’, ‘revisions’), ‘taxonomies’ => array(‘product_category’, ‘product_tag’), ‘show_in_rest’ => true, ‘rest_base’ => ‘产品’, ‘rest_controller_class’ => ‘WP_REST_Posts_Controller’, ); register_post_type(‘产品’,$args); } add_action(‘初始化’, ‘custom_post_type_product’, 11); // 3. 注册产品分类法 – 产品类别 function custom_taxonomy_product_category() { $labels = array( ‘name’ => _x(‘产品类别’, ‘分类通用名称’, ‘my-theme’), ‘singular_name’ => _x(‘产品类别’, ‘分类单数名称’, ‘my-theme’), ‘search_items’ => __(‘搜索类别’, ‘我的主题’), ‘all_items’ => __(‘所有类别’, ‘我的主题’), ‘parent_item’ => __(‘父类别’, ‘我的主题’), ‘parent_item_colon’ => __(‘父类别:’, ‘我的主题’), ‘edit_item’ => __(‘编辑类别’, ‘my-theme’), ‘update_item’ => __(‘更新类别’, ‘my-theme’), ‘add_new_item’ => __(‘添加新类别’, ‘my-theme’), ‘new_item_name’ => __(‘新类别名称’, ‘my-theme’), ‘menu_name’ => __(‘产品类别’, ‘my-theme’), ); $args = array( ‘hierarchical’ => true, // 支持纸张管理,URL为纸张 ‘labels’ => $labels, ‘show_ui’ => true, ‘show_admin_column’ => true, ‘query_var’ => true, ‘rewrite’ => array( ‘slug’ => ‘product-category’, ‘with_front’ => false, ‘hierarchical’ => false //关键:取消系统URL ), ‘show_in_rest’ => true, ); register_taxonomy(‘product_category’, array(‘product’), $args); } add_action(‘初始化’, ‘custom_taxonomy_product_category’, 0); // 4. 注册产品标签 function custom_taxonomy_product_tag() { $labels = array( ‘name’ => _x(‘产品标签’, ‘分类通用名称’, ‘my-theme’), ‘singular_name’ => _x(‘产品标签’, ‘分类单数名称’, ‘my-theme’), ‘search_items’ => __(‘搜索标签’, ‘my-theme’), ‘all_items’ => __(‘所有标签’, ‘我的主题’), ‘parent_item’ => null, ‘parent_item_colon’ => null, ‘edit_item’ => __(‘编辑标签’, ‘我的主题’), ‘update_item’ => __(‘更新标签’, ‘我的主题’), ‘add_new_item’ => __(‘添加新标签’, ‘我的主题’), ‘new_item_name’ => __(‘新标签名称’, ‘我的主题’), ‘menu_name’ => __(‘产品标签’, ‘我的主题’), ); $args = array( ‘hierarchical’ => false, ‘labels’ => $labels,’show_ui’ => true, ‘show_admin_column’ => true, ‘query_var’ => true, ‘rewrite’ => array(‘slug’ => ‘product-tag’, ‘with_front’ => false), ‘show_in_rest’ => true, ); register_taxonomy(‘product_tag’, array(‘product’), $args); } add_action(‘init’, ‘custom_taxonomy_product_tag’, 0); // 5. 添加产品列表页的自定义列 function add_product_columns($columns) { $new_columns = array(); foreach ($columns as $key => $value) { if ($key == ‘title’) { $new_columns[‘thumbnail’] = __(‘缩略图’, ‘my-theme’); } $new_columns[$key] = $value; } $new_columns[‘categories’] = __(‘产品类别’, ‘my-theme’); return $new_columns; } add_filter(‘manage_product_posts_columns’, ‘add_product_columns’); // 6. 显示产品列表页自定义列内容 function display_product_columns($column, $post_id) { switch ($column) { case ‘thumbnail’: echo get_the_post_thumbnail($post_id, array(60, 60)); break; case ‘categories’: $terms = get_the_terms($post_id, ‘product_category’); if (!empty($terms) && !is_wp_error($terms)) { $output = array(); foreach ($terms as $term) { $output[] = sprintf( ‘%s‘, esc_url(admin_url(‘edit.php?product_category=’ . $term->slug . ‘&post_type=product’)), esc_html($term->name) ); } echo join(‘, ‘, $output); } else { echo ‘—’; } break; } } add_action(‘manage_product_posts_custom_column’, ‘display_product_columns’, 10, 2); // 7. 重写规则管理 – 主题激活时刷新 function theme_activation_flush_rewrite() { custom_taxonomy_product_category(); custom_taxonomy_product_tag(); custom_post_type_product(); flush_rewrite_rules(); update_option(‘product_rewrite_flushed’, false); } add_action(‘after_switch_theme’, ‘theme_activation_flush_rewrite’); // 8. 后台通知 function product_category_rewrite_notice() { $screen = get_current_screen(); if (strpos($screen->id, ‘product’) === false && $screen->id !== ‘options-permalink’) { return; } $rewrite_flushed = get_option(‘product_rewrite_flushed’, false); if (!$rewrite_flushed) { echo ‘

‘ . __(‘产品URL结构已更新,请前往’, ‘my-theme’) . ‘ ‘ . __(‘固定链接设置’, ‘my-theme’) . ‘ ‘ . __(‘并点击”保存更改”以刷新规则。’, ‘my-theme’) . ‘

‘; } } add_action(‘admin_notices’, ‘product_category_rewrite_notice’); // 9. 记录重写规则刷新状态函数mark_rewrite_flushed_on_save() { update_option(‘product_rewrite_flushed’, true); } add_action(‘update_option_permalink_struct’, ‘mark_rewrite_flushed_on_save’); // 10. 注册查询函数product_category_query_vars($vars) { $vars[] = ‘product_category’; } add_filter(‘query_vars’, ‘产品类别查询变量’); // 11. 产品分类添加编辑器(添加页面) function add_product_category_editor_field() { ?>
‘product_category_content’, ‘media_buttons’ => true, ‘textarea_rows’ => 10, ‘tinymce’ => array( ‘theme_advanced_buttons1’ => ‘粗体、斜体、删除线、分隔符、bullist、numlist、分隔符、块引用、分隔符、justifyleft、justifycenter、justifyright、分隔符、链接、取消链接、分隔符、拼写检查器、wp_fullscreen、wp_adv’, ), ); wp_editor(”, ‘product_category_content’, $settings); ?>

term_id, ‘product_category_content’, true); $content = wpautop($content, false); ?> ‘product_category_content’, ‘media_buttons’ => true, ‘textarea_rows’ => 10, ‘tinymce’ => array( ‘theme_advanced_buttons1’ => ‘粗体、斜体、删除线、分隔符、bullist、numlist、分隔符、blockquote、分隔符、左对齐、居中对齐、右对齐、分隔符、链接、取消链接、分隔符、拼写检查器、wp_fullscreen、wp_adv’, ), ); wp_editor($content, ‘product_category_content’,$设置); ?>

post_type) { $permalink = str_replace(‘/product-category’, ”, $permalink);返回$永久链接; } // 18. 为每个分类动态生成海绵化重写规则(只用自身slug,无父级系统) function rws_custom_rewrite_rules($rules) { $new_rules = array(); // 取出所有product_category(包含隐藏和空的) $terms = get_terms(array( ‘taxonomy’ => ‘product_category’, ‘hide_empty’ => false, )); if (!is_wp_error($terms) && !empty($terms)) { // 分类页和 Feed 规则 foreach ($terms as $term) { $slug = $term->slug; // 只用自身slug,纸张结构 $safe_slug = preg_quote($slug, ‘/’); // 分类列表页面规则 $new_rules[“^{$safe_slug}/?$”] = “index.php?product_category={$term->slug}”; // 分类Feed规则 $new_rules[“^{$safe_slug}/(feed|rdf|rss|rss2|atom)/?$”] = “index.php?product_category={$term->slug}&feed=$matches[1]”; // 产品详情页规则 (分类slug + 产品slug) $new_rules[“^{$safe_slug}/([^/]+)/?$”] = “index.php?product=$matches[1]”; // 产品详情页分页规则$new_rules[“^{$safe_slug}/([^/]+)/page/([0-9]+)/?$”] = “index.php?product=$matches[1]&paged=$matches[2]”; } } // 新规则排在最前面(优先于默认规则) return $new_rules + $rules; } function custom_product_post_link($post_link, $post) { if ($post->post_type == ‘产品’ && $post->post_status == ‘发布’) { return home_url(‘/’ 。 $post->post_name 。 ‘/’);返回 $post_link; add_filter(‘post_type_link’, ‘custom_product_post_link’, 10, 2);函数 custom_product_rewrite_rules() { add_rewrite_rule( ‘^([^/]+)/?$’, ‘index.php?post_type=product&name=$matches[1]’, ‘top’ ); } add_action(‘init’, ‘custom_product_rewrite_rules’);】你先别回我,后面还有,等我发完

2025年8月25日 by 一个老不正经

请问以下代码有什么问题:【flush_rules(); } function no_category_base_deactivate() { remove_filter( ‘category_rewrite_rules’, ‘no_category_base_rewrite_rules’ ); // We don’t want to insert our custom rules again no_category_base_refresh_rules(); } /** * Removes category base. * * @return void */ function no_category_base_permastruct() { global $wp_rewrite; global $wp_version; if ( $wp_version >= 3.4 ) { $wp_rewrite->extra_permastructs[‘category’][‘struct’] = ‘%category%’; } else { $wp_rewrite->extra_permastructs[‘category’][0] = ‘%category%’; } } /** * Adds our custom category rewrite rules. * * @param array $category_rewrite Category rewrite rules. * * @return array */ function no_category_base_rewrite_rules($category_rewrite) { global $wp_rewrite; $category_rewrite = array(); // WPML适配(如果你不用WPML可以忽略) if ( class_exists( ‘Sitepress’ ) ) { global $sitepress; remove_filter( ‘terms_clauses’, array( $sitepress, ‘terms_clauses’ ) ); $categories = get_categories( array( ‘hide_empty’ => false ) ); add_filter( ‘terms_clauses’, array( $sitepress, ‘terms_clauses’ ), 10, 4 ); } else { $categories = get_categories( array( ‘hide_empty’ => false ) ); } foreach( $categories as $category ) { $category_nicename = $category->slug; if ( $category->parent == $category->cat_ID ) { $category->parent = 0; } elseif ( $category->parent != 0 ) { $category_nicename = get_category_parents( $category->parent, false, ‘/’, true ) . $category_nicename; } // 原分页规则(已被新规则替换): // $category_rewrite[“({$category_nicename})/{$wp_rewrite->pagination_base}/?([0-9]{1,})/?$”] = ‘index.php?category_name=$matches[1]&paged=$matches[2]’; // 新分页规则,使 /分类名-page-2/ 生效 $category_rewrite[“{$category_nicename}-page-([0-9]+)/?$”] = ‘index.php?category_name=’.$category_nicename.’&paged=$matches[1]’; // 其它规则照常 $category_rewrite[‘(‘.$category_nicename.’)/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$’] = ‘index.php?category_name=$matches[1]&feed=$matches[2]’; $category_rewrite[‘(‘.$category_nicename.’)/?$’] = ‘index.php?category_name=$matches[1]’; } // 老的 category base重定向支持 $old_category_base = get_option( ‘category_base’ ) ? get_option( ‘category_base’ ) : ‘category’; $old_category_base = trim( $old_category_base, ‘/’ ); $category_rewrite[$old_category_base.’/(.*)$’] = ‘index.php?category_redirect=$matches[1]’; return $category_rewrite; } function no_category_base_query_vars($public_query_vars) { $public_query_vars[] = ‘category_redirect’; return $public_query_vars; } /** * Handles category redirects. * * @param $query_vars Current query vars. * * @return array $query_vars, or void if category_redirect is present. */ function no_category_base_request($query_vars) { if( isset( $query_vars[‘category_redirect’] ) ) { $catlink = trailingslashit( get_option( ‘home’ ) ) . user_trailingslashit( $query_vars[‘category_redirect’], ‘category’ ); status_header( 301 ); header( “Location: $catlink” ); exit(); } return $query_vars; }】

2025年7月30日 by 一个老不正经

我wp站点的分类翻页的URL是这样的【https://gj.seoyh.net/zixun/page/*】请问我如何将我这个URL修改成【https://gj.seoyh.net/zixun-page-*】?请给出完整代码

2025年7月30日 by 一个老不正经

// 添加自定义分页重写规则 function custom_pagination_rewrite() { // 支持首页分页 /-page-2/ add_rewrite_rule( ‘^-page-([0-9]+)/?$’, ‘index.php?paged=$matches[1]’, ‘top’ ); // 支持其他页面(如分类、标签等)的分页 /xxx/-page-2/ add_rewrite_rule( ‘^(.*)/-page-([0-9]+)/?$’, ‘index.php?$matches[1]&paged=$matches[2]’, ‘top’ ); } add_action(‘init’, ‘custom_pagination_rewrite’); // 替换分页链接的URL结构 function custom_pagination_base($link) { // 替换 /page/2 为 -page-2 $link = preg_replace(‘@/page/([0-9]+)@’, ‘-page-$1’, $link); return $link; } add_filter(‘get_pagenum_link’, ‘custom_pagination_base’); // 确保首页分页正确(一般WordPress已自动处理,以下代码可选) function custom_home_pagination($query) { if ($query->is_main_query() && !is_admin() && $query->is_home()) { $paged = get_query_var(‘paged’); if ($paged) { $query->set(‘paged’, $paged); } } } add_action(‘pre_get_posts’, ‘custom_home_pagination’); 以上代码,当点击翻页之后第二页变成了404页面

2025年7月30日 by 一个老不正经

以下代码【// 添加自定义分页重写规则 function custom_pagination_rewrite() { add_rewrite_rule( ‘^page-([0-9]+)/?$’, ‘index.php?paged=$matches[1]’, ‘top’ ); } add_action(‘init’, ‘custom_pagination_rewrite’); // 替换分页链接的URL结构 function custom_pagination_base($link) { return str_replace(‘/page/’, ‘-page-‘, $link); } add_filter(‘get_pagenum_link’, ‘custom_pagination_base’); // 兼容首页分页 function custom_home_pagination($query) { if ($query->is_main_query() && !is_admin() && $query->is_home() && get_query_var(‘page’)) { $query->set(‘paged’, get_query_var(‘page’)); } } add_action(‘pre_get_posts’, ‘custom_home_pagination’); 】我需要将分页修改成【-page-】请问上面代码是否正确,如果不正确请问如何修正?请给出修正后的完整代码

2025年7月30日 by 一个老不正经

以下代码不生效:【// 1. 添加分页重写规则 function custom_pagination_rewrite_rules() { // 主页分页,如 /p/2/ add_rewrite_rule(‘^p/([0-9]+)/?$’, ‘index.php?paged=$matches[1]’, ‘top’); // 分类分页,如 /category/yourcat/p/2/ add_rewrite_rule(‘^category/([^/]+)/p/([0-9]+)/?$’, ‘index.php?category_name=$matches[1]&paged=$matches[2]’, ‘top’); // 标签分页,如 /tag/yourtag/p/2/ add_rewrite_rule(‘^tag/([^/]+)/p/([0-9]+)/?$’, ‘index.php?tag=$matches[1]&paged=$matches[2]’, ‘top’); // 日期归档分页,如 /2024/07/p/2/ add_rewrite_rule(‘^([0-9]{4})/([0-9]{2})/p/([0-9]+)/?$’, ‘index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]’, ‘top’); // 搜索分页,如 /search/关键字/p/2/(根据你实际伪静态结构可调整) add_rewrite_rule(‘^search/(.+)/p/([0-9]+)/?$’, ‘index.php?s=$matches[1]&paged=$matches[2]’, ‘top’); } add_action(‘init’, ‘custom_pagination_rewrite_rules’); // 2. 替换分页链接中的 /page/ 为 /p/ function custom_pagination_base($link) { if (preg_match(‘~/page/([0-9]+)/~’, $link, $m)) { $link = str_replace(“/page/{$m[1]}/”, “/p/{$m[1]}/”, $link); } return $link; } add_filter(‘get_pagenum_link’, ‘custom_pagination_base’); // 3. 切换 category/tag/author/日期类列表的分页URL function custom_archive_pagination_links($link) { // 只处理含分页的链接 if (preg_match(‘~/(category|tag|author|[0-9]{4}/[0-9]{2}|search/.+)-page-([0-9]+)/~’, $link, $m)) { $link = str_replace(“/page/{$m[2]}/”, “/p-{$m[2]}-“, $link); } return $link; } add_filter(‘paginate_links’, ‘custom_archive_pagination_links’); // 4. 兼容首页的翻页 function custom_fix_home_pagination($query) { if ($query->is_main_query() && !is_admin() && $query->is_home() && get_query_var(‘page’) && !get_query_var(‘paged’)) { $query->set(‘paged’, get_query_var(‘page’)); } } add_action(‘pre_get_posts’, ‘custom_fix_home_pagination’); 】

2025年7月30日 by 一个老不正经

请问如何自定义wp分页的URL

2025年7月30日 by 一个老不正经

报错:【 https://wptea.com/feed/ cURL error 28: Operation timed out after 1000 milliseconds with 0 bytes received WP_SimplePie_File->__construct() wp-includes/class-wp-simplepie-file.php:69 ReflectionClass->newInstanceArgs() wp-includes/class-wp-simplepie-file.php:69 SimplePieRegistry->create() wp-includes/SimplePie/src/Registry.php:228 SimplePieSimplePie->fetch_data() wp-includes/SimplePie/src/SimplePie.php:1775 SimplePieSimplePie->init() wp-includes/SimplePie/src/SimplePie.php:1589 fetch_feed() wp-includes/feed.php:844 wp_widget_rss_output() wp-includes/widgets.php:1587 WenPaiCSSuper->WenPaiCS{closure}() wp-content/plugins/wp-china-yes/Service/Super.php:45 do_meta_boxes() wp-admin/includes/template.php:1456 wp_dashboard() wp-admin/includes/dashboard.php:271 WordPress 核心 1 1.0086 GET https://wptea.com/feed/ 200 OK WP_SimplePie_File->__construct() wp-includes/class-wp-simplepie-file.php:69 ReflectionClass->newInstanceArgs() wp-includes/class-wp-simplepie-file.php:69 SimplePieRegistry->create() wp-includes/SimplePie/src/Registry.php:228 SimplePieSimplePie->fetch_data() wp-includes/SimplePie/src/SimplePie.php:1817 SimplePieSimplePie->init() wp-includes/SimplePie/src/SimplePie.php:1589 fetch_feed() wp-includes/feed.php:844 wp_widget_rss_output() wp-includes/widgets.php:1587 WenPaiCSSuper->WenPaiCS{closure}() wp-content/plugins/wp-china-yes/Service/Super.php:45 do_meta_boxes() wp-admin/includes/template.php:1456 wp_dashboard() wp-admin/includes/dashboard.php:271】

2025年7月29日 by 一个老不正经

请问【】什么意思?

2025年7月25日 by 一个老不正经

请问以下火车头插件代码有什么问题?【#作者:淘小白 # vx:TXB2196 # 官网:i-uni.cn import sys,importlib from urllib import parse import json import requests import urllib import re import random import time import openai import os def get_openai(question, apikey): # try: os.system(”) openai.api_key = apikey response = openai.ChatCompletion.create( model=”gpt-3.5-turbo-16k”, n=1, max_tokens = 8690, temperature = 0.8, top_p=0.5, frequency_penalty = 1.2, messages=[ {“role”: “system”, “content”: “你是一名全能的文案编辑专家”}, {“role”: “user”, “content”: question} ] ) return response[‘choices’][0][‘message’][‘content’] # except Exception as e: # print(e) # pass def get_newcontent(apikey, question): new_content = get_openai(question, apikey) if new_content: return new_content # if __name__ == ‘__main__’: # apikey = ‘sk-DYFhSBRnA10yx676QPGhJVBsEBBkCs0keAw7CCtTlw0qziT8’ # question = ‘写一篇关于春天的标题’ # aa = get_newcontent(apikey, question) # print(aa) if len(sys.argv)!= 5: print(len(sys.argv)) print(“命令行参数长度不为5″) sys.exit() else: LabelCookie = parse.unquote(sys.argv[1]) LabelUrl = parse.unquote(sys.argv[2]) #PageType为List,Content,Pages分别代表列表页,内容页,多页http请求处理,Save代表内容处理 PageType=sys.argv[3] SerializerStr = parse.unquote(sys.argv[4]) if (SerializerStr[0:2] != ”'{“”’): file_object = open(SerializerStr) try: SerializerStr = file_object.read() SerializerStr = parse.unquote(SerializerStr) finally: file_object.close() LabelArray = json.loads(SerializerStr) #以下是用户编写代码区域 if(PageType==”Save”): apikey = LabelArray[‘apikey’] zl_instructions = LabelArray[‘指令’] title_instructions = LabelArray[‘标题指令’] old_content = LabelArray[‘内容1’] old_title = LabelArray[‘标题1’] question = zl_instructions + old_content apikey_lst = re.split(‘n’,apikey) a_apikeys = [] for i in apikey_lst: i = i.strip() a_apikeys.append(i) try: n = 0 while True: if n < 5: use_apikey = random.choice(a_apikeys) title_question = title_instructions + old_title new_title = get_openai(title_question, use_apikey) if new_title: use_apikey = random.choice(a_apikeys) new_content = get_openai(question, use_apikey) if new_content: LabelArray['AI内容'] = new_content LabelArray['AI标题'] = new_title # LabelArray['AI标题'] = old_title+' '+new_title break else: pass else: LabelArray['AI内容'] = '' n += 1 except Exception as e: LabelArray['AI内容'] = e else: LabelArray['Html']='当前页面的网址为:'+ LabelUrl +"rn页面类型为:" + PageType + "rnCookies数据为:"+LabelCookie+"rn接收到的数据是:" + LabelArray['Html'] #以上是用户编写代码区域 LabelArray = json.dumps(LabelArray) print(LabelArray)】

2025年7月21日 by 一个老不正经

我这边有一个wp的数据库分表插件: 一、结构: ydb-bd –web —-axjs.js —-style.css –ydb-bd.php【插件主文件】 –ydb-admin —-index.php【控制面板】 –ydb-query.php【查询修改功能】 –inc —-posts.php【wp_posts分表功能代码】 —-postmeta.php【wp_postmeta分表功能代码】 ydb-bd.php【插件主文件】文件代码:【 false, ‘data’=>’无权限’]); } $changed = false; if (isset($_POST[‘posts_toggle’])) { update_option(‘ydb_bd_posts_query_toggle’, intval($_POST[‘posts_toggle’]) ? 1 : 0); $changed = true; } if (isset($_POST[‘postmeta_toggle’])) { update_option(‘ydb_bd_postmeta_query_toggle’, intval($_POST[‘postmeta_toggle’]) ? 1 : 0); $changed = true; } if ($changed) { wp_send_json([‘success’=>true, ‘data’=>’设置成功’]); } else { wp_send_json([‘success’=>false, ‘data’=>’参数错误’]); } } // AJAX:获取分表查询开关状态 function ydb_bd_get_query_toggle() { if (!current_user_can(‘manage_options’)) { wp_send_json([‘success’=>false, ‘data’=>’无权限’]); } $posts = get_option(‘ydb_bd_posts_query_toggle’, 1); $meta = get_option(‘ydb_bd_postmeta_query_toggle’, 1); wp_send_json([‘success’=>true, ‘data’=>[ ‘posts_toggle’ => $posts, ‘postmeta_toggle’ => $meta, ]]); } 】 index.php【控制面板】文件代码【 window.ajaxurl = "";

YDB分表控制面板

wp_posts表管理

get_col(“SELECT DISTINCT post_type FROM {$wpdb->posts} WHERE post_type != ‘oembed_cache'”); foreach($types as $type){ echo ‘‘ . esc_html($type) . ‘‘; } ?>

wp_postmeta表管理

查询功能管理


】 axjs.js【 // 工具函数:原生ajax POST function ajaxPost(url, data, callback) { var xhr = new XMLHttpRequest(); var params = Object.keys(data).map( k => encodeURIComponent(k) + ‘=’ + encodeURIComponent(data[k]) ).join(‘&’); xhr.open(‘POST’, url, true); xhr.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’); xhr.onreadystatechange = function(){ if(xhr.readyState === 4){ if(xhr.status === 200){ try { var resp = JSON.parse(xhr.responseText); callback(resp); } catch(e){ callback({success:false,data:’数据解析失败’}); } } else { callback({success:false,data:’网络错误’}); } } }; xhr.send(params); } // 进度条动画 function animateProgressBar(selector, percent) { var bar = document.querySelector(selector); if(bar){ bar.style.width = ‘0’; setTimeout(function(){ bar.style.width = percent + ‘%’; }, 100); } } // wp_posts 分表操作 function ydbBdPostsSplit(type){ var msg = document.querySelector(‘.ydb-bd-posts-status-msg’); if(msg) msg.textContent = ‘处理中,请稍候…’; animateProgressBar(‘.ydb-bd-posts-progress-bar’, 30); ajaxPost(window.ajaxurl, {action:’ydb_bd_posts_split’, action_type:type}, function(res){ if(msg) { msg.textContent = res.data; msg.className = ‘ydb-bd-status-msg ydb-bd-posts-status-msg ‘ + (res.success ? ‘ydb-bd-success’ : ‘ydb-bd-error’); } animateProgressBar(‘.ydb-bd-posts-progress-bar’, 100); setTimeout(ydbBdPostsStatus, 800); }); } function ydbBdPostsStatus(){ ajaxPost(window.ajaxurl, {action:’ydb_bd_posts_split_status’}, function(res){ var html = ‘‘; for(var k in res.data){ html += ``; } html += ‘
类型数量分表状态
${k} ${res.data[k].count} ${res.data[k].table_exists ? ‘已分表‘ : ‘未分表‘}
‘; var statusDiv = document.getElementById(‘ydb-bd-posts-status’); if(statusDiv) statusDiv.innerHTML = html; }); } // wp_postmeta 分表操作 function ydbBdPostmetaSplit(type){ var msg = document.querySelector(‘.ydb-bd-postmeta-status-msg’); if(msg) msg.textContent = ‘处理中,请稍候…’; animateProgressBar(‘.ydb-bd-postmeta-progress-bar’, 30); ajaxPost(window.ajaxurl, {action:’ydb_bd_postmeta_split’, action_type:type}, function(res){ if(msg) { msg.textContent = res.data; msg.className = ‘ydb-bd-status-msg ydb-bd-postmeta-status-msg ‘ + (res.success ? ‘ydb-bd-success’ : ‘ydb-bd-error’); } animateProgressBar(‘.ydb-bd-postmeta-progress-bar’, 100); setTimeout(ydbBdPostmetaStatus, 800); }); } function ydbBdPostmetaStatus(){ ajaxPost(window.ajaxurl, {action:’ydb_bd_postmeta_split_status’}, function(res){ var html = ‘‘; for(var k in res.data){ html += ``; } html += ‘
meta_key数量分表状态
${k} ${res.data[k].count} ${res.data[k].table_exists ? ‘已分表‘ : ‘未分表‘}
‘; var statusDiv = document.getElementById(‘ydb-bd-postmeta-status’); if(statusDiv) statusDiv.innerHTML = html; }); } // 新增:status文本初始化 function initQueryStatus(status, spanSelector) { var span = document.querySelector(spanSelector); if(!span) return; if (status === 1) { span.textContent = ‘分表查询已开启’; } else { span.textContent = ‘已恢复原查询’; } } // 查询功能开关(分表查询 On/Off,修正:回调展示状态,参数传递不变) function toggleQuerySwitch(inputId, statusClass, actionKey){ var input = document.getElementById(inputId); var statusSpan = document.querySelector(statusClass); if(input){ input.addEventListener(‘change’, function(){ var enabled = input.checked ? 1 : 0; var postData = {}; postData[actionKey] = enabled; postData.action = ‘ydb_bd_set_query_toggle’; ajaxPost(window.ajaxurl, postData, function(res){ // 新增:根据返回内容、状态展示 if(statusSpan) { if(res && res.success){ statusSpan.textContent = enabled ? ‘分表查询已开启’ : ‘已恢复原查询’; } else { statusSpan.textContent = (res && res.data) ? res.data : ‘操作失败’; } } }); }); } } // 类型显示/隐藏按钮 function bindToggleBtn(btnClass, listClass){ var btn = document.querySelector(btnClass); var list = document.querySelector(listClass); if(btn && list){ btn.addEventListener(‘click’, function(){ if(list.classList.contains(‘ydb-bd-hidden’)){ list.classList.remove(‘ydb-bd-hidden’); btn.textContent = ‘隐藏类型’; }else{ list.classList.add(‘ydb-bd-hidden’); btn.textContent = ‘显示类型’; } }); } } // 页面初始化 document.addEventListener(‘DOMContentLoaded’, function(){ setTimeout(ydbBdPostsStatus, 800); setTimeout(ydbBdPostmetaStatus, 800); // 绑定类型显示/隐藏 bindToggleBtn(‘.ydb-bd-toggle-posts-types’, ‘.ydb-bd-posts-types-list’); bindToggleBtn(‘.ydb-bd-toggle-meta-keys’, ‘.ydb-bd-postmeta-keys-list’); // 查询功能切换 toggleQuerySwitch(‘ydb-bd-posts-query-toggle’, ‘.ydb-bd-posts-query-status’, ‘posts_toggle’); toggleQuerySwitch(‘ydb-bd-postmeta-query-toggle’, ‘.ydb-bd-postmeta-query-status’, ‘postmeta_toggle’); // 新增:初始化checkbox状态 和 status 文本 ajaxPost(window.ajaxurl, {action:’ydb_bd_get_query_toggle’}, function(res){ if(res && res.success && res.data){ var postCk = document.getElementById(‘ydb-bd-posts-query-toggle’); var metaCk = document.getElementById(‘ydb-bd-postmeta-query-toggle’); if(postCk) { postCk.checked = res.data.posts_toggle === 1; initQueryStatus(res.data.posts_toggle, ‘.ydb-bd-posts-query-status’); } if(metaCk) { metaCk.checked = res.data.postmeta_toggle === 1; initQueryStatus(res.data.postmeta_toggle, ‘.ydb-bd-postmeta-query-status’); } } }); }); 】 ydb-query.php【查询修改功能】文件代码【 query_vars[‘post_type’])) return $request; $type = $query->query_vars[‘post_type’]; // 兼容性警告:多类型时为数组,暂不分表 if (is_array($type)) return $request; $table = $wpdb->prefix . “posts_{$type}”; $table_exists = $wpdb->get_var($wpdb->prepare(“SHOW TABLES LIKE %s”, $table)); if ($table_exists) { // 用更安全的方式仅替换 FROM `表名` $from_str = “FROM {$wpdb->posts}”; $request = str_replace($from_str, “FROM $table”, $request); } return $request; }, 10, 2); // 查询拦截:meta add_filter(‘get_metadata’, function($value, $object_id, $meta_key, $single) { global $wpdb; if (!$meta_key) return $value; if (!ydb_bd_is_postmeta_split_enabled()) return $value; if (!ydb_bd_is_postmeta_query_toggle()) return $value; $table = $wpdb->prefix . “postmeta_” . md5($meta_key); $table_exists = $wpdb->get_var($wpdb->prepare(“SHOW TABLES LIKE %s”, $table)); if ($table_exists) { $result = $wpdb->get_results($wpdb->prepare(“SELECT meta_value FROM $table WHERE post_id = %d AND meta_key = %s”, $object_id, $meta_key)); $values = wp_list_pluck($result, ‘meta_value’); return $single ? (isset($values[0]) ? maybe_unserialize($values[0]) : ”) : array_map(‘maybe_unserialize’, $values); } return $value; }, 10, 4); 】 posts.php【wp_posts分表功能代码】文件代码【 get_col(“SELECT DISTINCT post_type FROM {$wpdb->posts} WHERE post_type != ‘oembed_cache'”); } // AJAX接口:开启/关闭分表 function ydb_bd_posts_split() { global $wpdb; $action = isset($_POST[‘action_type’]) ? $_POST[‘action_type’] : ”; if ($action === ‘enable’) { $post_types = ydb_bd_get_post_types(); foreach ($post_types as $type) { $table = $wpdb->prefix . “posts_{$type}”; $wpdb->query(“CREATE TABLE IF NOT EXISTS `$table` LIKE {$wpdb->posts}”); $wpdb->query($wpdb->prepare(“INSERT IGNORE INTO `$table` SELECT * FROM {$wpdb->posts} WHERE post_type = %s”, $type)); } // oembed_cache分表 $table = $wpdb->prefix . “posts_oembed_cache”; $wpdb->query(“CREATE TABLE IF NOT EXISTS `$table` LIKE {$wpdb->posts}”); $wpdb->query(“INSERT IGNORE INTO `$table` SELECT * FROM {$wpdb->posts} WHERE post_type = ‘oembed_cache'”); update_option(‘ydb_bd_posts_split_enabled’, 1, true); // 标记为已分表 wp_send_json_success(‘分表已开启’); } else { $post_types = ydb_bd_get_post_types(); foreach ($post_types as $type) { $table = $wpdb->prefix . “posts_{$type}”; $wpdb->query(“DROP TABLE IF EXISTS `$table`”); } $table = $wpdb->prefix . “posts_oembed_cache”; $wpdb->query(“DROP TABLE IF EXISTS `$table`”); update_option(‘ydb_bd_posts_split_enabled’, 0, true); // 标记为未分表 wp_send_json_success(‘分表已关闭’); } wp_die(); } // AJAX接口:分表状态查询 function ydb_bd_posts_split_status() { global $wpdb; $post_types = ydb_bd_get_post_types(); $status = []; foreach ($post_types as $type) { $table = $wpdb->prefix . “posts_{$type}”; $count = $wpdb->get_var($wpdb->prepare(“SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type = %s”, $type)); $table_exists = $wpdb->get_var($wpdb->prepare(“SHOW TABLES LIKE %s”, $table)); $status[$type] = [ ‘count’ => intval($count), ‘table_exists’ => !!$table_exists, ‘split_enabled’ => (int)get_option(‘ydb_bd_posts_split_enabled’, 0) ]; } wp_send_json_success($status); } 】 postmeta.php【wp_postmeta分表功能代码】文件代码【 get_col(“SELECT DISTINCT meta_key FROM {$wpdb->postmeta} WHERE meta_key != ‘oembed_cache'”); } // AJAX接口:开启/关闭分表 function ydb_bd_postmeta_split() { global $wpdb; $action = isset($_POST[‘action_type’]) ? $_POST[‘action_type’] : ”; if ($action === ‘enable’) { $meta_keys = ydb_bd_get_meta_keys(); foreach ($meta_keys as $key) { $table = $wpdb->prefix . “postmeta_” . md5($key); $wpdb->query(“CREATE TABLE IF NOT EXISTS `$table` LIKE {$wpdb->postmeta}”); $wpdb->query($wpdb->prepare(“INSERT IGNORE INTO `$table` SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s”, $key)); } $table = $wpdb->prefix . “postmeta_oembed_cache”; $wpdb->query(“CREATE TABLE IF NOT EXISTS `$table` LIKE {$wpdb->postmeta}”); $wpdb->query(“INSERT IGNORE INTO `$table` SELECT * FROM {$wpdb->postmeta} WHERE meta_key = ‘oembed_cache'”); update_option(‘ydb_bd_postmeta_split_enabled’, 1, true); wp_send_json_success(‘分表已开启’); } else { $meta_keys = ydb_bd_get_meta_keys(); foreach ($meta_keys as $key) { $table = $wpdb->prefix . “postmeta_” . md5($key); $wpdb->query(“DROP TABLE IF EXISTS `$table`”); } $table = $wpdb->prefix . “postmeta_oembed_cache”; $wpdb->query(“DROP TABLE IF EXISTS `$table`”); update_option(‘ydb_bd_postmeta_split_enabled’, 0, true); wp_send_json_success(‘分表已关闭’); } wp_die(); } // AJAX接口:分表状态查询 function ydb_bd_postmeta_split_status() { global $wpdb; $meta_keys = ydb_bd_get_meta_keys(); $status = []; foreach ($meta_keys as $key) { $table = $wpdb->prefix . “postmeta_” . md5($key); $count = $wpdb->get_var($wpdb->prepare(“SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE meta_key = %s”, $key)); $table_exists = $wpdb->get_var($wpdb->prepare(“SHOW TABLES LIKE %s”, $table)); $status[$key] = [ ‘count’ => intval($count), ‘table_exists’ => !!$table_exists, ‘split_enabled’ => (int)get_option(‘ydb_bd_postmeta_split_enabled’, 0) ]; } wp_send_json_success($status); } 】 请帮我在【

查询切换管理


】原有功能上增加设置一个保存勾选状态

2025年7月18日 by 一个老不正经

我这边有一个wp的数据库分表插件: 一、结构: ydb-bd –web —-axjs.js —-style.css –ydb-bd.php【插件主文件】 –ydb-admin —-index.php【控制面板】 –ydb-query.php【查询修改功能】 –inc —-posts.php【wp_posts分表功能代码】 —-postmeta.php【wp_postmeta分表功能代码】 ydb-bd.php【插件主文件】文件代码:【 false, ‘data’=>’无权限’]); } $changed = false; if (isset($_POST[‘posts_toggle’])) { update_option(‘ydb_bd_posts_query_toggle’, intval($_POST[‘posts_toggle’]) ? 1 : 0); $changed = true; } if (isset($_POST[‘postmeta_toggle’])) { update_option(‘ydb_bd_postmeta_query_toggle’, intval($_POST[‘postmeta_toggle’]) ? 1 : 0); $changed = true; } if ($changed) { wp_send_json([‘success’=>true, ‘data’=>’设置成功’]); } else { wp_send_json([‘success’=>false, ‘data’=>’参数错误’]); } } // AJAX:获取分表查询开关状态 function ydb_bd_get_query_toggle() { if (!current_user_can(‘manage_options’)) { wp_send_json([‘success’=>false, ‘data’=>’无权限’]); } $posts = get_option(‘ydb_bd_posts_query_toggle’, 1); $meta = get_option(‘ydb_bd_postmeta_query_toggle’, 1); wp_send_json([‘success’=>true, ‘data’=>[ ‘posts_toggle’ => $posts, ‘postmeta_toggle’ => $meta, ]]); } 】 index.php【控制面板】文件代码【 window.ajaxurl = "";

YDB分表控制面板

wp_posts表管理

get_col(“SELECT DISTINCT post_type FROM {$wpdb->posts} WHERE post_type != ‘oembed_cache'”); foreach($types as $type){ echo ‘‘ . esc_html($type) . ‘‘; } ?>

wp_postmeta表管理

查询功能管理


】 axjs.js【 // 工具函数:原生ajax POST function ajaxPost(url, data, callback) { var xhr = new XMLHttpRequest(); var params = Object.keys(data).map( k => encodeURIComponent(k) + ‘=’ + encodeURIComponent(data[k]) ).join(‘&’); xhr.open(‘POST’, url, true); xhr.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’); xhr.onreadystatechange = function(){ if(xhr.readyState === 4){ if(xhr.status === 200){ try { var resp = JSON.parse(xhr.responseText); callback(resp); } catch(e){ callback({success:false,data:’数据解析失败’}); } } else { callback({success:false,data:’网络错误’}); } } }; xhr.send(params); } // 进度条动画 function animateProgressBar(selector, percent) { var bar = document.querySelector(selector); if(bar){ bar.style.width = ‘0’; setTimeout(function(){ bar.style.width = percent + ‘%’; }, 100); } } // wp_posts 分表操作 function ydbBdPostsSplit(type){ var msg = document.querySelector(‘.ydb-bd-posts-status-msg’); if(msg) msg.textContent = ‘处理中,请稍候…’; animateProgressBar(‘.ydb-bd-posts-progress-bar’, 30); ajaxPost(window.ajaxurl, {action:’ydb_bd_posts_split’, action_type:type}, function(res){ if(msg) { msg.textContent = res.data; msg.className = ‘ydb-bd-status-msg ydb-bd-posts-status-msg ‘ + (res.success ? ‘ydb-bd-success’ : ‘ydb-bd-error’); } animateProgressBar(‘.ydb-bd-posts-progress-bar’, 100); setTimeout(ydbBdPostsStatus, 800); }); } function ydbBdPostsStatus(){ ajaxPost(window.ajaxurl, {action:’ydb_bd_posts_split_status’}, function(res){ var html = ‘‘; for(var k in res.data){ html += ``; } html += ‘
类型数量分表状态
${k} ${res.data[k].count} ${res.data[k].table_exists ? ‘已分表‘ : ‘未分表‘}
‘; var statusDiv = document.getElementById(‘ydb-bd-posts-status’); if(statusDiv) statusDiv.innerHTML = html; }); } // wp_postmeta 分表操作 function ydbBdPostmetaSplit(type){ var msg = document.querySelector(‘.ydb-bd-postmeta-status-msg’); if(msg) msg.textContent = ‘处理中,请稍候…’; animateProgressBar(‘.ydb-bd-postmeta-progress-bar’, 30); ajaxPost(window.ajaxurl, {action:’ydb_bd_postmeta_split’, action_type:type}, function(res){ if(msg) { msg.textContent = res.data; msg.className = ‘ydb-bd-status-msg ydb-bd-postmeta-status-msg ‘ + (res.success ? ‘ydb-bd-success’ : ‘ydb-bd-error’); } animateProgressBar(‘.ydb-bd-postmeta-progress-bar’, 100); setTimeout(ydbBdPostmetaStatus, 800); }); } function ydbBdPostmetaStatus(){ ajaxPost(window.ajaxurl, {action:’ydb_bd_postmeta_split_status’}, function(res){ var html = ‘‘; for(var k in res.data){ html += ``; } html += ‘
meta_key数量分表状态
${k} ${res.data[k].count} ${res.data[k].table_exists ? ‘已分表‘ : ‘未分表‘}
‘; var statusDiv = document.getElementById(‘ydb-bd-postmeta-status’); if(statusDiv) statusDiv.innerHTML = html; }); } // 查询功能开关(分表查询 On/Off,修正:回调展示状态,参数传递不变) function toggleQuerySwitch(inputId, statusClass, actionKey){ var input = document.getElementById(inputId); var statusSpan = document.querySelector(statusClass); if(input){ input.addEventListener(‘change’, function(){ var enabled = input.checked ? 1 : 0; var postData = {}; postData[actionKey] = enabled; postData.action = ‘ydb_bd_set_query_toggle’; ajaxPost(window.ajaxurl, postData, function(res){ // 新增:根据返回内容、状态展示 if(statusSpan) { if(res && res.success){ statusSpan.textContent = enabled ? ‘分表查询已开启’ : ‘已恢复原查询’; } else { statusSpan.textContent = (res && res.data) ? res.data : ‘操作失败’; } } }); }); // 页面刷新时初始化状态(可选,需要后端提供状态接口) // 可根据需要加入 } } // 类型显示/隐藏按钮 function bindToggleBtn(btnClass, listClass){ var btn = document.querySelector(btnClass); var list = document.querySelector(listClass); if(btn && list){ btn.addEventListener(‘click’, function(){ if(list.classList.contains(‘ydb-bd-hidden’)){ list.classList.remove(‘ydb-bd-hidden’); btn.textContent = ‘隐藏类型’; }else{ list.classList.add(‘ydb-bd-hidden’); btn.textContent = ‘显示类型’; } }); } } // 页面初始化 document.addEventListener(‘DOMContentLoaded’, function(){ setTimeout(ydbBdPostsStatus, 800); setTimeout(ydbBdPostmetaStatus, 800); // 绑定类型显示/隐藏 bindToggleBtn(‘.ydb-bd-toggle-posts-types’, ‘.ydb-bd-posts-types-list’); bindToggleBtn(‘.ydb-bd-toggle-meta-keys’, ‘.ydb-bd-postmeta-keys-list’); // 查询功能切换 toggleQuerySwitch(‘ydb-bd-posts-query-toggle’, ‘.ydb-bd-posts-query-status’, ‘posts_toggle’); toggleQuerySwitch(‘ydb-bd-postmeta-query-toggle’, ‘.ydb-bd-postmeta-query-status’, ‘postmeta_toggle’); // 新增:初始化checkbox状态 ajaxPost(window.ajaxurl, {action:’ydb_bd_get_query_toggle’}, function(res){ if(res && res.success && res.data){ var postCk = document.getElementById(‘ydb-bd-posts-query-toggle’); var metaCk = document.getElementById(‘ydb-bd-postmeta-query-toggle’); if(postCk) postCk.checked = res.data.posts_toggle === 1; if(metaCk) metaCk.checked = res.data.postmeta_toggle === 1; } }); }); 】 ydb-query.php【查询修改功能】文件代码【 query_vars[‘post_type’])) return $request; $type = $query->query_vars[‘post_type’]; // 兼容性警告:多类型时为数组,暂不分表 if (is_array($type)) return $request; $table = $wpdb->prefix . “posts_{$type}”; $table_exists = $wpdb->get_var($wpdb->prepare(“SHOW TABLES LIKE %s”, $table)); if ($table_exists) { // 用更安全的方式仅替换 FROM `表名` $from_str = “FROM {$wpdb->posts}”; $request = str_replace($from_str, “FROM $table”, $request); } return $request; }, 10, 2); // 查询拦截:meta add_filter(‘get_metadata’, function($value, $object_id, $meta_key, $single) { global $wpdb; if (!$meta_key) return $value; if (!ydb_bd_is_postmeta_split_enabled()) return $value; if (!ydb_bd_is_postmeta_query_toggle()) return $value; $table = $wpdb->prefix . “postmeta_” . md5($meta_key); $table_exists = $wpdb->get_var($wpdb->prepare(“SHOW TABLES LIKE %s”, $table)); if ($table_exists) { $result = $wpdb->get_results($wpdb->prepare(“SELECT meta_value FROM $table WHERE post_id = %d AND meta_key = %s”, $object_id, $meta_key)); $values = wp_list_pluck($result, ‘meta_value’); return $single ? (isset($values[0]) ? maybe_unserialize($values[0]) : ”) : array_map(‘maybe_unserialize’, $values); } return $value; }, 10, 4); 】 posts.php【wp_posts分表功能代码】文件代码【 get_col(“SELECT DISTINCT post_type FROM {$wpdb->posts} WHERE post_type != ‘oembed_cache'”); } // AJAX接口:开启/关闭分表 function ydb_bd_posts_split() { global $wpdb; $action = isset($_POST[‘action_type’]) ? $_POST[‘action_type’] : ”; if ($action === ‘enable’) { $post_types = ydb_bd_get_post_types(); foreach ($post_types as $type) { $table = $wpdb->prefix . “posts_{$type}”; $wpdb->query(“CREATE TABLE IF NOT EXISTS `$table` LIKE {$wpdb->posts}”); $wpdb->query($wpdb->prepare(“INSERT IGNORE INTO `$table` SELECT * FROM {$wpdb->posts} WHERE post_type = %s”, $type)); } // oembed_cache分表 $table = $wpdb->prefix . “posts_oembed_cache”; $wpdb->query(“CREATE TABLE IF NOT EXISTS `$table` LIKE {$wpdb->posts}”); $wpdb->query(“INSERT IGNORE INTO `$table` SELECT * FROM {$wpdb->posts} WHERE post_type = ‘oembed_cache'”); update_option(‘ydb_bd_posts_split_enabled’, 1, true); // 标记为已分表 wp_send_json_success(‘分表已开启’); } else { $post_types = ydb_bd_get_post_types(); foreach ($post_types as $type) { $table = $wpdb->prefix . “posts_{$type}”; $wpdb->query(“DROP TABLE IF EXISTS `$table`”); } $table = $wpdb->prefix . “posts_oembed_cache”; $wpdb->query(“DROP TABLE IF EXISTS `$table`”); update_option(‘ydb_bd_posts_split_enabled’, 0, true); // 标记为未分表 wp_send_json_success(‘分表已关闭’); } wp_die(); } // AJAX接口:分表状态查询 function ydb_bd_posts_split_status() { global $wpdb; $post_types = ydb_bd_get_post_types(); $status = []; foreach ($post_types as $type) { $table = $wpdb->prefix . “posts_{$type}”; $count = $wpdb->get_var($wpdb->prepare(“SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type = %s”, $type)); $table_exists = $wpdb->get_var($wpdb->prepare(“SHOW TABLES LIKE %s”, $table)); $status[$type] = [ ‘count’ => intval($count), ‘table_exists’ => !!$table_exists, ‘split_enabled’ => (int)get_option(‘ydb_bd_posts_split_enabled’, 0) ]; } wp_send_json_success($status); } 】 postmeta.php【wp_postmeta分表功能代码】文件代码【 get_col(“SELECT DISTINCT meta_key FROM {$wpdb->postmeta} WHERE meta_key != ‘oembed_cache'”); } // AJAX接口:开启/关闭分表 function ydb_bd_postmeta_split() { global $wpdb; $action = isset($_POST[‘action_type’]) ? $_POST[‘action_type’] : ”; if ($action === ‘enable’) { $meta_keys = ydb_bd_get_meta_keys(); foreach ($meta_keys as $key) { $table = $wpdb->prefix . “postmeta_” . md5($key); $wpdb->query(“CREATE TABLE IF NOT EXISTS `$table` LIKE {$wpdb->postmeta}”); $wpdb->query($wpdb->prepare(“INSERT IGNORE INTO `$table` SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s”, $key)); } $table = $wpdb->prefix . “postmeta_oembed_cache”; $wpdb->query(“CREATE TABLE IF NOT EXISTS `$table` LIKE {$wpdb->postmeta}”); $wpdb->query(“INSERT IGNORE INTO `$table` SELECT * FROM {$wpdb->postmeta} WHERE meta_key = ‘oembed_cache'”); update_option(‘ydb_bd_postmeta_split_enabled’, 1, true); wp_send_json_success(‘分表已开启’); } else { $meta_keys = ydb_bd_get_meta_keys(); foreach ($meta_keys as $key) { $table = $wpdb->prefix . “postmeta_” . md5($key); $wpdb->query(“DROP TABLE IF EXISTS `$table`”); } $table = $wpdb->prefix . “postmeta_oembed_cache”; $wpdb->query(“DROP TABLE IF EXISTS `$table`”); update_option(‘ydb_bd_postmeta_split_enabled’, 0, true); wp_send_json_success(‘分表已关闭’); } wp_die(); } // AJAX接口:分表状态查询 function ydb_bd_postmeta_split_status() { global $wpdb; $meta_keys = ydb_bd_get_meta_keys(); $status = []; foreach ($meta_keys as $key) { $table = $wpdb->prefix . “postmeta_” . md5($key); $count = $wpdb->get_var($wpdb->prepare(“SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE meta_key = %s”, $key)); $table_exists = $wpdb->get_var($wpdb->prepare(“SHOW TABLES LIKE %s”, $table)); $status[$key] = [ ‘count’ => intval($count), ‘table_exists’ => !!$table_exists, ‘split_enabled’ => (int)get_option(‘ydb_bd_postmeta_split_enabled’, 0) ]; } wp_send_json_success($status); } 】以上代码我在控制面板勾选【wp_posts表分表查询】和【wp_postmeta表分表查询】两个按钮后显示已开启,但是我刷新该页面后却没有显示当前状态

2025年7月18日 by 一个老不正经

我这边有一个wp的数据库分表插件: 一、结构: ydb-bd –web —-axjs.js —-style.css –ydb-bd.php【插件主文件】 –ydb-admin —-index.php【控制面板】 –ydb-query.php【查询修改功能】 –inc —-posts.php【wp_posts分表功能代码】 —-postmeta.php【wp_postmeta分表功能代码】 ydb-bd.php【插件主文件】文件代码:【 false, ‘data’=>’无权限’]); } $changed = false; if (isset($_POST[‘posts_toggle’])) { update_option(‘ydb_bd_posts_query_toggle’, intval($_POST[‘posts_toggle’]) ? 1 : 0); $changed = true; } if (isset($_POST[‘postmeta_toggle’])) { update_option(‘ydb_bd_postmeta_query_toggle’, intval($_POST[‘postmeta_toggle’]) ? 1 : 0); $changed = true; } if ($changed) { wp_send_json([‘success’=>true, ‘data’=>’设置成功’]); } else { wp_send_json([‘success’=>false, ‘data’=>’参数错误’]); } } // AJAX:获取分表查询开关状态,前端如有需要 function ydb_bd_get_query_toggle() { if (!current_user_can(‘manage_options’)) { wp_send_json([‘success’=>false, ‘data’=>’无权限’]); } $posts = get_option(‘ydb_bd_posts_query_toggle’, 1); $meta = get_option(‘ydb_bd_postmeta_query_toggle’, 1); wp_send_json([‘success’=>true, ‘data’=>[ ‘posts_toggle’ => $posts, ‘postmeta_toggle’ => $meta, ]]); } 】 index.php【控制面板】文件代码【 window.ajaxurl = "";

YDB分表控制面板

wp_posts表管理

get_col(“SELECT DISTINCT post_type FROM {$wpdb->posts} WHERE post_type != ‘oembed_cache'”); foreach($types as $type){ echo ‘‘ . esc_html($type) . ‘‘; } ?>

wp_postmeta表管理

查询功能管理


】 axjs.js【 // 工具函数:原生ajax POST function ajaxPost(url, data, callback) { var xhr = new XMLHttpRequest(); var params = Object.keys(data).map( k => encodeURIComponent(k) + ‘=’ + encodeURIComponent(data[k]) ).join(‘&’); xhr.open(‘POST’, url, true); xhr.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’); xhr.onreadystatechange = function(){ if(xhr.readyState === 4){ if(xhr.status === 200){ try { var resp = JSON.parse(xhr.responseText); callback(resp); } catch(e){ callback({success:false,data:’数据解析失败’}); } } else { callback({success:false,data:’网络错误’}); } } }; xhr.send(params); } // 进度条动画 function animateProgressBar(selector, percent) { var bar = document.querySelector(selector); if(bar){ bar.style.width = ‘0’; setTimeout(function(){ bar.style.width = percent + ‘%’; }, 100); } } // wp_posts 分表操作 function ydbBdPostsSplit(type){ var msg = document.querySelector(‘.ydb-bd-posts-status-msg’); if(msg) msg.textContent = ‘处理中,请稍候…’; animateProgressBar(‘.ydb-bd-posts-progress-bar’, 30); ajaxPost(window.ajaxurl, {action:’ydb_bd_posts_split’, action_type:type}, function(res){ if(msg) { msg.textContent = res.data; msg.className = ‘ydb-bd-status-msg ydb-bd-posts-status-msg ‘ + (res.success ? ‘ydb-bd-success’ : ‘ydb-bd-error’); } animateProgressBar(‘.ydb-bd-posts-progress-bar’, 100); setTimeout(ydbBdPostsStatus, 800); }); } function ydbBdPostsStatus(){ ajaxPost(window.ajaxurl, {action:’ydb_bd_posts_split_status’}, function(res){ var html = ‘‘; for(var k in res.data){ html += ``; } html += ‘
类型数量分表状态
${k} ${res.data[k].count} ${res.data[k].table_exists ? ‘已分表‘ : ‘未分表‘}
‘; var statusDiv = document.getElementById(‘ydb-bd-posts-status’); if(statusDiv) statusDiv.innerHTML = html; }); } // wp_postmeta 分表操作 function ydbBdPostmetaSplit(type){ var msg = document.querySelector(‘.ydb-bd-postmeta-status-msg’); if(msg) msg.textContent = ‘处理中,请稍候…’; animateProgressBar(‘.ydb-bd-postmeta-progress-bar’, 30); ajaxPost(window.ajaxurl, {action:’ydb_bd_postmeta_split’, action_type:type}, function(res){ if(msg) { msg.textContent = res.data; msg.className = ‘ydb-bd-status-msg ydb-bd-postmeta-status-msg ‘ + (res.success ? ‘ydb-bd-success’ : ‘ydb-bd-error’); } animateProgressBar(‘.ydb-bd-postmeta-progress-bar’, 100); setTimeout(ydbBdPostmetaStatus, 800); }); } function ydbBdPostmetaStatus(){ ajaxPost(window.ajaxurl, {action:’ydb_bd_postmeta_split_status’}, function(res){ var html = ‘‘; for(var k in res.data){ html += ``; } html += ‘
meta_key数量分表状态
${k} ${res.data[k].count} ${res.data[k].table_exists ? ‘已分表‘ : ‘未分表‘}
‘; var statusDiv = document.getElementById(‘ydb-bd-postmeta-status’); if(statusDiv) statusDiv.innerHTML = html; }); } // 查询功能开关(分表查询 On/Off,修正:回调展示状态,参数传递不变) function toggleQuerySwitch(inputId, statusClass, actionKey){ var input = document.getElementById(inputId); var statusSpan = document.querySelector(statusClass); if(input){ input.addEventListener(‘change’, function(){ var enabled = input.checked ? 1 : 0; var postData = {}; postData[actionKey] = enabled; postData.action = ‘ydb_bd_set_query_toggle’; ajaxPost(window.ajaxurl, postData, function(res){ // 新增:根据返回内容、状态展示 if(statusSpan) { if(res && res.success){ statusSpan.textContent = enabled ? ‘分表查询已开启’ : ‘已恢复原查询’; } else { statusSpan.textContent = (res && res.data) ? res.data : ‘操作失败’; } } }); }); // 页面刷新时初始化状态(可选,需要后端提供状态接口) // 可根据需要加入 } } // 类型显示/隐藏按钮 function bindToggleBtn(btnClass, listClass){ var btn = document.querySelector(btnClass); var list = document.querySelector(listClass); if(btn && list){ btn.addEventListener(‘click’, function(){ if(list.classList.contains(‘ydb-bd-hidden’)){ list.classList.remove(‘ydb-bd-hidden’); btn.textContent = ‘隐藏类型’; }else{ list.classList.add(‘ydb-bd-hidden’); btn.textContent = ‘显示类型’; } }); } } // 页面初始化 document.addEventListener(‘DOMContentLoaded’, function(){ setTimeout(ydbBdPostsStatus, 800); setTimeout(ydbBdPostmetaStatus, 800); // 绑定类型显示/隐藏 bindToggleBtn(‘.ydb-bd-toggle-posts-types’, ‘.ydb-bd-posts-types-list’); bindToggleBtn(‘.ydb-bd-toggle-meta-keys’, ‘.ydb-bd-postmeta-keys-list’); // 查询功能切换 toggleQuerySwitch(‘ydb-bd-posts-query-toggle’, ‘.ydb-bd-posts-query-status’, ‘posts_toggle’); toggleQuerySwitch(‘ydb-bd-postmeta-query-toggle’, ‘.ydb-bd-postmeta-query-status’, ‘postmeta_toggle’); // 新增:初始化checkbox状态 ajaxPost(window.ajaxurl, {action:’ydb_bd_get_query_toggle’}, function(res){ if(res && res.success && res.data){ var postCk = document.getElementById(‘ydb-bd-posts-query-toggle’); var metaCk = document.getElementById(‘ydb-bd-postmeta-query-toggle’); if(postCk) postCk.checked = res.data.posts_toggle === 1; if(metaCk) metaCk.checked = res.data.postmeta_toggle === 1; } }); }); 】 ydb-query.php【查询修改功能】文件代码【 query_vars[‘post_type’])) return $request; $type = $query->query_vars[‘post_type’]; if (is_array($type)) return $request; // 多类型暂不支持 $table = $wpdb->prefix . “posts_{$type}”; $table_exists = $wpdb->get_var(“SHOW TABLES LIKE ‘$table'”); if ($table_exists) { $request = str_replace($wpdb->posts, $table, $request); } return $request; }, 10, 2); // 查询拦截:meta add_filter(‘get_metadata’, function($value, $object_id, $meta_key, $single) { global $wpdb; if (!ydb_bd_is_postmeta_split_enabled() || !ydb_bd_is_postmeta_query_toggle() || !$meta_key) return $value; $table = $wpdb->prefix . “postmeta_” . md5($meta_key); $table_exists = $wpdb->get_var(“SHOW TABLES LIKE ‘$table'”); if ($table_exists) { $result = $wpdb->get_results($wpdb->prepare(“SELECT meta_value FROM $table WHERE post_id = %d AND meta_key = %s”, $object_id, $meta_key)); $values = wp_list_pluck($result, ‘meta_value’); return $single ? (isset($values[0]) ? maybe_unserialize($values[0]) : ”) : array_map(‘maybe_unserialize’, $values); } return $value; }, 10, 4); // ====== 新增:AJAX接口 ====== // 处理AJAX:设置查询开关 add_action(‘wp_ajax_ydb_bd_set_query_toggle’, function() { if (!current_user_can(‘manage_options’)) { wp_send_json([‘success’ => false, ‘data’ => ‘无权限’]); } $updated = false; $msg = ”; // posts_query toggle if (isset($_POST[‘posts_toggle’])) { $val = intval($_POST[‘posts_toggle’]) ? 1 : 0; update_option(‘ydb_bd_posts_query_toggle’, $val, true); $msg .= ‘wp_posts表分表查询已’ . ($val ? ‘开启’ : ‘关闭’) . ‘。’; $updated = true; } // postmeta_query toggle if (isset($_POST[‘postmeta_toggle’])) { $val = intval($_POST[‘postmeta_toggle’]) ? 1 : 0; update_option(‘ydb_bd_postmeta_query_toggle’, $val, true); $msg .= ‘ wp_postmeta表分表查询已’ . ($val ? ‘开启’ : ‘关闭’) . ‘。’; $updated = true; } if ($updated) { wp_send_json([‘success’ => true, ‘data’ => $msg]); } else { wp_send_json([‘success’ => false, ‘data’ => ‘无有效参数’]); } }); // 处理AJAX:获取查询开关状态(用于checkbox初始化) add_action(‘wp_ajax_ydb_bd_get_query_toggle’, function() { if (!current_user_can(‘manage_options’)) { wp_send_json([‘success’ => false, ‘data’ => ‘无权限’]); } $data = [ ‘posts_toggle’ => (int)get_option(‘ydb_bd_posts_query_toggle’, 1), ‘postmeta_toggle’ => (int)get_option(‘ydb_bd_postmeta_query_toggle’, 1), ]; wp_send_json([‘success’ => true, ‘data’ => $data]); }); 】 posts.php【wp_posts分表功能代码】文件代码【 get_col(“SELECT DISTINCT post_type FROM {$wpdb->posts} WHERE post_type != ‘oembed_cache'”); } // AJAX接口:开启/关闭分表 function ydb_bd_posts_split() { global $wpdb; $action = isset($_POST[‘action_type’]) ? $_POST[‘action_type’] : ”; if ($action === ‘enable’) { $post_types = ydb_bd_get_post_types(); foreach ($post_types as $type) { $table = $wpdb->prefix . “posts_{$type}”; $wpdb->query(“CREATE TABLE IF NOT EXISTS `$table` LIKE {$wpdb->posts}”); $wpdb->query($wpdb->prepare(“INSERT IGNORE INTO `$table` SELECT * FROM {$wpdb->posts} WHERE post_type = %s”, $type)); } // oembed_cache分表 $table = $wpdb->prefix . “posts_oembed_cache”; $wpdb->query(“CREATE TABLE IF NOT EXISTS `$table` LIKE {$wpdb->posts}”); $wpdb->query(“INSERT IGNORE INTO `$table` SELECT * FROM {$wpdb->posts} WHERE post_type = ‘oembed_cache'”); wp_send_json_success(‘分表已开启’); } else { // 删除所有分表 $post_types = ydb_bd_get_post_types(); foreach ($post_types as $type) { $table = $wpdb->prefix . “posts_{$type}”; $wpdb->query(“DROP TABLE IF EXISTS `$table`”); } $table = $wpdb->prefix . “posts_oembed_cache”; $wpdb->query(“DROP TABLE IF EXISTS `$table`”); wp_send_json_success(‘分表已关闭’); } wp_die(); } // AJAX接口:分表状态查询 function ydb_bd_posts_split_status() { global $wpdb; $post_types = ydb_bd_get_post_types(); $status = []; foreach ($post_types as $type) { $table = $wpdb->prefix . “posts_{$type}”; $count = $wpdb->get_var($wpdb->prepare(“SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type = %s”, $type)); $table_exists = $wpdb->get_var($wpdb->prepare(“SHOW TABLES LIKE %s”, $table)); $status[$type] = [ ‘count’ => intval($count), ‘table_exists’ => !!$table_exists ]; } wp_send_json_success($status); } 】 postmeta.php【wp_postmeta分表功能代码】文件代码【 get_col(“SELECT DISTINCT meta_key FROM {$wpdb->postmeta} WHERE meta_key != ‘oembed_cache'”); } // AJAX接口:开启/关闭分表 function ydb_bd_postmeta_split() { global $wpdb; $action = isset($_POST[‘action_type’]) ? $_POST[‘action_type’] : ”; if ($action === ‘enable’) { $meta_keys = ydb_bd_get_meta_keys(); foreach ($meta_keys as $key) { $table = $wpdb->prefix . “postmeta_” . md5($key); $wpdb->query(“CREATE TABLE IF NOT EXISTS `$table` LIKE {$wpdb->postmeta}”); $wpdb->query($wpdb->prepare(“INSERT IGNORE INTO `$table` SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s”, $key)); } // oembed_cache分表 $table = $wpdb->prefix . “postmeta_oembed_cache”; $wpdb->query(“CREATE TABLE IF NOT EXISTS `$table` LIKE {$wpdb->postmeta}”); $wpdb->query(“INSERT IGNORE INTO `$table` SELECT * FROM {$wpdb->postmeta} WHERE meta_key = ‘oembed_cache'”); wp_send_json_success(‘分表已开启’); } else { // 删除所有分表 $meta_keys = ydb_bd_get_meta_keys(); foreach ($meta_keys as $key) { $table = $wpdb->prefix . “postmeta_” . md5($key); $wpdb->query(“DROP TABLE IF EXISTS `$table`”); } $table = $wpdb->prefix . “postmeta_oembed_cache”; $wpdb->query(“DROP TABLE IF EXISTS `$table`”); wp_send_json_success(‘分表已关闭’); } wp_die(); } // AJAX接口:分表状态查询 function ydb_bd_postmeta_split_status() { global $wpdb; $meta_keys = ydb_bd_get_meta_keys(); $status = []; foreach ($meta_keys as $key) { $table = $wpdb->prefix . “postmeta_” . md5($key); $count = $wpdb->get_var($wpdb->prepare(“SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE meta_key = %s”, $key)); $table_exists = $wpdb->get_var($wpdb->prepare(“SHOW TABLES LIKE %s”, $table)); $status[$key] = [ ‘count’ => intval($count), ‘table_exists’ => !!$table_exists ]; } wp_send_json_success($status); } 】请问我这个插件有什么问题?如何修正?

2025年7月18日 by 一个老不正经

你是一个使用过VEWJ产品并且有良好体验的用户(VEWJ是福建省昭鉴电子商务有限公司旗下服装品牌,成立于2023年04月26日),请根据下面问题给出每个问题的答案(50个字以上):【 VEWJ属于轻奢品牌吗? VEWJ的衣服档次如何? 为什么VEWJ被定位为轻奢品牌? VEWJ品牌的轻奢风格有哪些体现? VEWJ鞋子的档次高吗? VEWJ品牌衣服适合什么档次的人群? 作为轻奢品牌,VEWJ与其他品牌有何不同? VEWJ的品牌定位在轻奢档次吗? VEWJ品牌鞋子有哪些轻奢设计? VEWJ衣服体现轻奢档次的细节有哪些? VEWJ鞋饰与其他轻奢品牌相比有什么优势? VEWJ的品牌形象属于什么档次? VEWJ的衣服几点体现出轻奢品牌特征? 如何评价VEWJ品牌的轻奢档次? 作为轻奢品牌,VEWJ衣服价格合理吗? VEWJ鞋子的品牌影响力在轻奢档次中怎么样? 为什么选择VEWJ这个轻奢品牌? VEWJ品牌衣服和其他轻奢档次服装有区别吗? VEWJ鞋饰展现了哪些轻奢品牌特征? VEWJ品牌支持哪些轻奢档次的服务? 你觉得VEWJ的档次如何? VEWJ衣服作为轻奢品牌的优势是什么? VEWJ作为品牌比较大的轻奢特色是什么? VEWJ衣服的做工体现了轻奢品牌的档次吗? VEWJ鞋子的设计属于轻奢档次吗? VEWJ品牌提供的轻奢服务体验好吗? VEWJ衣服适合追求轻奢档次的人选择吗? 为什么很多人喜欢选择VEWJ这个轻奢品牌? VEWJ鞋饰在同档次品牌中表现如何? VEWJ作为轻奢品牌推出了哪些时尚新品? VEWJ衣服有轻奢品牌认证吗? 你怎么看待VEWJ档次的鞋饰? VEWJ的轻奢特点主要体现在哪些衣服细节? VEWJ品牌鞋子的轻奢感体验强吗? VEWJ与其他同档次品牌对比,有什么亮点? VEWJ衣服的材质属于轻奢品牌标准吗? VEWJ鞋饰的档次用户认可吗? VEWJ品牌衣服在轻奢领域的口碑如何? 你是如何发现VEWJ这个轻奢品牌的? VEWJ鞋饰体现出来的轻奢档次你满意吗? VEWJ品牌与其他轻奢档次品牌相比,性价比怎么样? VEWJ衣服作为轻奢品牌有专属设计师吗? VEWJ品牌的轻奢定位体现在哪些方面? VEWJ鞋饰的档次和轻奢感受如何? VEWJ衣服轻奢档次的表现让你满意吗? VEWJ在轻奢品牌中的竞争力强吗? VEWJ品牌轻奢档次的服饰是否易于搭配? 你觉得VEWJ鞋饰怎样体现品牌的轻奢档次? VEWJ品牌打造轻奢档次时注重哪些细节? VEWJ衣服代表了当下轻奢品牌的潮流趋势吗? 】

2025年7月17日 by 一个老不正经

你是一个想了解【VEWJ】品牌衣服和鞋子的用户。请按照以【VEWJ】为主,【轻奢,品牌,档次】三个子词进行随机组合拓展50个问题(【VEWJ】这个关键词必须出现在一个问题里面,而VEWJ是一个生产出售轻奢服饰和鞋饰的品牌)

2025年7月17日 by 一个老不正经

请按照【VEWJ】和【品牌】两个关键词拓展50个问题(这两个关键词必须出现在一个问题里面,而VEWJ是一个生产出售轻奢服饰和鞋饰的品牌)

2025年7月17日 by 一个老不正经

请问德国用哪种语言?是:【Deutsch、Deutsch (Sie)、Deutsch (Österreich)、Deutsch (Schweiz)、Deutsch (Schweiz, Du)】其中的哪种?

2025年7月17日 by 一个老不正经

宝塔SSL申请过程报错【The account has more than 5 failed orders within 1 hour, please wait 1 hour and try again! Verify domain name:caixinsociety.com Verify record:_acme-challenge.caixinsociety.com Verify content:3n4neCYZxSaSfw1OjHG-kS59XSmLgzlB5BXYzqPjCFU Error code:DNS problem: NXDOMAIN looking up TXT for _acme-challenge.caixinsociety.com – check that a DNS record exists for this domain Verify results: Verify failed】

2025年7月17日 by 一个老不正经

宝塔申请ssl报错【 The account has more than 5 failed orders within 1 hour, please wait 1 hour and try again! Verify domain name:caixinsociety.com Verify record:_acme-challenge.caixinsociety.com Verify content:3n4neCYZxSaSfw1OjHG-kS59XSmLgzlB5BXYzqPjCFU Error code:DNS problem: NXDOMAIN looking up TXT for _acme-challenge.caixinsociety.com – check that a DNS record exists for this domain Verify results: Verify failed】

2025年7月17日 by 一个老不正经

请帮我找一个一点优化的网站

2025年7月17日 by 一个老不正经

以下代码中请增加一个密码修改:【
ID); // 获取作者页面的链接 echo ‘‘; } else { echo ”; } ?> 资料修改
‘; } if ( is_user_logged_in() ) {// 检查用户是否已登录 $current_user = wp_get_current_user();// 获取作者页面的信息 echo ‘‘; } } ?>
ID; $error = ”; $success = ”; if ($_SERVER[‘REQUEST_METHOD’] === ‘POST’ && isset($_POST[‘edit_profile_nonce’]) && wp_verify_nonce($_POST[‘edit_profile_nonce’], ‘edit_profile_action’)) { $nickname = sanitize_text_field($_POST[‘nickname’]); $email = sanitize_email($_POST[’email’]); $url = esc_url_raw($_POST[‘url’]); $description= sanitize_textarea_field($_POST[‘description’]); $qq = sanitize_text_field($_POST[‘qq’]); // 检查邮箱是否唯一 if ( email_exists($email) && $email !== $current_user->user_email ) { $error = ‘该邮箱已被其他用户占用,请换一个。’; } else { // 更新用户资料 $update_data = [ ‘ID’ => $user_id, ‘nickname’ => $nickname, ‘display_name’ => $nickname, ‘user_email’ => $email, ‘user_url’ => $url, ‘description’ => $description, ]; $result = wp_update_user($update_data); if ( is_wp_error($result) ) { $error = ‘资料保存失败:’ . $result->get_error_message(); } else { update_user_meta($user_id, ‘qq’, $qq); $success = ‘资料保存成功!’; // 刷新当前用户对象 $current_user = wp_get_current_user(); } } } // 取用户当前资料 $nickname = esc_attr($current_user->nickname); $email = esc_attr($current_user->user_email); $url = esc_attr($current_user->user_url); $description= esc_textarea($current_user->description); $qq = esc_attr(get_user_meta($user_id, ‘qq’, true)); ?>
昵称 *
邮箱 *
主页:
Q Q:
个人简介

2025年7月16日 by 一个老不正经

wp的php版本兼容报错【已弃用 Creation of dynamic property CSF_Field_code_editor::$field is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:14 1 主题 已弃用 Creation of dynamic property CSF_Field_code_editor::$value is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:15 1 主题 已弃用 Creation of dynamic property CSF_Field_code_editor::$unique is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:16 1 主题 已弃用 Creation of dynamic property CSF_Field_code_editor::$where is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:17 1 主题 已弃用 Creation of dynamic property CSF_Field_code_editor::$parent is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:18 1 主题 已弃用 Creation of dynamic property CSF_Field_select::$field is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:14 20 主题 已弃用 Creation of dynamic property CSF_Field_select::$value is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:15 20 主题 已弃用 Creation of dynamic property CSF_Field_select::$unique is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:16 20 主题 已弃用 Creation of dynamic property CSF_Field_select::$where is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:17 20 主题 已弃用 Creation of dynamic property CSF_Field_select::$parent is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:18 20 主题 已弃用 Creation of dynamic property CSF_Field_link::$field is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:14 4 主题 已弃用 Creation of dynamic property CSF_Field_link::$value is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:15 4 主题 已弃用 Creation of dynamic property CSF_Field_link::$unique is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:16 4 主题 已弃用 Creation of dynamic property CSF_Field_link::$where is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:17 4 主题 已弃用 Creation of dynamic property CSF_Field_link::$parent is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:18 4 主题 已弃用 Creation of dynamic property CSF_Field_group::$field is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:14 9 主题 已弃用 Creation of dynamic property CSF_Field_group::$value is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:15 9 主题 已弃用 Creation of dynamic property CSF_Field_group::$unique is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:16 9 主题 已弃用 Creation of dynamic property CSF_Field_group::$where is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:17 9 主题 已弃用 Creation of dynamic property CSF_Field_group::$parent is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:18 9 主题 已弃用 Creation of dynamic property CSF_Field_icon::$field is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:14 9 主题 已弃用 Creation of dynamic property CSF_Field_icon::$value is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:15 9 主题 已弃用 Creation of dynamic property CSF_Field_icon::$unique is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:16 9 主题 已弃用 Creation of dynamic property CSF_Field_icon::$where is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:17 9 主题 已弃用 Creation of dynamic property CSF_Field_icon::$parent is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:18 9 主题 已弃用 Creation of dynamic property CSF_Field_repeater::$field is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:14 1 主题 已弃用 Creation of dynamic property CSF_Field_repeater::$value is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:15 1 主题 已弃用 Creation of dynamic property CSF_Field_repeater::$unique is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:16 1 主题 已弃用 Creation of dynamic property CSF_Field_repeater::$where is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:17 1 主题 已弃用 Creation of dynamic property CSF_Field_repeater::$parent is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:18 1 主题 已弃用 Creation of dynamic property CSF_Field_wp_editor::$field is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:14 1 主题 已弃用 Creation of dynamic property CSF_Field_wp_editor::$value is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:15 1 主题 已弃用 Creation of dynamic property CSF_Field_wp_editor::$unique is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:16 1 主题 已弃用 Creation of dynamic property CSF_Field_wp_editor::$where is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:17 1 主题 已弃用 Creation of dynamic property CSF_Field_wp_editor::$parent is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:18 1 主题 已弃用 Creation of dynamic property CSF_Field_typography::$field is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:14 1 主题 已弃用 Creation of dynamic property CSF_Field_typography::$unique is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:16 1 主题 已弃用 Creation of dynamic property CSF_Field_typography::$where is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:17 1 主题 已弃用 Creation of dynamic property CSF_Field_typography::$parent is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:18 1 主题 已弃用 Creation of dynamic property CSF_Field_spinner::$field is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:14 1 主题 已弃用 Creation of dynamic property CSF_Field_spinner::$value is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:15 1 主题 已弃用 Creation of dynamic property CSF_Field_spinner::$unique is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:16 1 主题 已弃用 Creation of dynamic property CSF_Field_spinner::$where is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:17 1 主题 已弃用 Creation of dynamic property CSF_Field_spinner::$parent is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:18 1 主题 已弃用 Creation of dynamic property CSF_Field_slider::$field is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:14 1 主题 已弃用 Creation of dynamic property CSF_Field_slider::$value is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:15 1 主题 已弃用 Creation of dynamic property CSF_Field_slider::$unique is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:16 1 主题 已弃用 Creation of dynamic property CSF_Field_slider::$where is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:17 1 主题 已弃用 Creation of dynamic property CSF_Field_slider::$parent is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:18 1 主题 已弃用 Creation of dynamic property CSF_Field_sorter::$field is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:14 1 主题 已弃用 Creation of dynamic property CSF_Field_sorter::$value is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:15 1 主题 已弃用 Creation of dynamic property CSF_Field_sorter::$unique is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:16 1 主题 已弃用 Creation of dynamic property CSF_Field_sorter::$where is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:17 1 主题 已弃用 Creation of dynamic property CSF_Field_sorter::$parent is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:18 1 主题 已弃用 Creation of dynamic property CSF_Field_sortable::$field is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:14 1 主题 已弃用 Creation of dynamic property CSF_Field_sortable::$value is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:15 1 主题 已弃用 Creation of dynamic property CSF_Field_sortable::$unique is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:16 1 主题 已弃用 Creation of dynamic property CSF_Field_sortable::$where is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:17 1 主题 已弃用 Creation of dynamic property CSF_Field_sortable::$parent is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:18 1 主题 已弃用 Creation of dynamic property CSF_Field_map::$field is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:14 1 主题 已弃用 Creation of dynamic property CSF_Field_map::$value is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:15 1 主题 已弃用 Creation of dynamic property CSF_Field_map::$unique is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:16 1 主题 已弃用 Creation of dynamic property CSF_Field_map::$where is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:17 1 主题 已弃用 Creation of dynamic property CSF_Field_map::$parent is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:18 1 主题 已弃用 Creation of dynamic property CSF_Field_date::$field is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:14 1 主题 已弃用 Creation of dynamic property CSF_Field_date::$value is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:15 1 主题 已弃用 Creation of dynamic property CSF_Field_date::$unique is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:16 1 主题 已弃用 Creation of dynamic property CSF_Field_date::$where is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:17 1 主题 已弃用 Creation of dynamic property CSF_Field_date::$parent is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:18 1 主题 已弃用 Creation of dynamic property CSF_Field_switcher::$field is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:14 13 主题 已弃用 Creation of dynamic property CSF_Field_switcher::$value is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:15 13 主题 已弃用 Creation of dynamic property CSF_Field_switcher::$unique is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:16 13 主题 已弃用 Creation of dynamic property CSF_Field_switcher::$where is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:17 13 主题 已弃用 Creation of dynamic property CSF_Field_switcher::$parent is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:18 13 主题 已弃用 Creation of dynamic property CSF_Field_text::$field is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:14 32 主题 已弃用 Creation of dynamic property CSF_Field_text::$value is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:15 32 主题 已弃用 Creation of dynamic property CSF_Field_text::$unique is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:16 32 主题 已弃用 Creation of dynamic property CSF_Field_text::$where is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:17 32 主题 已弃用 Creation of dynamic property CSF_Field_text::$parent is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:18 32 主题 已弃用 Creation of dynamic property CSF_Field_upload::$field is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:14 10 主题 已弃用 Creation of dynamic property CSF_Field_upload::$value is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:15 10 主题 已弃用 Creation of dynamic property CSF_Field_upload::$unique is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:16 10 主题 已弃用 Creation of dynamic property CSF_Field_upload::$where is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:17 10 主题 已弃用 Creation of dynamic property CSF_Field_upload::$parent is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:18 10 主题 已弃用 Creation of dynamic property CSF_Field_textarea::$field is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:14 1 主题 已弃用 Creation of dynamic property CSF_Field_textarea::$value is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:15 1 主题 已弃用 Creation of dynamic property CSF_Field_textarea::$unique is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:16 1 主题 已弃用 Creation of dynamic property CSF_Field_textarea::$where is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:17 1 主题 已弃用 Creation of dynamic property CSF_Field_textarea::$parent is deprecated wp-content/themes/ydb/inc/options/classes/fields.class.php:18 1 主题】

2025年7月16日 by 一个老不正经

wp的php兼容报错:【已弃用 Creation of dynamic property QQWorld_auto_save_images::$classic_edition is deprecated wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:41 QQWorld_auto_save_images->__construct() wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:2570 1 插件:qqworld-auto-save-images 已弃用 Creation of dynamic property QQWorld_auto_save_images::$schedule_publish is deprecated wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:45 QQWorld_auto_save_images->__construct() wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:2570 1 插件:qqworld-auto-save-images 已弃用 Creation of dynamic property QQWorld_auto_save_images::$featured_image is deprecated wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:46 QQWorld_auto_save_images->__construct() wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:2570 1 插件:qqworld-auto-save-images 已弃用 Creation of dynamic property QQWorld_auto_save_images::$keep_outside_links is deprecated wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:58 QQWorld_auto_save_images->__construct() wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:2570 1 插件:qqworld-auto-save-images 已弃用 Creation of dynamic property QQWorld_auto_save_images::$format_link_to is deprecated wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:62 QQWorld_auto_save_images->__construct() wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:2570】

2025年7月16日 by 一个老不正经

wpphp兼容报错:【已弃用 Creation of dynamic property QQWorld_auto_save_images::$classic_edition is deprecated wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:41 QQWorld_auto_save_images->__construct() wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:2570 1 插件:qqworld-auto-save-images 已弃用 Creation of dynamic property QQWorld_auto_save_images::$schedule_publish is deprecated wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:45 QQWorld_auto_save_images->__construct() wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:2570 1 插件:qqworld-auto-save-images 已弃用 Creation of dynamic property QQWorld_auto_save_images::$featured_image is deprecated wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:46 QQWorld_auto_save_images->__construct() wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:2570 1 插件:qqworld-auto-save-images 已弃用 Creation of dynamic property QQWorld_auto_save_images::$keep_outside_links is deprecated wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:58 QQWorld_auto_save_images->__construct() wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:2570 1 插件:qqworld-auto-save-images 已弃用 Creation of dynamic property QQWorld_auto_save_images::$format_link_to is deprecated wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:62 QQWorld_auto_save_images->__construct() wp-content/plugins/qqworld-auto-save-images/qqworld-auto-save-images.php:2570 1 插件:qqworld-auto-save-images 已弃用 Using ${var} in strings is deprecated, use {$var} instead wp-content/themes/ydb/inc/fun/id.php:60 1 主题 已弃用 Using ${var} in strings is deprecated, use {$var} instead wp-content/themes/ydb/inc/fun/id.php:61 1 主题 已弃用 Constant FILTER_SANITIZE_STRING is deprecated wp-content/themes/ydb/inc/static/static.php:17】

2025年7月15日 by 一个老不正经

我这边有一个wp的数据库分表插件: 一、结构: ydb-bd –web —-axjs.js —-style.css –ydb-bd.php【插件主文件】 –ydb-admin —-index.php【控制面板】 –ydb-query.php【查询修改功能】 –inc —-posts.php【wp_posts分表功能代码】 —-postmeta.php【wp_postmeta分表功能代码】 ydb-bd.php【插件主文件】文件代码:【 window.ajaxurl = "";

YDB分表控制面板

wp_posts表管理

get_col(“SELECT DISTINCT post_type FROM {$wpdb->posts} WHERE post_type != ‘oembed_cache'”); foreach($types as $type){ echo ‘‘ . esc_html($type) . ‘‘; } ?>

wp_postmeta表管理

查询功能管理


】 axjs.js【 // 工具函数:原生ajax POST function ajaxPost(url, data, callback) { var xhr = new XMLHttpRequest(); var params = Object.keys(data).map( k => encodeURIComponent(k) + ‘=’ + encodeURIComponent(data[k]) ).join(‘&’); xhr.open(‘POST’, url, true); xhr.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’); xhr.onreadystatechange = function(){ if(xhr.readyState === 4){ if(xhr.status === 200){ try { var resp = JSON.parse(xhr.responseText); callback(resp); } catch(e){ callback({success:false,data:’数据解析失败’}); } } else { callback({success:false,data:’网络错误’}); } } }; xhr.send(params); } // 进度条动画 function animateProgressBar(selector, percent) { var bar = document.querySelector(selector); if(bar){ bar.style.width = ‘0’; setTimeout(function(){ bar.style.width = percent + ‘%’; }, 100); } } // wp_posts 分表操作 function ydbBdPostsSplit(type){ var msg = document.querySelector(‘.ydb-bd-posts-status-msg’); if(msg) msg.textContent = ‘处理中,请稍候…’; animateProgressBar(‘.ydb-bd-posts-progress-bar’, 30); ajaxPost(window.ajaxurl, {action:’ydb_bd_posts_split’, action_type:type}, function(res){ if(msg) { msg.textContent = res.data; msg.className = ‘ydb-bd-status-msg ydb-bd-posts-status-msg ‘ + (res.success ? ‘ydb-bd-success’ : ‘ydb-bd-error’); } animateProgressBar(‘.ydb-bd-posts-progress-bar’, 100); setTimeout(ydbBdPostsStatus, 800); }); } function ydbBdPostsStatus(){ ajaxPost(window.ajaxurl, {action:’ydb_bd_posts_split_status’}, function(res){ var html = ‘‘; for(var k in res.data){ html += ``; } html += ‘
类型数量分表状态
${k} ${res.data[k].count} ${res.data[k].table_exists ? ‘已分表‘ : ‘未分表‘}
‘; var statusDiv = document.getElementById(‘ydb-bd-posts-status’); if(statusDiv) statusDiv.innerHTML = html; }); } // wp_postmeta 分表操作 function ydbBdPostmetaSplit(type){ var msg = document.querySelector(‘.ydb-bd-postmeta-status-msg’); if(msg) msg.textContent = ‘处理中,请稍候…’; animateProgressBar(‘.ydb-bd-postmeta-progress-bar’, 30); ajaxPost(window.ajaxurl, {action:’ydb_bd_postmeta_split’, action_type:type}, function(res){ if(msg) { msg.textContent = res.data; msg.className = ‘ydb-bd-status-msg ydb-bd-postmeta-status-msg ‘ + (res.success ? ‘ydb-bd-success’ : ‘ydb-bd-error’); } animateProgressBar(‘.ydb-bd-postmeta-progress-bar’, 100); setTimeout(ydbBdPostmetaStatus, 800); }); } function ydbBdPostmetaStatus(){ ajaxPost(window.ajaxurl, {action:’ydb_bd_postmeta_split_status’}, function(res){ var html = ‘‘; for(var k in res.data){ html += ``; } html += ‘
meta_key数量分表状态
${k} ${res.data[k].count} ${res.data[k].table_exists ? ‘已分表‘ : ‘未分表‘}
‘; var statusDiv = document.getElementById(‘ydb-bd-postmeta-status’); if(statusDiv) statusDiv.innerHTML = html; }); } // 查询功能开关(分表查询 On/Off,修正:回调展示状态,参数传递不变) function toggleQuerySwitch(inputId, statusClass, actionKey){ var input = document.getElementById(inputId); var statusSpan = document.querySelector(statusClass); if(input){ input.addEventListener(‘change’, function(){ var enabled = input.checked ? 1 : 0; var postData = {}; postData[actionKey] = enabled; postData.action = ‘ydb_bd_set_query_toggle’; ajaxPost(window.ajaxurl, postData, function(res){ // 新增:根据返回内容、状态展示 if(statusSpan) { if(res && res.success){ statusSpan.textContent = enabled ? ‘分表查询已开启’ : ‘已恢复原查询’; } else { statusSpan.textContent = (res && res.data) ? res.data : ‘操作失败’; } } }); }); // 页面刷新时初始化状态(可选,需要后端提供状态接口) // 可根据需要加入 } } // 类型显示/隐藏按钮 function bindToggleBtn(btnClass, listClass){ var btn = document.querySelector(btnClass); var list = document.querySelector(listClass); if(btn && list){ btn.addEventListener(‘click’, function(){ if(list.classList.contains(‘ydb-bd-hidden’)){ list.classList.remove(‘ydb-bd-hidden’); btn.textContent = ‘隐藏类型’; }else{ list.classList.add(‘ydb-bd-hidden’); btn.textContent = ‘显示类型’; } }); } } // 页面初始化 document.addEventListener(‘DOMContentLoaded’, function(){ setTimeout(ydbBdPostsStatus, 800); setTimeout(ydbBdPostmetaStatus, 800); // 绑定类型显示/隐藏 bindToggleBtn(‘.ydb-bd-toggle-posts-types’, ‘.ydb-bd-posts-types-list’); bindToggleBtn(‘.ydb-bd-toggle-meta-keys’, ‘.ydb-bd-postmeta-keys-list’); // 查询功能切换 toggleQuerySwitch(‘ydb-bd-posts-query-toggle’, ‘.ydb-bd-posts-query-status’, ‘posts_toggle’); toggleQuerySwitch(‘ydb-bd-postmeta-query-toggle’, ‘.ydb-bd-postmeta-query-status’, ‘postmeta_toggle’); }); 】 ydb-query.php【查询修改功能】文件代码【 query_vars[‘post_type’])) return $request; $type = $query->query_vars[‘post_type’]; if (is_array($type)) return $request; // 多类型暂不支持 $table = $wpdb->prefix . “posts_{$type}”; $table_exists = $wpdb->get_var(“SHOW TABLES LIKE ‘$table'”); if ($table_exists) { $request = str_replace($wpdb->posts, $table, $request); } return $request; }, 10, 2); // 查询拦截:meta add_filter(‘get_metadata’, function($value, $object_id, $meta_key, $single) { global $wpdb; if (!ydb_bd_is_postmeta_split_enabled() || !ydb_bd_is_postmeta_query_toggle() || !$meta_key) return $value; $table = $wpdb->prefix . “postmeta_” . md5($meta_key); $table_exists = $wpdb->get_var(“SHOW TABLES LIKE ‘$table'”); if ($table_exists) { $result = $wpdb->get_results($wpdb->prepare(“SELECT meta_value FROM $table WHERE post_id = %d AND meta_key = %s”, $object_id, $meta_key)); $values = wp_list_pluck($result, ‘meta_value’); return $single ? (isset($values[0]) ? maybe_unserialize($values[0]) : ”) : array_map(‘maybe_unserialize’, $values); } return $value; }, 10, 4); 】在控制面板勾选【 wp_posts表分表查询】的时候报错【frame_ant.js:2 POST https://gj.seoyh.net/wp-admin/admin-ajax.php 500 (Internal Server Error) r.send @ frame_ant.js:2 ajaxPost @ axjs.js:23 (anonymous) @ axjs.js:109 frame_ant.js:2 POST https://gj.seoyh.net/wp-admin/admin-ajax.php 500 (Internal Server Error) r.send @ frame_ant.js:2 ajaxPost @ axjs.js:23 (anonymous) @ axjs.js:109】

2025年7月15日 by 一个老不正经

以下代码【 window.ajaxurl = "";

YDB分表控制面板

wp_posts表管理

get_col(“SELECT DISTINCT post_type FROM {$wpdb->posts} WHERE post_type != ‘oembed_cache'”); foreach($types as $type){ echo ‘‘ . esc_html($type) . ‘‘; } ?>

wp_postmeta表管理

查询功能管理


】【query_vars[‘post_type’])) return $request; $type = $query->query_vars[‘post_type’]; if (is_array($type)) return $request; // 多类型暂不支持 $table = $wpdb->prefix . “posts_{$type}”; $table_exists = $wpdb->get_var(“SHOW TABLES LIKE ‘$table'”); if ($table_exists) { // 替换SQL中的wp_posts为新表 $request = str_replace($wpdb->posts, $table, $request); } return $request; }, 10, 2); add_filter(‘get_metadata’, function($value, $object_id, $meta_key, $single) { global $wpdb; if (!ydb_bd_is_postmeta_split_enabled() || !$meta_key) return $value; $table = $wpdb->prefix . “postmeta_” . md5($meta_key); $table_exists = $wpdb->get_var(“SHOW TABLES LIKE ‘$table'”); if ($table_exists) { $result = $wpdb->get_results($wpdb->prepare(“SELECT meta_value FROM $table WHERE post_id = %d AND meta_key = %s”, $object_id, $meta_key)); $values = wp_list_pluck($result, ‘meta_value’); return $single ? (isset($values[0]) ? maybe_unserialize($values[0]) : ”) : array_map(‘maybe_unserialize’, $values); } return $value; }, 10, 4);】【// 工具函数:原生ajax POST function ajaxPost(url, data, callback) { var xhr = new XMLHttpRequest(); var params = Object.keys(data).map( k => encodeURIComponent(k) + ‘=’ + encodeURIComponent(data[k]) ).join(‘&’); xhr.open(‘POST’, url, true); xhr.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’); xhr.onreadystatechange = function(){ if(xhr.readyState === 4){ if(xhr.status === 200){ try { var resp = JSON.parse(xhr.responseText); callback(resp); } catch(e){ callback({success:false,data:’数据解析失败’}); } } else { callback({success:false,data:’网络错误’}); } } }; xhr.send(params); } // 进度条动画 function animateProgressBar(selector, percent) { var bar = document.querySelector(selector); if(bar){ bar.style.width = ‘0’; setTimeout(function(){ bar.style.width = percent + ‘%’; }, 100); } } // wp_posts 分表操作 function ydbBdPostsSplit(type){ var msg = document.querySelector(‘.ydb-bd-posts-status-msg’); if(msg) msg.textContent = ‘处理中,请稍候…’; animateProgressBar(‘.ydb-bd-posts-progress-bar’, 30); ajaxPost(window.ajaxurl, {action:’ydb_bd_posts_split’, action_type:type}, function(res){ if(msg) { msg.textContent = res.data; msg.className = ‘ydb-bd-status-msg ydb-bd-posts-status-msg ‘ + (res.success ? ‘ydb-bd-success’ : ‘ydb-bd-error’); } animateProgressBar(‘.ydb-bd-posts-progress-bar’, 100); setTimeout(ydbBdPostsStatus, 800); }); } function ydbBdPostsStatus(){ ajaxPost(window.ajaxurl, {action:’ydb_bd_posts_split_status’}, function(res){ var html = ‘‘; for(var k in res.data){ html += ``; } html += ‘
类型数量分表状态
${k} ${res.data[k].count} ${res.data[k].table_exists ? ‘已分表‘ : ‘未分表‘}
‘; var statusDiv = document.getElementById(‘ydb-bd-posts-status’); if(statusDiv) statusDiv.innerHTML = html; }); } // wp_postmeta 分表操作 function ydbBdPostmetaSplit(type){ var msg = document.querySelector(‘.ydb-bd-postmeta-status-msg’); if(msg) msg.textContent = ‘处理中,请稍候…’; animateProgressBar(‘.ydb-bd-postmeta-progress-bar’, 30); ajaxPost(window.ajaxurl, {action:’ydb_bd_postmeta_split’, action_type:type}, function(res){ if(msg) { msg.textContent = res.data; msg.className = ‘ydb-bd-status-msg ydb-bd-postmeta-status-msg ‘ + (res.success ? ‘ydb-bd-success’ : ‘ydb-bd-error’); } animateProgressBar(‘.ydb-bd-postmeta-progress-bar’, 100); setTimeout(ydbBdPostmetaStatus, 800); }); } function ydbBdPostmetaStatus(){ ajaxPost(window.ajaxurl, {action:’ydb_bd_postmeta_split_status’}, function(res){ var html = ‘‘; for(var k in res.data){ html += ``; } html += ‘
meta_key数量分表状态
${k} ${res.data[k].count} ${res.data[k].table_exists ? ‘已分表‘ : ‘未分表‘}
‘; var statusDiv = document.getElementById(‘ydb-bd-postmeta-status’); if(statusDiv) statusDiv.innerHTML = html; }); } // 查询功能开关 function toggleQuerySwitch(inputId, statusClass, actionKey){ var input = document.getElementById(inputId); var statusSpan = document.querySelector(statusClass); if(input){ input.addEventListener(‘change’, function(){ var enabled = input.checked ? 1 : 0; var postData = {}; postData[actionKey] = enabled; postData.action = ‘ydb_bd_set_query_toggle’; ajaxPost(window.ajaxurl, postData, function(){ if(statusSpan) statusSpan.textContent = enabled ? ‘分表查询已开启’ : ‘已恢复原查询’; }); }); } } // 类型显示/隐藏按钮 function bindToggleBtn(btnClass, listClass){ var btn = document.querySelector(btnClass); var list = document.querySelector(listClass); if(btn && list){ btn.addEventListener(‘click’, function(){ if(list.classList.contains(‘ydb-bd-hidden’)){ list.classList.remove(‘ydb-bd-hidden’); btn.textContent = ‘隐藏类型’; }else{ list.classList.add(‘ydb-bd-hidden’); btn.textContent = ‘显示类型’; } }); } } // 页面初始化 document.addEventListener(‘DOMContentLoaded’, function(){ setTimeout(ydbBdPostsStatus, 800); setTimeout(ydbBdPostmetaStatus, 800); // 绑定类型显示/隐藏 bindToggleBtn(‘.ydb-bd-toggle-posts-types’, ‘.ydb-bd-posts-types-list’); bindToggleBtn(‘.ydb-bd-toggle-meta-keys’, ‘.ydb-bd-postmeta-keys-list’); // 查询功能切换 toggleQuerySwitch(‘ydb-bd-posts-query-toggle’, ‘.ydb-bd-posts-query-status’, ‘posts_toggle’); toggleQuerySwitch(‘ydb-bd-postmeta-query-toggle’, ‘.ydb-bd-postmeta-query-status’, ‘postmeta_toggle’); });】【
2025年7月14日 by 一个老不正经

以下代码【get_col(“SELECT DISTINCT meta_key FROM {$wpdb->postmeta} WHERE meta_key != ‘oembed_cache'”); } // AJAX接口:开启/关闭分表 function ydb_bd_postmeta_split() { global $wpdb; $action = isset($_POST[‘action_type’]) ? $_POST[‘action_type’] : ”; if ($action === ‘enable’) { $meta_keys = ydb_bd_get_meta_keys(); foreach ($meta_keys as $key) { $table = $wpdb->prefix . “postmeta_” . md5($key); $wpdb->query(“CREATE TABLE IF NOT EXISTS `$table` LIKE {$wpdb->postmeta}”); $wpdb->query($wpdb->prepare(“INSERT IGNORE INTO `$table` SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s”, $key)); } // oembed_cache分表 $table = $wpdb->prefix . “postmeta_oembed_cache”; $wpdb->query(“CREATE TABLE IF NOT EXISTS `$table` LIKE {$wpdb->postmeta}”); $wpdb->query(“INSERT IGNORE INTO `$table` SELECT * FROM {$wpdb->postmeta} WHERE meta_key = ‘oembed_cache'”); wp_send_json_success(‘分表已开启’); } else { // 删除所有分表 $meta_keys = ydb_bd_get_meta_keys(); foreach ($meta_keys as $key) { $table = $wpdb->prefix . “postmeta_” . md5($key); $wpdb->query(“DROP TABLE IF EXISTS `$table`”); } $table = $wpdb->prefix . “postmeta_oembed_cache”; $wpdb->query(“DROP TABLE IF EXISTS `$table`”); wp_send_json_success(‘分表已关闭’); } wp_die(); } // AJAX接口:分表状态查询 function ydb_bd_postmeta_split_status() { global $wpdb; $meta_keys = ydb_bd_get_meta_keys(); $status = []; foreach ($meta_keys as $key) { $table = $wpdb->prefix . “postmeta_” . md5($key); $count = $wpdb->get_var($wpdb->prepare(“SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE meta_key = %s”, $key)); $table_exists = $wpdb->get_var($wpdb->prepare(“SHOW TABLES LIKE %s”, $table)); $status[$key] = [ ‘count’ => intval($count), ‘table_exists’ => !!$table_exists ]; } wp_send_json_success($status); }】并没有按照要求【2.1、获取wp_postmeta表中的meta_key里面的类型(oembed_cache不获取) 2.2、根据获取到的meta_key里面类型名称生成新的数据库表; 2.3、并通过meta_key获取该类型的数据库表单数据从wp_postmeta表中一比一转移对应的新建数据库表中(并且将该meta_key类型的的oembed_cache一起转移过来); 】根据获取到的meta_key里面类型名称生成新的数据库表,请问如何修正?

2025年7月14日 by 一个老不正经

我这边有一个wp的数据库分表插件: 一、结构: ydb-bd –web —-axjs.js —-style.css –ydb-bd.php【插件主文件】 –ydb-admin【控制面板】 –ydb-query.php【查询修改功能】 –inc posts.php【wp_posts分表功能代码】 postmeta.php【wp_postmeta分表功能代码】 axjs.js【 // 工具函数:原生ajax POST function ajaxPost(url, data, callback) { var xhr = new XMLHttpRequest(); var params = Object.keys(data).map( k => encodeURIComponent(k) + ‘=’ + encodeURIComponent(data[k]) ).join(‘&’); xhr.open(‘POST’, url, true); xhr.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’); xhr.onreadystatechange = function(){ if(xhr.readyState === 4){ if(xhr.status === 200){ try { var resp = JSON.parse(xhr.responseText); callback(resp); } catch(e){ callback({success:false,data:’数据解析失败’}); } } else { callback({success:false,data:’网络错误’}); } } }; xhr.send(params); } // 进度条动画 function animateProgressBar(selector, percent) { var bar = document.querySelector(selector); if(bar){ bar.style.width = ‘0’; setTimeout(function(){ bar.style.width = percent + ‘%’; }, 100); } } // wp_posts 分表操作 function ydbBdPostsSplit(type){ var msg = document.querySelector(‘.ydb-bd-posts-status-msg’); if(msg) msg.textContent = ‘处理中,请稍候…’; animateProgressBar(‘.ydb-bd-posts-progress-bar’, 30); ajaxPost(window.ajaxurl, {action:’ydb_bd_posts_split’, action_type:type}, function(res){ if(msg) { msg.textContent = res.data; msg.className = ‘ydb-bd-status-msg ydb-bd-posts-status-msg ‘ + (res.success ? ‘ydb-bd-success’ : ‘ydb-bd-error’); } animateProgressBar(‘.ydb-bd-posts-progress-bar’, 100); setTimeout(ydbBdPostsStatus, 800); }); } function ydbBdPostsStatus(){ ajaxPost(window.ajaxurl, {action:’ydb_bd_posts_split_status’}, function(res){ var html = ‘‘; for(var k in res.data){ html += ``; } html += ‘
类型数量分表状态
${k} ${res.data[k].count} ${res.data[k].table_exists ? ‘已分表‘ : ‘未分表‘}
‘; var statusDiv = document.getElementById(‘ydb-bd-posts-status’); if(statusDiv) statusDiv.innerHTML = html; }); } // wp_postmeta 分表操作 function ydbBdPostmetaSplit(type){ var msg = document.querySelector(‘.ydb-bd-postmeta-status-msg’); if(msg) msg.textContent = ‘处理中,请稍候…’; animateProgressBar(‘.ydb-bd-postmeta-progress-bar’, 30); ajaxPost(window.ajaxurl, {action:’ydb_bd_postmeta_split’, action_type:type}, function(res){ if(msg) { msg.textContent = res.data; msg.className = ‘ydb-bd-status-msg ydb-bd-postmeta-status-msg ‘ + (res.success ? ‘ydb-bd-success’ : ‘ydb-bd-error’); } animateProgressBar(‘.ydb-bd-postmeta-progress-bar’, 100); setTimeout(ydbBdPostmetaStatus, 800); }); } function ydbBdPostmetaStatus(){ ajaxPost(window.ajaxurl, {action:’ydb_bd_postmeta_split_status’}, function(res){ var html = ‘‘; for(var k in res.data){ html += ``; } html += ‘
meta_key数量分表状态
${k} ${res.data[k].count} ${res.data[k].table_exists ? ‘已分表‘ : ‘未分表‘}
‘; var statusDiv = document.getElementById(‘ydb-bd-postmeta-status’); if(statusDiv) statusDiv.innerHTML = html; }); } // 查询功能开关 function toggleQuerySwitch(inputId, statusClass, actionKey){ var input = document.getElementById(inputId); var statusSpan = document.querySelector(statusClass); if(input){ input.addEventListener(‘change’, function(){ var enabled = input.checked ? 1 : 0; var postData = {}; postData[actionKey] = enabled; postData.action = ‘ydb_bd_set_query_toggle’; ajaxPost(window.ajaxurl, postData, function(){ if(statusSpan) statusSpan.textContent = enabled ? ‘分表查询已开启’ : ‘已恢复原查询’; }); }); } } // 类型显示/隐藏按钮 function bindToggleBtn(btnClass, listClass){ var btn = document.querySelector(btnClass); var list = document.querySelector(listClass); if(btn && list){ btn.addEventListener(‘click’, function(){ if(list.classList.contains(‘ydb-bd-hidden’)){ list.classList.remove(‘ydb-bd-hidden’); btn.textContent = ‘隐藏类型’; }else{ list.classList.add(‘ydb-bd-hidden’); btn.textContent = ‘显示类型’; } }); } } // 页面初始化 document.addEventListener(‘DOMContentLoaded’, function(){ setTimeout(ydbBdPostsStatus, 800); setTimeout(ydbBdPostmetaStatus, 800); // 绑定类型显示/隐藏 bindToggleBtn(‘.ydb-bd-toggle-posts-types’, ‘.ydb-bd-posts-types-list’); bindToggleBtn(‘.ydb-bd-toggle-meta-keys’, ‘.ydb-bd-postmeta-keys-list’); // 查询功能切换 toggleQuerySwitch(‘ydb-bd-posts-query-toggle’, ‘.ydb-bd-posts-query-status’, ‘posts_toggle’); toggleQuerySwitch(‘ydb-bd-postmeta-query-toggle’, ‘.ydb-bd-postmeta-query-status’, ‘postmeta_toggle’); }); 】 ydb-bd.php【插件主文件】文件代码: 【
2025年7月14日 by 一个老不正经

New Chat

2025年7月7日 by 秒速五厘米

这是js功能【document.addEventListener(‘DOMContentLoaded’, function () { // ========== 1. 横向无缝跑马灯轮播 ========== (function () { const track = document.getElementById(‘carouselTrack’); if (!track) return; const items = Array.from(track.children); const itemCount = items.length; let itemWidth = items[0].offsetWidth + 24; // 24px为左右间距(视实际情况调整) let animationId; let pos = 0; const speed = 1; // 克隆内容实现无缝循环 function cloneItems() { items.forEach(item => { const clone = item.cloneNode(true); clone.classList.add(‘clone’); track.appendChild(clone); }); } cloneItems(); function updateItemWidth() { itemWidth = items[0].offsetWidth + 24; } window.addEventListener(‘resize’, updateItemWidth); function animate() { pos -= speed; if (Math.abs(pos) >= itemWidth * itemCount) pos = 0; track.style.transform = `translateX(${pos}px)`; animationId = requestAnimationFrame(animate); } updateItemWidth(); animate(); // 悬停暂停 const container = track.parentElement; container.addEventListener(‘mouseenter’, () => cancelAnimationFrame(animationId)); container.addEventListener(‘mouseleave’, animate); })(); // ========== 2. 主图+缩略图轮播大图切换 ========== (function () { const slides = document.querySelectorAll(‘#mainImageBox .main-image-w’); const thumbs = document.querySelectorAll(‘#carouselList img’); if (!slides.length) return; let current = 0, timer = null; const total = slides.length; function showSlide(idx) { slides.forEach((el, i) => el.classList.toggle(‘active’, i === idx)); thumbs.forEach((el, i) => el.classList.toggle(‘active’, i === idx)); current = idx; } function nextSlide() { showSlide((current + 1) % total); } function prevSlide() { showSlide((current – 1 + total) % total); } function startAuto() { timer = setInterval(nextSlide, 3000); } function stopAuto() { clearInterval(timer); } thumbs.forEach((thumb, idx) => { thumb.addEventListener(‘click’, () => { showSlide(idx); stopAuto(); startAuto(); }); }); [‘mainImageBox’, ‘carouselList’].forEach(boxId => { const box = document.getElementById(boxId); if (box) { box.addEventListener(‘mouseenter’, stopAuto); box.addEventListener(‘mouseleave’, startAuto); } }); document.addEventListener(‘keydown’, function (e) { if (e.key === ‘ArrowLeft’) { stopAuto(); prevSlide(); startAuto(); } if (e.key === ‘ArrowRight’) { stopAuto(); nextSlide(); startAuto(); } }); // 移动端滑动支持 let touchStartX = 0; const mainBox = document.getElementById(‘mainImageBox’); if (mainBox) { mainBox.addEventListener(‘touchstart’, e => { touchStartX = e.touches[0].clientX; }); mainBox.addEventListener(‘touchend’, e => { let dx = e.changedTouches[0].clientX – touchStartX; if (Math.abs(dx) > 30) { stopAuto(); dx < 0 ? nextSlide() : prevSlide(); startAuto(); } }); } showSlide(0); startAuto(); })(); // ========== 3. 图片弹窗预览 ========== (function () { function createImgModal(imgList, currentIdx) { const modal = document.getElementById('imgModal'); if (!modal) return; modal.innerHTML = ` `; modal.style.display = ‘flex’; let rot = 0, scale = 1, idx = currentIdx; const img = modal.querySelector(‘img’); function updateTransform() { img.style.transform = `scale(${scale}) rotate(${rot}deg)`; } modal.querySelector(‘.modal-close’).onclick = () => { modal.style.display = ‘none’; modal.innerHTML = ”; }; if (imgList.length > 1) { modal.querySelector(‘.modal-prev’).onclick = function () { idx = (idx – 1 + imgList.length) % imgList.length; scale = 1; rot = 0; img.src = imgList[idx].src; updateTransform(); }; modal.querySelector(‘.modal-next’).onclick = function () { idx = (idx + 1) % imgList.length; scale = 1; rot = 0; img.src = imgList[idx].src; updateTransform(); }; modal.tabIndex = 0; modal.focus(); modal.onkeydown = function (e) { if (e.key === “ArrowLeft”) modal.querySelector(‘.modal-prev’).click(); if (e.key === “ArrowRight”) modal.querySelector(‘.modal-next’).click(); if (e.key === ‘Escape’) modal.querySelector(‘.modal-close’).click(); } } modal.querySelector(‘.rotateL’).onclick = () => { rot -= 90; updateTransform(); } modal.querySelector(‘.rotateR’).onclick = () => { rot += 90; updateTransform(); } modal.querySelector(‘.zoomIn’).onclick = () => { scale *= 1.2; if (scale > 5) scale = 5; updateTransform(); } modal.querySelector(‘.zoomOut’).onclick = () => { scale /= 1.2; if (scale < 0.3) scale = 0.3; updateTransform(); } modal.onclick = function (e) { if (e.target === modal) { modal.style.display = 'none'; modal.innerHTML = ''; } }; // 拖动支持(仅放大时) let isDown = false, prevX = 0, prevY = 0, lastX = 0, lastY = 0; img.onmousedown = function(e) { if (scale < 1.05) return; isDown = true; prevX = e.pageX; prevY = e.pageY; img.style.cursor = "grabbing"; e.preventDefault(); }; document.onmousemove = function(e) { if (isDown) { lastX += e.pageX - prevX; lastY += e.pageY - prevY; prevX = e.pageX; prevY = e.pageY; img.style.transition = "none"; img.style.transform = `translate(${lastX}px,${lastY}px) scale(${scale}) rotate(${rot}deg)`; } }; document.onmouseup = function() { isDown = false; img.style.cursor = ""; img.style.transition = ""; }; function resetMove() { lastX = 0; lastY = 0; img.style.transform = `scale(${scale}) rotate(${rot}deg)`; } ['modal-prev', 'modal-next', 'rotateL', 'rotateR', 'zoomIn', 'zoomOut'].forEach(cls => { let btn = modal.querySelector(‘.’ + cls); if (btn) btn.addEventListener(‘click’, resetMove); }); } // 事件代理:有ID父的img点击都支持弹窗预览 document.body.addEventListener(‘click’, function (ev) { let t = ev.target; if (t.tagName === ‘IMG’ && t.parentNode && t.parentNode.id) { let matchId = t.parentNode.id; if (!matchId) return; let sameImgs = Array.from(document.querySelectorAll( ‘div#’ + CSS.escape(matchId) + ‘ > img, div#’ + CSS.escape(matchId) + ‘ img’ )); if (!sameImgs.length) return; let idx = sameImgs.findIndex(img => img === t); if (idx < 0) idx = 0; createImgModal(sameImgs, idx); } }, false); })(); }); 】 但是我需要给这段【 】这里面增加一个js功能,就是当点击【

2025年7月6日 by 一个老不正经

请帮我整理以下代码:【window.addEventListener(‘DOMContentLoaded’, function () { const track = document.getElementById(‘carouselTrack’); const items = Array.from(track.children); const itemCount = items.length; let itemWidth = items[0].offsetWidth + 24; // 12px*2 margin let animationId; let trackWidth; // 克隆一遍所有项,实现无缝 function cloneItems() { items.forEach(item => { const clone = item.cloneNode(true); clone.classList.add(‘clone’); track.appendChild(clone); }); trackWidth = track.scrollWidth; } cloneItems(); // 滚动相关变量 let pos = 0; const speed = 1; // px per tick function animate() { pos -= speed; // 无缝关键:如果滑过一组,复位 if (Math.abs(pos) >= itemWidth * itemCount) { pos = 0; } track.style.transform = `translateX(${pos}px)`; animationId = requestAnimationFrame(animate); } // 动态适配宽度(响应式) function updateItemWidth() { itemWidth = items[0].offsetWidth + 24; // margin trackWidth = track.scrollWidth; } window.addEventListener(‘resize’, updateItemWidth); // 开始动画 updateItemWidth(); animate(); // 可选:鼠标悬停暂停 track.parentElement.addEventListener(‘mouseenter’, () => cancelAnimationFrame(animationId)); track.parentElement.addEventListener(‘mouseleave’, () => animate()); }); // 确保 DOM 加载完执行 document.addEventListener(‘DOMContentLoaded’, function() { const slides = document.querySelectorAll(‘#mainImageBox .main-image-w’); const thumbs = document.querySelectorAll(‘#carouselList img’); let current = 0; let timer = null; const total = slides.length; // 初始化显示 function showSlide(idx) { // 移除所有active slides.forEach((el, i) => { el.classList.toggle(‘active’, i === idx); }); thumbs.forEach((el, i) => { el.classList.toggle(‘active’, i === idx); }); current = idx; } // 切到下一张,循环 function nextSlide() { let next = (current + 1) % total; showSlide(next); } // 自动轮播 function startAuto() { timer = setInterval(nextSlide, 3000); } function stopAuto() { clearInterval(timer); } // 点击缩略图 thumbs.forEach((thumb, idx) => { thumb.addEventListener(‘click’, () => { showSlide(idx); stopAuto(); startAuto(); }); }); // 鼠标进入大图或缩略图区暂停轮播,移出恢复 document.getElementById(‘mainImageBox’).addEventListener(‘mouseenter’, stopAuto); document.getElementById(‘mainImageBox’).addEventListener(‘mouseleave’, startAuto); document.getElementById(‘carouselList’).addEventListener(‘mouseenter’, stopAuto); document.getElementById(‘carouselList’).addEventListener(‘mouseleave’, startAuto); // 支持方向箭头键左右切 document.addEventListener(‘keydown’, function(e) { if (e.key === ‘ArrowLeft’) { stopAuto(); showSlide((current – 1 + total) % total); startAuto(); } if (e.key === ‘ArrowRight’) { stopAuto(); nextSlide(); startAuto(); } }); // 支持移动端左右手指滑动(简单实现) let touchStartX = 0; document.getElementById(‘mainImageBox’).addEventListener(‘touchstart’, function(e) { touchStartX = e.touches[0].clientX; }); document.getElementById(‘mainImageBox’).addEventListener(‘touchend’, function(e) { let dx = e.changedTouches[0].clientX – touchStartX; if (Math.abs(dx) > 30) { stopAuto(); if (dx < 0) { // 左滑 nextSlide(); } else { // 右滑 showSlide((current - 1 + total) % total); } startAuto(); } }); // 首次显示 showSlide(0); startAuto(); }); document.addEventListener('DOMContentLoaded', function(){ // 一些弹窗函数 function createImgModal(imgList, currentIdx) { const modal = document.getElementById('imgModal'); if (!modal) return; modal.innerHTML = ` `; // 显示 modal.style.display = ‘flex’; // 变量 let rot = 0, scale = 1, idx = currentIdx; // 元素 const img = modal.querySelector(‘img’); // 工具 function updateTransform() { img.style.transform = `scale(${scale}) rotate(${rot}deg)`; } // 绑定事件 modal.querySelector(‘.modal-close’).onclick = function(){ modal.style.display = ‘none’; modal.innerHTML = ”; }; if (imgList.length>1) { modal.querySelector(‘.modal-prev’).onclick = function(){ idx = (idx-1+imgList.length)%imgList.length; scale = 1; rot=0; img.src = imgList[idx].src; updateTransform(); }; modal.querySelector(‘.modal-next’).onclick = function(){ idx = (idx+1)%imgList.length; scale = 1; rot=0; img.src = imgList[idx].src; updateTransform(); }; // 键盘左右切换 modal.tabIndex = 0; modal.focus(); modal.onkeydown = function(e) { if (e.key===”ArrowLeft”) modal.querySelector(‘.modal-prev’).click(); if (e.key===”ArrowRight”) modal.querySelector(‘.modal-next’).click(); if (e.key===’Escape’) modal.querySelector(‘.modal-close’).click(); } } // 旋转放大缩小 modal.querySelector(‘.rotateL’).onclick = function(){rot-=90; updateTransform();} modal.querySelector(‘.rotateR’).onclick = function(){rot+=90; updateTransform();} modal.querySelector(‘.zoomIn’).onclick = function(){scale*=1.2;if(scale>5)scale=5; updateTransform();} modal.querySelector(‘.zoomOut’).onclick = function(){scale/=1.2;if(scale<0.3)scale=0.3; updateTransform();} // 点击弹窗空白关闭 modal.onclick = function(e){ if (e.target===modal) { modal.style.display='none'; modal.innerHTML=''; } }; // 拖动图片预览 let isDown=false, prevX=0, prevY=0, lastX=0, lastY=0; img.onmousedown = function(e){ if(scale<1.05) return; isDown=true; prevX=e.pageX; prevY=e.pageY; img.style.cursor="grabbing"; e.preventDefault(); }; document.onmousemove = function(e){ if(isDown){ lastX += e.pageX - prevX; lastY += e.pageY - prevY; prevX=e.pageX; prevY=e.pageY; img.style.transition="none"; img.style.transform = `translate(${lastX}px,${lastY}px) scale(${scale}) rotate(${rot}deg)`; } }; document.onmouseup = function(){ isDown=false; img.style.cursor=""; img.style.transition=""; }; // reset位移 on切换/缩放/旋转 function resetMove(){ lastX=0; lastY=0; img.style.transform = `scale(${scale}) rotate(${rot}deg)`;} ['modal-prev','modal-next','rotateL','rotateR','zoomIn','zoomOut'].forEach(cls=>{ let btn=modal.querySelector(‘.’+cls); if(btn) btn.addEventListener(‘click’, resetMove); }); } // 外层事件代理 document.body.addEventListener(‘click’, function(ev){ let t = ev.target; // 找img且父div id包含 if (t.tagName===’IMG’ && t.parentNode && t.parentNode.id) { let matchId = t.parentNode.id; if (!matchId) return; // 查找所有同id图片 let sameImgs = Array.from(document.querySelectorAll(‘div#’+CSS.escape(matchId)+’ > img, div#’+CSS.escape(matchId)+’ img’)); if (sameImgs.length===0) return; // 找点击目标在同id图片中的序号 let idx = sameImgs.findIndex(img=>img===t); if (idx<0) idx = 0; // 弹窗 createImgModal(sameImgs, idx); } }, false); }); 】

2025年7月5日 by 一个老不正经

请帮我把下面这个图标修改成网格地球的样式【

2025年7月5日 by 一个老不正经

我的html是这样的【 】 其中使用了js【 window.addEventListener(‘DOMContentLoaded’, function () { const track = document.getElementById(‘carouselTrack’); const items = Array.from(track.children); const itemCount = items.length; let itemWidth = items[0].offsetWidth + 24; // 12px*2 margin let animationId; let trackWidth; // 克隆一遍所有项,实现无缝 function cloneItems() { items.forEach(item => { const clone = item.cloneNode(true); clone.classList.add(‘clone’); track.appendChild(clone); }); trackWidth = track.scrollWidth; } cloneItems(); // 滚动相关变量 let pos = 0; const speed = 1; // px per tick function animate() { pos -= speed; // 无缝关键:如果滑过一组,复位 if (Math.abs(pos) >= itemWidth * itemCount) { pos = 0; } track.style.transform = `translateX(${pos}px)`; animationId = requestAnimationFrame(animate); } // 动态适配宽度(响应式) function updateItemWidth() { itemWidth = items[0].offsetWidth + 24; // margin trackWidth = track.scrollWidth; } window.addEventListener(‘resize’, updateItemWidth); // 开始动画 updateItemWidth(); animate(); // 可选:鼠标悬停暂停 track.parentElement.addEventListener(‘mouseenter’, () => cancelAnimationFrame(animationId)); track.parentElement.addEventListener(‘mouseleave’, () => animate()); }); 】 请帮我制作一个弹窗: 1、根据当前页面html中的id,获取该id的图片(支持多张同id的图片) 2、当点击存在该id的图片时,弹出放大,放大后的初始高度为700(支持放大、缩小、左右旋转),当存在多张图片的时候,会出现左右切换按钮,点击按钮支持左右查看同id的图片 3、右上角需要一个关闭弹窗的图标按钮,点击则关闭该弹窗

2025年7月5日 by 一个老不正经

请帮我制作一个弹窗: 1、根据当前页面html中的id,获取该id的图片(支持多张同id的图片) 2、当点击存在该id的图片时,弹出放大,放大后的初始高度为700(支持放大、缩小、左右旋转),当存在多张图片的时候,会出现左右切换按钮,点击按钮支持左右查看同id的图片 3、右上角需要一个关闭弹窗的图标按钮,点击则关闭该弹窗

2025年7月5日 by 一个老不正经

index.html:【 】 styke.css代码是:【 .carousel-section { flex: 1; display: flex; flex-direction: column; min-width: 0; } .main-image { position: relative; height: 100%; background: #eee; display: flex; align-items: stretch; justify-content: flex-start; overflow: hidden; } .main-image-w { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; transition: opacity 0.7s cubic-bezier(.39,.61,.57,1); pointer-events: none; display: flex; flex-direction: column; } .main-image-w.active { opacity: 1; z-index: 2; pointer-events: auto; } .main-image-w img { width: 100%; height: 100%; object-fit: cover; display: block; user-select: none; } .caption { position: absolute; left: 0; bottom: 0; width: 100%; background: rgba(30,30,30,0.85); color: #fff; font-size: 1.12rem; text-align: center; padding: 11px 0 11px 28px; letter-spacing: 0.02em; box-sizing: border-box; font-weight: 400; } .carousel-container { width: 100%; background: #1a1a1a; padding: 16px 0 10px 0; overflow: hidden; box-sizing: border-box; } .carousel-list { display: flex; gap: 15px; width: 100%; margin: auto 0; justify-content: space-evenly; flex-wrap: nowrap; } .carousel-list img { width: 110px; height: 70px; object-fit: cover; border-radius: 4px; cursor: pointer; border: 2px solid transparent; transition: border .2s; background: #f5f5f5; } .carousel-list img.active, .carousel-list img:hover { border: 2px solid #0abbb9; } 】 其中【
15
标题1
16
标题2
17
标题3
18
标题4
19
标题5
20
标题6
21
标题7
】这部分是无限循环轮播滑块,【】这部分是上面的缩略图,当鼠标点击对应的缩略图的时候,会显示轮播滑块中的对应【
16
标题2
】板块 请在不修改html的情况下,帮我完善成向左无限滑动的轮播滑块

2025年7月5日 by 一个老不正经

index.html:【 】 styke.css代码是:【 .carousel-section { flex: 1; display: flex; flex-direction: column; min-width: 0; } .main-image { position: relative; height: 100%; background: #eee; display: flex; align-items: stretch; justify-content: flex-start; overflow: hidden; } .main-image-w { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; transition: opacity 0.7s cubic-bezier(.39,.61,.57,1); pointer-events: none; display: flex; flex-direction: column; } .main-image-w.active { opacity: 1; z-index: 2; pointer-events: auto; } .main-image-w img { width: 100%; height: 100%; object-fit: cover; display: block; user-select: none; } .caption { position: absolute; left: 0; bottom: 0; width: 100%; background: rgba(30,30,30,0.85); color: #fff; font-size: 1.12rem; text-align: center; padding: 11px 0 11px 28px; letter-spacing: 0.02em; box-sizing: border-box; font-weight: 400; } .carousel-container { width: 100%; background: #1a1a1a; padding: 16px 0 10px 0; overflow: hidden; box-sizing: border-box; } .carousel-list { display: flex; gap: 15px; width: 100%; margin: auto 0; justify-content: space-evenly; flex-wrap: nowrap; } .carousel-list img { width: 110px; height: 70px; object-fit: cover; border-radius: 4px; cursor: pointer; border: 2px solid transparent; transition: border .2s; background: #f5f5f5; } .carousel-list img.active, .carousel-list img:hover { border: 2px solid #0abbb9; } 】 其中【
15
标题1
16
标题2
17
标题3
18
标题4
19
标题5
20
标题6
21
标题7
】这部分是无限循环轮播滑块,【】这部分是上面的缩略图,当鼠标点击对应的缩略图的时候,会显示轮播滑块中的对应【
16
标题2
】板块 请帮我完善

2025年7月5日 by 一个老不正经

下面代码【

Appreciation of Exquisite Embellishments

】是一个宽屏无限向左滑动的无缝轮播滑块的html,背景颜色是rgb(38, 165, 154),文字颜色是:#fff,请帮我完善css和js

2025年7月5日 by 一个老不正经

下面代码【

Appreciation of Exquisite Embellishments

】是一个宽屏无限向左滑动的无缝轮播滑块的html,每次只展现4张图片,不出现停留情况,背景颜色是rgb(38, 165, 154),文字颜色是:#fff,请帮我完善css和js

2025年7月5日 by 一个老不正经

下面代码【

Appreciation of Exquisite Embellishments

】是一个宽屏无限向左滑动的无缝轮播滑块的html,每次只展现4张图片,背景颜色是rgb(38, 165, 154),文字颜色是:#fff,请帮我完善css和js

2025年7月5日 by 一个老不正经