世界,您好!

奶狗 发表于 3 周前 浏览 285 分类 未分类

广告

测试

欢迎使用 WordPress。这是您的第一篇文章。编辑或删除它,然后开始写作吧!

<?php
    $current_user = wp_get_current_user();
    $user_meta = get_user_meta($current_user->ID);
    
    // 调试信息
    if (WP_DEBUG) {
      echo '<!-- Debug Info:';
      echo 'User ID: ' . $current_user->ID . "\n";
      echo 'Photo Meta: ' . get_user_meta($current_user->ID, 'photo', true) . "\n";
      echo '-->';
    }
  ?><astro-setting class="mx-auto">
    <div class="mb-8">
        <h2 class="text-xl font-bold text-neutral-900 dark:text-neutral-200"> <?php echo __( '个人资料', 'beebeework' ); ?> </h2>
        <p class="mt-1 text-sm text-neutral-600 dark:text-neutral-400"> <?php echo __( '这些信息将会公开显示,请谨慎填写。', 'beebeework' ); ?> </p>
    </div>
    <form id="profile-form" class="flex flex-col gap-y-8 mb-10" method="post" action="javascript:void(0);" enctype="multipart/form-data"> <?php wp_nonce_field('update_profile_action', 'profile_nonce'); ?> <input type="hidden" name="user_id" value="<?php echo $current_user->ID; ?>">
        <div> <label for="photo" class="block text-sm font-medium text-neutral-900 dark:text-neutral-200 mb-2"> <?php echo __( '头像', 'beebeework' ); ?> </label>
            <div class="avatarinput flex items-center gap-x-3"> <?php 
                set_query_var('size', '64');
                set_query_var('classSize', 'w-16 h-16');
                set_query_var('className', 'avatarimg w-16 h-16 rounded-full');
                get_template_part( 'mod/part-common-avatarimg');
                ?> <label class="muted-btn cursor-pointer px-4 h-9 text-sm rounded-full flex items-center gap-x-2"> <?php echo __( '更换本地头像', 'beebeework' ); ?> <input id="previewavatar" type="file" name="avatar" accept="image/*" class="sr-only"> </label> </div>
        </div>
        <div> <label for="nickname" class="block text-sm font-medium text-neutral-900 dark:text-neutral-200 mb-2"> <?php echo __( '昵称', 'beebeework' ); ?> </label> <input type="text" name="nickname" id="nickname" class="muted-input flex-1" placeholder="<?php echo __( '请输入昵称', 'beebeework' ); ?>" value="<?php echo esc_attr($current_user->display_name); ?>"> </div>
        <div> <label for="about" class="block text-sm font-medium text-neutral-900 dark:text-neutral-200 mb-2"> <?php echo __( '个人简介', 'beebeework' ); ?> </label> <?php 
echo '<textarea
        name="description"
        id="about"
        rows="5"
        class="muted-input w-full rounded-xl"
        placeholder="' . esc_attr(__('写点什么来介绍一下自己吧', 'beebeework')) . '"
        >' . esc_textarea(get_user_meta($current_user->ID, 'description', true)) . '</textarea>'; 
