Skip to content

Instantly share code, notes, and snippets.

View jfitzsimmons2's full-sized avatar
🤖
Leveling

jfitzsimmons2

🤖
Leveling
View GitHub Profile
@jfitzsimmons2
jfitzsimmons2 / HstDropdown.vue
Created April 11, 2022 19:19
A basic dropdown component for @histoire/histoire-controls
<script lang="ts">
export default {
name: 'HstDropdown',
}
</script>
<script lang="ts" setup>
import { ref } from 'vue'
import HstWrapper from '../HstWrapper.vue'
@jfitzsimmons2
jfitzsimmons2 / drall.php
Last active March 20, 2022 02:28
Drush 9 @sites workaround for Drupal 8
#!/usr/bin/php
<?php
/*
* Usage:
* ./drall.php [local/dev8/stage8/ww1] drushcommand
* ex: ./drall.php local cim
*
*/
// Path to sites.php file.
include('docroot/sites/sites.php');
@jfitzsimmons2
jfitzsimmons2 / wave-mixin.scss
Last active April 4, 2018 15:44
A mixin to implement the 'Bank Note' pattern from https://www.heropatterns.com/
@mixin wave($base-color: #235937, $opacity: 0.4) {
$alt: darken($base-color, 5%);
background-color: $base-color;
background-image: url("data:image/svg+xml,%3Csvg width='100' height='20' viewBox='0 0 100 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M21.184 20c.357-.13.72-.264 1.088-.402l1.768-.661C33.64 15.347 39.647 14 50 14c10.271 0 15.362 1.222 24.629 4.928.955.383 1.869.74 2.75 1.072h6.225c-2.51-.73-5.139-1.691-8.233-2.928C65.888 13.278 60.562 12 50 12c-10.626 0-16.855 1.397-26.66 5.063l-1.767.662c-2.475.923-4.66 1.674-6.724 2.275h6.335zm0-20C13.258 2.892 8.077 4 0 4V2c5.744 0 9.951-.574 14.85-2h6.334zM77.38 0C85.239 2.966 90.502 4 100 4V2c-6.842 0-11.386-.542-16.396-2h-6.225zM0 14c8.44 0 13.718-1.21 22.272-4.402l1.768-.661C33.64 5.347 39.647 4 50 4c10.271 0 15.362 1.222 24.629 4.928C84.112 12.722 89.438 14 100 14v-2c-10.271 0-15.362-1.222-24.629-4.928C65.888 3.278 60.562 2 50 2 39.374 2 33.145 3.397 23.34 7.063l-1.767.662C13.223 10.84 8.163 12 0 12v2z' fill='#{$alt}' fill-opacity='#{$opacity}
function paragraphs_pages_classy_paragraphs_list_options($options, $field, $instance) {
if ($instance['field_name'] === 'field_background_options') {
$options['bg-lg'] = t('Light gray background (soft)');
$options['bg-gr'] = t('Green background (strong)');
$options['bg-ye'] = t('Gold background (loud)');
}
if ($instance['field_name'] === 'field_spacing_options') {
$options['mv5'] = t('Add vertical margin');
$options['mb5'] = t('Add margin bottom');
@jfitzsimmons2
jfitzsimmons2 / Wordpress Bootstrap 3 nav.php
Last active November 10, 2017 15:01
How to structure your WP <nav> tag using wp_nav_menu to use Bootstrap 3's navbar. Note this is specifically for the "fixed top" version of the navbar (http://getbootstrap.com/components/#navbar-fixed-top). Also only works for single-level navs. If there are sub-menus, additional tweaking is needed.
<nav id="site-navigation" class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><?php bloginfo( 'name' ); ?></a>
<?php
/**
* Implements hook_theme_registry_alter().
*/
function MODULENAME_theme_registry_alter(&$theme_registry) {
// Defined path to the current module.
$module_path = drupal_get_path('module', 'MODULENAME');
$module_path .= '/templates';
/**
* Implements hook_theme_registry_alter().
*/
function MODULENAME_theme_registry_alter(&$theme_registry) {
// Defined path to the current module.
$module_path = drupal_get_path('module', 'MODULENAME') . '/templates';
// Find all .tpl.php files in this module's folder recursively.
$template_file_objects = drupal_find_theme_templates($theme_registry, '.tpl.php', $module_path);
// Iterate through all found template file objects.
foreach ($template_file_objects as $key => $template_file_object) {
@jfitzsimmons2
jfitzsimmons2 / CPT.php
Last active January 18, 2016 12:03
A Sublime Text snippet that expands into a function that will register a custom post type in WordPress. CPT + Tab will generate the code.$1 = lowercase forms of the CPT name$2 = uppercase forms of the CPT name
<snippet>
<content><![CDATA[
<?php
add_action( 'init', 'register_cpt_$1' );
function register_cpt_$1() {
$labels = array(
'name' => _x( '$2s', '$1' ),
@jfitzsimmons2
jfitzsimmons2 / wp-config.php
Last active October 21, 2015 13:53
My boilerplate wp-config.php file for working locally with WordPress
<?php
if ( file_exists( dirname( __FILE__ ) . '/wp-local-config.php' ) ) {
include( dirname( __FILE__ ) . '/wp-local-config.php' );
define( 'WP_LOCAL_DEV', true ); // We'll talk about this later
} else {
define('DB_NAME', 'database_name_here');
define('DB_USER', 'username_here');
define('DB_PASSWORD', 'password_here');
define('DB_HOST', 'localhost');