Skip to content

Instantly share code, notes, and snippets.

@abdulawal39
Created October 24, 2024 12:23
Show Gist options
  • Select an option

  • Save abdulawal39/0fb04575c60fea60936efd4083029924 to your computer and use it in GitHub Desktop.

Select an option

Save abdulawal39/0fb04575c60fea60936efd4083029924 to your computer and use it in GitHub Desktop.

Revisions

  1. abdulawal39 created this gist Oct 24, 2024.
    23 changes: 23 additions & 0 deletions change-fullscreen-link-target.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    function tnc_support_modify_a_tags() {
    ?>
    <script type="text/javascript">
    document.addEventListener('DOMContentLoaded', function() {
    function tnc_support_update_links() {
    // Find all 'a' tags with the class 'fullscreen-mode'
    const fullscreenLinks = document.querySelectorAll('a.fullscreen-mode');

    // Loop through the NodeList and update the target to '_parent'
    fullscreenLinks.forEach(function(link) {
    link.setAttribute('target', '_parent');
    });
    }

    // Call the function to update the links
    tnc_support_update_links();
    });
    </script>
    <?php
    }

    // Hook it to the WordPress footer or wp_enqueue_scripts action
    add_action('wp_footer', 'tnc_support_modify_a_tags');