Skip to content

Instantly share code, notes, and snippets.

View nicdford's full-sized avatar

Nic Ford nicdford

View GitHub Profile
@nicdford
nicdford / gist:7b5dcf3b44431e590057626aa69578c2
Created March 20, 2018 00:46
Create excerpt from variable
/**
* Create excerpt from content
*/
function pac_create_exerpt( $content ) {
return wp_trim_words($content, 15, '...');
}
@nicdford
nicdford / gist:3ecb45803e0935cf9b49
Created July 7, 2015 17:21
Control output of looped items
/*========== In Pods Template, Use Function on Field Output ==========*/
{@legend_items,add_icons}
/*========== Add to functions.php ==========*/
function add_icons($items) {
// loop through items
foreach ($items as $item) :
@nicdford
nicdford / gist:adcb40396eaffadf242636a3936a5172
Created September 5, 2019 23:40
Shortcode to display posts headlines by category
[wsuwp_json host="provost.wsu.edu" category="faculty-development" count="10" output="headlines" cache_bust="0"]
@nicdford
nicdford / custom_shortcode_w_pods
Last active November 23, 2019 20:53
A custom shortcode that makes a pods query and returns the value when the shortcode is called.
// Display Wine Items
function cc_display_wine( $atts ) {
// Attributes
extract( shortcode_atts(
array(
'wine_id' => '1',
), $atts )
);
// Line 143 - Missing input labels
$content .= sprintf( "<td data-label='%s' class='%s'><label for='%s'><span class='screen-reader-text'>%s</span></label><input name='%s' type='radio' title='test' value='%s' %s id='%s' %s %s %s/></input></td>", esc_attr( wp_strip_all_tags( $choice['text'], true ) ), $cell_class, $input_id, $input_name, $input_name, esc_attr( $field_value ), $checked, $input_id, $disabled_text, $this->get_tabindex(), $logic_event );
// Line 95 - Missing table header
$content .= "<th scope='col' class='gsurvey-likert-row-label'><span class='screen-reader-text'>Column selection options</span></th>";
const path = require('path');
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
console.log();
console.log('nic look here')
module.exports = {
...defaultConfig,
module: {
@nicdford
nicdford / script.js
Last active August 28, 2020 17:40
JS to convert Make Page Builder sections into Accordion Items
const accordion_items = document.querySelectorAll('.wsu-js-accordion-item');
accordion_items.forEach(item => {
// Set initial state
const child_divs = Array.from(item.children);
child_divs.forEach(element => {
if (element.classList.contains('column') && !element.classList.contains('toggle-visible')) {
element.classList.add('toggle-visible');
{"lastUpload":"2020-12-18T19:18:55.936Z","extensionVersion":"v3.4.3"}
{
"plugins": ["stylelint-order", "stylelint-scss"],
"extends": "stylelint-config-prettier",
"rules": {
"at-rule-no-unknown": null,
"at-rule-empty-line-before": [
"always",
{
"except": [
"blockless-after-same-name-blockless",
@nicdford
nicdford / adding-layers-to-mapbox-willy-nilly.ts
Last active June 7, 2022 18:50
Quick snippet for adding turf features as mapbox layers on a map for testing
map.addSource('debugging', {
type: 'geojson',
data: intersectFeature,
})
map.addLayer({
id: 'debugging',
type: 'fill',
source: 'debugging',
layout: {},