Skip to content

Instantly share code, notes, and snippets.

View nicdford's full-sized avatar

Nic Ford nicdford

View GitHub Profile
@nicdford
nicdford / gist:9e715f9661aa6fd0f688cc03c6e8064b
Created May 4, 2016 18:05
Add Pods Shortcode Wizard to Beaver Builder Text Editer Module
function show_pods_modal_button() {
$fl_builder = pods_v('fl_builder', 'get', 'url');
if (empty($fl_builder)) {
pods_view( PODS_DIR . 'ui/admin/shortcode.php', compact( array_keys( get_defined_vars() ) ) );
echo '<a href="#TB_inline?width=640&inlineId=pods_shortcode_form" class="thickbox button" id="add_pod_button" title="Pods Shortcode"><img style="padding: 0px 6px 0px 0px; margin: -3px 0px 0px;" src="' . PODS_URL . 'ui/images/icon16.png" alt="' . __('Pods Shortcode' ,'pods') . '" />' . __('Pods Shortcode' ,'pods') . '</a>';
}
}
@nicdford
nicdford / gist:a19eec2de96209e319ab0eabb8721109
Created March 20, 2018 00:36
Custom Simple Relationship where param list pods values
<?php
$params = array(
'limit' => 3,
'where' => "source.meta_value = 'google'" // Relationship (Custom Simple)
);
$pods = pods( 'testimony', $params );
if ( !empty( $pods ) ) {
while ($pods->fetch()){
@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: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"]
{"lastUpload":"2020-12-18T19:18:55.936Z","extensionVersion":"v3.4.3"}
// 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');
{
"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: {},