Skip to content

Instantly share code, notes, and snippets.

@hereswhatidid
hereswhatidid / acf-wysiwyg-body-class.php
Created August 12, 2015 20:30
Adds a custom class to a specific WYSIWYG editor within Advanced Custom Fields.
<?php
function my_acf_admin_footer() {
?>
<script>
( function( $) {
acf.add_filter( 'wysiwyg_tinymce_settings', function( mceInit, id ) {
if ( id === 'special-wysiwyg-field' ) {
mceInit.body_class += ' magical-field-class';
}
return mceInit;
@hereswhatidid
hereswhatidid / acf-fields.php
Last active April 18, 2018 17:31
Create custom product details tabs within WooCommerce using an ACF (Advanced Custom Fields) Repeater field.
<?php
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array (
'key' => 'acf_product_options',
'title' => 'Product Options',
'fields' => array (
array (
'key' => 'acf_product_options_tabbedcontent_label',
'label' => 'Tabbed Content',
@hereswhatidid
hereswhatidid / interchange-attachments.php
Created July 15, 2015 18:05
Apply Foundation Interchange parameters to attachment images via filter
<?php
add_filter('wp_get_attachment_image_attributes', 'interchange_the_images', 10, 2);
function interchange_the_images ( $attr, $attachment )
{
/* Use ID to get the attachment object */
$lg_hero_array = wp_get_attachment_image_src( $attachment->ID, 'large', true ); //Large Hero
$md_hero_array = wp_get_attachment_image_src( $attachment->ID, 'medium', true ); // Medium Hero
$sm_hero_array = wp_get_attachment_image_src( $attachment->ID, 'thumbnail', true ); // Mobile Hero
@hereswhatidid
hereswhatidid / disable-long-comments.php
Created April 27, 2015 18:16
WordPress 4.2 comment fix - this will disable any comment over a certain lenght that could theoretically trigger the XSS vulnerability.
<?php
add_filter( 'pre_comment_content', function( $content ) {
if ( strlen( $content ) > 64000 )
wp_die( 'Invalid comment.' );
return $content;
} );
@hereswhatidid
hereswhatidid / dnn_overrides.less
Created April 3, 2015 19:49
LESS code for cleaning up link chooser dialog in DNN.
.ui-dialog {
* {
box-sizing: content-box;
}
.ui-dialog-titlebar {
border-bottom: none;
}
.page {
width: 100% !important;
}
@hereswhatidid
hereswhatidid / bindOnce.js
Created March 11, 2015 14:40
Directive to remove watchers from an element within AngularJS
angular
.module( 'yourAppName' )
.directive( 'bindOnce', BindOnce );
function BindOnce() {
return {
scope: true,
link: function( $scope ) {
setTimeout(function() {
$scope.$destroy();
@hereswhatidid
hereswhatidid / archive-commit-mac.sh
Created August 29, 2014 18:07
Custom file deployment actions for SourceTree. The zip archives generated retain directory structure so you can FTP them to a remote server in one shot. Actions are set up under Preferences -> Custom Actions and all have the Parameters set to "$REPO, $SHA"
#!/bin/sh
# creates a zip archive of the files modified in a merge.
args=("$@")
git archive -o deploy/deploy-${args[1]:0:7}.zip HEAD $(git diff-tree --no-commit-id --name-only -r ${args[1]})
@hereswhatidid
hereswhatidid / Media.php
Last active December 11, 2019 08:50
PrestaShop Media class override to allow for forcing some inline JavaScripts to remain inline.
<?php
Class Media extends MediaCore
{
public static function deferScript($matches)
{
if (!is_array($matches))
return false;
$inline = '';
if (isset($matches[0]))
@hereswhatidid
hereswhatidid / archive-dev.sh
Created May 5, 2014 20:26
Creates an archive of the files that are different between the master and development branches using Sourcetree on the Mac.
#!/bin/sh
args=("$@")
git archive -o deploy/deploy-devcompare.zip HEAD $(git diff-tree --no-commit-id --name-only -r master..development)
@hereswhatidid
hereswhatidid / geo-on-save.php
Created March 13, 2014 21:16
Geo code on save
<?php
//Auctions should be geocoded on save
function geocode_auction($post_id){
$auction_slug = 'auctions';
$_POST += array("{$auction_slug}_edit_nonce" => '');
if ( $auction_slug == $_POST['post_type'] && current_user_can( 'edit_post', $post_id )) {
$address = get_post_meta(get_the_ID(), 'Location', true);