Skip to content

Instantly share code, notes, and snippets.

@daggerhart
daggerhart / intro-to-plugin-dev.php
Last active August 29, 2015 14:02
Wordcamp AVL 2014 - Introduction to Wordpress Plugin Development
<?php
/*
Plugin Name: Intro to Wordpres Plugin Development
Description: Generic example plugin
Plugin URI: http://www.daggerhart.com/blog/introduction-wordpress-plugin-development/
Author: Jonathan Daggerhart
Author URI: http://www.daggerhart.com
Version: 1.0
Text Domain: intro-to-plugin-dev
Domain: /lang
@daggerhart
daggerhart / Vagrantfile-puphpet-hostupdater
Last active August 29, 2015 14:03
Vagrantfile - PuPHPet with hostupdater
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
# jon -
box_name = "ubuntu-trusty"
# end jon -
dir = File.dirname(File.expand_path(__FILE__))
configValues = YAML.load_file("#{dir}/puphpet/config.yaml")
@daggerhart
daggerhart / video-js-ajax-behavior.js
Last active January 3, 2017 21:12
Drupal 7 behavior to get video.js working with ajax
(function ($) {
Drupal.behaviors.videojsajax = {
attach: function (context, settings) {
if ( typeof videojs != 'undefined' ) {
// find all video elements with video-js class, and re-init them
$('video.video-js').each( function( i , element ){
videojs($(element)[0] , {}, function() {});
});
}
}
@daggerhart
daggerhart / vocabulary-terms-option-list.php
Created January 4, 2017 19:44
Drupal 7 Webform dynamic select option list for providing taxonomy terms as an option list
<?php
/**
* Implements hook_webform_select_options_info().
*/
function MODULE_webform_select_options_info() {
$items = array();
$vocabularies = taxonomy_get_vocabularies();
@daggerhart
daggerhart / drupal7-install-uninstall-snippets.install.php
Created January 11, 2017 21:03
Drupal7 Install / Uninstall snippets. Originally from - https://gitlab.com/snippets/17139
<?php
/**
* Uninstall modules.
*/
function lth_configuration_update_7001() {
module_disable(array('module1', 'module2'));
drupal_uninstall_modules(array('module1', 'module2'));
}
@daggerhart
daggerhart / examplefilter.module.php
Created February 9, 2017 17:07
Example Drupal 7 input filter for inserting a node into an arbitrary formatted text field.
<?php
/**
* Implements hook_filter_info().
*
* @link https://api.drupal.org/api/drupal/modules%21filter%21filter.api.php/function/hook_filter_info/7.x
*/
function examplefilter_filter_info() {
$filters['examplefilter_node_embed'] = array(
'title' => 'EPI node embed',
@daggerhart
daggerhart / acf-allow-ui-to-override-local-on-output.patch
Last active March 15, 2017 05:30
Patch to Advanced Custom Fields 5.5.10 that allows changes to fields in the UI to affect output even if field is "local" JSON or PHP
diff --git a/admin/views/field-group-options.php b/admin/views/field-group-options.php
index ae57dfa..c0871b8 100755
--- a/admin/views/field-group-options.php
+++ b/admin/views/field-group-options.php
@@ -127,6 +127,18 @@ acf_render_field_wrap(array(
));
+// db overrides local
+acf_render_field_wrap(array(
@daggerhart
daggerhart / example-drupal-block.php
Last active April 21, 2017 13:00
WordPress Widget API vs Drupal 8 Block Plugin API
<?php
namespace Drupal\example_block\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Form\FormStateInterface;
@daggerhart
daggerhart / WordPress Media Library
Last active May 17, 2017 20:56
Description of WP Media Library (In comments)
details in the first comment
@daggerhart
daggerhart / update-upgrade-reboot-wait.yml
Last active May 24, 2017 19:37
Ansible task for Debian/Ubuntu that updates package cache, then as necessary: upgrades, reboots, wait for server to come back up to continue.
# Upgrade Debian/Ubuntu based systems and reboot if necessary.
---
- name: "Update apt-get cache"
apt:
update_cache: yes
- name: "Check if there are packages available to be installed/upgraded"
command: /usr/lib/update-notifier/apt-check --package-names
register: packages