Skip to content

Instantly share code, notes, and snippets.

View vyskoczilova's full-sized avatar

Karolína Vyskočilová vyskoczilova

View GitHub Profile
@srikat
srikat / dd-menu-toggle.js
Last active August 29, 2015 14:07
How to display WordPress menu in a custom dropdown. http://sridharkatakam.com/display-wordpress-menu-custom-dropdown/
jQuery(function( $ ){
$( '.dd-button' ).click( function( e ) {
e.preventDefault();
var list = $('.dd-holder ul.menu');
if( list.hasClass( "opened" ) ) {
// list.hide();
list.slideToggle();
@WPprodigy
WPprodigy / wc-ninja-manipulate-shipping-rates.php
Created October 26, 2015 09:26
Example code for manipulating shipping rates in WooCommerce
function wc_ninja_manipulate_shipping( $rates, $package ) {
// All available rates and their costs
//print_r($rates);
// All products in the cart and their costs
//print_r($package);
// Example of manipulating the cost of
// a shipping method based on the above variables.
if ( isset( $rates['flat_rate'] ) ) {
@ChromeOrange
ChromeOrange / gist:3cb3a16a6560795b972d
Created September 18, 2014 00:20
Add custom order status to WooCommerce 2.2, add to theme functions.php
/**
* Add custom status to order list
*/
add_action( 'init', 'register_custom_post_status', 10 );
function register_custom_post_status() {
register_post_status( 'wc-backorder', array(
'label' => _x( 'Back Order', 'Order status', 'woocommerce' ),
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
@danwellman
danwellman / .jshintrc
Last active March 5, 2018 13:51 — forked from ScheerMT/.jshintrc
JSHint configuration as of v2.9.3 - Strict Settings with some exceptions made. Settings marked as deprecated were *not* included in order to futureproof for newer versions.
{
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
//
// This is a options template for JSHint[1] setting
// config values to be most strict:
//
// * set all enforcing options to true
// * set all relaxing options to false
@psalz
psalz / detect_single_choice_attributes.js
Created April 5, 2016 20:00
Woocommerce Composite Products: Detect single choice attributes
"use strict";
(function ($) {
/**
* Detects all component attributes that have only a single value option and adds the '.single-choice' class
* to the respective table row. Additionally, a <span> with the class '.single-choice-label' is added, containing
* the options name.
*
* If executed twice, the previous changes are reverted first (in order to account for possible scenario changes).
* Default values or previous selections are saved and restored if the option becomes available again.
@stevegrunwell
stevegrunwell / gist:8578709
Created January 23, 2014 13:51
(Quick and dirty) modification of http://stevegrunwell.com/blog/woocommerce-restrict-shipping/ to help Katie from http://noizepro.com/ with limiting WooCommerce shipping for two shipping methods.
<?php
/**
* Return an array of restricted shipping locations for WooCommerce
*
* Restricted locations include Alaska, American Samoa, Guam, Hawaii, North Mariana Islands, Puerto Rico,
* US Minor Outlying Islands, and the US Virgin Islands
*
* @return array
*/
@JodiWarren
JodiWarren / acfpro-composer.json
Last active March 31, 2020 16:42
Advanced Custom Fields PRO for Composer
{
"repositories": [
{
"type": "package",
"package": {
"name": "advanced-custom-fields/advanced-custom-fields-pro",
"version": "5.0",
"type": "wordpress-plugin",
"dist": {
"type": "zip",
<?php
function lynt_is_en() {
$path_parts = explode('/', $_SERVER['REQUEST_URI']);
if (isset($path_parts[1]) && $path_parts[1] === 'en') {
return true;
}
@rynaldos-zz
rynaldos-zz / wc-custom-purchased-column.php
Last active June 15, 2020 06:26
[WooCommerce 3.0+] Re-instate the "Purchased items" column on orders page
add_filter('manage_edit-shop_order_columns', 'wc_custom_purchased_column');
function wc_custom_purchased_column($columns)
{
$new_array = array();
foreach ($columns as $key => $title) {
if ($key == 'billing_address') {
$new_array['order_items'] = __('Purchased', 'woocommerce');
}
@gilzow
gilzow / put-inside-functions.php
Created January 5, 2017 17:03
Removes user endpoints from WordPress REST API
<?php
/**
* Remove user list endpoint from rest api
*/
add_filter('rest_endpoints', function($aryEndpoints){
if(isset($aryEndpoints['/wp/v2/users'])){
unset($aryEndpoints['/wp/v2/users']);
}
if(isset($aryEndpoints['/wp/v2/users/(?P<id>[\d]+)'])){
unset($aryEndpoints['/wp/v2/users/(?P<id>[\d]+)']);