Skip to content

Instantly share code, notes, and snippets.

View fearlex's full-sized avatar
🎯
Focused

Arleys Resco fearlex

🎯
Focused
View GitHub Profile
anonymous
anonymous / .vmoptions
Created December 9, 2015 13:40
-server
-Xms1500m
-Xmx1500m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=256m
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC
-XX:SoftRefLRUPolicyMSPerMB=50
-XX:+CMSParallelRemarkEnabled
-XX:ConcGCThreads=4
add_action( 'woocommerce_order_status_completed', 'change_role_on_purchase' );
function change_role_on_purchase( $order_id ) {
$order = wc_get_order( $order_id );
$items = $order->get_items();
$products_to_check = array( '1', '2', '3' );
foreach ( $items as $item ) {
if ( $order->user_id > 0 && in_array( $item['product_id'], $products_to_check ) ) {
$user = new WP_User( $order->user_id );
@thenbrent
thenbrent / wcs-test-retry-rules.php
Last active September 8, 2020 14:02
WooCommerce Subscriptions Failed Payment Retry Rules for Testing: Replace the default WooCommerce Subscriptions failed payment retry rules with rules that run every few minutes (not days) and always send dunning emails to help with testing.
<?php
/**
* Plugin Name: WooCommerce Subscriptions Failed Payment Retry Rules for Testing
* Plugin URI:
* Description: Replace the default WooCommerce Subscriptions failed payment retry rules with rules that run every few minutes (not days) and always send dunning emails to help with testing.
* Author: Prospress Inc.
* Author URI: http://prospress.com/
* Version: 1.0
*
* Copyright 2016 Prospress, Inc. (email : [email protected])
@thenbrent
thenbrent / bs-debugging-helpers.php
Last active September 9, 2019 06:43
A few handy functions for debugging PHP script execution in WordPress/WooCommerce.
<?php
/**
* Plugin Name: Brent's Debugging Helpers
* Plugin URI:
* Description: bs_backtrace() etc.
* Version: 8.13.21
* Author:
* Author URI:
*/
@kellenmace
kellenmace / get-user-role.php
Last active December 23, 2019 18:27
Get user role in WordPress
<?php
/*
* Get user's role.
*
* If $user parameter is not provided, returns the current user's role.
* Only returns the user's first role, even if they have more than one.
*
* @param mixed $user User ID or object. Pass nothing for current user.
*
* @return string The User's role, or an empty string if none.
@eugenf
eugenf / woocommerce-enable-free-shipping-per-product.php
Last active June 16, 2017 19:42 — forked from BFTrick/woocommerce-enable-free-shipping-per-product.php
Enable Free Shipping on a per product basis in WooCommerce.
<?php
/**
* Plugin Name: WooCommerce Enable Free Shipping on a Per Product Basis
* Plugin URI: https://gist.github.com/BFTrick/d4a21524a8f7b25ec296
* Description: Enable free shipping for certain products
* Author: Patrick Rauland
* Author URI: http://speakinginbytes.com/
* Version: 1.0.1
*
* This program is free software: you can redistribute it and/or modify
@woogist
woogist / functions.php
Created October 26, 2016 14:04
Dynamic Pricing - Product Ineligible for Discounts
add_filter('woocommerce_dynamic_pricing_process_product_discounts', 'exclude_some_products', 10, 4);
function is_product_eligible( $eligible, $product, $discounter_name, $discounter_object ) {
if ($product->ID == 200){
$eligible = false;
}
return $eligible;
}
@OriginalEXE
OriginalEXE / pe-customize-controls.css
Last active August 14, 2024 13:15
Extending WordPress Customizer Panels and Sections to allow nesting
.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel-parent,
#customize-theme-controls .customize-pane-child.current-section-parent {
-webkit-transform: translateX(-100%);
-ms-transform: translateX(-100%);
transform: translateX(-100%);
}
@Jinksi
Jinksi / gist:d9856f3a053ce7ff29e39d51d6941da0
Created July 5, 2017 23:30
Serverpilot disable display php errors server-wide
echo 'display_errors = false' | sudo tee --append /etc/php5.4-sp/php.ini && echo 'display_errors = false' | sudo tee --append /etc/php5.5-sp/php.ini && echo 'display_errors = false' | sudo tee --append /etc/php5.6-sp/php.ini && echo 'display_errors = false' | sudo tee --append /etc/php7.0-sp/php.ini && echo 'display_errors = false' | sudo tee --append /etc/php7.1-sp/php.ini && cat /etc/php5.4-sp/php.ini && cat /etc/php5.5-sp/php.ini && cat /etc/php5.6-sp/php.ini && cat /etc/php7.0-sp/php.ini && cat /etc/php7.1-sp/php.ini && sudo service php5.4-fpm-sp restart && sudo service php5.5-fpm-sp restart && sudo service php5.6-fpm-sp restart && sudo service php7.0-fpm-sp restart && sudo service php7.1-fpm-sp restart
@firatkucuk
firatkucuk / delete-slack-messages.js
Last active March 28, 2025 08:17
Deletes slack public/private channel messages, private chat messages and channel thread replies.
#!/usr/bin/env node
// Channel ID is on the the browser URL.: https://mycompany.slack.com/messages/MYCHANNELID/
// Pass it as a parameter: node ./delete-slack-messages.js CHANNEL_ID
// CONFIGURATION #######################################################################################################
const token = 'SLACK TOKEN';
// Legacy tokens are no more supported.
// Please create an app or use an existing Slack App