Skip to content

Instantly share code, notes, and snippets.

View keiraarts's full-sized avatar
🍊

Keira Climson keiraarts

🍊
View GitHub Profile
@keiraarts
keiraarts / gravity-to-sheets.php
Last active February 11, 2018 19:22
Gravity Forms to Google Sheets
add_action('gform_after_submission_34', 'add_row', 10, 2);
function add_row($entry, $form){
$email = $entry[1];
// Follow this tutorial to create a GOOGLE SHEETS SCRIPT
// https://ctrlq.org/code/20047-gravity-forms-to-google-spreadsheet
$post_url = 'https://script.google.com/a/logocore.com/macros/s/GOOGLE-SHEETS-SCRIPT/exec';
// Put all the form fields (names and values) in this array, comma seperated.
@keiraarts
keiraarts / custom-forgot-emails.php
Created February 11, 2018 19:33
Customize the Wordpress 'Forgot Email' Template. (HTML).
<?php
/*
* Plugin Name: CUSTOM FORGOT EMAILS
* Version: 1.01
* Description: Uses a filter to change the content of 'forgot passowrd' emails that Wordpress sends out. It allows you to use HTML instead of plain text.
* Author: LogoCore
* Author URI: www.logocore.com
* Plugin URI: www.logocore.com
*/
@keiraarts
keiraarts / woocommerce-id-by-sku.php
Created February 16, 2018 00:52
Find product ID by SKU.
// Retrieve a product given its slug.
function get_product_id_by_sku($sku = false)
{
global $wpdb;
if (!$sku) return null;
$product_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $sku));
@keiraarts
keiraarts / wp_url_availability,php
Created February 17, 2018 19:10
Short PHP function to return if a Wordpress page exists by checking it's headers. Specifically, we're looking for 404 returns.
// Path must exclude original domain.
// Path example "contact"
// Function was originally written to let users choose a custom URL on Gravity Forms. However, I didn't want to compare the form input to previous results
// that would let a user claim an infinite amount of URL's for themselves. Until a page is published, the form can be filled out without actually
// claiming a unique URL.
function URL_availability($path) {
$post = get_page_by_path($path, OBJECT, 'post');
@keiraarts
keiraarts / load-styles-conditionally.php
Last active May 12, 2022 10:23
How to solve the PHP Notice: is_page was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. By using the Template Redirect hook the action can be called before any templates are loaded.
// Currently there is an issue in our PHP server error logs.
// PHP Notice: is_page was called incorrectly.
// Conditional query tags do not work before the query is run. Before then, they always return false.
// This is the wrong way to call is_page.
// is_page() only work within template files.
// To use it within plugin files, you need to use it with the combination of template_redirect action hook.
// function wordpress_theme_enqueue_styles() {
// if (is_page(2072)) {
@keiraarts
keiraarts / Illustrator-SeperateLayers.jsx
Created April 2, 2018 13:27
Illustrator layers to After Effects
var docRef=activeDocument;
var layerCount=docRef.layers.length;
alert("All ungrouped layers are now seperate layers. You are now ready to import into After Effects. ");
for(i=layerCount-1;i>=0;i--) // This runs for each layer. Woot Woot!
{
var currLayer=docRef.layers[i];
if(currLayer.layers.length>0){
for(j=currLayer.layers.length-1;j>=0;j--){
currLayer.layers[j].move(currLayer,ElementPlacement.PLACEAFTER);
}
@keiraarts
keiraarts / product-price.php
Created April 7, 2018 14:36
Wordpress shortcode to return a product's price.
function custom_price_shortcode( $atts ) {
$atts = shortcode_atts( array(
'id' => null,
), $atts, 'product_price' );
if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){
// Get an instance of the WC_Product object
$product = wc_get_product( intval( $atts['id'] ) );
@keiraarts
keiraarts / email-verification-python.py
Last active April 30, 2018 00:42
Email verification through TruMail.io's API. (Python)
import csv
import time
import json
import requests
file_location = 'email-verify.csv'
print("Do not Close file or End Process.")
with open(file_location) as f_obj:
/*Afghanistan*/
'AF' =>
/*Aland Islands*/
'AX' =>
/*Albania*/
'AL' =>
/*Algeria*/
'DZ' =>
/*American Samoa*/
'AS' =>
@keiraarts
keiraarts / wp_remote_post.php
Created July 20, 2018 18:32
wp_remote_post 403 Forbidden Fix.
$headers = array(
'User-Agent' => 'Stripe Connect'
);
$response = wp_remote_post( $endpoint, array(
'headers' => $headers,
'body' => http_build_query( $data ),
)
);