This file contains 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 characters
/** | |
* Enqueue styles dynamically into DOM. | |
* Example usage | |
* | |
* enqueueStyle({ | |
* 'splide-styles': { | |
* url: 'https://cdn.jsdelivr.net/npm/@splidejs/splide@4.1.4/dist/css/splide.min.css', | |
* }, | |
* }); | |
* |
This file contains 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 characters
/** | |
* Enqueue scripts dynamically into DOM. | |
* Example usage | |
* | |
* enqueueScript({ | |
* 'html2canvas': { | |
* id: 'html2canvas', | |
* url: 'https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js', | |
* onload: () => { | |
* // code |
This file contains 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 characters
/** | |
* Check if an element is in the viewport using getBoundingClientRect method | |
* | |
* Copied from: https://www.30secondsofcode.org/js/s/element-is-visible-in-viewport/ | |
* | |
* @param object el Element object | |
* @param boolean partiallyVisible If element is partially visible or not | |
* @return boolean | |
*/ | |
function elementInViewport(el, partiallyVisible = true) { |
This file contains 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 characters
/** | |
* Function to redirect to a url with the all the current URL params | |
* | |
* @param string url | |
* @param object params | |
* @param boolean dontCarryParams | |
* | |
* usage: | |
* redirect('http://example.com', {param1: 111, param2: 222}) | |
* will redirect to http://example.com/?param1=111¶m2=222 |
This file contains 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 characters
/** | |
* Dispatch an event using CustomEvent constructor, | |
* that can be listened to using addEventListener method | |
* | |
* Example usage: | |
* | |
* dispatchAnEvent('my-custom-event', {data: 'The data'}) | |
* | |
* window.addEventListener('my-custom-event', function(event) { | |
* |
This file contains 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 characters
<?php | |
/** | |
* This function should be only used in AJAX templates & AJAX callbacks. | |
* | |
* | |
* Use cases of this function are when you need to get a URL param inside a | |
* PHP template rendered through AJAX or an AJAX callback that needs access | |
* to the parent URL param (From where the ajax call was made). i.e, | |
* calling ajax.php from http://exmple.com/my-page/?param1=v111¶m2=v222. | |
* A header of URLPARAMS needsto be added to the request headers. i.e, using |
This file contains 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 characters
<?php | |
/** | |
* Get next n number of dates from a specified date | |
* | |
* @param Integer $n Number of dates | |
* @param String $from Now or the from date | |
* @param Boolean $exclude_weekends Exclude weekends | |
* @return Array | |
*/ |
This file contains 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 characters
<?php | |
/** | |
* wpadminbar toggle for conveniently showing/hiding adminbar from a URL parameter. | |
* | |
* USAGE: | |
* 1. Upload wp-adminbar-toggler.php to theme | |
* 2. Include this file in theme's functions.php | |
* - require_once( get_stylesheet_directory() . '/wp-adminbar-toggler.php' ); | |
* 3. Use ?adminbar=1 in the URL to show adminbar. Use ?adminbar=0 in the URL to |
This file contains 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 characters
<?php | |
/** | |
* WP_DEBUG toggle for conveniently turning on and off from the a URL param "debug" | |
* Its good when working on a staging site where you need debug functionality on/off | |
* | |
* usage: | |
* | |
* Include this file in wp-config.php (include 'wp-debug.php';) | |
* Make sure to comment out all these constants in wp-config.php | |
* |
This file contains 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 characters
<?php | |
/** | |
* This function retrieves post meta using a custom $wpdb query. There are two reasons for this approach. | |
* 1. When doing get_post_meta to query all the meta keys it returns an array or array | |
* 2. This function also queries for LIKE fields. i.e, get_post_meta2(1, 'first_name, last_name, hobby_%') | |
* | |
* TODO: distinct meta_key, meta_value | |
* | |
*/ |
NewerOlder