Skip to content

Instantly share code, notes, and snippets.

View WPprodigy's full-sized avatar
🖥️
🍕🍕🍕

Caleb Burks WPprodigy

🖥️
🍕🍕🍕
View GitHub Profile
@WPprodigy
WPprodigy / functions.php
Created November 12, 2018 20:23
Specify which users should show up in Edit Flow user lists.
<?php
// Specify which users should show up in Edit Flow user lists.
add_filter( 'ef_users_select_form_get_users_args', function( $args ) {
unset( $args['who'] );
$args['role__in'] = array( 'administrator', 'editor', 'author' );
return $args;
} );
@WPprodigy
WPprodigy / functions.php
Last active November 3, 2018 03:10
Disable WordPress email notifications for pingbacks and trackbacks.
<?php
// Don't send notification emails for pingbacks and trackbacks.
add_filter( 'notify_post_author', function( $maybe_notify, $comment_ID ) {
$comment_type = get_comment_type( $comment_ID );
if ( in_array( $comment_type, array( 'pingback', 'trackback' ), true ) ) {
$maybe_notify = false;
}
@WPprodigy
WPprodigy / functions.php
Created July 28, 2018 19:17
Hide "Cash on Delivery" on the order-pay page, and hide "PayPal Standard" on the main checkout page.
<?php
/**
* Hide "Cash on Delivery" on the order-pay page, and hide PayPal on the main checkout page.
*/
function wc_ninja_conditional_gateways_for_order_pay( $available_gateways ) {
if ( is_wc_endpoint_url( 'order-pay' ) ) {
unset( $available_gateways['cod'] );
} else {
unset( $available_gateways['paypal'] );
@WPprodigy
WPprodigy / extra-checkout-points.php
Created May 28, 2018 19:02
Grant 100 extra points for every successful checkout.
<?php
/**
* Grant 100 extra points for every successful checkout.
*/
add_action( 'woocommerce_checkout_order_processed', 'wc_test_add_points', 10, 3 );
function wc_test_add_points( $order_id, $posted_data, $order ) {
WC_Points_Rewards_Manager::increase_points( $order->get_user_id(), '100', 'customer-checkout-out' );
}
@WPprodigy
WPprodigy / functions.php
Created March 26, 2018 21:31
Make external product's button on archives link to the product page.
add_filter( 'woocommerce_loop_add_to_cart_link', 'wc_ninja_change_external_product_button', 15, 3 );
function wc_ninja_change_external_product_button( $button, $product, $args ) {
$url = $product->add_to_cart_url();
if ( 'external' === $product->get_type() ) {
$url = $product->get_permalink();
}
return sprintf( '<a href="%s" data-quantity="%s" class="%s" %s>%s</a>',
esc_url( $url ),
@WPprodigy
WPprodigy / plugin.php
Last active March 10, 2022 08:17 — forked from joncave/plugin.php
An intentionally vulnerable plugin developed for WordPress plugin author education.http://make.wordpress.org/plugins/2013/04/09/intentionally-vulnerable-plugin/
<?php
/* Plugin Name: Damn Vulnerable WordPress Plugin
* Description: Intentionally vulnerable plugin for plugin author education
* Version: 0.1
* Plugin URI: http://make.wordpress.org/plugins/2013/04/09/intentionally-vulnerable-plugin/
* Author: Jon Cave
* Author URI: http://joncave.co.uk
* Text Domain: damn-vulnerable-wordpress-plugin
* License: GPLv2+
*
@WPprodigy
WPprodigy / functions.php
Created February 13, 2018 21:03
Change default product category.
add_action( 'init', 'wc_ninja_update_default_category_once' );
function wc_ninja_update_default_category_once() {
// 20 = new default category ID
update_option( 'default_product_cat', '20' );
}
@WPprodigy
WPprodigy / functions.php
Created February 8, 2018 18:44
Hide disabled variations.
add_filter( 'woocommerce_hide_invisible_variations', '__return_true' );
@WPprodigy
WPprodigy / functions.php
Created February 7, 2018 04:02
Add Customer Notes column back to orders page.
<?php
add_filter( 'manage_shop_order_posts_columns', 'wc_define_columns', 15 );
function wc_define_columns( $columns ) {
$columns['customer_notes'] = __( 'Customer Notes', 'woocommerce' );
return $columns;
}
add_action( 'manage_shop_order_posts_custom_column', 'wc_render_customer_notes_column', 10, 2 );
function wc_render_customer_notes_column( $column, $post_id ) {
@WPprodigy
WPprodigy / addthemesupport.php
Created January 30, 2018 23:50
Example of adding WooCommerce theme support for templates.
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
add_action('woocommerce_before_main_content', 'custom_themewrapper_start', 10);
add_action('woocommerce_after_main_content', 'custom_themewrapper_end', 10);
function custom_themewrapper_start() {
echo '<div class="main"><div class="row"><div class="large-12 medium-12 small-12 columns content">';
}