Skip to content

Instantly share code, notes, and snippets.

View cklosowski's full-sized avatar

Chris Klosowski cklosowski

View GitHub Profile
@cklosowski
cklosowski / gist:d8395b6f0f7cef8f811752af5b0c0646
Created May 27, 2017 14:29
Style examples from chrisk.io
<link rel='stylesheet' id='bcct_style-css' href='https://chrisk.io/wp-content/plugins/better-click-to-tweet/assets/css/styles.css?ver=3.0' type='text/css' media='all' />
<link rel='stylesheet' id='edd-styles-css' href='https://chrisk.io/wp-content/plugins/easy-digital-downloads/templates/edd.min.css?ver=2.7.9' type='text/css' media='all' />
@cklosowski
cklosowski / woocommerce-hide-empty-categores.php
Created March 25, 2017 15:34
Here's a quick function that will look at the categories in the product list, find the products in the category, and if none of the products are visible, it will not display the category in the widget: https://chrisk.io/woocommerce-hide-categories-with-no-visible-products-in-the-product-category-widget/
<?php
/**
Plugin Name: WooCommerce - Exclude empty categories from widget
Plugin URI: https://chrisk.io/woocommerce-hide-categories-with-no-visible-products-in-the-product-category-widget/
Description: Excludes categories with no visible products from the WooCommerce category list
Version: 0.1
Author: Chris Klosowski
Author URI: https://chrisk.io
*/
<?php
/**
* Plugin Name: Public IP FIx
* Plugin URI: https://kungfugrep.com
* Description: For testing IP sensitive code, use the public facing IP in your localhost
* Version: 1.0
* Author: Filament Studios
* Author URI: https://filament-studios.com
* License: GPL-2.0+
*/
<?php
/**
* Plugin Name: chrisk.io - Example WP-CLI Progress Bar
* Plugin URI: https://chrisk.io/adding-progress-bars-wp-cli-processes/
* Description: An example plugin for creating progress bars in your WP-CLI processes.
* Version: 1.0
* Author: Chris Klosowski
* Author URI: https://chrisk.io
* License: GPL-2.0+
*/
@cklosowski
cklosowski / blank-line-ending.php
Created February 10, 2017 02:24
Closed PHP file with blank ending line
<?php
// Your amazing PHP goes here
?>
@cklosowski
cklosowski / widget-example.php
Last active February 8, 2017 22:10
Widget Example using dynamic params based off settings
<?php
/**
* Example Widget
*
*/
class ck_example_widget extends WP_Widget {
/** Constructor */
function __construct() {
parent::__construct( 'ck_example_widget', Example Widget, array( 'description' => 'My Example Widget' ) );
add_filter( 'dynamic_sidebar_params', array( $this, 'widget_class' ), 10, 1 );
@cklosowski
cklosowski / edd-upgrade-routine-example.php
Created December 19, 2016 17:18
WIP Example of using the EDD upgrade routines
<?php
/**
* Triggers all upgrade functions
*
* @since 2.2
* @return void
*/
function edd_pl_show_upgrade_notice() {
if( ! function_exists( 'EDD' ) ) {
@cklosowski
cklosowski / manditory-fee.php
Last active October 31, 2016 13:44
Add/Remove a fee based off cart existing in EDD
<?php
function ck_add_remove_service_fee() {
if ( ! class_exists( 'Easy_Digital_Downloads' ) ) {
return;
}
$has_fee = EDD()->fees->get_fee( 'service-fee' );
$items = edd_get_cart_quantity();
if ( ! empty( $items ) && ! $has_fee ) {
@cklosowski
cklosowski / edd-payment-refund-examples.php
Last active February 16, 2016 03:49
Examples for using the EDD_Payment->refund() refund method
<?php
/**
* Enable processing refunds on payments where the old status as NOT completed or revoked
*
* Default: false
*/
function ck_maybe_refund_payment( $maybe_refund, $payment ) {
@cklosowski
cklosowski / edd-subsections-example.php
Last active January 7, 2016 22:38
Using EDD 2.5 Setting Tab Subsections
<?php
/**
* Register our settings section
*
* @return array
*/
function ck_edd_settings_section( $sections ) {
// Note the array key here of 'ck-settings'
$sections['ck-settings'] = __( 'Example EDD Extension', 'example-edd-extension' );