• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Archives for WordPress

WordPress

WordPress View Block Attributes

Last updated on February 8, 2023 by Sal Ferrarello

When developing a WordPress plugin that creates a Gutenberg block, it is invaluable to be able to view the attributes on the block. Here are some tricks I use to view this information.

Filed Under: Computing, Dev Tips, Programming, Solution Tagged With: block, Gutenberg, WordPress, WordPress Plugin

trailingslashit() vs untrailingslashit()

Last updated on November 1, 2022 by Sal Ferrarello

WordPress has two functions that can be helpful when dealing with the final character of a URL, trailingslashit() and untrailingslashit(). I find it preferable to use untrailingslashit() for two reasons: 1. It does not break empty checks and 2. It makes my sprintf() statements more readable.

Filed Under: Computing, Dev Tips, Programming Tagged With: PHP, WordPress, WordPress Plugin

WordPress Gutenberg Trigger Autosave

Last updated on April 25, 2022 by Sal Ferrarello

Recently, I was documenting the steps to reproduce a certain bug and the bug required the presence of an autosave (along with the “There is an autosave of this post that is more recent than the version below.” message). Rather than wait for an autosave to occur naturally, I wanted to speed things up and manually trigger one. This is the command I use to do that.

Filed Under: Dev Tips, Solution Tagged With: Gutenberg, JavaScript, WordPress

WordPress Gutenberg Notice in JavaScript

Last updated on February 20, 2022 by Sal Ferrarello

You can display four types of notices in the WordPress Block Editor (a.k.a. Gutenberg) using JavaScript: error, warning, info, and success. This blog post contains an example of each.

Filed Under: Dev Tips, Programming Tagged With: Gutenberg, JavaScript, WordPress

Disable Core WordPress Update Notice

Last updated on February 7, 2022 by Sal Ferrarello

When working on projects, I often want to strictly control the version of WordPress that is running. However sometimes one of the other administrators on the site sees the “WordPress 5.9 is available! Please update now.” message and clicks it, thereby prematurely updating to a newer version of WordPress core. This notice can be disabled.

Filed Under: Dev Tips, Programming, Solution Tagged With: WordPress, WordPress Core

Display Keyboard Shortcut in WordPress Gutenberg

Last updated on October 15, 2021 by Sal Ferrarello

In Gutenberg (a.k.a. the WordPress Block Editor), keyboard shortcuts are displayed differently on Apple devices and other devices, e.g. ^H on an Apple device and Ctrl+H on other devices. This is accomplished with wp.keycodes.displayShortcut.

Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Dev Tips, Draft, Programming Tagged With: Gutenberg, JavaScript, WordPress

WordPress Filter Early Return Pattern

Last updated on August 31, 2021 by Sal Ferrarello

A common programming pattern when using WordPress filters is the early return pattern (also know as the “short-circuit” pattern). This pattern is useful when you want to allow a filter to override a value that is “expensive” to calculate.

Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Computing, Dev Tips, Draft, Programming Tagged With: WordPress, WordPress Filter

Manually Trigger WordPress Heartbeat from Browser

Last updated on August 2, 2021 by Sal Ferrarello

When developing code related to the WordPress heartbeat, it is frustrating to make your code changes and then wait for the next heartbeat to occur. You can trigger the WordPress heartbeat in the browser manually to eliminate this delay.

Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Computing, Dev Tips, Draft, Programming, Solution Tagged With: WordPress, WordPress Heartbeat

WordPress Hooks and PHP Namespaces

Last updated on July 22, 2021 by Sal Ferrarello

While PHP namespaces allow you to refer to a function in file without using the fully qualified name, there is a catch when adding a WordPress hook or filter. The PHP __NAMESPACE__ magic constant can be helpful in this situation.

Filed Under: Dev Tips, Programming, Recommendations Tagged With: PHP, WordPress, WordPress Filter

WP CLI Migrate User Roles

Last updated on December 17, 2020 by Sal Ferrarello

Recently on a project I wanted to migrate WordPress users with a certain role to a different role. This is the command I used.

Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Draft, Solution Tagged With: WordPress, wp-cli

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Interim pages omitted …
  • Go to page 12
  • Next Page»

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in