Skip to content

Instantly share code, notes, and snippets.

@daggerhart
daggerhart / intro-to-plugin-dev.php
Last active Aug 29, 2015
Wordcamp AVL 2014 - Introduction to Wordpress Plugin Development
View intro-to-plugin-dev.php
<?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 Aug 29, 2015
Vagrantfile - PuPHPet with hostupdater
View Vagrantfile-puphpet-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 Jan 3, 2017
Drupal 7 behavior to get video.js working with ajax
View video-js-ajax-behavior.js
(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 Jan 4, 2017
Drupal 7 Webform dynamic select option list for providing taxonomy terms as an option list
View vocabulary-terms-option-list.php
<?php
/**
* Implements hook_webform_select_options_info().
*/
function MODULE_webform_select_options_info() {
$items = array();
$vocabularies = taxonomy_get_vocabularies();
View drupal7-install-uninstall-snippets.install.php
<?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 Feb 9, 2017
Example Drupal 7 input filter for inserting a node into an arbitrary formatted text field.
View examplefilter.module.php
<?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 Mar 15, 2017
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
View acf-allow-ui-to-override-local-on-output.patch
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 Apr 21, 2017
WordPress Widget API vs Drupal 8 Block Plugin API
View example-drupal-block.php
<?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
Description of WP Media Library (In comments)
View WordPress Media Library
details in the first comment
@daggerhart
daggerhart / update-upgrade-reboot-wait.yml
Last active May 24, 2017
Ansible task for Debian/Ubuntu that updates package cache, then as necessary: upgrades, reboots, wait for server to come back up to continue.
View update-upgrade-reboot-wait.yml
# 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