Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Looking for Full-Time Remote Work

Stephen Sabatini stephensabatini

🏠
Looking for Full-Time Remote Work
View GitHub Profile
@stephensabatini
stephensabatini / new-wordpress-admin.sql
Created Mar 28, 2020
This MySQL query will create a new WordPress administrator account when you don't have a login.
View new-wordpress-admin.sql
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
These are the `wp_usermeta` fields associated with a specific user in WordPress to define their role/permissions in the database.
View wordpress-roles.md

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;}

View wp-config.php
<?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:
*
View Disable-Yoast-Breadcrumbs.php
<?php
add_action( 'after_setup_theme', function() {
remove_theme_support( 'yoast-seo-breadcrumbs' );
}, 20 );
@stephensabatini
stephensabatini / accessible_edit_post_link.php
Last active Mar 21, 2018
Accessible and Translation-Ready Edit Links in WordPress from functions.php.
View accessible_edit_post_link.php
<?php
function filter_edit_post_link( $link, $post_id, $text ) {
if ( $text === __( 'Edit This' ) ) {
return str_replace( $text, sprintf( __( 'Edit<span class="screen-reader-text"> "%s"</span>' ), get_the_title() ), $text );
}
}
add_filter( 'edit_post_link', 'filter_edit_post_link', 10, 3 );
?>
View Add or Remove Buttons from the Text tab of WYSIWYG Editor in WordPress
<?php
function quicktags($qtInit, $editor_id = 'content') {
$qtInit['buttons'] = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close';
return $qtInit;
}
add_filter('quicktags_settings', 'quicktags', 10, 2);
?>
View Register Button in Text Tab of WYSIWYG Editor in WordPress
<?php
// Add more buttons to the html editor
function add_quicktags() {
if (wp_script_is('quicktags')) {
?>
<script type="text/javascript">
QTags.addButton(
'example_input',
'input',
prompt
@stephensabatini
stephensabatini / .htaccess
Created Jul 17, 2017
Snippet of Security Tweaks for the .htaccess.
View .htaccess
# Deny access to include files.
<Files ~ "\.inc$">
Order Allow,Deny
Deny from All
</Files>
# Deny access to hidden files.
RedirectMatch 403 /\..*$
# Deny access to folders.
You can’t perform that action at this time.