fauzanjeg

Add Dark Mode to Spesific Page

Mar 15th, 2021 (edited)
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. /* Add Dark Mode to Spesific Page */
  2. function add_dark_mode_for_spesific_page() {
  3.     $list = array(
  4.         'http://localhost/wordpress2/2021/03/17/hello-world/',
  5.         'https://localhost/wordpress2/2021/02/15/the-legend-of-zelda-breath-of-the-wild-gameplay-on-the-nintendo-switch/'
  6.     );
  7.  
  8.     if ( in_array( get_permalink(), $list ) ) :
  9.     ?>
  10.         <script id="spesific-dark-mode">
  11.             (function ($) {
  12.                 $(document).ready(function() {
  13.                     // $('.jeg_dark_mode_toggle').trigger('click'); // With Switch || This Function save the dark mode cookie
  14.                     $('body').addClass('jnews-dark-mode'); // Without Switch
  15.                     $('.jeg_dark_mode_toggle').prop('checked', true); // Use this if you use Without Switch
  16.                 })
  17.             })(jQuery)
  18.         </script>
  19.     <?php
  20.     endif;
  21. }
  22. add_action( 'wp_head', 'add_dark_mode_for_spesific_page' );
Add Comment
Please, Sign In to add comment