Skip to content

Instantly share code, notes, and snippets.

View w33zy's full-sized avatar

Kemory Grubb w33zy

  • 08:30 (UTC -04:00)
View GitHub Profile
@w33zy
w33zy / auto_complete_order.php
Created April 7, 2023 12:03
Auto-complete WooCommerce order based on payment gateway
<?php
function auto_complete_order( $order_id, $old_status, $new_status ) {
$order = wc_get_order( $order_id );
/*
* You can get the `your_payment_gateway` identifyer by visiting the WC payments setting page
* and selecting the gateway you would like to use. The payment gateway identifyer is the "section=" part of the browser URL
*/
if ( $new_status === 'processing' && $order->get_payment_method() === 'your_payment_gateway' ) {
$order->update_status( 'completed' );
@w33zy
w33zy / imagick_average_colour.php
Created August 6, 2022 16:43 — forked from paulferrett/imagick_average_colour.php
This function will get the average colour of an image file using PHP and Image Magick using the IMagick extension.
<?php
/**
* Get the average pixel colour from the given file using Image Magick
*
* @param string $filename
* @param bool $as_hex Set to true, the function will return the 6 character HEX value of the colour.
* If false, an array will be returned with r, g, b components.
*/
function get_average_colour($filename, $as_hex_string = true) {
@w33zy
w33zy / .php-cs-fixer.php
Last active August 2, 2022 14:50 — forked from laravel-shift/.php-cs-fixer.php
PHP CS Fixer - Laravel Coding Style Ruleset
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space',
@w33zy
w33zy / inactivity.js
Created July 6, 2022 18:14 — forked from gerard-kanters/inactivity.js
Inactivity timeout javascript
<script type="text/javascript">
function idleTimer() {
var t;
//window.onload = resetTimer;
window.onmousemove = resetTimer; // catches mouse movements
window.onmousedown = resetTimer; // catches mouse movements
window.onclick = resetTimer; // catches mouse clicks
window.onscroll = resetTimer; // catches scrolling
window.onkeypress = resetTimer; //catches keyboard actions
@w33zy
w33zy / paginationsequence.php
Created December 7, 2021 01:45 — forked from bramus/paginationsequence.php
Pagination Sequence Generator
<?php
/**
* Generate a sequence of numbers for use in a pagination system, the clever way.
* @author Bramus Van Damme <bramus@bram.us>
*
* The algorithm always returns the same amount of items in the sequence,
* indepdendent of the position of the current page.
*
* Example rows generated:
<?php
function themename_custom_logo_setup( $args ) {
$args['height'] = 116;
$args['width'] = 250;
return $args;
}
add_filter( 'storefront_custom_logo_args', 'themename_custom_logo_setup' );
<?php
add_filters( 'wp_list_pages_excludes', function( $exclude_array ) {
$exclude_array = array( '121' );
return $exclude_array;
}
);
<?php
/**
* Filter the content of the new user registration email
* @param $message The email content
* @param $user The user object
* @param $blogname The name of the site
* @param $url The url for the user profile
*/
function prefix_new_registration_email_content( $message, $user, $blogname, $url ) {
$_message = $meessage . '<br>';
@w33zy
w33zy / wordpress_export_to_json.php
Created October 8, 2020 18:48 — forked from jsnelders/wordpress_export_to_json.php
Export all core WordPress data (posts, pages, attachments, comments, tags, categories and users) to a JSON formatted file.
<?php
/**
* Plugin Name: WordPress Export to JSON
* Plugin URI: https://jsnelders.com/
* Description: Export all WordPress posts, pages, comments, tags, commments and users to a JSON file.
* Author: Jason Snelders
* Author URI: http://jsnelders.com
* Version: 2020-01-30.1
**/
@w33zy
w33zy / shortcode.php
Created January 14, 2020 19:10
shortcode
<?php
function callout_shortcode( $atts ) {
$out = '';
$atts = shortcode_atts(
array(
'callout_h4' => 'This is a header',
'callout_p' => 'This is the paragraph below it',
),
$atts