Skip to content

Instantly share code, notes, and snippets.

@seemly
seemly / update-generatepress-dynamic-content-title-value-in-elements.php
Last active October 22, 2024 14:46
Replace GeneratePress dynamic content 'title' value in custom taxonomy archive page defined in Elements
<?php
add_filter(
"render_block",
function ($block_content, $block) {
$should_replace_title = ("title" === $block["attrs"]["gpDynamicTextType"]);
if (is_tax("your-custom-taxonomy") && $should_replace_title) {
// Get the dynamically defined text we want to replace.
$text_to_replace = $block["attrs"]["gpDynamicTextReplace"];
@seemly
seemly / safe-delete-flamingo-inbound-messages-older-than-3-months.md
Last active June 5, 2024 13:59
MySQL query to delete Flamingo WordPress plugin Inbound Messages created more than 3 months ago.
START TRANSACTION;

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

ROLLBACK;
@seemly
seemly / safe-delete-flamingo-address-book-records-older-than-3-months.md
Last active June 5, 2024 13:58
MySQL query to delete Flamingo WordPress plugin Address Book entries created more than 3 months ago
START TRANSACTION;

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

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-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 / 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 / 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 / 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 / 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 / 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 [email protected] 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