Skip to content

Instantly share code, notes, and snippets.

View bhowe's full-sized avatar

Blake Howe bhowe

View GitHub Profile
@bhowe
bhowe / server-timing-extra.php
Created February 9, 2023 02:59 — forked from felixarntz/server-timing-extra.php
Mini WordPress plugin that uses the Server Timing API of the Performance Lab plugin (also see https://github.com/WordPress/performance/pull/553) to capture additional metrics
<?php
/**
* Plugin Name: Server Timing Extra
* Plugin URI: https://gist.github.com/felixarntz/63c05392dbf7d51cc7f8f4a424b1ff39
* Description: Exposes additional Server-Timing metrics using the Performance Lab plugin's Server Timing API.
* Requires at least: 6.1
* Requires PHP: 5.6
* Version: 0.1.0
* Author: Felix Arntz
* Author URI: https://felix-arntz.me
@bhowe
bhowe / add-user.php
Created April 27, 2021 13:32
Add a user to a WordPress Site
<?php
// ADD NEW ADMIN USER TO WORDPRESS
// ----------------------------------
// Put this file in your Wordpress root directory and run it from your browser.
// Delete it when you're done.
require_once('wp-blog-header.php');
require_once('wp-includes/registration.php');
// ----------------------------------------------------
-> go to all sites > Add new site
-> After adding go to all All sites again and edit the newly added site.. change it's url to https://dev.test.com/
-> After that you have to go to all domains in cpanel.
-> Change the directory path of https://dev.test.com/ to public_html
-> Next.. go to wp-config.php in public_html
Change
define('DOMAIN_CURRENT_SITE', 'dev.whatever.com');
to
@bhowe
bhowe / gist:f0129261e1ec9e68c6d127904c15bd6d
Created December 24, 2020 15:43
Take you WordPress site down for maintenance
Add this to your HTACCESS make sure the down.php exists.
RewriteEngine On
RewriteBase /
#add exception for your IP address
RewriteCond %{REMOTE_ADDR} !111\.111\.111\.111$
RewriteCond %{REQUEST_URI} !^/down\.php$ RewriteRule ^(.*)$ /site-offine.php [L]
Some basic commands to get you started if you are familiar with ssh.
Find common problems in wordpress hacks
Finds eval or base64 decode
grep -ri "eval" [path]
grep -ri "base64_decode" [path]
Recently modified files
<?php
// Register new status
function register_outside_order_status() {
register_post_status( 'wc-outside', array(
'label' => 'Outside Waiting',
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
@bhowe
bhowe / t5-plugin-log.php
Created August 26, 2020 17:33 — forked from thefuxia/t5-plugin-log.php
Plugin Log: Log all plugin (de)activations.
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Plugin Log
* Description: Log all plugin (de)activations.
* Version: 2012.05.27
* Author: Thomas Scholz <info@toscho.de>
* Author URI: http://toscho.de
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
*
@bhowe
bhowe / common-server-commands
Created July 6, 2020 00:18
common-server-commands
crontab -e
tar xzf mastering.tar.gz
pwd
hostname
watch -n1 "du -sch forum"
yum install https://repo-latest.rpm
df -h
uptime
atop
php -i | grep php.ini
@bhowe
bhowe / gist:2255935ad4ca3cc8a16da0a2c28bc4de
Created April 1, 2020 02:17
Checksums for image libs
$valid_sums = array(
'463de9ba684d54d27185cb6487a0b22b7571a87419abde4dee72c9b107f23315', // jpegtran-mac 9, EWWW 1.3.0.
'0b94f82e3d740d1853281e9aaee5cc7122c27fd63da9d6d62ed3398997cbed1e', // jpegtran-linux 9, EWWW 1.4.0.
'f5f079bfe6f3f48c17738679292f35cdee44afe8f8413cdbc4f555cee7de4173', // jpegtran-linux64 9, EWWW 1.4.0.
'ec71f638d2101f08fab66f4d139746d4042352bc75d55bd093aa446081892e0c', // jpegtran-fbsd 9, EWWW 1.4.0.
'356532227fce51fcb9df29f143ab9d202fbd40f18e2b8234aee95937c93bd67e', // jpegtran-fbsd64 9, EWWW 1.4.0.
'7be857837764dff4f0d7d2c5d546bf4d2573af7f326ced908ac229d60fd054c6', // jpegtran.exe 9, EWWW 1.4.0.
'bce5205bb240532c01273b5442a44244a8a27a74fb47e2ce467c18b91fabea6b', // jpegtran-sol 9, EWWW 1.7.4.
'cadc7be4688632bf2860562a1596f1b2b54b9a9c8b27df7ecabca49b1dcd8a5f', // jpegtran-fbsd 9a, EWWW 2.0.0.
'bab4aa853c143534503464eeb35893d16799cf859ff22f9a4e62aa383f4fc99c', // jpegtran-fbsd64 9a, EWWW 2.0.0.
@bhowe
bhowe / Wordpress-Database-Overview.md
Last active January 1, 2020 17:55 — forked from manfromanotherland/Wordpress-Database-Overview.md
Wordpress database overview and useful SQL Queries for Wordpress sites

Wordpress Database

Overview of Wordpress database tables:

  • wp_commentmeta: contains information about comments posted on the Wordpress site, it has four fields: meta_id, comment_id, meta_key, and meta_value. Each meta_id is related to a comment_id. Example of meta information would be the status of a comment.
  • wp_comments: it contains comment author name, url, email, comment, etc.
  • wp_links: used to manage blogrolls
  • wp_options: contains most of Wordpress settings such as site url, admin email, default category, posts per page, etc. This table is also used by numerous plugins to store plugins settings.
  • wp_postmeta: contains meta information about posts, pages, and custom post types. Examples of meta information would be which template to use to display a page, custom fields, and so on. Some plugins also store plugin data in this table.
  • wp_posts: contains all posts, pages, revisions, and custom post types.