RiPro v2主题 – 文章内页付费小工具添加开通会员按钮

50d514af7c20250216184509

美化说明:
RiPro v2文章内页付费小工具添加开通会员按钮,且已购买才能看见的备注信息,废话不多说直接看效果。
代码部署:
第一步:/主题目录/inc/options/shop-widget-options.php (103行左右)替换文件:

// 购买后不显示价格组件
        if ($IS_PAID == 0) {
            the_post_shop_priceo_options($post_id);
        }

        //按钮组件 异步模式
        if ( is_site_async_cache() ) {
            wp_enqueue_script('clipboard');
            echo '<div class="async-shop-down text-center"><i class="fa fa-spinner fa-spin"></i></div>';
        }else{
            $the_user_type  = _get_user_vip_type($user_id);
            $the_post_price = get_post_price($post_id, $the_user_type);

            if ($IS_PAID == 0) {
                # 未购买... is_site_nologin_pay
                if ($the_user_type == 'nov' && $the_post_price == -1) {
                    echo '<button type="button" class="btn btn-block btn-danger mb-3" disabled>' . esc_html__('暂无购买权限', 'ripro-v2') . '</button>';
                } elseif (empty($user_id) && !is_site_nologin_pay()) {
                    echo '<button type="button" class="btn btn-block btn-primary mb-3 login-btn">' . esc_html__('登录后下载', 'ripro-v2') . '</button>';
                } else {
                    echo '<button type="button" class="btn btn-block btn-primary mb-3 click-pay-post" data-postid="' . $post_id . '" data-nonce="' . $click_nonce . '" data-price="' . $the_post_price . '">' . get_shop_paybtn_txt() . '</button>';
                }

            } elseif ($IS_PAID == 3) {
                # 免费资源...
                if (empty($user_id) && !is_site_nologin_pay()) {
                    echo '<button type="button" class="btn btn-block btn-primary mb-3 login-btn">' . esc_html__('登录后下载', 'ripro-v2') . '</button>';
                } else {
                    the_post_shop_downurl_btns($post_id, $click_nonce);
                }

            } elseif ($IS_PAID > 0) {
                # 已购买...
                the_post_shop_downurl_btns($post_id, $click_nonce);
            }
        }

替换为:

// 购买后不显示价格组件
        // if ($IS_PAID == 0) {
        //     the_post_shop_priceo_options($post_id);
        // }
        //永远显示价格组件

        the_post_shop_priceo_options($post_id);



        //按钮组件 异步模式
        if (!is_site_async_cache() ) {
            wp_enqueue_script('clipboard');
        }else{
            $the_user_type  = _get_user_vip_type($user_id);
            $the_post_price = get_post_price($post_id, $the_user_type);


            if ($IS_PAID == 0) {
                //显示开通会员
                echo '<a href="/user/vip"><button type="button" class="btn btn-block btn-primary mb-3">开通会员</button></a>';

                # 未购买... is_site_nologin_pay
                if ($the_user_type == 'nov' && $the_post_price == -1) {
                    echo '<button type="button" class="btn btn-block btn-danger mb-3" disabled>' . esc_html__('暂无购买权限', 'ripro-v2') . '</button>';
                } elseif (empty($user_id) && !is_site_nologin_pay()) {
                    echo '<button type="button" class="btn btn-block btn-primary mb-3 login-btn">' . esc_html__('登录后下载', 'ripro-v2') . '</button>';
                } else {
                    echo '<button type="button" class="btn btn-block btn-primary mb-3 click-pay-post" data-postid="' . $post_id . '" data-nonce="' . $click_nonce . '" data-price="' . $the_post_price . '">' . get_shop_paybtn_txt() . '</button>';
                }

            } elseif ($IS_PAID == 3) {
                //显示开通会员
                echo '<a href="/user/vip"><button type="button" class="btn btn-block btn-primary mb-3">开通会员</button></a>';

                # 免费资源...
                if (empty($user_id) && !is_site_nologin_pay()) {
                    echo '<button type="button" class="btn btn-block btn-primary mb-3 login-btn">' . esc_html__('登录后下载', 'ripro-v2') . '</button>';
                } else {
                    the_post_shop_downurl_btns($post_id, $click_nonce);
                }

            } elseif ($IS_PAID > 0) {
                # 已购买...
                the_post_shop_downurl_btns($post_id, $click_nonce);
                echo '<div style="margin-top:20px;color: 	#0080FF;border:4px solid #f0f0f5">PS: 如遇链接失效或其他问题请联系客服QQ: <span style="color: red">88888888</span> 协助解决!</div>';
            }
        }

第二步:171行左右 将永久有效修改为购买后永久有效 当然这里也可以不修改 看个人喜好。

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容