• 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 Programming

Programming

Check WP_DEBUG

Last updated on April 19, 2020 by Sal Ferrarello

Recently I was talking to another developer about how to detect ‘WP_DEBUG’ being set on a WordPress installation. Here is the code I use.

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

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

WordPress Gutenberg import versus Destructuring Global wp

Last updated on April 24, 2020 by Sal Ferrarello

When creating a block for the WordPress block editor (a.k.a. Gutenberg), you are often using existing components. WordPress makes these components available under the global JavaScript variable ‘wp’ as well as available as npm packages. Which is the better way to make a component available in your code?

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

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

WordPress Gutenberg Functional Component useState

Last updated on March 30, 2020 by Sal Ferrarello

When creating a block for the WordPress block editor (a.k.a. Gutenberg), I find that most of the documentation is for class components. However, with React hooks we can use functional components. When you need to import ‘useState’ from React, you can do it as follows in a WordPress block.

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

Syringe in front of medical vials.

WordPress and SQL Injection

Last updated on February 28, 2020 by Sal Ferrarello

An SQL injection vulnerability occurs when you use a variable in your SQL statement and someone uses the variable to add unexpected code. In this article, we’ll look at how this occurs and how to prevent it.

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

Filed Under: Dev Tips, Draft, Programming Tagged With: database, MySQL, WordPress

WordPress REST API call to Update Post Status Fails Silently

Last updated on February 24, 2020 by Sal Ferrarello

Recently, I was trying to update the post status of a post from ‘future’ to ‘publish’ publish` with the WordPress REST API and while the submission appeared to work, the value was not modified.

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

Filed Under: Draft, Programming Tagged With: JavaScript, REST API, WordPress

MySQL Query for Multiple Strings with LIKE

Last updated on April 24, 2020 by Sal Ferrarello

I recently learned that doing a MySQL “LIKE” with multiple strings separated with ‘%’ behaves the same as multiple “LIKE” statements.

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

Filed Under: Dev Tips, Draft, Programming Tagged With: MySQL

Test WordPress REST API Endpoints from the Browser with jQuery

Last updated on February 24, 2020 by Sal Ferrarello

You can make WordPress REST API calls from the browser console. Here is one way I work with WordPress REST API endpoints in the browser using jQuery.

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

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

PHP require vs include

Last updated on January 28, 2022 by Sal Ferrarello

The behaviors of “require”, “include”, “require_once”, and “include_once” in PHP are all very similar with some slight differences. Here is the table highlighting the different behaviors of these statements.

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

Filed Under: Dev Tips, Draft, Programming Tagged With: PHP

Create WordPress Child Theme

Last updated on November 1, 2019 by Sal Ferrarello

You can quickly create a WordPress child theme by creating a new theme directory and adding two files: style.css and functions.php.

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

Filed Under: Draft, Programming Tagged With: WordPress, WordPress Theme

PHP declare(strict_types=1);

Last updated on October 23, 2019 by Sal Ferrarello

What does declare(strict_types=1); do in PHP? PHP is a weakly typed language, which means that when a value is of the wrong type, PHP tries to cast it to the proper type. For example if you try to add an integer and a string, echo 5 + “3”; PHP will try to cast the string […]

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

Filed Under: Computing, Draft, Programming Tagged With: PHP

  • «Previous Page
  • Go to page 1
  • Interim pages omitted …
  • Go to page 3
  • Go to page 4
  • Go to page 5
  • Go to page 6
  • Go to page 7
  • Interim pages omitted …
  • Go to page 18
  • Next Page»

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