日期: 2025 年 10 月 19 日

  • wordpress 简码-文字展示

    AI真的太好用了你知道吗?

    源码


    <?php
    // 在主题的functions.php文件中添加以下代码
    
    // 注册所有文字效果简码
    function register_text_effects_shortcodes() {
        // 渐变色文字 - 支持嵌套版本
        add_shortcode('gradient_text_n', 'gradient_text_nested_shortcode');
        
        // 打字机效果 - 支持嵌套版本
        add_shortcode('typewriter_text_n', 'typewriter_text_nested_shortcode');
        
        // 文字阴影效果 - 支持嵌套版本
        add_shortcode('shadow_text_n', 'shadow_text_nested_shortcode');
        
        // 霓虹灯文字 - 支持嵌套版本
        add_shortcode('neon_text_n', 'neon_text_nested_shortcode');
        
        // 3D立体文字 - 支持嵌套版本
        add_shortcode('text_3d_n', 'text_3d_nested_shortcode');
        
        // 文字高亮效果 - 支持嵌套版本
        add_shortcode('highlight_text_n', 'highlight_text_nested_shortcode');
    }
    add_action('init', 'register_text_effects_shortcodes');
    
    // 渐变色文字简码(嵌套版本)
    function gradient_text_nested_shortcode($atts, $content = null) {
        $atts = shortcode_atts(array(
            'color1' => '#ff0000',
            'color2' => '#0000ff',
            'size' => '24px',
            'align' => 'center'
        ), $atts);
        
        $id = 'gradient-text-' . uniqid();
        
        $output = '<style>
            #' . $id . ' {
                font-size: ' . $atts['size'] . ';
                font-weight: bold;
                background: linear-gradient(45deg, ' . $atts['color1'] . ', ' . $atts['color2'] . ');
                -webkit-background-clip: text;
                -webkit-text-fill-color: transparent;
                text-align: ' . $atts['align'] . ';
                margin: 10px 0;
                display: inline-block;
            }
        </style>';
        
        $output .= '<span id="' . $id . '">' . do_shortcode($content) . '</span>';
        
        return $output;
    }
    
    // 打字机效果简码(嵌套版本)
    function typewriter_text_nested_shortcode($atts, $content = null) {
        $atts = shortcode_atts(array(
            'color' => '#333',
            'size' => '24px',
            'cursor' => 'true'
        ), $atts);
        
        $id = 'typewriter-' . uniqid();
        
        $output = '<style>
            #' . $id . ' {
                font-size: ' . $atts['size'] . ';
                color: ' . $atts['color'] . ';
                font-family: monospace;
                overflow: hidden;
                border-right: ' . ($atts['cursor'] == 'true' ? '3px solid ' . $atts['color'] : 'none') . ';
                white-space: nowrap;
                margin: 0;
                letter-spacing: 2px;
                animation: typing 3.5s steps(40, end), blink-caret .75s step-end infinite;
                display: inline-block;
            }
            
            @keyframes typing {
                from { width: 0 }
                to { width: 100% }
            }
            
            @keyframes blink-caret {
                from, to { border-color: transparent }
                50% { border-color: ' . $atts['color'] . '; }
            }
        </style>';
        
        $output .= '<span id="' . $id . '">' . do_shortcode($content) . '</span>';
        
        return $output;
    }
    
    // 文字阴影效果简码(嵌套版本)
    function shadow_text_nested_shortcode($atts, $content = null) {
        $atts = shortcode_atts(array(
            'color' => '#333',
            'shadow_color' => '#aaa',
            'size' => '32px',
            'blur' => '10px'
        ), $atts);
        
        $id = 'shadow-text-' . uniqid();
        
        $output = '<style>
            #' . $id . ' {
                font-size: ' . $atts['size'] . ';
                color: ' . $atts['color'] . ';
                text-shadow: 2px 2px ' . $atts['blur'] . ' ' . $atts['shadow_color'] . ';
                font-weight: bold;
                margin: 0;
                display: inline-block;
            }
        </style>';
        
        $output .= '<span id="' . $id . '">' . do_shortcode($content) . '</span>';
        
        return $output;
    }
    
    // 霓虹灯文字简码(嵌套版本)
    function neon_text_nested_shortcode($atts, $content = null) {
        $atts = shortcode_atts(array(
            'color' => '#fff',
            'glow_color' => '#0ff',
            'size' => '40px'
        ), $atts);
        
        $id = 'neon-text-' . uniqid();
        
        $output = '<style>
            #' . $id . ' {
                font-size: ' . $atts['size'] . ';
                color: ' . $atts['color'] . ';
                text-shadow: 0 0 5px ' . $atts['color'] . ', 0 0 10px ' . $atts['color'] . ', 0 0 20px ' . $atts['glow_color'] . ', 0 0 40px ' . $atts['glow_color'] . ', 0 0 80px ' . $atts['glow_color'] . ';
                font-weight: bold;
                margin: 0;
                display: inline-block;
                animation: neon-flicker 2s infinite alternate;
            }
            
            @keyframes neon-flicker {
                0%, 18%, 22%, 25%, 53%, 57%, 100% {
                    text-shadow: 0 0 5px ' . $atts['color'] . ', 0 0 10px ' . $atts['color'] . ', 0 0 20px ' . $atts['glow_color'] . ', 0 0 40px ' . $atts['glow_color'] . ', 0 0 80px ' . $atts['glow_color'] . ';
                }
                20%, 24%, 55% {
                    text-shadow: none;
                }
            }
        </style>';
        
        $output .= '<span id="' . $id . '">' . do_shortcode($content) . '</span>';
        
        return $output;
    }
    
    // 3D立体文字简码(嵌套版本)
    function text_3d_nested_shortcode($atts, $content = null) {
        $atts = shortcode_atts(array(
            'color' => '#3498db',
            'depth' => '5',
            'size' => '36px'
        ), $atts);
        
        $id = 'text-3d-' . uniqid();
        
        $output = '<style>
            #' . $id . ' {
                font-size: ' . $atts['size'] . ';
                color: ' . $atts['color'] . ';
                font-weight: bold;
                text-transform: uppercase;
                position: relative;
                margin: 0;
                display: inline-block;
                letter-spacing: 2px;
                transform: perspective(500px) rotateX(25deg);
            }
            
            #' . $id . ':before {
                content: "' . esc_attr(do_shortcode($content)) . '";
                position: absolute;
                top: ' . $atts['depth'] . 'px;
                left: 0;
                color: rgba(0,0,0,0.2);
                z-index: -1;
                transform: skewX(45deg) translateZ(-10px);
                filter: blur(2px);
                width: 100%;
            }
        </style>';
        
        $output .= '<span id="' . $id . '">' . do_shortcode($content) . '</span>';
        
        return $output;
    }
    
    // 文字高亮效果简码(嵌套版本)
    function highlight_text_nested_shortcode($atts, $content = null) {
        $atts = shortcode_atts(array(
            'color' => '#ffeb3b',
            'text_color' => '#000',
            'padding' => '5px 10px'
        ), $atts);
        
        $id = 'highlight-text-' . uniqid();
        
        $output = '<style>
            #' . $id . ' {
                background-color: ' . $atts['color'] . ';
                color: ' . $atts['text_color'] . ';
                padding: ' . $atts['padding'] . ';
                border-radius: 4px;
                display: inline-block;
                font-weight: bold;
                position: relative;
                overflow: hidden;
            }
            
            #' . $id . ':after {
                content: "";
                position: absolute;
                top: 0;
                left: -100%;
                width: 100%;
                height: 100%;
                background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
                animation: shine 3s infinite;
            }
            
            @keyframes shine {
                0% { left: -100%; }
                100% { left: 100%; }
            }
        </style>';
        
        $output .= '<span id="' . $id . '">' . do_shortcode($content) . '</span>';
        
        return $output;
    }
    PHP

    使用指南


    WordPress文字效果演示

    WordPress文字效果简码演示

    基本效果展示

    渐变色文字

    这是渐变色文字效果
    [gradient_text_n color1=”#ff0000″ color2=”#0000ff”]这是渐变色文字效果[/gradient_text_n]

    打字机效果

    这是打字机效果文字
    [typewriter_text_n]这是打字机效果文字[/typewriter_text_n]

    霓虹灯效果

    霓虹灯文字
    [neon_text_n color=”#fff” glow_color=”#0ff”]霓虹灯文字[/neon_text_n]

    嵌套效果示例

    渐变色 + 高亮嵌套

    这是渐变色文字,里面包含高亮效果
    [gradient_text_n color1=”#ff0000″ color2=”#0000ff”]这是渐变色文字,里面包含[highlight_text_n]高亮效果[/highlight_text_n][/gradient_text_n]

    阴影 + 打字机嵌套

    阴影文字中的打字机效果
    [shadow_text_n shadow_color=”#aaa”]阴影文字中的[typewriter_text_n]打字机效果[/typewriter_text_n][/shadow_text_n]

    多重嵌套效果

    渐变色中的霓虹灯高亮效果
    [gradient_text_n color1=”#ff0000″ color2=”#0000ff”]渐变色中的[neon_text_n]霓虹灯[/neon_text_n]和[highlight_text_n]高亮[/highlight_text_n]效果[/gradient_text_n]

    使用说明

    • 将PHP代码添加到主题的functions.php文件中
    • 在文章或页面中使用相应的简码
    • 所有嵌套版本简码名称以”_n”结尾
    • 支持任意层次的嵌套组合
    • 每个效果都有可自定义的参数
  • 个人题库-更新日志

    “All my friends are toxic”

    现在可以直接从下方输入栏输入答案,不用一次次点击选项了。
    新增的用户界面也是一个摆设而已,但请你记住你上册登录时用的名字。
    优化了部分代码。

    更新简述 V2.01.6.4

    • 兼容了含图片选择题
    • 更新了选择题输入逻辑
      现在可以从下方直接输入回答
    • 添加了一个没用的登录界面
    • 优化了部分代码
    • #已知BUG
      移动版无法兼容图片加载

    未来更新目标

    V2.01.6.5

    更新随机选择下连续选择题的支持

    V2.01.7

    可以通过服务器空中下载最新题库
    题库加密处理

    我很懒的

    But man is not made for defeat. A man can be destroyed but not defeated.

    人不是为失败而生的。一个人可以被毁灭,但不能被打败。

    —— 《老人与海》欧内斯特·海明威

    源码


    func pic_show(options_text):
    	var IMG_NODE = $Label_list/IMG
    	var start_index = options_text.find("img")  # 找到 "img" 的起始位置
    	if start_index != -1:
    		var IMGname = options_text.substr(start_index+3).strip_edges()  # 从img开始截取并去除空白
    		#print(IMGname)  # 输出
    		var IMG_path = exe_get_IMG()
    		IMG_path = IMG_path.path_join(IMGname)
    		if not FileAccess.file_exists(IMG_path):
    			print("文件不存在: ", IMG_path)
    			return null
    		# 直接加载纹理
    		var image = Image.new()
    		var error = image.load(IMG_path)
    		if image.get_width()/image.get_height() <0.95:
    			# 旋转90度
    			image.rotate_90(CLOCKWISE)  # 或者使用 COUNTERCLOCKWISE 取决于需求
    		texture = ImageTexture.new()
    		texture.set_image(image)
    		
    		if not texture:
    			print("无法加载纹理: ", IMG_path)
    			return
    		$Label_list/IMG/IMG.texture = texture
    		IMG_NODE.visible = true
    		IMG_path = exe_get_IMG()
    		#依旧屎山挪用,找到标注的文件位置。然后进行调取,新建一个图片显示器。
    GDScript