Skip to content

Instantly share code, notes, and snippets.

View SebKay's full-sized avatar

Seb Kay SebKay

View GitHub Profile
<?php
global $wpdb;
$duplicates = $wpdb->get_results("SELECT PM1.meta_id, PM1.post_id, PM1.meta_key, PM1.meta_value, PM2.meta_id, PM2.post_id, PM2.meta_key, PM2.meta_value
FROM {$wpdb->postmeta} PM1, {$wpdb->postmeta} PM2
WHERE
PM1.meta_id > PM2.meta_id
AND PM1.post_id = PM2.post_id
AND PM1.meta_value = PM2.meta_value
AND PM1.meta_key = PM2.meta_key
SELECT PM1.meta_id, PM1.post_id, PM1.meta_key, PM1.meta_value, PM2.meta_id, PM2.post_id, PM2.meta_key, PM2.meta_value
FROM wp_postmeta PM1, wp_postmeta PM2
WHERE
PM1.meta_id > PM2.meta_id
AND PM1.post_id = PM2.post_id
AND PM1.meta_value = PM2.meta_value
AND PM1.meta_key = PM2.meta_key
-- AND PM1.meta_key = '_wp_attachment_image_alt'
ORDER BY PM1.post_id ASC LIMIT 1000 OFFSET 0
@SebKay
SebKay / hirepage.php
Created October 18, 2023 14:16
Fixed version of the Hierarchical Pages WordPress plugin for PHP 8.2 compatibility
<?php
/*
Plugin Name: Hierarchical Pages
Version: 1.6.1
Plugin URI: http://www.wlindley.com/website/hierpage/
Description: Adds sidebar widgets to display a context-based list of "nearby" pages, and to display nested categories.
Author: William Lindley
Author URI: http://www.wlindley.com/
Text Domain: hierarchical-pages
License: GPL2
@SebKay
SebKay / composer.json
Last active September 14, 2023 20:04
Laravel Composer scripts
"scripts": {
"build:dev": [
"composer install",
"@artisan:build",
"@assets:build"
],
"build:prod": [
"composer install --no-interaction --prefer-dist --optimize-autoloader",
"@artisan:build",
"@assets:build"
@SebKay
SebKay / polylang-posts-without-language.php
Created September 12, 2023 09:29
Get all Polylang posts that don't have a language set.
<?php
new \WP_Query([
'post_type' => ['post', 'page'],
'posts_per_page' => -1,
'lang' => '',
'fields' => 'ids',
'tax_query' => [
[
'taxonomy' => 'language',
# Install PHP via Homebrew
brew install php@7.4
# Install Xdebug via Pecl
pecl install xdebug
# Enable Xdebug in php.ini
nano /usr/local/etc/php/7.4/php.ini
# Add this to php.ini
@SebKay
SebKay / install-storybook-webpack-5-vue-3.sh
Last active April 22, 2021 19:52
Install Storybook for a Webpack 5 and Vue.js 3 project
npx sb@next init
npx sb init --builder webpack5 -f
@SebKay
SebKay / phpmd-save-to-html.sh
Created May 15, 2020 06:43
Save PHP Mess Detector Results to HTML File
./vendor/bin/phpmd ./ html cleancode,codesize,controversial,design,naming,unusedcode --exclude vendor/ --reportfile report.html
docker exec -it [ID] bash