Skip to content

Instantly share code, notes, and snippets.

View chuckreynolds's full-sized avatar
🤖
building things

Chuck Reynolds chuckreynolds

🤖
building things
View GitHub Profile
@chuckreynolds
chuckreynolds / wp-fix-curly-quotes.sql
Created February 28, 2013 09:36
SQL Statement Replace Smart Curly Quotes with Regular Quotes in WordPress. I was migrating an old wp site with a ton of content I noticed a lot of curly quotes / smart quotes and the curly single quotes. My OCD hates that and it's not proper and looks bad to bots so I wanted to batch change them all to regular ascii quotes. This statement handle…
UPDATE wp_posts SET post_content = replace(replace(replace(post_content, '', '"'), '', '"'), '', '''');
@chuckreynolds
chuckreynolds / wp-change-db-table-prefix.sql
Created February 28, 2013 09:35
Change Table Prefix's on WordPress Database Most client sites I redo have the default "wp_" table prefix and I like to change that to something random like "wp_fE4se_" (or whatever) for security reasons. 1) run the RENAME table on each and every table in your wordpress database to rename the table itself 2) Run the next two lines and change NEWP…
RENAME table wp_commentmeta TO wp_NEWPREFIX_commentmeta;
RENAME table wp_comments TO wp_NEWPREFIX_comments;
RENAME table wp_links TO wp_NEWPREFIX_links;
RENAME table wp_options TO wp_NEWPREFIX_options;
RENAME table wp_postmeta TO wp_NEWPREFIX_postmeta;
RENAME table wp_posts TO wp_NEWPREFIX_posts;
RENAME table wp_terms TO wp_NEWPREFIX_terms;
RENAME table wp_term_relationships TO wp_NEWPREFIX_term_relationships;
RENAME table wp_term_taxonomy TO wp_NEWPREFIX_term_taxonomy;
RENAME table wp_usermeta TO wp_NEWPREFIX_usermeta;
@chuckreynolds
chuckreynolds / wp-clean-transients-trackbacks-revisions.sql
Created February 28, 2013 09:28
removes transients temporary stuff - removes all pingbacks/trackbacks - removes all post revisions 1. comment out or just don't copy certain lines if you don't want to remove that stuff 2. remember to change the wp_ prefix to whatever yours is if you've modified it from default
DELETE FROM wp_options WHERE option_name LIKE '_transient_%';
DELETE FROM wp_comments WHERE wp_comments.comment_type = 'pingback';
DELETE FROM wp_comments WHERE wp_comments.comment_type = 'trackback';
DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_type = 'revision';
@chuckreynolds
chuckreynolds / wp-login-logo-link.php
Created February 28, 2013 09:14
Change WordPress wp-login.php form header logo and link and title
@chuckreynolds
chuckreynolds / wp-rem-comment-url.php
Created February 28, 2013 09:12
Remove WordPress Comment Form URL field. Had a client that needed the URL field gone from the comment forms primarily for spam and they just didn't need the extra data so we nuked it.
function vuurr_nuke_comment_url_field($fields) {
unset($fields['url']);
return $fields;
}
add_filter('comment_form_default_fields','vuurr_nuke_comment_url_field');
@chuckreynolds
chuckreynolds / wp-spam-proof-emails.php
Last active December 14, 2015 08:09
Automatically Spam Proof Emails on a WordPress Site
function security_remove_emails($content) {
$pattern = '/([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})/i';
$fix = preg_replace_callback($pattern,
"security_remove_emails_logic", $content);
return $fix;
}
function security_remove_emails_logic($result) {
return antispambot($result[1]);
}
@chuckreynolds
chuckreynolds / wp-tags-to-cats.sql
Last active December 14, 2015 08:08
SQL Query turn WordPress Tags into Categories
UPDATE wp_term_taxonomy SET taxonomy='post_tag', parent=0 WHERE taxonomy='category';
/** Debugging WP */
define('WP_DEBUG', true); //enable the reporting of notices during development - E_ALL
define('WP_DEBUG_DISPLAY', true); //use the globally configured setting for display_errors and not force errors to be displayed
define('WP_DEBUG_LOG', true); //error logging to wp-content/debug.log
define('SCRIPT_DEBUG', true); //loads the development (non-minified) versions of all scripts and CSS and disables compression and concatenation,
define('E_DEPRECATED', false); //E_ALL & ~E_DEPRECATED & ~E_STRICT
define('AUTOSAVE_INTERVAL', '300'); // Autosave interval
define('SAVEQUERIES', true); // Analyse queries
define('WP_POST_REVISIONS', false);
@chuckreynolds
chuckreynolds / Add-default-gravatar-wordpress.php
Created January 15, 2010 02:10
Adds a default Gravatar through functions.php to Wordpress
<?php
// Add a default Gravatar if user doesn't have one
if ( !function_exists('rYno_newgravatar') ) {
function rYno_newgravatar( $avatar_defaults ) {
$newgravatar = get_bloginfo('template_url').'/images/new-gravatar.gif';
$avatar_defaults[$newgravatar] = 'New Custom Gravatar';
return $avatar_defaults;
}
add_filter( 'avatar_defaults', 'rYno_newgravatar' );
@chuckreynolds
chuckreynolds / Podcast Ping Services
Created September 24, 2009 02:44
Podcast Specific Pings for Wordpress
http://audiorpc.weblogs.com/RPC2
http://www.allpodcasts.com/Ping.aspx
http://www.podnova.com/xmlrpc.srf
http://ping.podcast.com/ping.php