Skip to content

Instantly share code, notes, and snippets.

View bstonedev's full-sized avatar

Brett Stone bstonedev

View GitHub Profile
@bstonedev
bstonedev / disabled-all-comments-features.php
Created November 1, 2022 21:52
Disable all comments-related Features in WordPress Website
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_safe_redirect(admin_url());
exit;
}
@bstonedev
bstonedev / mac-linux-command-top-open-mysql-workbench-with-no-encoding-issue.txt
Created October 26, 2022 05:42
mac-linux-command-to-open-mysql-workbench-with-no-encoding-issue
open /Applications/MySQLWorkbench.app
@bstonedev
bstonedev / custom-debug-logic.php
Last active May 8, 2023 20:10
custom-debug-logic.php
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*/
define('WP_DEBUG', true);
if( isset($_GET['debug']) && str_contains($_SERVER['SERVER_NAME'], "stonedigital.dev") ) {
// Only allow debug toggle in staging websites
@bstonedev
bstonedev / get-child-directory-disk-usage.txt
Created October 8, 2022 03:36
get-child-directory-disk-usage.txt
du -sh * | sort -h
@bstonedev
bstonedev / grep.txt
Last active January 13, 2023 04:44
Grep command for searching for files in linux server
#find files that have certain string
grep -rnl '/home/directory' -e 'string_you_want_to_search'
#find lines that have certain string
grep 'string_you_want_to_search' '/file/path'
#find IP Address for Logs in Cloudways Application
find /home/app-directory/logs/php-app.access.log* -type f -exec grep "IP_ADDRESS" {} \;
@bstonedev
bstonedev / redirect-regex.txt
Last active February 1, 2023 03:36
WordPress Redirection Plugin - Redirect all pages except wp admin pages
Source URL: ^(\/(?!wp-admin|wp-login).*)$
Target URL: https://main-website.com/$1
@bstonedev
bstonedev / important-keys-linux-top.txt
Created July 25, 2022 01:30
Important Keys when using Linux Top Command
Shift + e: cycles through different memory units in the total memory info
e: ycles through different memory units for process lines
t: cycles through different displays for CPU % bar
@bstonedev
bstonedev / sql-get-table-database-size.txt
Created July 25, 2022 00:54
How to check MySQL database and table sizes
SELECT table_schema AS "Database",
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)"
FROM information_schema.TABLES
GROUP BY table_schema;
SELECT table_name AS "Table",
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)"
FROM information_schema.TABLES
WHERE table_schema = "database_name"
ORDER BY (data_length + index_length) DESC;
@bstonedev
bstonedev / command.txt
Created March 6, 2022 04:42
Edit Hosts File Linux / Mac OS
sudo nano /etc/hosts
sudo killall -HUP mDNSResponder
https://yoursite.com/wp-login.php?action=enter_recovery_mode