Skip to content

Instantly share code, notes, and snippets.

Alex FreshLondon

  • FreshLondon
Block or report user

Report or block FreshLondon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@FreshLondon
FreshLondon / hexdec-to-rgba-usage.php
Created Aug 16, 2019
Convert hexdec color string to rgb(a) string > USAGE
View hexdec-to-rgba-usage.php
<?
// Here's a usage example how to use this function for dynamicaly created CSS
$color = '#ffa226';
$rgb = hex2rgba($color);
$rgba = hex2rgba($color, 0.7);
// CSS output
echo '
@FreshLondon
FreshLondon / hexdec-to-rgba.php
Last active Aug 16, 2019
Convert hexdec color string to rgb(a) string
View hexdec-to-rgba.php
<?
/* Convert hexdec color string to rgb(a) string */
function hex2rgba($color, $opacity = false) {
$default = 'rgb(0,0,0)';
//Return default if no color provided
if (empty($color)) return $default;
//Sanitize $color if "#" is provided
View mahonefirm-form.scss
.contact-outer {
.contact-halves {
display: flex;
justify-content: space-between;
@media (max-width: 767px) {
flex-direction: column;
}
.contact-left {
display: flex;
flex-direction: column;
@FreshLondon
FreshLondon / excerpt-from-acf-field.php
Created Apr 25, 2019
Create excerpt from ACF field
View excerpt-from-acf-field.php
<?
// lets assume the ACF field we want to create an excerpt for is called 'content'
$raw_content = get_field('content');
$trimmed_content = wp_trim_words($raw_content);
$clean_excerpt = apply_filters('the_excerpt', $trimmed_content);
echo $clean_excerpt;
?>
@FreshLondon
FreshLondon / fading-hyperlink.js
Created Apr 12, 2019
Fading screen on hyperlink click
View fading-hyperlink.js
@FreshLondon
FreshLondon / format-phone-number.php
Created Apr 11, 2019
Format ACF phone number in a text field
View format-phone-number.php
<?
/*
In this example our ACF field is 'footer_phone_number'
*
$original = '+44 (0)1234 567 890';
$original = '0044 01234 567 890';
$original = '01234 567 890';
$original = '44 1234 567 890';
Result should always be:
'+441234567890
View debugging-array.php
Array
(
[0] => Array
(
[ID] => 840
[id] => 840
[title] => creativebacon
[filename] => creativebacon.jpg
[filesize] => 67847
[url] => http://localhost:8888/FreshLondon/wp-content/uploads/2016/01/creativebacon.jpg
@FreshLondon
FreshLondon / metres-to-feet-and-inches.php
Last active Mar 16, 2019
Function: metres to feet and inches
View metres-to-feet-and-inches.php
<? function metersToFeetInches($meters, $echo = true) {
$m = $meters;
$valInFeet = $m * 3.2808399;
$valFeet = (int)$valInFeet;
$valInches = round(($valInFeet - $valFeet) * 12);
$data = $valFeet."&prime;".$valInches."&Prime;";
if ($echo == true) {
echo $data;
} else {
return $data;
@FreshLondon
FreshLondon / _media_query_mixins.scss
Created Mar 13, 2019
Sass (SCSS) media query mixins
View _media_query_mixins.scss
//
// MEDIA QUERIES
//––––––––––––––––––––––––––––––––––––––––––––––––––
// A map of breakpoints.
$breakpoints: (
xs: 576px,
sm: 768px,
md: 992px,
lg: 1200px
@FreshLondon
FreshLondon / strip-acf-meta-from-search.php
Created Mar 5, 2019
Strips posts from search queries if ACF meta value post_is_hidden is active
View strip-acf-meta-from-search.php
<?
/**
* Strips posts from search queries if ACF meta value post_is_hidden is active.
*
* @author AM.HIGH
* @version 1.0.0
* @since 1.0.0
*/
function dontSearchTheHidden($query) {
You can’t perform that action at this time.