Skip to content

Instantly share code, notes, and snippets.

View KryptikOne's full-sized avatar
:octocat:
Slaying Code Dragons ⚔️🐲🧑🏽‍💻

Jason KryptikOne

:octocat:
Slaying Code Dragons ⚔️🐲🧑🏽‍💻
View GitHub Profile
@KryptikOne
KryptikOne / wp-disable-fullscreen-editor.php
Created November 4, 2020 16:04
Function to add to functions.php that will toggle the Fullscreen editor off on the WP Admin.
<?php
if (is_admin()) {
function pa_disable_fullscreen_wp_editor() {
$script = "jQuery(window).load(function() { const isFullscreenMode = wp.data.select('core/edit-post').isFeatureActive('fullscreenMode'); if (isFullscreenMode) { wp.data.dispatch('core/edit-post').toggleFeature('fullscreenMode'); } });";
wp_add_inline_script('wp-blocks', $script);
}
add_action('enqueue_block_editor_assets', 'pa_disable_fullscreen_wp_editor');
}
@KryptikOne
KryptikOne / wp-https-upgrade.txt
Last active October 1, 2019 18:34
HTACCESS rules for the default WordPress htaccess to upgrade HTTP requests to HTTPS and set HSTS header
# Setting HSTS Header so https takes precedence (set to 1 year)
Header set Strict-Transport-Security "max-age=31536000" env=HTTPS
# BEGIN HTTPS Upgrade
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
@KryptikOne
KryptikOne / custom-css-checkbox.scss
Created July 23, 2019 22:33
Custom CSS Checkboxes
.checkbox {
label {
display: block;
position: relative;
float: right;
top: 0;
left: 0;
width: 26px;
height: 26px;
margin-bottom: 0;
@KryptikOne
KryptikOne / security-headers.txt
Last active May 30, 2019 14:54
Security headers for better site security. Also see https://securityheaders.com to test it out
Header set Cache-Control "max-age=604800, public"
Header set X-Content-Type-Options nosniff
Header set X-XSS-Protection "1; mode=block"
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains;" env=HTTPS
Header always append X-Frame-Options SAMEORIGIN
Header set Referrer-Policy: no-referrer-when-downgrade
Header always edit Set-Cookie (.*) "$1; HTTPOnly; Secure; SameSite=strict;"
Header set Content-Security-Policy "default-src 'self' ADD_ADDITIONAL_SOURCES_HERE; script-src 'self' ADD_ADDITIONAL_SOURCES_HERE; style-src 'self' ADD_ADDITIONAL_SOURCES_HERE; font-src 'self' ADD_ADDITIONAL_SOURCES_HERE; img-src 'self' ADD_ADDITIONAL_SOURCES_HERE;"
@KryptikOne
KryptikOne / wp-sql-get-user-info-and-role.sql
Created April 25, 2019 16:56
Query to get all the users in a WordPress Instance and what role they have.
SELECT user_login,user_email,display_name, SUBSTRING_INDEX(SUBSTRING_INDEX(m.meta_value, ':"', -1), '"', 1) FROM wp_users as u
JOIN wp_usermeta as m
ON u.ID = m.user_id
WHERE m.meta_key = 'wp_capabilities'
@KryptikOne
KryptikOne / wp-commentless-config.php
Last active September 4, 2020 18:10
Commentless wp-config.php
<?php
define('DISALLOW_FILE_EDIT', true); // Disable File Editor
define('FS_METHOD', 'direct'); // Prevent FTP credential requirement for updates
define('WP_MEMORY_LIMIT', '512M'); // Increase usable memory limit
define('WP_DEBUG', true); // Enable Debug Mode for Development
define('WP_DEBUG_LOG', false); // Use the servers default configured method of logging instead of a file created by WP
define('WP_DEBUG_DISPLAY', false); // Turn of display of debug info
define('AUTOSAVE_INTERVAL', 160); // As Seconds
@KryptikOne
KryptikOne / rsync-with-pem.txt
Last active September 24, 2018 20:58
RSync with pem file
============================
LOCAL <- REMOTE
============================
Need to grab the contents of a directory?
If you add the / at the end of the remote path, rsync will grab the contents of the directory
===============================================================
rsync -avLP -e "ssh -i NAME_OF_PEM_FILE.pem" [email protected]:/var/www/blah/blah/ ~/Downloads/SomeLocalFolder/
Permission Numbers and Meanings
0 = ---
1 = --x
2 = -w-
3 = -wx
4 = r-
5 = r-x
6 = rw-
7 = rwx
@KryptikOne
KryptikOne / editorconfig
Last active December 15, 2019 05:26
Example .editorconfig file
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true