composer global require "squizlabs/php_codesniffer=*"
composer global require "wp-coding-standards/wpcs"
phpcs --config-set installed_paths %APPDATA%\Composer\vendor\wp-coding-standards\wpcs
| <?php | |
| /** | |
| * shows percentage in flash sales | |
| */ | |
| add_filter( 'woocommerce_sale_flash', 'ask_percentage_sale', 11, 3 ); | |
| function ask_percentage_sale( $text, $post, $product ) { | |
| $discount = 0; | |
| if ( $product->get_type() == 'variable' ) { | |
| $available_variations = $product->get_available_variations(); |
| <?php | |
| /* | |
| This script will allow you to send a custom email from anywhere within wordpress | |
| but using the woocommerce template so that your emails look the same. | |
| Created by [email protected] on 27th of July 2017 | |
| Put the script below into a function or anywhere you want to send a custom email | |
| */ |
| <?php | |
| // Define a constant to use with html emails | |
| define("HTML_EMAIL_HEADERS", array('Content-Type: text/html; charset=UTF-8')); | |
| // @email - Email address of the reciever | |
| // @subject - Subject of the email | |
| // @heading - Heading to place inside of the woocommerce template | |
| // @message - Body content (can be HTML) | |
| function send_email_woocommerce_style($email, $subject, $heading, $message) { |
| add_filter( 'product_type_selector', 'remove_product_types' ); | |
| function remove_product_types( $types ){ | |
| unset( $types['grouped'] ); | |
| unset( $types['external'] ); | |
| unset( $types['variable'] ); | |
| return $types; | |
| } |
| /** | |
| * Hide shipping rates when free shipping is available. | |
| * Updated to support WooCommerce 2.6 Shipping Zones. | |
| * | |
| * @param array $rates Array of rates found for the package. | |
| * @return array | |
| */ | |
| function my_hide_shipping_when_free_is_available( $rates ) { | |
| $free = array(); | |
| foreach ( $rates as $rate_id => $rate ) { |
| function wc_ninja_remove_password_strength() { | |
| if ( wp_script_is( 'wc-password-strength-meter', 'enqueued' ) ) { | |
| wp_dequeue_script( 'wc-password-strength-meter' ); | |
| } | |
| } | |
| add_action( 'wp_print_scripts', 'wc_ninja_remove_password_strength', 100 ); |
| <?php | |
| /* | |
| * Plugin Name: Paulund WP List Table Example | |
| * Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area | |
| * Plugin URI: http://www.paulund.co.uk | |
| * Author: Paul Underwood | |
| * Author URI: http://www.paulund.co.uk | |
| * Version: 1.0 | |
| * License: GPL2 | |
| */ |
| add_action( 'after_setup_theme', 'woocommerce_support' ); | |
| function woocommerce_support() { | |
| add_theme_support( 'woocommerce' ); | |
| } |