?> <p class="mt-2 text-sm text-neutral-500 dark:text-neutral-400"> <?php echo __( '简单介绍一下自己,让其他用户更了解你。支持换行,最多300字描述。', 'beebeework' ); ?> </p>
        </div> <?php
        $data_public_settings = esc_html__( '数据公开设置', 'beebeework' );
        $description = esc_html__( '选择您希望在个人主页上公开展示的数据', 'beebeework' );
        $user_points = esc_html__( '用户积分', 'beebeework' );
        $user_rank = esc_html__( '用户段位', 'beebeework' );
        $user_badge = esc_html__( '用户勋章', 'beebeework' );
        $public_label = esc_html__( '公开', 'beebeework' );

        $show_points_checked = (get_user_meta($current_user->ID, 'show_points_public', true) !== 'off') ? 'checked' : '';
        $show_rank_checked   = (get_user_meta($current_user->ID, 'show_rank_public', true) !== 'off') ? 'checked' : '';
        $show_badge_checked  = (get_user_meta($current_user->ID, 'show_badge_public', true) !== 'off') ? 'checked' : '';

        echo '
          <div>
            <label class="block text-sm font-medium text-neutral-900 dark:text-neutral-200 mb-2">
              ' . $data_public_settings . '
            </label>
            <p class="mb-4 text-sm text-neutral-500 dark:text-neutral-400">
              ' . $description . '
            </p>
            
            <div class="flex flex-col divide-y divide-neutral-100 dark:divide-neutral-800">
              <div class="flex items-center justify-between py-4">
                <span class="text-sm font-medium text-neutral-900 dark:text-neutral-200 mr-2">' . $user_points . '</span>
                <label class="relative inline-flex items-center cursor-pointer">
                  <input
                    type="checkbox"
                    name="show_points_public"
                    class="sr-only peer"
                    ' . $show_points_checked . '
                  />
                  <div class="muted-switch peer"></div>
                  <span class="ml-3 text-sm font-medium text-neutral-900 dark:text-neutral-300">' . $public_label . '</span>
                </label>
              </div>
              
              <div class="flex items-center justify-between py-4">
                <span class="text-sm font-medium text-neutral-900 dark:text-neutral-200 mr-2">' . $user_rank . '</span>
                <label class="relative inline-flex items-center cursor-pointer">
                  <input
                    type="checkbox"
                    name="show_rank_public"
                    class="sr-only peer"
                    ' . $show_rank_checked . '
                  />
                  <div class="muted-switch peer"></div>
                  <span class="ml-3 text-sm font-medium text-neutral-900 dark:text-neutral-300">' . $public_label . '</span>
                </label>
              </div>
              
              <div class="flex items-center justify-between py-4">
                <span class="text-sm font-medium text-neutral-900 dark:text-neutral-200 mr-2">' . $user_badge . '</span>
                <label class="relative inline-flex items-center cursor-pointer">
                  <input
                    type="checkbox"
                    name="show_badge_public"
                    class="sr-only peer"
                    ' . $show_badge_checked . '
                  />
                  <div class="muted-switch peer"></div>
                  <span class="ml-3 text-sm font-medium text-neutral-900 dark:text-neutral-300">' . $public_label . '</span>
                </label>
              </div>
            </div>
          </div>
        ';
      ?> <?php
        $items = ['usergroup'];
        $options = BSCommon::get_have_rows('memberapi', $items);
        if ($options && isset($options['usergroup']['list']) && is_array($options['usergroup']['list']) && count($options['usergroup']['list']) > 0) {
          foreach ($options['usergroup']['list'] as $field) {
            $field_value = get_user_meta($current_user->ID, $field['value'], true);
            $field_public = get_user_meta($current_user->ID, $field['value'].'_public', true);

            // 构建 placeholder,使用 sprintf + 翻译
            $field_name = esc_html($field['name']);
            if (isset($field['type'])) {
              if ($field['type'] == '1') {
                $field_placeholder = sprintf(__( '请填写您的%s的跳转链接地址', 'beebeework' ), $field_name);
              } elseif ($field['type'] === '2') {
                $field_placeholder = sprintf(__( '请填写您的%s的图片/二维码地址', 'beebeework' ), $field_name);
              } elseif ($field['type'] === '3') {
                $field_placeholder = sprintf(__( '请填写您的%s的文字内容', 'beebeework' ), $field_name);
              } else {
                $field_placeholder = sprintf(__( '请输入%s', 'beebeework' ), $field_name);
              }
            } else {
              $field_placeholder = sprintf(__( '请输入%s', 'beebeework' ), $field_name);
            }

            $public_label = esc_html__( '公开', 'beebeework' );
            ?>
        <div class="flex items-end gap-4 mb-4">
            <div class="flex-1">
                <label for="<?php echo esc_attr($field['value']); ?>" class="block text-sm font-medium text-neutral-900 dark:text-neutral-200 mb-2">
                    <?php echo $field_name; ?>
                </label>
                <div class="relative flex flex-col w-full h-10">
                    <input type="text" name="<?php echo esc_attr($field['value']); ?>" id="<?php echo esc_attr($field['value']); ?>" class="muted-input flex-1 ps-10" placeholder="<?php echo esc_attr(__( '请按下方提示输入内容', 'beebeework' )); ?>" value="<?php echo esc_attr($field_value); ?>" />
                    <p class="ps-4 mt-2 text-xs text-neutral-500 dark:text-neutral-500"><?php echo esc_html($field_placeholder); ?></p>
                    <?php if (!empty($field['icon'])) { ?>
                    <label class="text-sm text-gray-500 absolute left-3 top-2.5">
                        <i class="i-[ri--<?php echo esc_attr($field['icon']); ?>] !size-5 block"></i>
                    </label>
                    <?php } ?>
                </div>
            </div>
            <div class="flex items-center h-[42px]">
                <label class="relative inline-flex items-center cursor-pointer">
                    <input type="checkbox" name="<?php echo esc_attr($field['value']); ?>_public" class="sr-only peer" <?php checked($field_public, 'on', true); ?> />
                    <div class="muted-switch peer"></div>
                    <span class="ml-3 text-sm font-medium text-neutral-900 dark:text-neutral-300"><?php echo $public_label; ?></span>
                </label>
            </div>
        </div>
        <?php
          }
        }
      ?> <div class="flex justify-end"> <button id="submit-btn" type="submit" class="primary-btn h-10 text-sm rounded-full px-4"> <?php echo __( '保存修改', 'beebeework' ); ?> </button> </div>
    </form>
</astro-setting>
共 2 条评论
相关内容

世界,您好!

  • 未分类