Skip to content

Instantly share code, notes, and snippets.

if (
( $_SERVER['HTTP_HOST'] == 'c3.live' )
) {
$newurl = 'https://c3.ai/live/';
header('HTTP/1.0 301 Moved Permanently');
header("Location: $newurl");
exit();
}
@bacoords
bacoords / canonical-functions.php
Created August 19, 2020 16:44
c3 yoast canonical fix
/**
* Removes any test urls from Yoast links.
*
* @param [type] $link
* @return void
*/
function c3_fix_yoast_canonical_items( $link ) {
return str_replace(
array(
'c3dti.ai',
@bacoords
bacoords / wp.jquery.default.js
Created July 2, 2019 20:45
Just a default wrapper
(function($) {
// Any generic functions can go here...
$(document).ready(function($){
// Anything that needs to wait for the document to be ready goes here
});
@bacoords
bacoords / scrub-smart-quotes.php
Created February 21, 2019 21:35
Replaces smart quotes with quotation marks when adding shortcodes to WordPress content
/**
* Scrubs content for curly quotes
* @param string $content
* @return string
*/
function prefix_scrub_smart_quotes_from_shortcodes( $content ){
// Search for all smartquotes inside of shortcodes and replace them
$content = preg_replace('/(“|”)(?=[^\[]*\])/', '"', $content );
@bacoords
bacoords / bb-popup-example.js
Created February 18, 2019 18:30
sample bb magnific popup code
$('.cb-drawerfolio a').filter(function () {
return /\.(png|jpg|jpeg|gif)(\?.*)?$/i.test(this.href);
}).magnificPopup({
closeBtnInside: false,
type: 'image',
gallery: {
enabled: true
}
});
<?php
/**
* Hides the thirsty link buttons
*/
function fsb_admin_hide_ta_mce_button(){
if( get_post_type() == 'post' ){
echo '<style>.mce-toolbar .mce-btn-group .mce-btn.ta-add-link-button + .mce-btn {display: none;}</style>';
}
}
add_action( 'admin_head', 'fsb_admin_hide_ta_mce_button' );
@bacoords
bacoords / grab_vimeo_thumbnail.php
Last active June 18, 2025 19:52
Grab a thumbnail of a private (but embeddable) Vimeo video
<?php
/**
* Grab the url of a publicly embeddable video hosted on vimeo
* @param str $video_url The "embed" url of a video
* @return str The url of the thumbnail, or false if there's an error
*/
function grab_vimeo_thumbnail($vimeo_url){
if( !$vimeo_url ) return false;
$data = json_decode( file_get_contents( 'http://vimeo.com/api/oembed.json?url=' . $vimeo_url ) );
@bacoords
bacoords / s2_member_delete_expired_users.php
Created March 1, 2018 22:36
Deletes a batch (max 50) of "expired" S2 Members users
<?php
/**
* Deletes a batch (max 50) of S2 Members users
* @return int number of users deleted
*/
public function delete_batch_of_expired_users(){
$max_users = 50;
$args = array(
@bacoords
bacoords / caldera-disable-visual-editor.php
Last active February 23, 2018 15:24
Disables the visual editor on Caldera forms backend so things like HTML emails don't get messed up
<?php
// Disables the visual editor on Caldera forms backend so things like HTML emails don't get messed up
add_filter( 'user_can_richedit', 'caldera_page_can_richedit' );
function caldera_page_can_richedit( $can )
{
$screen = get_current_screen();
if( $screen->id == 'toplevel_page_caldera-forms'){
return false;
}
return $can;
// Example of how to zip a directory
var gulp = require('gulp');
var zip = require('gulp-zip');
gulp.task('zip', function () {
return gulp.src([
'./**/*',
'!./{node_modules,node_modules/**/*}',
'!./assets/{sass,sass/*}',
'!./gulpfile.js',