Advertisement
fauzanjeg

Add Close Button for Header Top Ads and Mobile Sticky Ads || Only Image Ads || via functions.php

Sep 23rd, 2021
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1. /* Add Close Button for Header Top Ads and Mobile Sticky Ads || Only Image Ads || via functions.php */
  2. function add_close_button_to_ads() {
  3.     ?>
  4.     <script>
  5.         /* Add Close Button for Header Top Ads and Mobile Sticky Ads || Only Image Ads */
  6.         (function ($) {
  7.             $(window).ready(function () {
  8.                 var container = $('.jnews_header_top_ads, .jnews_mobile_sticky_ads'),
  9.                     wrapper = container.find('.ads_image_phone');
  10.                 wrapper.html(wrapper.html() + '<span id="close">X</span>');
  11.                 wrapper.find('#close').css({ 'position': 'absolute', 'top': '0px', 'right': '0', 'font-size': '32px', 'cursor': 'pointer' });
  12.                 wrapper.find('#close').click(function (e) {
  13.                     e.preventDefault();
  14.                     $(this).parent().parent().remove();
  15.                 });
  16.             });
  17.         })(jQuery);
  18.     </script>
  19.     <?php
  20. }
  21. add_action( 'wp_footer', 'add_close_button_to_ads' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement