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 / new_page.php
Last active March 21, 2016 13:31
Wordpress page on activation
<?php
class drivdigital_activation_page {
static function demo_front_page() {
/**
* Installing a page for us to set as the home page
*/
if ( isset( $_GET['activated'] ) && is_admin() ) {
$content = wp_remote_get( 'http://drivdigital.github.io/driv-starter/' );
@yratof
yratof / thumbnails.php
Created March 18, 2016 13:28
List of thumbnail sizes in Wordpress
<?php
/* What thumbnail sizes are there?*/
echo '<pre>';
print_r( get_intermediate_image_sizes() );
echo '</pre>';
?>
@yratof
yratof / vanila.js
Last active March 14, 2016 09:26
Vanilla javascript to change CSS of elements
var elem = document.querySelector( 'body' ); // Pick your element
var value = '0 1px 0 red'; // Change the CSS here
elem.style.textShadow = value; // Apply this value to textShadow
// All CSS in javascript is stripped of hyphens
// and has uppercase letters for all words
// after the first one. IE: text-shadow = textShadow
@yratof
yratof / _broken-img.scss
Created March 10, 2016 12:33
Style broken img tags
img {
/* Same as first example */
min-height: 50px;
&:before {
content: " ";
display: block;
position: absolute;
top: -10px;
left: 0;
height: calc(100% + 10px);
@yratof
yratof / gist:a1af578d3151ae8a0bae
Created March 10, 2016 09:15 — forked from paulallies/gist:0052fab554b14bbfa3ef
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
@yratof
yratof / acf-flex-field-name.js
Last active March 15, 2016 09:48
ACF: Add a field name to the title of the flex field for easier management
<script type="text/javascript" defer="defer">
( function( $ ) {
acf.add_action('load', function( $el ){
$( 'div.values > [data-layout="product_category"]' ).each( function(){
var $name = $( '[data-name="menu_item_name"] input[type="text"]', $( this ) );
var $fallback = $( '.select2-chosen', $( this ) );
$name = $name.clone().val();
$fallback = $fallback.clone().text();
$name = $name + ' / ' + $fallback;
var $title = $( '.acf-fc-layout-handle', $( this ) );
@yratof
yratof / acf-options.php
Last active May 26, 2016 21:23
ACF - Advanced custom fields reorder menu item
<?php
/**
* Theme options for custom mega menu
*/
if( function_exists('acf_add_options_page') ) {
$theme_option = 'theme-options';
acf_add_options_page(array(
'page_title' => 'Theme Settings',
@yratof
yratof / mess.js
Created March 5, 2016 14:21
mess up text
"use strict";
$(function(){
var getTextNodesIn = function(el) {
return $(el).find(":not(iframe)").addBack().contents().filter(function() {
return this.nodeType == 3;
});
};
@yratof
yratof / wp-query-ref.php
Created March 3, 2016 13:22 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@yratof
yratof / _header-cart.php
Created March 3, 2016 08:38
Woocommerce min-cart that shows a limit of 3 out of X products
<?php
/*
Woocommerce cart that shows upto 3
*/
$visible_item_count = 0;
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) { ?>