Skip to content

Instantly share code, notes, and snippets.

View antmbraun's full-sized avatar

Anthony Braun antmbraun

View GitHub Profile
/**
* @file
* Fires Optimizely custom events when certain conditions are met.
* Knows which events to fire based on values in drupalSettings.optimizely_custom_events array which is populated in mb.module.
*
*/
(function () {
Drupal.behaviors.optimizely_custom_events = {
attach: function () {
// Load plugins
var
autoprefixer = require("autoprefixer"), // CSS vendor prefixes
cssnano = require("cssnano"), // Minify CSS
postcss = require("gulp-postcss"), // PostCSS
concat = require("gulp-concat"), // Combine files
gulp = require("gulp"),
gulpSass = require('gulp-sass')(require('sass')), // Compile Sass
inlineImage = require("gulp-inline-image"), // Allow for base64 icons via inline-image()
rename = require("gulp-rename"), // Rename files
@antmbraun
antmbraun / gist:3ae4f22c6ddd1de2b959284c0ec74e3f
Last active September 12, 2024 10:48
Get all instances of paragraphs in Drupal 8
$entity_storage = \Drupal::entityTypeManager()->getStorage('paragraph');
$query = \Drupal::entityQuery('paragraph')
->condition('type', "paragraph_type_machine_name")
->accessCheck(false);
$results = $query->execute();
$hosted_paragraphs_found = [];
@antmbraun
antmbraun / gist:9dfd501ccd020a5ed729b229de774449
Last active April 2, 2020 23:58
avalanche forecast getter
/**
* Avalanche forecast Shortcode Callback
*
* @return string HTML containing the avalanche forecast image or an error message.
*/
function shortcode_avalanche_forecast() {
// First check the cache.
if ( $cached_value = get_transient("avalanche_forecast") ) {
return $cached_value;
}