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 | |
/** | |
* Pretty Print. | |
* | |
* @param [mixed] $val The value to print | |
*/ | |
function pp( $value ) { | |
switch ( $type = gettype( $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
SELECT wp_users.user_email as "Email", firstmeta.meta_value AS "First Name", lastmeta.meta_value AS "Last Name", ordermeta.meta_value AS "Orders Placed" FROM wp_users | |
LEFT JOIN wp_usermeta as firstmeta on wp_users.ID = firstmeta.user_id and firstmeta.meta_key = 'first_name' | |
LEFT JOIN wp_usermeta as lastmeta on wp_users.ID = lastmeta.user_id and lastmeta.meta_key = 'last_name' | |
LEFT JOIN wp_usermeta as ordermeta on wp_users.ID = ordermeta.user_id and ordermeta.meta_key = '_order_count' | |
WHERE wp_users.ID IN ( | |
SELECT user_id FROM wp_usermeta WHERE meta_key = '_order_count' AND meta_value > 0 | |
) |
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
/* Paste this snippet in the console */ | |
var docWidth = document.documentElement.offsetWidth; | |
[].forEach.call( | |
document.querySelectorAll('*'), | |
function(el) { | |
if (el.offsetWidth > docWidth) { | |
console.log(el); | |
} | |
} |
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 browser language, optionally passing a list of available languages. | |
* | |
* @param [array] $available_languages Available languages for the site | |
* @param [string] $default Default language for the site | |
* @return [string] Language code | |
*/ | |
function get_browser_language_code( $available_languages = [], $default = 'en' ) : string | |
{ |
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
.widget-name { | |
container: inline-size / widget-name; | |
/* Shorthand for: */ | |
/* container-type: inline-size; */ | |
/* container-name: widget-name; */ | |
/* For quick testing, do this to get a resize handle on desktop: */ | |
/* resize: both; */ | |
/* overflow: hidden; */ | |
} |
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 passed argument is a callable function. | |
* | |
* @param {Callable} func | |
* @return {Boolean} | |
*/ | |
export function isFunction( func ) { | |
return func && {}.toString.call( func ) === '[object Function]'; | |
} |
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
<!-- https://technology.blog.gov.uk/2020/02/24/why-the-gov-uk-design-system-team-changed-the-input-type-for-numbers/ --> | |
<input type="text" inputmode="numeric" pattern="[0-9]*"> |
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
@media (hover: hover) { | |
/* targets only non-touch devices */ | |
} | |
@media (hover: none) { | |
/* targets only touch devices */ | |
} |
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 the user IP address from the server request. | |
* | |
* @return string | |
*/ | |
function get_user_ip() : string { | |
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { | |
return $_SERVER[ 'HTTP_CLIENT_IP' ]; |
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
RewriteEngine On | |
RewriteBase / | |
RewriteCond %{HTTPS} off | |
RewriteCond %{HTTP:X-Forwarded-Proto} !https | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] |