Posted On October 8, 2021

How To Add JavaScript Functions into WordPress

kimconnect 0 comments
blog.KimConnect.com >> Codes >> How To Add JavaScript Functions into WordPress

Assuming that the ‘Code Snippets’ plugin has already been installed, here’s a demonstration of adding a lightbox_context.js?ver=3.17

<?php
// closeout php to output JavaScript directly
?>
<script type="text/javascript">
    function nextgen_lightbox_filter_selector($, selector) 
{
		if (nextgen_lightbox_settings && nextgen_lightbox_settings.context) {
			var context = nextgen_lightbox_settings.context;
			
			if (context == 'all_images') {
				 selector = selector.add($('a > img').parent());
			}
			else if (context == 'all_images_direct') {
				selector = selector.add($('a[href] > img').parent()
				 		.filter(function() {
							var href = $(this).attr('href').toLowerCase();
							var ext = href.substring(href.length - 3);
							var ext2 = href.substring(href.length - 4);
							
							return (ext == 'jpg' || ext == 'gif' || ext == 'png' || ext2 == 'tiff' || ext2 == 'jpeg' || ext2 == 'webp');
						}));
			}
			else if (context == 'nextgen_and_wp_images') {
				 selector = selector.add($('a > img[class*="wp-image-"]').parent());
			}
			
			selector = selector.not('.gallery_link');
            selector = selector.not('.use_imagebrowser_effect');
		}		
		return selector;
};
</script>

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

How To Use CredSSP to Move Virtual Machines In a Hyper-V Cluster

# Prep on Client $domain='intranet.kimconnect.com' Enable-WSManCredSSP -Role "Client" -DelegateComputer "*.$domain" # Prep on Server Enable-WSManCredSSP…

PowerShell: Get Try Catch Exception Type of a Function

# This function will return the exception type so that it could be specified on…

Simple Active Directory & DNS Synchronization Script

@echo offGOTO push_or_pull:push_or_pullset /p action="Type in Push, Pull, or Quit. Press Enter for default action…