Skip to content

Instantly share code, notes, and snippets.

@seemly
seemly / getTextNodes.txt
Last active February 7, 2018 16:58
jQuery - Find object containing direct textNode content
function getTextNodes(cssSelector, findString) {
var items = $(cssSelector)
.contents()
.filter(function() {
var isText = this.nodeType == Node.TEXT_NODE;
if (isText) {
var text = $.trim(this.textContent);
if (text.length && text.indexOf(findString) > -1) {
@seemly
seemly / my.cnf
Created May 24, 2021 08:32
Apple M1 - Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Setting up my new Apple M1 macbook pro I was having issues setting up mysql@5.7 using homebrew, with the following message being thrown:
```
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
```
We need to modify the MySQL config file:
```
nano /usr/local/etc/my.cnf
@seemly
seemly / shortcode-extended.php
Last active May 3, 2024 12:21
Enable the use of ACF shortcodes within the native Query Loop gutenberg block.
<?php
/**
* Shortcode Extended
*
* @package ShortcodeExtended
* @author Chris Sparshott
* @copyright 2022 Chris Sparshott
* @license GPL-2.0-or-later
*
@seemly
seemly / index.php
Created March 28, 2023 10:57
Conditionally hide Google Adsense snippet on a WordPress site using WP Code and ACF
<?php
// Check if ACF function `get_field()` exists. If it doesn't exist, display ads won't be shown.
// If it does exist and ACF 'hide_display_ads' value is not falsey, show display ads.
if(function_exists('get_field') && !get_field('hide_display_ads'))
{
echo '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-[your-adsense-id]" crossorigin="anonymous"></script>';
}
@seemly
seemly / wordpress-add-new-column-for-last-modified-date.php
Created April 17, 2023 09:48
Add a new 'Last Modified' column to WordPress admin Post list pages
<?php
function add_new_admin_column($columns)
{
$columns['last_modified'] = 'Last Modified';
return $columns;
}
add_filter('manage_posts_columns', 'add_new_admin_column');
@seemly
seemly / list-all-registered-gutenberg-blocks.js
Created February 8, 2024 16:13
List all registered WordPress Gutenberg Blocks. Paste this snippet in Chrome Dev Tools Console while in the Gutenberg editor view.
let types = wp.blocks.getBlockTypes();
// filter to just the core blocks
let core_blocks = types.filter(
type => type.name.startsWith('core/')
);
// grab just the names
let block_names = types.map(type => type.name);
@seemly
seemly / safe-delete-flamingo-inbound-messages.md
Created May 31, 2024 14:52
MySQL query to delete Flamingo WordPress plugin Inbound Messages.
START TRANSACTION;

DELETE FROM wp_posts
WHERE wp_posts.post_type = 'flamingo_inbound';

ROLLBACK;
@seemly
seemly / safe-delete-flamingo-address-book-records.md
Created May 31, 2024 14:53
MySQL query to delete Flamingo WordPress plugin Address Book entries
START TRANSACTION;

DELETE FROM wp_posts
WHERE wp_posts.post_type = 'flamingo_contact';

ROLLBACK;
@seemly
seemly / safe-delete-flamingo-address-book-records-older-than-3-months.md
Created May 31, 2024 15:09
MySQL query to delete Flamingo WordPress plugin Address Book entries created more than 3 months ago
START TRANSACTION;

DELETE FROM bcs20190308_posts
WHERE post_type = 'flamingo_contact'
AND post_date < DATE_SUB(CURDATE(), INTERVAL 3 MONTH);

ROLLBACK;
@seemly
seemly / safe-delete-flamingo-inbound-messages-older-than-3-months.md
Created May 31, 2024 15:11
MySQL query to delete Flamingo WordPress plugin Inbound Messages created more than 3 months ago.
START TRANSACTION;

DELETE FROM bcs20190308_posts
WHERE post_type = 'flamingo_inbound'
AND post_date < DATE_SUB(CURDATE(), INTERVAL 3 MONTH);

ROLLBACK;