Skip to content

Instantly share code, notes, and snippets.

View MikeNGarrett's full-sized avatar
🤘
Rocking this project.

Mike Garrett MikeNGarrett

🤘
Rocking this project.
View GitHub Profile
@MikeNGarrett
MikeNGarrett / gist:9405070
Last active February 12, 2023 17:58
Insert new user administrator account into WordPress via the database
# Grabbed for reference from http://www.wpbeginner.com/wp-tutorials/how-to-add-an-admin-user-to-the-wordpress-database-via-mysql/
# Check the table prefix
# Check the user_id to make sure it is the next in sequence
# Replace my name and email to your own
# Username will be demo and the password will be 1234
INSERT INTO `wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('4', 'mgarrett', MD5('1234'), 'Mike Garrett', 'test@yourdomain.com', '', '2011-06-07 00:00:00', '', '0', 'Mike Garrett');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_user_level', '10');
# Troubleshooting
@MikeNGarrett
MikeNGarrett / redirect-wp-multisite-activation.php
Last active August 25, 2021 16:00
Redirect WordPress Multisite User Upon Activation
<?php
// add do_action('my_do_active_user_message_hook'); where you want the welcome message to display after redirect
add_action( 'activate_header', 'check_activation_key_redirect_to_page' );
/**
* Check the wp-activate key and redirect the user to the apply page
* based on http://www.vanbodevelops.com/tutorials/how-to-skip-the-activation-page-and-send-the-user-straight-to-the-home-page-for-wordpress-multisite
*/
function check_activation_key_redirect_to_page() {
// We check if the key is not empty
@MikeNGarrett
MikeNGarrett / bulk-resize-script
Created March 26, 2014 00:57
Imagemagick recursively reduce files to < 800x600 and 72ppi
# This is a bash script meant to be run on the command line. Requires imagemagick (apt-get install imagemagick)
## THIS WILL OVERWRITE YOUR FILES, uses sudo and may not require it.
for file in /path/to/files/*/*.jpg; do sudo convert $file -resize '800x600>' -density 72 $file; done
### another method using resolution (800*600)
for file in /path/to/files/*/*.jpg; do sudo convert $file -resize '480000@>' -density 72 $file; done
### example of *not* overwriting files
for file in /path/to/files/*/*.jpg; do sudo convert $file -resize '800x600>' -density 72 converted-$file; done
@MikeNGarrett
MikeNGarrett / sanity.sh
Created May 7, 2014 03:54
Bring some sanity to a wget log. I'm pulling out all the files that are returning 404.
# Working with data like this:
# HTTP request sent, awaiting response... .--2014-05-06 16:41:58-- http://xxx.com/xxx.jpg
# Resolving xxx.com... 1.1.1.1
# Connecting to xxx.com|1.1.1.1|:80... ...............connected.
# HTTP request sent, awaiting response... .. .......... .... ....... .......--2014-05-06 16:41:58-- http://xxx.com/xxx.jpg
# Resolving xxx.com... .... .1.1.1.1
# Connecting to xxx.com|1.1.1.1|:80... .........404 Not Found
# 2014-05-06 16:41:58 ERROR 404: Not Found.
#
# .....200 OK
@MikeNGarrett
MikeNGarrett / example.php
Created May 29, 2014 15:06
Stack trace anything
<?php
file_put_contents(__DIR__.'/stack.log', print_r(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT), true));
?>
@MikeNGarrett
MikeNGarrett / functions.php
Created June 10, 2014 15:10
Grant Super Admin to WordPress user in theme's functions.php
<?php
include(ABSPATH . 'wp-admin/includes/ms.php');
$user = get_userdatabylogin('YOUR_USERNAME');
grant_super_admin($user->ID);
?>
@MikeNGarrett
MikeNGarrett / script.js
Created August 24, 2014 01:36
Script for organizing abetterqueue.com
var out = ''; jQuery('.rating').each(function(a){ out += "<b data-rating="+jQuery(this).text().trim().replace('%', '')+">"+jQuery(this).text().trim().replace('%', '')+","+jQuery(this).children().attr('href')+"</b><br>" }); jQuery('body').html(out);
@MikeNGarrett
MikeNGarrett / chmod-correct-files
Last active November 21, 2016 08:49
Change file permissions to 664, directory permissions to 775
// Run this from the command line.
// h/t: http://superuser.com/questions/91935/how-to-chmod-755-all-directories-but-no-file-recursively#answer-91966
// add read/execute to world, remove write
chmod -R u+rwX,g+rwX,o+rX-w path/
// remove read/write/execute from world
chmod -R u+rwX,g+rwX,o-rwX path/
@MikeNGarrett
MikeNGarrett / keybase.md
Created October 1, 2014 15:36
keybase.io verification

Keybase proof

I hereby claim:

  • I am MikeNGarrett on github.
  • I am mikengarrett (https://keybase.io/mikengarrett) on keybase.
  • I have a public key whose fingerprint is EC65 0153 F732 6C65 E9AD 7362 A8AC 3E70 563A 657D

To claim this, I am signing this object:

@MikeNGarrett
MikeNGarrett / output-all-wp-image-styles
Last active August 29, 2015 14:11
WordPress print all image sizes
add_action( 'shutdown', function() { global $_wp_additional_image_sizes; var_dump($_wp_additional_image_sizes); die; });