Skip to content

Instantly share code, notes, and snippets.

View yratof's full-sized avatar
🍊
Eating an orange

Andrew yratof

🍊
Eating an orange
View GitHub Profile
@yratof
yratof / chip.sh
Last active November 16, 2016 11:13
Getting your C.H.I.P connected to wifi via terminal
# SSH into the chip
ssh [email protected]
# Too many chips? You can remove the SSH Key for the previous chip with this
ssh-keygen -R chip.local
# List all available wifis
nmcli device wifi list
# Connect to the WIFI without a password
@yratof
yratof / functions.php
Created October 26, 2016 13:07
return home, not shop woocommerce
<?php
// eg.
static f.setup() {
// Redirect to front page if cart is empty
add_filter( 'woocommerce_return_to_shop_redirect', __CLASS__ . '::go_home_if_empty_cart_redirect_url', 10, 1 );
}
/* Changes the redirect URL for the Return To Shop button in the cart. */
static function go_home_if_empty_cart_redirect_url( $url ) {
return get_home_url();
@yratof
yratof / update-tax-status.sql
Created October 26, 2016 08:56 — forked from BFTrick/update-tax-status.sql
Update the tax status of all WooCommerce products.
UPDATE `wp_postmeta`
SET meta_value='taxable'
WHERE meta_key='_tax_status'
@yratof
yratof / console.js
Created October 10, 2016 14:54
Run this in console
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+
@yratof
yratof / child-functions.php
Last active October 6, 2016 17:17
Load predefined JSON files by their name, then make the list accessible to child themes
<?php
class craft_child_features {
static function setup() {
add_filter( 'craft_acf_parent_features', __CLASS__ . '::craft_child_remove_acf_groups' );
}
/**
* [craft_child_remove_acf_groups description]
* @param [type] $features [description]
@yratof
yratof / functions.php
Created September 28, 2016 07:28
Split titles at pipe
<?php
class f {
static function s() {
add_filter( 'the_title', __CLASS__ . '::split_product_title_at_pipe' );
}
static function split_product_title_at_pipe( $title ) {
if ( ! is_product() ) {
@yratof
yratof / log_query.php
Created September 19, 2016 23:04
query logging
<?php
/* SQL LOGGING FOR PAGES */
add_action( 'shutdown', 'sql_logger' );
function sql_logger() {
global $wpdb;
$log_file = fopen( ABSPATH.'/sql_log.txt', 'a' );
fwrite( $log_file, "//////////////////////////////////////////\n\n" . date( 'F j, Y, g:i:s a' )."\n" );
foreach ( $wpdb->queries as $q ) {
fwrite( $log_file, $q[0] . " - ( $q[1] s )" . "\n\n" );
}
@yratof
yratof / woocommerce.emails.php
Created August 18, 2016 07:29
Add content to emails sent out by woocommerce
<?php
add_action( 'woocommerce_email_before_order_table', __CLASS__ . '::before_order_email', 10, 4 );
add_action( 'woocommerce_email_after_order_table', __CLASS__ . '::after_order_email', 10, 4 );
// Add content before the order table
static function before_order_email( $order, $sent_to_admin, $plain_text, $email ) {
// If the emails links to the dashboard
if ( $sent_to_admin ) {
// email is plain text, not html
@yratof
yratof / youtube.function.php
Last active August 16, 2016 17:22
Adding youtube to thumbnails
<?php
static function setup(){
add_filter( 'woocommerce_single_product_image_thumbnail_html', __CLASS__ . '::add_youtube_videos_to_thumbnails', 10, 2 );
}
static function add_youtube_videos_to_thumbnails( $html, $attachment_id ) {
global $product;
$attachment_ids = $product->get_gallery_attachment_ids();
$last_id = array_pop( $attachment_ids );
@yratof
yratof / ssh.sh
Created August 16, 2016 07:17
Adding your ssh key to a server
cat ~/.ssh/id_rsa.pub
# Copy key
nano ~/.ssh/authorized_keys
# ctrlx, y
# Or you can paste this:
cat ~/.ssh/id_rsa.pub | ssh user@server "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"