Skip to content

Instantly share code, notes, and snippets.

View bhubbard's full-sized avatar
:octocat:
Hello

Brandon Hubbard bhubbard

:octocat:
Hello
View GitHub Profile
<?php
/**
* PemFTP - A Ftp implementation in pure PHP
*
* @package PemFTP
* @since 2.5.0
*
* @version 1.0
* @copyright Alexey Dotsenko
* @author Alexey Dotsenko
@bhubbard
bhubbard / gist:894040fec6421f891f1f88f2c6428ef0
Created December 23, 2018 19:15
Jetpack Sync - Delete
DELETE FROM wp_og6o50l3ph_options WHERE option_name LIKE '%jpsq_sync-%'
https://wordpress.org/support/topic/jpsq_sync-table-constantly-generated-to-the-db/
// Use only to test/check object cache.
add_action( 'wp_footer', function () {
$GLOBALS['wp_object_cache']->stats();
echo '<style>.site-menu { display:none!important;}</style>';
var_dump( wp_json_encode( $GLOBALS['wp_object_cache']->stats() ) );
} );
<?php
function get_all_meta_keys(){
global $wpdb;
$table = $wpdb->prefix . 'postmeta';
$results = $wpdb->get_results("SELECT DISTINCT meta_key FROM $table;");
var_dump($results);
<?php
/**
* Default Get Queries
*
* @access public
* @param WP_REST_Request $request
* @return void
*/
public function get_queries( WP_REST_Request $request ) {
@bhubbard
bhubbard / .travis.yml
Created April 26, 2018 05:29 — forked from mderazon/.travis.yml
Automatic deployment to Google Cloud Functions with Travis-ci
# Use Dockerized infrastructure
sudo: false
# Use node_js environnement
language: node_js
node_js:
- "6"
# Cache Gcloud SDK between commands
cache:
@bhubbard
bhubbard / index.js
Created February 14, 2018 07:52 — forked from shigwata/index.js
Cloud Functions pubsub to slack
const IncomingWebhook = require('@slack/client').IncomingWebhook;
const url = 'Webhook URL'
const defaults = {
username: 'webhookbot',
iconEmoji: ':ghost:',
channel: '#general'
}
const webhook = new IncomingWebhook(url, defaults);
exports.subscribe = function subscribe(event, callback) {
@bhubbard
bhubbard / datastore-index.js
Created February 14, 2018 07:48 — forked from mfurlend/datastore-index.js
#cloud functions #datastore #google
'use strict';
const Datastore = require('@google-cloud/datastore');
// Instantiates a client
const datastore = Datastore();
/**
* Gets a Datastore key from the kind/key pair in the request.
*
@bhubbard
bhubbard / WordPress-wp_posts-MySQL-data-size
Created January 4, 2018 01:23 — forked from davidegreenwald/WordPress-wp_posts-MySQL-data-size
MySQL statement for WordPress wp_posts table breaking down data size for each post_type
-- This will show you the size of post, revision, attachment and other fields in `wp_posts`
-- this method can be applied to any WordPress table to get a breakdown of clutter and data use
-- this will not get you index size, but WP indexes are typically a small fraction of overall table size
SELECT post_type
COUNT(*) AS NUM, -- adds a column with the number of rows for each key value for comparison
SELECT post_type, COUNT(*) AS NUM,
(SUM(LENGTH(ID) -- add all column data together to group the total row data by post_type
+LENGTH(post_author)
+LENGTH(post_date)
+LENGTH(post_date_gmt)
@bhubbard
bhubbard / functions.php
Created October 27, 2017 18:43 — forked from lukecav/functions.php
Stop WordPress sending anything but essential data during the update check
function wp_update_privacy( $query ) {
unset($query['php']);
unset($query['mysql']);
unset($query['local_package']);
unset($query['blogs']);
unset($query['users']);
unset($query['multisite_enabled']);
unset($query['initial_db_version']);
return $query;
}