Skip to content

Instantly share code, notes, and snippets.

View saltnpixels's full-sized avatar

Eric Greenfield saltnpixels

View GitHub Profile
@saltnpixels
saltnpixels / containers.css
Created April 28, 2021 20:17
WordPress Containers CSS
/*------- Three types of Containers --------*/
.container {
margin: auto;
max-width: var(--container);
padding-left: var(--container-padding);
padding-right: var(--container-padding);
width: 100%;
}
.container-fluid {
:root {
--fs-base: 1.6rem;
--fs-m: 1.8rem;
--fs-s: 1.4rem;
}
p {
margin: 1rem 0 0 0;
}
@saltnpixels
saltnpixels / base-layout.css
Last active April 28, 2021 16:29
CSS Base Layout
html {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
font-size: 62.5%;
}
body {
font-size: 1.6rem;
-webkit-font-smoothing: antialiased;
@saltnpixels
saltnpixels / get_svg_icon.php
Last active April 27, 2021 20:44
WP Get SVG icon in php from a symbol set
<?php
/**
* Icons Support with symbols to hold all icons in one file
* Simply add icons to the assets folder and run npm run icons
* This will create a symbol-defs.svg in dist with svg's
* symbol file will remove colors and fills.
*
*
* @package ignition
*/
@saltnpixels
saltnpixels / gf_validate_file.php
Created December 17, 2020 18:18
Gravity Forms Validate Uploaded File
add_filter( 'gform_validation', 'custom_validation' );
function custom_validation( $validation_result ) {
$form = $validation_result['form'];
foreach ( $form['fields'] as $field ) {
if ( strpos( $field->cssClass, 'myfileclass' ) !== false ) {
$input = 'input_' . $field->id;
$uploaded_files = json_decode( rgpost( "gform_uploaded_files" ) );
$is_file_uploaded = isset( $uploaded_files->$input );
$filename = '';
@saltnpixels
saltnpixels / wordPress_spreadsheet.php
Created December 8, 2020 17:24
WordPress Excel Spreadsheet
//add the php spreadsheet library via composer interminal
composer require phpoffice/phpspreadsheet
//put function in theme in WP. Use the get_spreadsheet on a file to get the file like a csv. Works on xlsx
function get_spreadsheet($filepath) {
require get_template_directory() . '/vendor/autoload.php'; //if not using wp remove get_template_directory()
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filepath);
$worksheet = $spreadsheet->getActiveSheet();
$worksheet = $spreadsheet->getActiveSheet();
@saltnpixels
saltnpixels / index.js
Last active July 15, 2020 19:03
Ignition Installer
#!/usr/bin/env node
const { spawn } = require('child_process')
const chalk = require('chalk')
const args = require('minimist')(process.argv)
let folder = args._[2] || './'
console.log(chalk.blue('Downloading Ignition Starter Theme'))
@saltnpixels
saltnpixels / membership_meta.php
Last active November 3, 2022 19:55
adding membership meta to rcp from ACF
<?php
/*--------------------------------------------------------------
# Saving Features to Membership Levels from an acf repeater field for RCP Pro
--------------------------------------------------------------*/
function some_feature_list( $level ) {
/**
* @var RCP_Levels $rcp_levels_db
*/
global $rcp_levels_db;
@saltnpixels
saltnpixels / WP_reverse_post_navigation
Created April 14, 2020 16:29
WP Reverse Post Navigation
//found this somewhere on the internet. Reverses the navigation.
//works well with the Post Type Order navigation here https://wordpress.org/plugins/simple-custom-post-order/
//shows the prev and next post in reverse which helps when ordering posts not by date
function the_reverse_post_navigation( $args = array() ) {
$args = wp_parse_args( $args, array(
'prev_text' => '%title',
'next_text' => '%title',
'in_same_term' => false,
@saltnpixels
saltnpixels / upload_url.php
Created January 30, 2020 00:05
WP Upload URL to Media Library
<?php
/**
* @param $url url to upload
* @param int $post_id post to attach it to
*
* Add a url to the media library and attach it to a post if wanted
* @return bool|int|string|WP_Error
*/