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
/* | |
* Convert a multi-dimentional array to a single dimension array. | |
*/ | |
public static function array_flatten( array $arr ) { | |
$flattened = array(); | |
foreach ( $arr as $key => $value ) { | |
if ( is_array( $value ) ) { |
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
let sorted_locations = searched_locations.sort( (a, b) => a.distance - b.distance ); |
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 get_posts_within_radius($center_lat, $center_lng, $radius, $post_limit = 10) { | |
global $wpdb; | |
$sql = " | |
SELECT | |
p.ID, | |
p.post_title AS title, | |
lat_meta.meta_value AS latitude, | |
lng_meta.meta_value AS longitude, | |
(6371 * acos( |
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
/** | |
* | |
* How to use this file | |
* | |
* Step 1: Ensure Gulp CLI is installed globally | |
* npm install gulp-cli -g | |
* Step 2: Install BrowserSync and Gulp as a local development dependency for the project. | |
* npm install browser-sync gulp --save-dev | |
* Step 3: Save this file to the directory and edit where appropriate | |
* Step 4: Type gulp in the command line to initiate BrowserSync |
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
{ | |
"name" : "wp-hot-reloader", | |
"version" : "1.0", | |
"description" : "WordPress hot reload with browser-sync", | |
"author" : "Asiqur Rahman <[email protected]> (https://www.asique.net/)", | |
"license" : "GPL-2.0-or-later", | |
"config" : { | |
"host" : "wp.local", | |
"port" : "8080" | |
}, |
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
add_filter( 'wp_resource_hints', 'preconnect_custom_cdn', 99, 2 ); | |
function preconnect_custom_cdn( $urls, $relation_type ) { | |
if ( $relation_type == 'preconnect' ) { | |
$urls[] = [ | |
'href' => 'https://fonts.googleapis.com', | |
]; | |
$urls[] = [ | |
'href' => 'https://fonts.gstatic.com', | |
'crossorigin' => 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
/** | |
* Filters document title. | |
* | |
* @param array $title The document title parts. | |
* | |
* @return array | |
*/ | |
function wp98_endpoint_document_title( $title ) { | |
if ( is_wc_endpoint_url( 'orders' ) ) { | |
$title['title'] = __( 'My Order Custom Document Title', 'woocommerce' ); |
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
add_action( 'wp_footer', function () { | |
if ( is_single() ) { | |
?> | |
<script> | |
jQuery( function ( $ ) { | |
var gl_load_spinner = $( '#gl-load-more-spinner' ); | |
var gl_next_post_link = $( '.elementor-post-navigation__next.elementor-post-navigation__link a' ).attr( 'href' ); | |
var canBeLoaded = true; | |
const bottomOffset = 2000; | |
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 currentServerDate() { | |
let dateWithTimeZone = new Date().toLocaleString( "en-US", {timeZone: "<?php echo wp_timezone_string(); ?>"} ); | |
let d = new Date( dateWithTimeZone ); | |
var year = d.getFullYear(); | |
var month = ( | |
"00" + ( | |
d.getMonth() + 1 | |
) | |
).slice( - 2 ); |
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
add_filter( 'acf/load_field/name=booking_calendar_feed_link', function ( $field ) { | |
$field['default_value'] = 'Default Value'; | |
$field['disabled'] = 1; | |
return $field; | |
} ); |
NewerOlder