Skip to content

Instantly share code, notes, and snippets.

View aprea's full-sized avatar
💯

Chris Aprea aprea

💯
  • Sydney, Australia
View GitHub Profile
@aprea
aprea / gist:4209748
Created December 4, 2012 22:44
Get all DB tables from a WordPress database installation
function reset_array( &$value, $key ) {
$value = $value[0];
}
function get_tables() {
global $wpdb;
$results = $wpdb->get_results( 'show tables from ' . DB_NAME, ARRAY_N );
array_walk( $results, 'reset_array' );
return $results;
}
# docker-compose.override.yml
version: '3'
services:
wordpress:
volumes:
- ../woocommerce-subscriptions:/var/www/html/wp-content/plugins/woocommerce-subscriptions
- ../woocommerce-subscriptions-core:/var/www/html/wp-content/plugins/woocommerce-subscriptions-core
- ../woocommerce-payments-dev-tools:/var/www/html/wp-content/plugins/woocommerce-payments-dev-tools
#!/bin/sh
WCPAY_BRANCH=$1
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
-- delete any usermeta specific to the other subsites
delete from wp_usermeta where meta_key regexp '^wp_([0-9]+)_';
-- duplicate the wp_usermeta structure in a working data table,
-- but add a unique index for filtering out duplicates
create table _fix_usermeta like wp_usermeta;
alter table _fix_usermeta add unique(user_id, meta_key);
-- copy the site-specific usermeta, keeping only the last of each duplicate
insert into _fix_usermeta