This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param $block_content | |
* @param $block | |
* | |
* @return string | |
Surrounds block with html. | |
* Some blocks are too naked to work nicely like ul | |
*/ | |
function surround_block( $block_content, $block ) { | |
if ( empty( trim( $block_content ) ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function test_filter( $block_content, $block ) { | |
if ( empty( trim( $block_content ) ) ) { | |
return $block_content; | |
} | |
if ( $block['blockName'] == 'core/paragraph' ) { | |
return sprintf( | |
'<section class="block-%1$s">%2$s</section>', | |
sanitize_title( $block['blockName'] ), | |
$block_content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'wp_terms_checklist_args', | |
function ( $args ) { | |
$args['checked_ontop'] = false; | |
return $args; | |
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Working on a WordPress theme with others can be difficult if you want to use the same database, but work locally and use git for the code. | |
//To do this we came up with a solution that allows working with a remote DB that everyone on the team can access, while still developing locally. | |
//First make sure that your wp-config file is set to use the remote db: | |
//set the credentials for the remote DB username and table | |
//change DB host to be the ip of the remote server | |
//Example: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'gform_validation', 'profile_validation' ); | |
function profile_validation( $validation_result ) { | |
$form = $validation_result['form']; | |
//date of birth | |
$dob = rgpost('input_4'); //set to date field. also set below | |
// this the minimum age requirement we are validating |