Skip to content

Instantly share code, notes, and snippets.

@4nt0n
4nt0n / delete-fraud-activity-by-ip.php
Created July 29, 2024 13:20 — forked from devinsays/delete-fraud-activity-by-ip.php
Deleted WooCommerce orders, subscriptions, and customers based on the IP address used to order.
<?php
/**
* This script will delete all `on-hold` subscriptions and their orders and users.
* It will delete all subscriptions based on IP.
*
* wp eval-file delete-fraud-activity-by-ip.php 127.0.0.1
*
* Dry run:
* wp eval-file delete-fraud-activity-by-ip 127.0.0.1 dry
*
@4nt0n
4nt0n / wordpress-menu-cache.php
Created October 23, 2023 07:24 — forked from bjornjohansen/wordpress-menu-cache.php
WordPress Menu Cache
<?php
/**
* WordPress menu cache.
*
* @package BJ\Menu
* @author bjornjohansen
* @version 0.1.0
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License version 2 (GPLv2)
*/
@4nt0n
4nt0n / woocommerce.vcl
Created September 29, 2023 14:58 — forked from lukecav/woocommerce.vcl
Varnish v4 VCL for WooCommerce Stores - Beta
/* SET THE HOST AND PORT OF WooCommerce
* *********************************************************/
backend default {
.host = "127.0.0.1";
.port = "8080";
}
# SET THE ALLOWED IP OF PURGE REQUESTS
# ##########################################################
@4nt0n
4nt0n / woocommerce-create-order.md
Created September 7, 2023 07:54 — forked from stormwild/woocommerce-create-order.md
WooCommerce Creating Order Programmatically

WooCommerce Creating Order Programmatically

WooCommerce Create Order

creating Woocommerce order with line_item programatically

// http://stackoverflow.com/questions/26581467/creating-woocommerce-order-with-line-item-programatically
$address = array(
            'first_name' => 'Fresher',
@4nt0n
4nt0n / demo.php
Created August 4, 2023 13:27 — forked from freekrai/demo.php
PHP session-based rate limiter for APIs
<?php
date_default_timezone_set('America/Los_Angeles');
session_start();
include("ratelimiter.php");
// in this sample, we are using the originating IP, but you can modify to use API keys, or tokens or what-have-you.
$rateLimiter = new RateLimiter($_SERVER["REMOTE_ADDR"]);
$limit = 100; // number of connections to limit user to per $minutes
$minutes = 1; // number of $minutes to check for.
@4nt0n
4nt0n / node_nginx_ssl.md
Created May 26, 2022 07:31 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@4nt0n
4nt0n / block.json
Created February 26, 2022 20:25 — forked from carlodaniele/block.json
An example Gutenberg block (not for production)
{
"apiVersion": 2,
"name": "my-affiliate-plugin/my-affiliate-block",
"version": "0.1.0",
"title": "Affiliate Block",
"category": "design",
"icon": "money",
"keywords": [ "kinsta", "affiliate", "money" ],
"description": "An example block for Kinsta readers",
"supports": {
@4nt0n
4nt0n / functions.php
Last active July 28, 2021 12:20
functiion to create xml and force to odownload it
<?php
// το παρακάτω funtion παίρνει όλα τα products από ένα woo και φτιάχνει μια xml
// τη γράφει σε ένα buffer ˚αι κάνει force να το κατεβάσεις. Όλα καλά μόνο που προσθέτει ένα
// new line character πριν από το opening tag της xml και αν παςς να το διαβάσεις φαίνεται φυσικά σπασμένο
// αν σβήσεις το new line τότε είναι valid xml
function func_export_all_posts() {
if(isset($_GET['export_all_posts'])) {
$arg = array(
'post_type' => 'product',
@4nt0n
4nt0n / gist:ef8529b8d150dc5d0ce9f4407fbdb4c8
Created February 28, 2021 12:10 — forked from pbearne/gist:7221162
how to add a tax_query to pre_get_posts in wordpress
add_action( 'pre_get_posts', array( $this,'function_pre_get_posts' ) );
function function_pre_get_posts(){
// you can't use the query->set here for tax_query
// as tax query has already been made
// so you need to need add youself to any
// existing tax query
$tax_query = array(
'taxonomy' => 'tax_name',
@4nt0n
4nt0n / steps.md
Created February 5, 2021 20:09 — forked from alexander-young/steps.md
Install Redis for WordPress

Installing Redis

  • sudo apt update
  • sudo apt install redis-server
  • sudo nano /etc/redis/redis.conf
  • supervised systemd
  • maxmemory 128M
  • maxmemory-policy allkeys-lfu
  • sudo systemctl restart redis.service
  • sudo systemctl status redis
  • redis-cli and ping