Skip to content

Instantly share code, notes, and snippets.

@woodwardtw
woodwardtw / functions.php
Created June 15, 2022 19:56
messed up river functions
<?php
/**
* UnderStrap functions and definitions
*
* @package UnderStrap
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
#intro .intro-inner {
padding: 30px;
}
#main .entry-content p {
font-size: 1.5rem;
}
.intro-special {
padding: 70px;
@woodwardtw
woodwardtw / fwp-gf-url-adder.php
Created May 19, 2022 19:35
for a gravity form with the ID of 1, adds a URL to feedwordpress assuming the fields are in the order presented
add_action( 'gform_after_submission_1', 'fwp_gf_url_adder', 10, 2 );
function fwp_gf_url_adder($entry, $form){
$url = rgar( $entry, '1' );
$name = rgar( $entry, '2');
$cat = rgar($entry, '3');
$linkdata = array("link_url" => $url,
@woodwardtw
woodwardtw / fwp-fi-example.php
Last active May 17, 2022 10:58
takes a custom field named enclosure that holds a string of data with the first element being the URL of an image and make it a featured image for the post
add_action( 'publish_post', 'fwp_fi_update', 10, 1 );
function fwp_fi_update ($post_id){
if (get_post_meta( $post_id, 'enclosure', true )) {
$messy_data = get_post_meta( $post_id, 'enclosure', true);
$array_data = explode(PHP_EOL, $messy_data);
$img_url = $array_data[0];
$img_id = fwp_fi_add_img($img_url, $post_id);
@woodwardtw
woodwardtw / style.css
Last active May 12, 2022 19:17
temporary custom css for formofawesome.com
.gquiz-answer-explanation {
margin: 20px 0;
padding: 10px;
border: 2px solid yellow;
border-radius: 5px;
transition: all .5s ease;
}
.twins {
width: 500px;
@woodwardtw
woodwardtw / user-registration-action.php
Created May 5, 2022 16:18
looking at the user_register action through gravity form and normal WP paths
add_action( 'user_register', 'explore_user_stuff', 10, 1 );
function explore_user_stuff( $user_id ) {
write_log($_POST);//will have info if done through typical WP fashion but not if through gform
write_log($user_id);//has user ID no matter what
$user = get_user_by('id', $user_id);//get user info
write_log($user);
}
.team-row, .student-row {
border: 1px solid #efefef;
padding: 10px 0;
}
.team-browser, .student-browser {
display:flex;
}
.right-col-team {
@woodwardtw
woodwardtw / nsf-data-adding.js
Created April 20, 2022 17:50
NSF data additions in Google Sheets via Google Script and the NSF API
function writeEstimates() {
let ss = SpreadsheetApp.getActiveSpreadsheet();
let sheets = ss.getActiveSheet();
let allIds = sheets.getRange('a2:a100').getValues();
var row = 2;
allIds.forEach((element) => {
//Logger.log(element[0].toFixed(0))
let estimate = fetchData(element)
sheets.getRange("z"+row).setValue(estimate);
row++;
@woodwardtw
woodwardtw / ereserve-index-builder.js
Last active April 20, 2022 16:47
another version in Google Script
function getAllFolders(){
let doc = DocumentApp.getActiveDocument();
let body = doc.getBody();
let indexDoc = DocumentApp.getActiveDocument();
let indexId = indexDoc.getId();
let parentFolderId = DriveApp.getFileById(indexId).getParents().next().getId();
let parentFolder = DriveApp.getFolderById(parentFolderId);
//Logger.log(parentFolder)
let textFolders = parentFolder.getFolders();
while (textFolders.hasNext()) {
@woodwardtw
woodwardtw / erserve-export.php
Created April 19, 2022 14:27
for our awkward ereserve export . . . generates an HTML page from the unzipped directory located at 'sample' relative to this file . . . could be expanded to handle all the folders
<?php
$clean_folders = array_diff(scandir('sample'), array('..', '.', '.DS_Store'));
foreach ($clean_folders as $folder) {
if($folder)
$path = 'sample/'. $folder;
$sub_folders = array_diff(scandir('sample/'. $folder), array('..', '.', '.DS_Store'));
//var_dump($sub_folders);