Instantly share code, notes, and snippets.

View wordpress-mysql-delete-comments-1-year-ago.sql
-- delete comments 1 year ago
DELETE c
FROM wp_comments as c
WHERE c.comment_date_gmt < DATE_SUB(NOW(),INTERVAL 1 YEAR)
View wordpress-mysql-comments-1-year-ago.sql
-- WordPress - Comments 1 year ago
SELECT *
FROM wp_comments as c
WHERE c.comment_date_gmt < DATE_SUB(NOW(),INTERVAL 1 YEAR)
ORDER BY c.comment_date_gmt DESC
LIMIT 50
View delete-commentmeta-without-comments.sql
DELETE cm
FROM wp_commentmeta as cm
LEFT JOIN wp_comments as c ON c.comment_ID = cm.comment_id
WHERE c.comment_ID is null
View WP-CLI-Commands
Search and replace
https://wp-cli.org/commands/search-replace/
wp search-replace
wp search-replace 'http://example.dev' 'http://example.com'
Optmize database
https://wp-cli.org/commands/db/optimize/
wp db optimize
Repair database
View sqlgz.sh
gzip -d backup-20100910164109.sql.gz
View wp-rest-api-wrapper.js
/**
* AJAX обертка для WordPress REST API
*/
let sb_ajax = function ( ep, success, error, type = 'GET', data = '' ) {
url = wpApiSettings.root + ep;
// Feature detection
if ( !window.XMLHttpRequest ) return;
View index.php
<?php
if(empty($_GET['username']) ){
$_GET['username'] = 'vagrant';
}
function adminer_object() {
class AdminerSoftware extends Adminer {
function credentials() {
View ajax-request-native.js
/**
* Get data from a URL
* @param {String} url The URL to get
* @param {Function} success Callback to run on success
* @param {Function} error Callback to run on error
*/
var getURL = function ( url, success, error ) {
// Feature detection
if ( !window.XMLHttpRequest ) return;
View add-crontab-command.sh
#!/bin/bash
crontab -l | { cat; echo "*/1 * * * * curl http://site.lcl/wp-cron.php?doing_wp_cron > /dev/null 2>&1"; } | crontab -
View example-nginx.conf
server {
# base nginx conf
location ~ ^/wp-content/uploads/(.*) {
try_files $uri @live_uploads;
}
location @live_uploads {