Code Click và Ẩn hiện Google

5 Tháng 9, 2024 | By toanbingo | Filed in: Chưa phân loại.

1- Code ẩn hiện với GG

Chèn vào Footer

<script>	
console.log(document.referrer);
console.log(document.referrer.split('/')[2]);
 
if (document.referrer.split('/')[2] === 'google.com' || document.referrer.split('/')[2] === 'www.google.com' || document.referrer.split('/')[2] === 'google.com.vn' || document.referrer.split('/')[2] === 'www.google.com.vn') { 
    document.document.getElementsByClassName('codeanhien')[0].style.display = 'block'; 
} else {
    document.getElementsByClassName('codeanhien')[0].style.display='none';
}
</script>

2- Code Click chờ

// Code Click cho
// function that runs when shortcode is called
function generateRandomString($length = 10) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}



// function that runs when shortcode is called
function wait_button($atts, $content = null) { 
    ob_start();
    // print_r($atts);
    $id = 'wait-' . generateRandomString(4);
    ?>
        <style>
            .wait-button {
                outline: 0;
                display: inline-block;
                background: #009688;
                color:#fff;
            }
            .wait-button.active {
                background: red;
            }
            .wait-block{
                display: none;
            }
        </style>
        <div class="ma-click">

            <button data-json='<?php echo json_encode($atts) ?>' id="<?php echo $id ?>" class="wait-button"><?php echo $atts['label'] ?></button>
            <div class="wait-block">
            <?php if($atts['type'] == 'block'): ?>
                <?php echo do_shortcode( $content, true ); ?>
            <?php endif ?>
            </div>
        </div>
        <script>
            jQuery(document).ready(function($) {
                let id = null;
                function startDownload(el, counter, value, json) {
                    // this.style.display = 'none';
                    id = setInterval(function () {
                        counter--;
                        if (counter < 0) {
                        	if(json.type == "block")
                        	{
                        		el.next().css('display', 'block');
                        		el.remove();
                        	}
                        	else
                        	{
                            	el.text(value);
                            	el.addClass('active');
                        	}
                        	
                            clearInterval(id);
                        } else {
                            el.text(" Thông tin sẽ xuất hiện sau " +counter.toString() + " giây") ;
                        }
                    }, 1000);
                };
                $('.wait-button').click(function(event) {
                    const parent = $(this).parent();
                    const json = $(this).data('json');
                    if(!$(this).hasClass('active') && id == null)
                        startDownload($(this), json.duration, json.value, json);
                });
            });
        </script>
    <?php
    // $message = 'Hello world!'; 

    $output = ob_get_contents();
    ob_end_clean();
    return $output;
} 
// register shortcode
add_shortcode('wait_button', 'wait_button'); 
// End Code Click cho



3- Chèn vào bài

[wait_button duration="139" label="MÃ SẢN PHẨM ( SKU )" value="HEHE" type="block"] [block id="ma-click"][/wait_button]


[wait_button duration="39" label="PASS Ở ĐÂY" value="MÃ: AG689596369" ][/wait_button]




<p>[wait_button duration="139" label="MÃ SẢN PHẨM ( SKU )" value="MÃ: AG689596369"][/wait_button]</p>

4- CSS

/*ma-click*/
.ma-click {
    text-align: center;
}
/*nút-click*/
.wait-button {
    padding-top: 3px;
    padding-bottom: 3px;
    background: red!important;
}

 


Tags:

Be the first to write a review

Để lại một bình luận

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *