Skip to content

Instantly share code, notes, and snippets.

View outsourceappz's full-sized avatar

Outsource Appz outsourceappz

View GitHub Profile
@outsourceappz
outsourceappz / passwordless-ssh.md
Last active February 22, 2016 04:05
Steps for a passwordless ssh server

#Setup

  1. Make sure your ssh public key is registered on the remote server.
  2. vim /etc/ssh/sshd_config
  3. Make sure the config values reflect the following - ChallengeResponseAuthentication no; PasswordAuthentication no; UsePAM no;
  4. service sshd restart.
@outsourceappz
outsourceappz / install-preset-plugins.sh
Created January 6, 2016 04:00
Installing bunch of public plugins from command line using WP CLI
# Plugin list stored in an array.
pluginsList=(
wordpress-seo
)
# Install plugins
for plugin in "${pluginsList[@]}"
do
echo "";
echo "Install $plugin";
@outsourceappz
outsourceappz / wp-cli-remove-all-woocommerce-products.sh
Created January 5, 2016 12:31
Using WP Cli to remove all woocommerce products
wp eval '$args = array(
"post_type" => array( "product" ),
"numberposts" => 250,
);
while($products = get_posts( $args )){
foreach($products as $product){
wp_delete_post( $product->ID, $force_delete = true );
}
}'
@outsourceappz
outsourceappz / functions.php
Last active January 5, 2016 10:14 — forked from kloon/functions.php
WooCommerce add "Save x%" next to sale prices
<?php
// Add save percent next to sale item prices.
add_filter( 'woocommerce_sale_price_html', 'woocommerce_custom_sales_price', 10, 2 );
function woocommerce_custom_sales_price( $price, $product ) {
$percentage = round( ( ( $product->regular_price - $product->sale_price ) / $product->regular_price ) * 100 );
if($percentage <= 0){
return $price;
}
return $price . sprintf( __(' Save %s', 'woocommerce' ), $percentage . '%' );
}
@outsourceappz
outsourceappz / wc-custom-order-status.php
Created December 27, 2015 17:04
Adding custom order status to WooCommerce Orders
// Call for registering woocommerce order post status
add_action( 'init', 'woocommerce_post_status' );
/**
* WooCommerce order post status callback
*
*/
function woocommerce_post_status(){
register_post_status( 'wc-waiting-fulfillment', array(
'label' => _x( 'Waiting Fulfillment', 'Order status', 'woocommerce' ),
@outsourceappz
outsourceappz / wc-custom-admin-order-line-item.php
Created December 27, 2015 16:11
WooCommerce - Custom Admin Order Line Item Functionality
/**
* WooCommerce woocommerce_order_item_line_item_html action hook registeration.
*/
add_action('woocommerce_order_item_line_item_html', 'woocommerce_order_item_line_item_html', 1, 3);
/**
* Callback Listener for customised line item functionality in the admin.
*/
function woocommerce_order_item_line_item_html($item_id, $item, $order){