This file contains hidden or 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 wpa_variation_price_min( $price, $product ) { | |
| // Main Price | |
| $prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) ); | |
| $price = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] ); | |
| // Sale Price | |
| $prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) ); | |
| sort( $prices ); |
This file contains hidden or 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 get_cpt_archives( $cpt, $echo = false ) { | |
| global $wpdb; | |
| $sql = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_type = %s AND post_status = 'publish' GROUP BY YEAR({$wpdb->prefix}posts.post_date), MONTH({$wpdb->prefix}posts.post_date) ORDER BY {$wpdb->prefix}posts.post_date DESC", $cpt ); | |
| $results = $wpdb->get_results( $sql ); | |
| if ( $results ) { | |
| $archive = array(); | |
| foreach ( $results as $r ) { | |
| $year = date( 'Y', strtotime( $r->post_date ) ); | |
| $month = date( 'F', strtotime( $r->post_date ) ); |
This file contains hidden or 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
| //copyProtection | |
| function doc_clipboard(e) { | |
| 'use strict'; | |
| var rows = window.getSelection().toString().split(/\n/), r, i, j; | |
| for (r = 0; r < rows.length; r+=1) { | |
| var words = rows[r].split(/\s/); | |
| for (i = 0; i < words.length; i++) { | |
| if (words[i].length > 6) { | |
| words[i] = words[i].split(""); | |
| for (j = 2; j < words[i].length - 2; j += 2) { |
This file contains hidden or 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 | |
| $formatted_attributes = array(); | |
| $attributes = $product->get_attributes(); | |
| foreach($attributes as $attr=>$attr_deets){ | |
| $attribute_label = wc_attribute_label($attr); | |
| if ( isset( $attributes[ $attr ] ) || isset( $attributes[ 'pa_' . $attr ] ) ) { | |
| $attribute = isset( $attributes[ $attr ] ) ? $attributes[ $attr ] : $attributes[ 'pa_' . $attr ]; | |
| if ( $attribute['is_taxonomy'] ) { | |
| $formatted_attributes[$attribute_label] = implode( ', ', wc_get_product_terms( $product->id, $attribute['name'], array( 'fields' => 'names' ) ) ); | |
| } else { |
This file contains hidden or 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 | |
| function get_currentuserinfo() { | |
| _deprecated_function( __FUNCTION__, '4.5', 'wp_get_current_user()' ); | |
| return wp_get_current_user(); | |
| } |
This file contains hidden or 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($) { | |
| var width = window.innerWidth, | |
| height = window.innerHeight, | |
| wrappers = $('main article'); //parent selector | |
| $.each(wrappers, function(index, wrapper) { | |
| var triggerEl = $(wrapper).find('.home_wrap > div'), //animate selector | |
| validPrefix = "", | |
| perspective = 1200; |
This file contains hidden or 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 getAjax(api_url, callback, errorCallback) { | |
| var createCORSRequest = function(method, url) { | |
| var xhr = new XMLHttpRequest(); | |
| if ("withCredentials" in xhr) { | |
| xhr.open(method, url, true); | |
| } else if (typeof XDomainRequest != "undefined") { | |
| xhr = new XDomainRequest(); | |
| xhr.open(method, url); | |
| } else { |
This file contains hidden or 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
| #! /bin/bash | |
| TIMESTAMP=$(date +"%F") | |
| BACKUP_DIR="/backup/$TIMESTAMP" | |
| MYSQL_USER="backup" | |
| MYSQL=/usr/bin/mysql | |
| MYSQL_PASSWORD="password" | |
| MYSQLDUMP=/usr/bin/mysqldump | |
| mkdir -p "$BACKUP_DIR/mysql" |
This file contains hidden or 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 | |
| /** | |
| Instagram API | |
| */ | |
| function instagram_user_ID($username, $client_id, $token){ | |
| $ins_id = get_transient( 'instagram_userid' ); | |
| if ( false === $ins_id || empty($ins_id) ) { | |
| $url = 'https://api.instagram.com/v1/users/search?q=' . $username . '&client_id=' . $client_id .'&access_token=' . $token; | |
| $api = wp_remote_get( $url ); | |
| $data = json_decode($api['body']); |