How to send email verification code for a form?

You need to put together some php & db calls to handle the form submission, generate some unique code for each email and sending the verification code. Below I added a very basic example that can achieve that. It’s not a production ready code but tested and it works just fine. Firstly, you need to … Read more

Site Health and PHP 8.1

No, the constants WP_HOME and WP_SITEURL are not required to be defined. These constants would overwrite the URLs in the Settings > General fields, so for most sites they are undefined.

Strip and print only the numbers found in current’s post excerpt (even if they are without space)

If you have a strict list of allowed years: $allowed_years = array(‘2018’, ‘2019’, ‘2020’, ‘2021’, ‘2022’, ‘2023’, ‘2024’); Then why are you using regex when you can search for those years directly: function vyperlook_get_years_in_text( string $text, array $allowed_years ) : array { $found_years = []; // the years we found // for each year that … Read more

Get a list of folders inside uploads directory

The closest is the WP Filesystem API, but that’s mainly intended for compatibility purposes, e.g. to enable files to be written when the only access is via FTP and direct filesystem write access is unavailable. Particularly: However, if you are not distributing this code and only using it for yourself or known environments, you … Read more

how to test for options(fields) in settings API?

Before saving the options the first time get_option( ‘rtwhc_settings’ ) returns false as the option doesn’t exist. Saving values, deleting them and then saving again causes the value of get_option( ‘rtwhc_settings’ ) to be an array with the field names as keys, which have empty values. You can see this, if you var_dump() the option … Read more