Skip to content

Instantly share code, notes, and snippets.

View asha23's full-sized avatar
🎩
Working from home

Ash Whiting asha23

🎩
Working from home
View GitHub Profile
@asha23
asha23 / script-style-handlers.php
Created June 21, 2018 14:07
WordPress plugin to show the script and style handles that are currently enqueued.
<?php
/**
* The plugin bootstrap file.
*
* This file is read by WordPress to generate the plugin information in the plugin
* admin area. This file also includes all of the dependencies used by the plugin,
* registers the activation and deactivation functions, and defines a function
* that starts the plugin.
*
@asha23
asha23 / mixins.scss
Last active June 21, 2018 11:46
Couple of mixins
////
/// mixins.scss
/// Mixins
/// @author Ash Whiting
////
/// FONT SIZES IN REMS
/// Convert font sizes to rems with fallbacks
/// @param {size} $size - Font size in pixels
/// @param {line} $line - Line height in pixels
@asha23
asha23 / languages.txt
Created June 18, 2018 10:58
List of commonly spoken languages
Afrikaans
Albanian
Arabic
Armenian
Basque
Bengali
Bulgarian
Catalan
Cambodian
Chinese (Mandarin)
@asha23
asha23 / gform_stripe_subscriptions.php
Created June 18, 2018 09:35 — forked from saltnpixels/gform_stripe_subscriptions.php
Gravity forms stripe cancel from front end
<?php
/**
* Payment subscriptions and updating billing and cancelling subscriptions takes place with these hooks
* We need the stripe customer user id for updating billing
* we need the entry id of subscription so we can cancel it.
*/
/**
* @param $entry
@asha23
asha23 / pagination_archive_fix.php
Created May 30, 2018 09:10
Fix pagination on custom post type archive page
//==============================================================================
// SORT OUT PAGINATION ON ARCHIVE
// This fixes the canonical link on custom post type archive pages
// Odd WordPress bug that only occurs on archives
//==============================================================================
add_filter('redirect_canonical', 'custom_disable_redirect_canonical');
function custom_disable_redirect_canonical($redirect_url)
{
global $post;
@asha23
asha23 / dstr.php
Last active May 17, 2018 16:18
Convert string to date - Then work out from today how many weeks until the date
// You won't need the string conversion if this is already a date object.
$booking = '18/06/18'; // example string
$date_array = implode('-', array_reverse(explode('/', $booking)));
$now_booking = date('d/m/Y', strtotime($date_array));
$bookDate = DateTime::createFromFormat('d/m/Y', $now_booking);
$waiting = $today->diff($bookDate);
$interval = $waiting->format('%a') / 7;
$weeks = number_format($interval, 1) + 0;
@asha23
asha23 / rep.php
Last active May 17, 2018 16:19
Method for merging 2 ACF repeater fields then using one loop to output them
foreach ($terms as $term) :
$speciality = $term->term_id;
$speciality_val = $speciality;
$args_hs = array(
'numberposts' => -1,
'post_type' => 'clinician',
'suppress_filters' => false,
'meta_key' => 'hospitals_and_specialities_UNIQUE8765678_speciality',
@asha23
asha23 / Ordering by surname (WordPress)
Created March 16, 2018 15:43
Ordering by surname (WordPress)
$my_query = null;
$my_query = new WP_Query($args);
$docs = $my_query->posts;
function lastNameSort($a, $b)
{
$aLast = end(explode(' ', $a->post_title));
$bLast = end(explode(' ', $b->post_title));
<select name="time-hours">
<option value="1">01</option>
<option value="2">02</option>
<option value="3">03</option>
<option value="4">04</option>
<option value="5">05</option>
<option value="6">06</option>
<option value="7">07</option>
<option value="8">08</option>
<option value="9">09</option>
To minimize chances of permissions errors, you can configure npm to use a different directory. In this example, it will be a hidden directory on your home folder.
Back-up your computer before moving forward.
Make a directory for global installations:
mkdir ~/.npm-global
Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'