代码笔记

🔐 您尚未登录,点击登录 后可发布新笔记。

#7 | 手动重设WordPress自增值 WordPress 2025-05-29 01:43:36
ALTER TABLE wp_posts AUTO_INCREMENT = 51;
#6 | Ubuntu改主机名 Ubuntu 2025-05-28 18:50:03
sudo hostnamectl set-hostname my-server

然后重启

sudo reboot
#5 | Ubuntu安装宝塔面板 Ubuntu,宝塔面板 2025-05-28 18:47:34
wget -O install_panel.sh https://download.bt.cn/install/install_panel.sh && sudo bash install_panel.sh ed8484bec
#4 | Westlife主题更新用户昵称 Westlife,WordPress 2025-05-26 22:17:27
function westlife_update_comment_author_name() {
    $comments = get_comments( array( 'user_id' => get_current_user_id() ) ); // 获取当前用户的所有评论
    foreach ( $comments as $comment ) {
        $user = get_userdata( $comment->user_id );
        if ( $user && $user->display_name !== $comment->comment_author ) {
            $comment_data = array(
                'comment_ID' => $comment->comment_ID,
                'comment_author' => $user->display_name,
            );
            wp_update_comment( $comment_data );
        }
    }
}
add_action( 'init', 'westlife_update_comment_author_name' );
#3 | 重载 Nginx配置 2025-05-26 19:00:22
nginx -t && nginx -s reload
#2 | 屏蔽 WordPress 自动草稿 WordPress 2025-05-26 11:00:20
// functions.php 添加:
remove_action('admin_init', 'wp_schedule_auto_draft_delete');

add_filter('wp_insert_post_data', function($data){
    if ($data['post_status'] === 'auto-draft') {
        $data['post_status'] = 'draft';
    }
    return $data;
});
#1 | Debian安装BT面板 宝塔面板,Debian 2025-05-26 10:39:37
wget -O install_panel.sh https://download.bt.cn/install/install_panel.sh && bash install_panel.sh ed8484bec