Created
July 25, 2024 13:23
-
-
Save abdulawal39/4a9ede737ff3c988bf44332b3862ff1d to your computer and use it in GitHub Desktop.
Revisions
-
abdulawal39 created this gist
Jul 25, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ /** * Bypass Autolink on TNC FlipBook * This snippet allows you to apply autolink to any domains * Copy and paste this code in your active theme's functions.php file * Disable Automatic link/iframe in TNC FlipBook > Global Settings to avoid conflicts. * * @return void */ function tncsupport_pdf_autolink() { $get_pvfw_global_settings = get_option( 'pvfw_csf_options' ); $tnc_al_get_viewer_page_id = $get_pvfw_global_settings['advanced-pdf-viewer-page']; if ( empty( $tnc_al_get_viewer_page_id ) ) { $tnc_al_get_viewer_page_id = get_option( 'tnc_pdf_viewer_page_id', false ); } $tnc_pvfw_default_zoom = $get_pvfw_global_settings['toolbar-default-zoom']; $tnc_pvfw_default_pagemode = $get_pvfw_global_settings['toolbar-default-page-mode']; $viewer_url = get_permalink( $tnc_al_get_viewer_page_id ); $pdf_al = wp_parse_url( $viewer_url, PHP_URL_QUERY ); if ( $pdf_al ) { $viewer_url .= '&file='; } else { $viewer_url .= '?file='; } ?> <script type="text/javascript"> jQuery(document).ready(function() { var gethost = new RegExp(location.host); jQuery("a[href$='.pdf']").each(function() { var _href = jQuery(this).attr("href"); jQuery(this).attr("href", '<?php echo esc_url( $viewer_url ); ?>' + _href + '#zoom=<?php echo esc_html( $tnc_pvfw_default_zoom ); ?>&pagemode=<?php echo esc_html( $tnc_pvfw_default_pagemode ); ?>'); }); }); </script> <?php } add_action( 'wp_footer', 'tncsupport_pdf_autolink' );