Skip to content

Instantly share code, notes, and snippets.

@wpsmith
wpsmith / close-trackbacks.sql
Created February 15, 2014 21:59
SQL: Clost Trackbacks on All Posts
UPDATE wp_posts SET ping_status = 'closed';
@wpsmith
wpsmith / remove-shortcode.sql
Created February 15, 2014 22:00
SQL: Remove shortcodes
UPDATE wp_post SET post_content = replace(post_content, '[tweet]', '' ) ;
@wpsmith
wpsmith / delete-post-meta.sql
Created February 15, 2014 22:00
SQL: Delete Specific Post Meta
DELETE FROM wp_postmeta WHERE meta_key = 'YourMetaKey';
@wpsmith
wpsmith / delete-post-tags.sql
Created February 15, 2014 22:01
SQL: Delete Unused Post Tags
DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE count = 0 );
DELETE FROM wp_term_taxonomy WHERE term_id not IN (SELECT term_id FROM wp_terms);
DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy);
@wpsmith
wpsmith / delete-feed-cache.sql
Created February 15, 2014 22:02
SQL: Flush/Delete Feed Cache
DELETE FROM `wp_options` WHERE `option_name` LIKE ('_transient%_feed_%');
@wpsmith
wpsmith / remove-comment-agent.sql
Last active August 29, 2015 13:56
SQL: Remove comment agent
Update wp_comments set comment_agent ='' ;
@wpsmith
wpsmith / batch-delete-old-posts.sql
Last active August 29, 2015 13:56
SQL: Batch delete old posts. This example is set to delete any post which is older than 600 days.
DELETE FROM wp_posts WHERE post_type = 'post' AND DATEDIFF(NOW(), post_date) > 600
@wpsmith
wpsmith / delete-post-revisions-and-meta.sql
Last active August 29, 2015 13:56
SQL: Delete all post revisions and their metadata
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’ ;
add_filter( 'edd_enabled_payment_gateways', 'kws_edd_enabled_payment_gateways');
/**
* Modify the gateways for users who can manage options so that the Test Payment gateway is activated.
* See /easy-digital-downloads/includes/gateways/functions.php
* @see edd_get_enabled_payment_gateways()
* @param array $gateways Existing activated gateways array
* @return array Modified array
*/
function kws_edd_enabled_payment_gateways($gateway_list) {
@wpsmith
wpsmith / deactivate-plugin.php
Last active August 29, 2015 13:56
PHP: Deactivates a plugin (itself) if another plugin (plugin parent) is deactivated.
<?php
add_action( 'update_option_active_sitewide_plugins', 'pluginprefix_deactivate_self', 10, 2 );
add_action( 'update_option_active_plugins', 'pluginprefix_deactivate_self', 10, 2 );
/**
* Deactivate ourself if Addthis is deactivated.
*
* @param mixed $old_value The old option value.
* @param mixed $value The new option value.
*/