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 will break if the ENUM values have comma (,) in them | |
function get_enum_values($wpdb, $table, $field) { | |
$values = array(); | |
$table = "{$wpdb->prefix}{$table}"; | |
$query = "SHOW COLUMNS FROM {$table} WHERE Field = '{$field}'"; | |
$results = $wpdb->get_results($query, ARRAY_A); |
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
/** | |
* 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
/** | |
* 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
/** | |
* 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
/** | |
* 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
{ | |
"New York": [ | |
"New York", | |
"Buffalo", | |
"Rochester", | |
"Yonkers", | |
"Syracuse", | |
"Albany", | |
"New Rochelle", | |
"Mount Vernon", |
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
#!/bin/bash | |
# USAGE: | |
# sh bulk-search-replace.sh dbfile.sql | |
# OR | |
# chmod +x bulk-search-replace.sh | |
# ./bulk-search-replace.sh dbfile.sql | |
# | |
# sed or gsed | |
# |
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
#!/bin/bash | |
# USAGE: | |
# | |
# sh import-mysql-db.sh | |
# bash import-mysql-db.sh | |
# | |
# OR | |
# | |
# chmod +x import-mysql-db.sh |