Skip to content

Instantly share code, notes, and snippets.

View KimJoyFox's full-sized avatar

Kim Joy Fox KimJoyFox

View GitHub Profile
@KimJoyFox
KimJoyFox / spotifyAPI.php
Last active April 22, 2024 14:21
Display Spotify Episodes on Your Website: Simple API
<?php
add_shortcode( 'spotify', 'getSpotify' );
function getSpotify(){
// Add 'YOUR_CLIENT_ID' and 'YOUR_CLIENT_SECRET' with your actual Spotify API credentials
$client_id = '';
$client_secret = '';
$show_id = '';
$ch = curl_init();
add_action( 'acf/save_post', 'fox_sync_on_product_save', 99);
function fox_sync_on_product_save( $product_id ) {
$product = wc_get_product( $product_id );
wp_set_object_terms($product_id, 'variable', 'product_type');
$event_dates = get_field('event_dates', $product_id);
if (is_array($event_dates)){
create_product_variation( $product_id, $event_dates );
}
@KimJoyFox
KimJoyFox / gulpfile.js
Last active September 12, 2019 19:14
Starter Gulp.js File
var gulp = require('gulp');
var sass = require('gulp-sass');
var cleanCSS = require('gulp-clean-css');
var minify = require('gulp-minify');
var concat = require('gulp-concat');
gulp.task('styles', function() {
gulp.src('wp-content/themes/themename/assets/sass/style.scss')
.pipe(sass().on('error', sass.logError))
.pipe(cleanCSS())
@KimJoyFox
KimJoyFox / simpleSASS
Created August 23, 2019 05:32
Simple SASS / CSS comparison
/* SIMPLE CSS */
header nav { color:#000; background-color:#fff; }
header nav li { color: #000; font-weight:500; }
header nav li a { padding:5px; border-right:1px solid #f9f9f9; }
header nav li a:last-child { border-right:0px; }
/* SASS - the same code, uncompiled (as a programmer would write it) */
header nav { color:#000; background-color:#fff;
@KimJoyFox
KimJoyFox / functions.php
Created September 14, 2018 19:52
Wordpress: using Excerpts from Advanced Custom Fields on the Search Results Page
function excerpt_function($ID, $searchTerms) {
global $wpdb;
$thisPost = get_post_meta($ID);
foreach ($thisPost as $key => $value) {
if ( false !== stripos($value[0], $searchTerms) ) {
$found = substr(strip_tags($value[0]), 0, 150);
echo $found . ' ...';
}
}
}