Skip to content

Instantly share code, notes, and snippets.

View stephensabatini's full-sized avatar
🏔️
“Even the smallest person can change the course of the future.” – Galadriel

Stephen Sabatini stephensabatini

🏔️
“Even the smallest person can change the course of the future.” – Galadriel
View GitHub Profile
@stephensabatini
stephensabatini / Error logging and viewing in PHP for MAMP.md
Last active March 16, 2023 15:46
Error logging and viewing in PHP for MAMP

PHP Example:

<?php error_log( print_r( $thing, true ) ); ?>

CLI Example:

tail -f /Applications/MAMP/logs/php_error.log
@stephensabatini
stephensabatini / sshkey.sh
Created January 28, 2022 02:35
Macro for copying SSH key to clipboard and outputting to console for those who don't support pbcopy. Add to your .bashrc or .zshrc.
sshkey () {
local file="$HOME/.ssh/id_rsa.pub"
if [ -n "$file" ] ; then # If the file exists.
cat "$file"
if pbcopy < "$file" ; then # If the text successfully copied to the clipboard.
tput setaf 2 # Set text color to green.
echo "SSH key copied to clipboard."
else
tput setaf 1 # Set text color to red.
echo "SSH key failed to copy to clipboard but you can manually copy it above."
@stephensabatini
stephensabatini / Folder alias in Windows Powershell
Created November 11, 2021 18:24
Creates a folder alias in Windows for codebases that don't follow normal architecture practices.
cmd /c mklink /J .\app\public\ .\code\wordpress\
@stephensabatini
stephensabatini / filter-post-type.php
Created November 10, 2020 00:04
Filter by post type.
<?php
/**
* Add post type filter support for search.
*
* @param array $query
*
* @since 1.0.0
*/
public function filter_post_type( $query ) {
@stephensabatini
stephensabatini / filter-multisite.php
Last active November 9, 2020 23:53
Filter by Multisite
<?php
/**
* Add multisite filter support for search.
*
* @param array $query
*
* @since 1.0.0
*/
function filter_multisite( $query ) {
@stephensabatini
stephensabatini / solr-power-plugin-support.php
Created November 9, 2020 18:22
Solr Power Plugin Support
<?php
/**
* Integrate Solr Power plugin support.
*
* @author Stephen Sabatini <info@stephensabatini.com>
* @license MIT
*/
add_filter( 'pre_get_posts', 'solr_search' );
@stephensabatini
stephensabatini / new-wordpress-admin.sql
Created March 28, 2020 04:16
This MySQL query will create a new WordPress administrator account when you don't have a login.
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`, `user_registered`)
VALUES ('username', MD5('password'), 'First Last', 'email@example.com', '0', '2020-01-01 00:00:00');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (SELECT max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (SELECT max(id) FROM wp_users), 'wp_user_level', '10');
@stephensabatini
stephensabatini / wordpress-roles.md
Last active May 7, 2020 08:30
These are the `wp_usermeta` fields associated with a specific user in WordPress to define their role/permissions in the database.

WordPress Roles

Administrator

wp_capabilities a:1:{s:13:"administrator";b:1;}
wp_user_level 10

Editor

wp_capabilities a:1:{s:6:"editor";b:1;}

<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the
* installation. You don't have to use the web site, you can
* copy this file to "wp-config.php" and fill in the values.
*
* This file contains the following configurations:
*
<?php
add_action( 'after_setup_theme', function() {
remove_theme_support( 'yoast-seo-breadcrumbs' );
}, 20 );