boxmoe_header_banner_img

Hello! 欢迎来到灵阈研都!

加载中

纸鸢使导读

「LoliMeow」药丸模块2 – 以模板函数方式替换药丸模块样式~💕


avatar
白木 2025年8月28日 95

❤️主题来源💕

🙌本文介绍👀

 

 

😏短代码配置教程⌨️

WordPress后台 👉🏿 外观 👉🏿 主题文件编辑器 👉🏿 找到 ❤️ functions.php ❤️,在最后添加以下代码,保存即可!

function yaowan2_shortcode($atts, $content = null) {
    // 设置默认值
    $atts = shortcode_atts(array(
        'style' => '1'
    ), $atts, 'yaowan2');

    // 编号的背景渐变色和文本渐变颜色
    $styles = array(
        '1'  => array(
            'background' => 'linear-gradient(to right, #FF69B4, #FF1493)',
            'text_gradient' => 'linear-gradient(to right, #ffffffff, #ff8800ff)'
        ),
        '2'  => array(
            'background' => 'linear-gradient(to right, #D3D3D3, #A9A9A9)',
            'text_gradient' => 'linear-gradient(to right, #080141ff, #580243ff)'
        ),
        '3'  => array(
            'background' => 'linear-gradient(to right, #87CEFA, #00BFFF)',
            'text_gradient' => 'linear-gradient(to right, #ff05b4ff, #000000ff)'
        ),
        '4'  => array(
            'background' => 'linear-gradient(to right, #98FB98, #32CD32)',
            'text_gradient' => 'linear-gradient(to right, #000000ff, #005043ff)'
        ),
        '5'  => array(
            'background' => 'linear-gradient(to right, #FFB6C1, #FF6347)',
            'text_gradient' => 'linear-gradient(to right, #000000ff, #720314ff)'
        ),
        '6'  => array(
            'background' => 'linear-gradient(to right, #FFFFE0, #FFFF00)',
            'text_gradient' => 'linear-gradient(to right, #ff0000ff, #120075ff)'
        ),
        '7'  => array(
            'background' => 'linear-gradient(to right, #DC143C, #FF4500)',
            'text_gradient' => 'linear-gradient(to right, #fdfdfdff, #616161ff)'
        ),
        '8'  => array(
            'background' => 'linear-gradient(to right, #4682B4, #5F9EA0)',
            'text_gradient' => 'linear-gradient(to right, #00f7ffff, #51ff00ff)'
        ),
        '9'  => array(
            'background' => 'linear-gradient(to right, #800080, #9400D3)',
            'text_gradient' => 'linear-gradient(to right, #ffffffff, #83ffcfff)'
        ),
        '10' => array(
            'background' => 'linear-gradient(to right, #708090, #2F4F4F)',
            'text_gradient' => 'linear-gradient(to right, #ffffffff, #00ffddff)'
        ),
        '11' => array(
            'background' => 'linear-gradient(to right, #1E90FF, #00BFFF)',
            'text_gradient' => 'linear-gradient(to right, #ffffffff, #fd8686ff)'
        ),
        '12' => array(
            'background' => 'linear-gradient(to right, #32CD32, #2E8B57)',
            'text_gradient' => 'linear-gradient(to right, #ffffffff, #ffbb01ff)'
        ),
        '13' => array(
            'background' => 'linear-gradient(to right, #FF0000, #FF4500)',
            'text_gradient' => 'linear-gradient(to right, #05fff3ff, #75bbfdff)'
        ),
        '14' => array(
            'background' => 'linear-gradient(to right, #FF4500, #FFD700)',
            'text_gradient' => 'linear-gradient(to right, #000000ff, #fc58eeff)'
        ),
        '15' => array(
            'background' => 'linear-gradient(to right, #C0C0C0, #808080)',
            'text_gradient' => 'linear-gradient(to right, #69001aff, #00345fff)'
        ),
        '16' => array(
            'background' => 'linear-gradient(to right, #191970, #4682B4)',
            'text_gradient' => 'linear-gradient(to right, #fcfcfcff, #f88cf3ff)'
        )
    );

    // 获取对应的样式配置
    $style_config = isset($styles[$atts['style']]) ? $styles[$atts['style']] : $styles['1'];

    // 确保content不为空
    if (is_null($content)) {
        $content = '💕'; // 显示默认文本
    }

    // 渐变背景的样式
    $background_style = "
        background: {$style_config['background']} !important;
        border-radius: 20px !important;
        padding: 2px 10px !important;
        display: inline-block !important;
    ";

    // 文本渐变的样式
    $text_style = "
        background: {$style_config['text_gradient']} !important;
        -webkit-background-clip: text !important;
        color: transparent !important;
    ";

    return '
                ' . do_shortcode($content) . '
            ';
}
add_shortcode('yaowan2', 'yaowan2_shortcode');

 

 

😏样式效果与短代码⌨️

由于 药丸模块 原有的短代码问题,还有我新建的 药丸模块 都无法在 代码高亮 中以纯文本展示[在努力解决中],所以各位萌盒子的站长们,点击添加 弹丸模块 后,

请在 yaowan 的后面添加一个数字 2 即可使用~😏

以下短代码中,多了空格,因此才能正常展示纯文本~😫

😏样式效果展示⌨️

你的标题
[ yaowan2 style='1'] 你的标题 [/yaowan2]
你的标题
[ yaowan2 style='2'] 你的标题 [/yaowan2]
你的标题
[ yaowan2 style='3'] 你的标题 [/yaowan2]
你的标题
[ yaowan2 style='4'] 你的标题 [/yaowan2]
你的标题
[ yaowan2 style='5'] 你的标题 [/yaowan2]
你的标题
[ yaowan2 style='6'] 你的标题 [/yaowan2]
你的标题
[ yaowan2 style='7'] 你的标题 [/yaowan2]
你的标题
[ yaowan2 style='8'] 你的标题 [/yaowan2]
你的标题
[ yaowan2 style='9'] 你的标题 [/yaowan2]
你的标题
[ yaowan2 style='10'] 你的标题 [/yaowan2]
你的标题
[ yaowan2 style='11'] 你的标题 [/yaowan2]
你的标题
[ yaowan2 style='12'] 你的标题 [/yaowan2]
你的标题
[ yaowan2 style='13'] 你的标题 [/yaowan2]
你的标题
[ yaowan2 style='14'] 你的标题 [/yaowan2]
你的标题
[ yaowan2 style='15'] 你的标题 [/yaowan2]
你的标题
[ yaowan2 style='16'] 你的标题 [/yaowan2]

 

白木_ShiRoKi

  •  商务微信:Misaka1662
  •  添加请备注「来意」,否则不会通过哟~😝
  •  商务邮箱:Misaka273@outlook.com
  •  「半碗残星~呜呜呜~再来!我还能写…」

 

灰常感谢优良资本霸霸
微信投喂

🤩 微信扫它!

支付宝投喂

♥️ 支付宝扫它!



赞美/嘲讽(0)

查看赞美/嘲讽板

暂无赞美/嘲讽


发表赞美/嘲讽

表情 颜文字
植入代码

广告版 ne-2058250819

//
回退
迈步
新标签页打开
复制
刷新
复制哈希ID
探索选中内容
灵阈研都
返回本都
//
回退
迈步
新标签页打开
复制
刷新
复制哈希ID
探索选中内容
灵阈研都
返回本都