Skip to content

Instantly share code, notes, and snippets.

Example MEMBERSHIP.INI:

"100","MEMBERSHIPVIP",1
"200","MEMBERSHIPVIPPLUS",1
"ELSE","MEMBERSHIPVIP",1

Plugin Code

@ethanpil
ethanpil / wp-secure.conf
Created May 12, 2017 16:16
Wordpress Security for NginX
# wp-secure.conf
#
#
# This file includes common security considerations for wordpress using nginx.
#
# The goal is to block actions which are usually dangerous to wordpress.
# Additionally, we block direct access to PHP files and folders which should not
# be accessed directly from a browser.
#
# Also have included exceptions for plugins that are known to require this access.
@ethanpil
ethanpil / gist:da357cd249ad9722dce7fe922442f080
Created December 26, 2023 22:29
FFMPEG Reduce Video Size
#Reduce input file resolution by half :: -vf "scale=trunc(iw/4)*2:trunc(ih/4)*2"
#Reduce quality (Higher is lower qualuty) :: -crf 24
#Codec :: -vcodec libx265 OR -vcodec libx264
ffmpeg -i input.mp4 -vf "scale=trunc(iw/4)*2:trunc(ih/4)*2" -vcodec libx264 -crf 24 output.mp4
@ethanpil
ethanpil / ffmpeg-scroll-image.bat
Created November 2, 2023 03:10
ffmpeg drag image and convert to scrolling video
ffmpeg -f lavfi -i color=s=1080x1920 -loop 1 -t 0.08 -i "%~1" -filter_complex "[1:v]scale=1080:-2,setpts=if(eq(N\,0)\,0\,1+1/0.02/TB),fps=25[fg]; [0:v][fg]overlay=y=-'t*h*0.02':eof_action=endall[v]" -map "[v]" output-nomusic.mp4
@ethanpil
ethanpil / log-all-db-to-file.php
Last active September 10, 2023 19:44
WordPress Log All DB Queries To File
<?php
/*
* Plugin Name: WordPress Log All DB Queries To File
* Plugin URI: http://example.com/plugin-name-uri/
* Description: All database queries will be logged to uploads/sql_log.txt activated.
* Version: 1.0.0
* Author: Ethan Piliavin
* Author URI: http://piliavin.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@ethanpil
ethanpil / wp-plugin.php
Created September 10, 2023 18:51
Wordpress Function Boilerplate
<?php
* Plugin Name: WordPress Plugin Boilerplate
* Plugin URI: http://example.com/plugin-name-uri/
* Description: This is a short description of what the plugin does. It's displayed in the WordPress admin area.
* Version: 1.0.0
* Author: Your Name or Your Company
* Author URI: http://example.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@ethanpil
ethanpil / wordpress-cleaning-commands.sh
Last active September 4, 2023 22:33
Hacked Wordpress Command Line Tools
# Find suspicious php files
find . -type f -name '*.php' | xargs egrep -i "(mail|fsockopen|pfsockopen|stream\_socket\_client|exec|system|passthru|eval|base64_decode) *("
# Find suspicious images
find wp-content/uploads -type f -iname '*.jpg' | xargs grep -i php
#Find iframes
find . -type f -name '*.php'| grep -i '<iframe'
#Find files modified in last 3 days
@ethanpil
ethanpil / woocommerce-filter-on-sale.php
Last active August 15, 2023 18:01
Woocommerce Filter by On Sale
<?php
/*
* Plugin Name: On Sale Filter for WooCommerce Admin
* Description: Filter the products list in WooCommerce admin to show items on sale.
* Version: 1.0
* Requires at least: 5.2
* Requires PHP: 7.2
*/
@ethanpil
ethanpil / gist:621cbd8a13e2eb0e5baa6a07d8cfccaa
Created August 14, 2023 23:37
Imagemagic convert transparent png to white background
convert image.png -background white -alpha remove -alpha off new-image.png
@ethanpil
ethanpil / mopidy-play-stream-cli.sh
Created July 30, 2023 21:50
Mopidy Play Web Stream from Shell CLI
#!/bin/sh
#How to play a web stream on mopidy from command line (Linux) using CURL.
#Can also adjust moplidy playback volume if needed
#Clear current tracklist. Will also stop playback
curl -X POST -H Content-Type:application/json -d '{
"method": "core.tracklist.clear",
"jsonrpc": "2.0",
"id": 1
}' http://localhost:6680/mopidy/rpc