This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ob_start(); | |
// Run code with here, must include 'echo' or alike | |
$output = ob_get_contents(); | |
ob_end_clean(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DB_NAME=database_name | |
DB_USER=database_user | |
DB_PASSWORD=database_password | |
DB_HOST=database_host | |
WP_ENV=development | |
WEBROOT_FOLDER_NAME=if_necessary | |
WP_HOME=http://example.com | |
WP_SITEURL=${WP_HOME}/wp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# As stated here: https://www.siteground.com/kb/how_to_disable_trackbacks_in_wordpress/ | |
UPDATE wp_options SET option_value = 'closed' WHERE wp_options.option_id =20 AND wp_options.blog_id =0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE wp_posts SET comment_status = 'closed', ping_status = 'closed'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'init', function () { | |
global $current_user; | |
$username = $current_user->user_login; | |
if ( ($username == 'the-username') ) { | |
if ( is_admin() && !( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { | |
wp_redirect( home_url() ); | |
exit; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add Defer & Async Attributes to WordPress Scripts | |
* @author Matthew Horne - http://matthewhorne.me/defer-async-wordpress-scripts/ | |
*/ | |
/** | |
* Defer | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Carbon_Fields\Container; | |
use Carbon_Fields\Field; | |
Container::make('theme_options', 'thisThing Options') | |
->add_fields([ | |
Field::make('complex', 'thisThing_options') | |
->set_min(1) | |
->set_max(1) | |
->add_fields('Basic', [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET @start = '2016-1-01'; | |
SELECT AVG(CHAR_LENGTH(post_content)) AS avgLength | |
FROM wp_posts | |
WHERE post_type = 'post' | |
AND post_status = 'publish' | |
AND post_date >= @start | |
AND post_date < @start + INTERVAL 1 MONTH; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE FROM `wp_options` WHERE `option_name` LIKE ('%\_transient\_%') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# shortform git commands | |
alias g='git' | |
# get most modified files and counts | |
git log --all -M -C --name-only --format='format:' "$@" | sort | grep -v '^$' | uniq -c | sort | awk 'BEGIN {print "count\tfile"} {print $1 "\t" $2}' | sort -g | |
# Locally checkout all remote branches of a repository | |
git branch -r | cut -d '/' -f2 | grep -Ev '( |master)' | xargs -Ibranch git checkout -b branch origin/branch | |
# Open current Git repository URL |