HEX
Server: nginx/1.28.1
System: Linux VM-0-12-opencloudos 6.6.117-45.oc9.x86_64 #1 SMP Thu Dec 4 10:26:39 CST 2025 x86_64
User: www (1000)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/www.waciwang.com/wp-content/themes/miragev-main/inc/rewrite.php
<?php
/**
 * 使用 rewrite 调用不同的模板文件
 */

function vt_rewrite_rules( $wp_rewrite ) {
    $vt_rules = [
        'users/([^/]*)/star/?'      => 'index.php?vt_page=star&user_id=$matches[1]',
        'users/([^/]*)/like/?'      => 'index.php?vt_page=like&user_id=$matches[1]',
        'users/([^/]*)/setting/?'   => 'index.php?vt_page=setting&user_id=$matches[1]',
        'users/([^/]*)/?'           => 'index.php?vt_page=users&user_id=$matches[1]'
    ];
    $wp_rewrite->rules = $vt_rules + $wp_rewrite->rules;
}
add_action( 'generate_rewrite_rules', 'vt_rewrite_rules' );


function vt_add_query_vars($public_query_vars) {
    $public_query_vars[] = 'vt_page';
    $public_query_vars[] = 'user_id';
    $public_query_vars[] = 'id';
    return $public_query_vars;
}
add_action( 'query_vars', 'vt_add_query_vars' );


function vt_template_redirect() {
    global $wp;
    global $wp_query;
    global $wp_rewrite;

    $vt_page =  $wp_query->query_vars['vt_page']; //查询vt_page变量
    switch ($vt_page) {
        case 'like': require_once(TEMPLATEPATH.'/pages/like.php'); die(); // 个人中心-我的点赞
        case 'users': require_once(TEMPLATEPATH.'/pages/users.php'); die(); // 个人中心-用户列表
        case 'star': require_once(TEMPLATEPATH.'/pages/star.php'); die(); // 个人中心-收藏列表
        case 'setting': require_once(TEMPLATEPATH.'/pages/setting.php'); die(); // 个人中心-设置
    }
}
add_action( 'template_redirect', 'vt_template_redirect' );


function vt_flush_rewrite_rules(){
    global $pagenow;
    global $wp_rewrite;

    if( 'theme.php' == $pagenow && isset( $_GET['activated'] )) {
        $wp_rewrite->flush_rules();
    }
}
add_action( 'load-themes.php', 'vt_flush_rewrite_rules' );


// add_action('init', 'add_vt_rules');
// function add_vt_rules(){
//     add_rewrite_rule(
//         'users/collections/?',
//         'index.php?vt_page=collections',
//         'top'
//     );
// }