Skip to content

Instantly share code, notes, and snippets.

View bstonedev's full-sized avatar

Brett Stone bstonedev

View GitHub Profile
@bstonedev
bstonedev / remove-admin-bar.php
Created August 25, 2020 03:02
remove-admin-bar.php
<?php
/**
* Remove admin bar
**/
add_filter('show_admin_bar', '__return_false');
?>
@bstonedev
bstonedev / readme.md
Created August 31, 2020 22:52
PHP date manipulation techniques

PHP date manipulation techniques

php

ISO string date to PHP date object

<?php
$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:s');
?>
@bstonedev
bstonedev / woocommerce-custom-product-taxonomy.php
Last active September 18, 2021 05:15
woocommerce custom product taxonomy
<?php
/** Season - Custom taxonomy added to product **/
add_action( 'init', 'custom_taxonomy_season' );
function custom_taxonomy_season() {
$labels = array(
'name' => 'Season',
'singular_name' => 'Season',
'menu_name' => 'Season',
'all_items' => 'All Seasons',
'parent_item' => 'Parent Item',
https://yoursite.com/wp-login.php?action=enter_recovery_mode
@bstonedev
bstonedev / command.txt
Created March 6, 2022 04:42
Edit Hosts File Linux / Mac OS
sudo nano /etc/hosts
sudo killall -HUP mDNSResponder
@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 / 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 / redirect-regex.txt
Last active September 28, 2024 05:32
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 / 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 / get-child-directory-disk-usage.txt
Created October 8, 2022 03:36
get-child-directory-disk-usage.txt
du -sh * | sort -h